-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulation_evaluation.py
128 lines (93 loc) · 3.82 KB
/
simulation_evaluation.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
import numpy as np
import data_visualization
import model_evaluation
import data_helper
import data_analysis
import os
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams.update({
'text.usetex': False,
'font.family': 'serif',
'font.serif': 'cmr10',
'font.size': 18,
'mathtext.fontset': 'cm',
'font.family': 'STIXGeneral',
'axes.unicode_minus': True})
#plot_path = "F:/GAN - PerformancePlots"
plot_path = "C:/Users/Flo/Documents/Uni/Ba-Arbeit/ba thesis/img/plots"
#--------------------------------------------------------------------
def savePdf(filename):
plt.savefig(plot_path + "/" + filename + '.pdf', bbox_inches='tight')
def savePng(filename):
plt.savefig(plot_path + "/" + filename + '.png', bbox_inches='tight')
#--------------------------------------------------------------------
def load_spin_states(TJ, L):
path = os.path.join(os.path.dirname(__file__), "..", "data", "train", str(L))
file_path = os.path.join(path, "simulation_states_TJ_{TJ}.npy".format(TJ=TJ))
states = np.load(file_path)
print("[load_spin_states] (TJ, L) = (%.2f, %d), Found states count:" % (TJ, L), states.shape[0])
return states
def load_spin_observables(TJ, L):
path = os.path.join(os.path.dirname(__file__), "..", "data", "train", L)
file_path = os.path.join(path, "simulation_observ_TJ_{TJ}.npy".format(TJ=TJ))
obser = np.transpose(np.load(file_path))
energy = obser[0]
m = obser[1]
mAbs = obser[2]
m2 = obser[3]
mAbs3 = obser[4]
m4 = obser[5]
print("[load_spin_observables] (TJ, L) = (%.2f, %d), Found data count:" % (TJ, L), energy.shape[0])
return energy, m, mAbs, m2, mAbs3, m4
#--------------------------------------------------------------------
def main():
Tc = 1.0 * 2.0 / np.log(1.0 + np.sqrt(2.0))
Ls = np.array([8, 16, 32, 64, 128], dtype=np.int32)
TJs = np.array([1.0, 1.5, 1.8, 2.0, 2.1, 2.2, 2.25, 2.26, 2.27, 2.3, 2.4, 2.5, 2.6, 3.0, 3.4,
2.28, 2.29, 2.31, 2.32, 2.33, 2.34, 2.35, 2.36, 2.37, 2.38, 2.39])
TJs = np.sort(TJs)
#--------------------------
#12, 4.3
size=(5.5, 4.3)
fig = plt.figure(figsize = size, constrained_layout = True)
matplotlib.rcParams.update({'font.size': 18})
plt.xlabel(r"$T/J$")
plt.ylabel(r"$\xi$")
plt.xlim([1.96, 2.61])
plt.axvline(Tc, color="gray", linestyle="--")
clrs = ["tab:blue", "tab:orange", "tab:green", "tab:red", "tab:purple"]
#--------------------------
for i in range(Ls.size):
x = Ls.size - 1 - i
L = Ls[x]
clr = clrs[x]
#--------------------------
#legend
te = r"$L$ = %d" % L
args = dict(horizontalalignment='left',verticalalignment='top', transform=plt.gca().transAxes, color=clr, size="large")
plt.text(1.02, 0.98-0.12*i, te, args)
#--------------------------
xis = list()
xis_err = list()
for TJ in TJs:
print("------ (TJ, L) = (%.2f, %d) ------" % (TJ, L))
N = L*L
#load sim data
#energy, m, mAbs, m2, mAbs3, m4 = load_spin_observables(TJ, L)
states = load_spin_states(TJ, L)
#calc obs
xi, xi_err = data_analysis.calc_spin_spin_correlation(states, N)
xis.append(xi)
xis_err.append(xi_err)
#--------------------------
plt.plot(TJs, xis, "--", color=clr, alpha=0.5, linewidth=0.8)
plt.errorbar(TJs, xis, fmt='.', yerr=xis_err, elinewidth=1, capsize=5, markersize=5, color=clr)
savePdf("simulation_evaluation")
#savePng("simulation_evaluation")
return
#--------------------------------------------------------------------
if __name__ == '__main__':
main()
plt.show()
#--------------------------------------------------------------------