-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_correlations
More file actions
41 lines (31 loc) · 988 Bytes
/
plot_correlations
File metadata and controls
41 lines (31 loc) · 988 Bytes
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
import numpy as np
import matplotlib.pyplot as plt
import csv
# ----- Load xi and rho -----
xi_data = {}
rho_data = {}
with open("ising_1D_data.csv") as f:
reader = csv.reader(f)
next(reader)
for row in reader:
T = float(row[0])
rho_data[T] = float(row[1])
xi_data[T] = float(row[2])
# ----- Plot ξ vs T -----
plt.figure(figsize=(8,6))
plt.plot(list(xi_data.keys()), list(xi_data.values()), 'o-', color='red')
plt.xlabel("Temperature T")
plt.ylabel("Correlation Length ξ")
plt.title("1D Ising Correlation Length vs Temperature")
plt.grid(True)
plt.savefig("ising_1D_xi_vs_T.png", dpi=150)
# ----- Plot ρ vs T -----
plt.figure(figsize=(8,6))
plt.plot(list(rho_data.keys()), list(rho_data.values()), 'o-', color='green')
plt.xlabel("Temperature T")
plt.ylabel("Domain Wall Density ρ")
plt.title("1D Ising Domain Wall Density vs Temperature")
plt.grid(True)
plt.savefig("ising_1D_rho_vs_T.png", dpi=150)
plt.close("all")
print("Plots generated.")