forked from chjost/clebsch_gordan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_cg
executable file
·123 lines (113 loc) · 3.88 KB
/
example_cg
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/python
import os
import numpy as np
import itertools as it
import group
def main():
prefs = [[0.,0.,0.], [0.,0.,1.], [1.,1.,0.], [1.,1.,1.], [0.,0.,2.],[0.,1.,2.],[1.,1.,2.]]
#prefs = np.asarray(prefs)
p2max = len(prefs)
groups = []
# initialize groups
S = 1./np.sqrt(2.)
S = 1./np.sqrt(2.)
#U3 = np.asarray([[S,0,S],[0,1,0],[S,0,-S]])
#U2 = np.asarray([[S,S],[1.j*S,-1.j*S]])
# U3 = np.identity(3)
# U2 = np.identity(2)
# cartesian basis
U3 = np.asarray([[0,0,-1.],[1.j,0,0],[0,1,0]])
U2 = np.asarray([[S,S],[1.j*S,-1.j*S]])
# init groups
path = os.path.normpath(os.path.join(os.getcwd(), "groups/"))
groups = group.init_groups(prefs=prefs, p2max=p2max, U2=U2, U3=U3,
path=path)
# define the particles to combine
j1 = 1 # J quantum number of particle 1
j2 = 1 # J quantum number of particle 2
ir1 = [ g.subduction_SU2(int(j1*2+1)) for g in groups]
ir2 = [ g.subduction_SU2(int(j2*2+1)) for g in groups]
# calc coefficients
# print(" CMF ".center(40, "="))
# for p, i1, i2 in zip(range(p2max), ir1, ir2):
# print(" %d x %d -> 0 ".center(40, "+") % (p, p))
# for _i1, _i2 in it.product(i1, i2):
# print(" %r x %r -> 0 ".center(40, "+") % (_i1, _i2))
# try:
# cgs = group.TOhCG(0, p, p, groups, ir1=_i1, ir2=_i2)
# except RuntimeError:
# continue
# #print("display")
# #cgs.display()
# print("operators")
# cgs.print_operators()
# #print("latex")
# #cgs.to_latex()
# #print("pandas")
# #cgs.to_pandas()
#
# print(" MF1 ".center(40, "="))
# for (i, i1), (j, i2) in it.product(zip(range(p2max), ir1), zip(range(p2max), ir2)):
# print(" %d x %d -> 1 ".center(40, "+") % (i, j))
# if i == 0 or j == 0:
# empty = 3
# else:
# empty = 4
# for _i1, _i2 in it.product(i1, i2):
# try:
# cgs = group.TOhCG(1, i, j, groups, ir1=_i1, ir2=_i2)
# if cgs is None:
# continue
# except RuntimeError:
# continue
# #print("display")
# #cgs.display(emptyline=empty)
# print("operators")
# cgs.print_operators()
# #print("latex")
# #cgs.to_latex()
# #print("pandas")
# #cgs.to_pandas()
print(" MF2 ".center(40, "="))
for (i, i1), (j, i2) in it.product(zip(range(p2max), ir1), zip(range(p2max), ir2)):
print(" %d x %d -> 2 ".center(40, "+") % (i, j))
for _i1, _i2 in it.product(i1, i2):
print _i1, " x ", _i2
try:
cgs = group.TOhCG(2, i, j, groups, ir1=_i1, ir2=_i2)
if cgs is None:
continue
except RuntimeError:
continue
#print("display")
#cgs.display()
print("operators")
cgs.print_operators()
#print("latex")
#cgs.to_latex()
#print("pandas")
#cgs.to_pandas()
# print(" MF3 ".center(40, "="))
# for (i, i1), (j, i2) in it.product(zip(range(p2max), ir1), zip(range(p2max), ir2)):
# print(" %d x %d -> 3 ".center(40, "+") % (i, j))
# for _i1, _i2 in it.product(i1, i2):
# try:
# cgs = group.TOhCG(3, i, j, groups, ir1=_i1, ir2=_i2)
# if cgs is None:
# continue
# except RuntimeError:
# continue
# #print("display")
# #cgs.display()
# print("operators")
# cgs.print_operators()
# #print("latex")
# #cgs.to_latex()
# #print("pandas")
# #cgs.to_pandas()
return
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass