-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_flav.py
More file actions
101 lines (85 loc) · 3.4 KB
/
Copy pathmake_flav.py
File metadata and controls
101 lines (85 loc) · 3.4 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from textwrap import dedent
from datetime import datetime
import sys
from ipart import opart
# NOTE: this could be done in the FORM preprocessor, but it would be clumsy.
# This is, among many things, due to the lack of the str.join(...) function.
try:
N = int(sys.argv[1])
except ValueError:
print(f"ERROR: Attempting to generate flavor structure when FLAV={sys.argv[1]} is not a simple number of pions")
sys.exit(1)
SUN = len(sys.argv) > 2 and sys.argv[2]
structs = {}
cayham = []
def form(trace, wildcard=''):
return ','.join(f'f{b}{wildcard}' for b in trace)
# def try_cayham(R, traces, cayham):
# breakup = 0
# for i,r in reversed(list(enumerate(R))):
# if r == 2:
# cayham.append(f"""`CAYHAMID' {
# '*'.join(f"Tr({form(trace,'?')})" for trace in traces)
# } = {
# '*'.join(
# [f"Tr({form(trace)})" for trace in traces[:i] + traces[i+1:-1]]
# + [f"Tr(ac({form(traces[i])}),{form(traces[-1])})"])
# };""")
# return True
# if r > 2 and not r % 2:
# breakup += 1
# if breakup == 2:
# cayham.append(f"""`CAYHAMID' {
# '*'.join(f"Tr({form(trace,'?')})" for trace in traces)
# } = {
# '*'.join(f"(Tr{form(trace,'?')})" for trace in traces[:i] + traces[i+1:])
# }*({
# ''.join(f"{'-' if j%2 else '+'}Tr({traces[i][0]},{traces[i][j]})*Tr({','.join(traces[i][1:j] + traces[j+1:])})")
# })/2;""")
# return True
# return False
def cayham_33():
return f"""`CAYHAMID' Tr(f1?,f2?,f3?)*Tr(f4?,f5?,f6?) =
+ Tr(f1,f4)*Tr(f2,f5)*Tr(f3,f6)
+ Tr(f1,f5)*Tr(f2,f6)*Tr(f3,f4)
+ Tr(f1,f6)*Tr(f2,f4)*Tr(f3,f5)
- Tr(f1,f4)*Tr(f2,f6)*Tr(f3,f5)
- Tr(f1,f5)*Tr(f2,f4)*Tr(f3,f6)
- Tr(f1,f6)*Tr(f2,f5)*Tr(f3,f4);"""
def cayham_split(r):
return f"""`CAYHAMID' Tr(f1?,...,f{r}?) = (
{endl.join(
f" {'+' if i%2 else '-'} Tr(f1,f{i})*Tr({','.join(
f'f{j}' for j in range(2,r+1) if j != i
)})" for i in range(2,r+1)
)})/2;"""
for R in opart(N, lambda x: x>1):
# Skip those that can be eliminated through Cayley-Hamilton
if not SUN and (any(r > 2 and not r % 2 for r in R) or R.count(3) >= 2):
continue
R.reverse()
traces = []
idx = 1
for p in R:
traces.append(list(range(idx, idx+p)))
idx += p
# if try_cayham(R, traces, cayham):
# continue
tag = 'x'.join(str(p) for p in R)
structs[tag] = '*'.join(f"Tr({form(trace)})" for trace in traces)
endl = '\n' + ' '*8
with open(f"flavs/flav{N}{'_SUN' if SUN else ''}.hf", 'w') as out:
print(dedent(f"""\
* Generated by make_flav.py on {datetime.now().strftime('%c')}
#define FLAVS{N} "{','.join(structs.keys())}"
#define PKE{N} "{','.join(['p'] * N)}"
{endl.join(f'#define Tr{tag} "{struct}"' for tag,struct in structs.items())}
{endl.join(f'#define Srel{tag} ""' for tag in structs)}
#define cayham{N} "
{
cayham_33() if not SUN and N >= 6 else ''
}
{
endl.join(cayham_split(r) for r in range(N,2,-2)) if not SUN else ''
}"
"""), file=out)