-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_me.py
142 lines (111 loc) · 4.18 KB
/
run_me.py
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import hmc_python
from hmc_python.util import *
from hmc_python.lparam import *
#------------------------------------------------
# File IO Defined in the code
pin = open("./hmc_python/sigma1.in","r")
ptout = open("./hmc_python/sigma1.out", "a")
ptacl = open("./hmc_python/sigma1.acl", "a");
ptlat = open("./hmc_python/sigma1.lat", "a");
ptprop = open("./hmc_python/sigma1.prop", "w");
ptpropacl = open("./hmc_python/sigma1.propacl", "w");
prompt = setup_gn()
readin(prompt)
#------------------------------------------------
coldlat()
# randomize() # Not defined here but present in the original code
# filelat(pin) # Getting converted will be merged later
av_sigma = 0.0 # grand average of <sigma>
av_psi = 0.0 # grand average of <psi_bar-psi>
t_ex_sigma = 0.0 # grand sum over all <sigma>s
seg_av_sigma = 0.0 # segment-average of <sigma> for tau_int
seg_av_prop = 0.0 # segment-average of <propagator[m]>
no_hmc = 0 # # of hmc steps calculated
no_acc = 0 # # of accepted configurations
counter = 0 # counter used in hmc.c
meas = 0 # meas is a switch for measurements
no_auto = 0 # no_auto is the index for autocoreln. measurement
no_prop = 0 # no_prop is the index for Prop-Acl calculation
a = 0 # a index used in tau_int measurements
ac = 0 # ac configuration index to ac_prop[ac]
acc = 0 # acc index used in G_temp[][acc] i.e. # of data point and also used as index in ac_store
bin = 0 # bin is index to bin_average
g = 0 # g configuration index to garbage i.e. garbage[g]
k = 0 # k configuration index to store i.e. store[k]
j = 0 # j configuration index to store[j], during measurements
global lattice
from hmc_python.lparam import *
print(lattice)
if sw_flag == 0:
# GARBAGE LOOPS AND AUTOCORELATION MEASUREMENTS LOOPS
for n in range(hmc_it):
no_acc += 1
no_hmc += hmc()
if no_acc<=no_garbage:
garbage[g] = average_sigma()
g += 1
bin +=1
if bin%bin_length == 0:
for m in range((g-bin),g):
bin_av[k] +=garbage[m]/bin_length
k += 1
bin = 0
if no_acc>no_garbage:
ac_store[acc] = average_sigma()
acc += 1
no_auto += 1
if no_auto%seg_length == 0:
lbd = acc - no_auto
for m in range(lbd,acc):
seg_av_sigma += ac_store[m]/seg_length
autocorel(seg_av_sigma,lbd,a)
a += 1
seg_av_sigma = 0
no_auto = 0
for i in range(0,volume):
con[i] = conf[i]
for i in range(0,volume):
conf[i] = lattice[i].sigma
acc_rate = no_acc/no_hmc
for n in range(0, MAXT_cut):
ptacl.write(f"{n+1}")
for u in range(NOT_cut):
d_t_int = 0
av_t_int = 0
for a in range(no_a_seg):
av_t_int += T_int[u][n][a]/no_a_seg
for a in range(no_a_seg):
d_t_int += (T_int[u][n][a] - av_t_int)**2
d_t_int = math.sqrt(d_t_int/(no_a_seg-1))
ptacl.write(f"\t{av_t_int}\t{d_t_int}")
ptacl.write("\n")
print(f"\n\n no_acc_traj={no_acc} \t no_hmc={no_hmc} \t acc_rate={acc_rate}")
for k in range(0,no_bin):
ptout.write(f"{k+1}\t{bin_av[k]}\n")
for i in range(0,volume):
ptlat.write(f"{lattice[i].sigma}\n")
if sw_flag == 1:
for n in range(meas_loop):
no_acc += 1
no_hmc += hmc()
meas = meas + 1
no_prop = no_prop + 1
if meas%meas_length == 0:
store[j] += average_sigma()
t_ex_sigma += store[j]
j += 1
if meas%prop_length == 0:
pass
av_sigma = t_ex_sigma / no_meas
sqdev = 0
for k in range(no_meas):
sqdev += (store[k]-av_sigma)**2
d_av_sigma = sqrt(sqdev/(no_meas-1))
acc_rate = no_acc/no_hmc
print(f"\n\n\ no_acc_traj = {no_acc} \t no_hmc = {no_hmc} \t acc_rate = {acc_rate} \n\n")
print(f"av_sigma={av_sigma} \t av_psi{av_psi}\n\n")
print(f"d_av_sigma={d_av_sigma} \t d_av_psi{d_av_psi}\n\n")
for i in range(0,volume):
ptlat.write(f"{lattice[i].sigma}\n")
else:
print("KILL YOURSELF, PLEASE !!!")