-
Notifications
You must be signed in to change notification settings - Fork 0
/
Convert3to31.m
55 lines (39 loc) · 1.17 KB
/
Convert3to31.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(*
Convert3to31.m
rewrites the GraphInfo files of FeynArts 3
as individual files for each topology in the
ShapeData directory
last modified 10 Mar 03 th
*)
Needs["FeynArts`"]
If[ FileType[$ShapeDataDir] === Directory,
Print["Conversion already performed (", $ShapeDataDir, " exists)."];
Abort[]
]
If[ !ValueQ[$TopologyDataDir],
$TopologyDataDir = ToFileName[{$FeynArtsDir, "GraphInfo"}] ]
sep = StringTake[ToFileName["d", "f"], {2, -2}]
BaseName[file_] :=
Block[ {p1, p2},
p1 = Flatten[{0, StringPosition[file, sep]}][[-1]] + 1;
p2 = Flatten[{0, StringPosition[file, "."]}][[-1]] - 1;
If[ p2 < p1, p2 = -1 ];
StringTake[file, {p1, p2}]
]
LoadOld[file_] := (
Get[file];
ToExpression[BaseName[file]]
)
cats = LoadOld/@ FileNames["*", $TopologyDataDir]
SaveNew[ _[cat_[top_]], shapedata_ ] :=
Block[ {topcode = TopologyCode[top], shapefile},
If[ Head[tag[topcode]] =!= tag,
Print[topcode, " in more than one category: ", tag[topcode], " and ", cat];
Abort[]
];
tag[topcode] = cat;
shapefile = ToFileName[$ShapeDataDir, topcode <> ".m"];
Put[shapedata, shapefile];
]
CreateDirectory[$ShapeDataDir]
Apply[SaveNew, DownValues/@ cats, {2}];