Updated scripts and figures
This commit is contained in:
parent
2ba820e85f
commit
a7198ca019
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
latex/images/pd_estimate_1_0.pdf
Normal file
BIN
latex/images/pd_estimate_1_0.pdf
Normal file
Binary file not shown.
BIN
latex/images/pd_estimate_2_4.pdf
Normal file
BIN
latex/images/pd_estimate_2_4.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -16,22 +16,23 @@ plt.rcParams.update(params)
|
||||
|
||||
def plot_from_file():
|
||||
files = [
|
||||
"output/burn_in_time/unordered_1_0_1421110368.txt",
|
||||
"output/burn_in_time/ordered_1_0_611577739.txt",
|
||||
# "output/burn_in_time/unordered_1_0_1421110368.txt",
|
||||
# "output/burn_in_time/ordered_1_0_611577739.txt",
|
||||
"output/burn_in_time/unordered_2_4_1212892317.txt",
|
||||
"output/burn_in_time/ordered_2_4_2408603856.txt",
|
||||
]
|
||||
labels = [
|
||||
"1.0, unordered",
|
||||
"1.0, urdered",
|
||||
"2.4, unordered",
|
||||
"2.4, ordered"
|
||||
"Unordered",
|
||||
"Ordered",
|
||||
# "2.4, unordered",
|
||||
# "2.4, ordered"
|
||||
]
|
||||
colors = [
|
||||
"seagreen",
|
||||
"darkred",
|
||||
"darkgoldenrod",
|
||||
"steelblue"
|
||||
"seagreen",
|
||||
# "steelblue",
|
||||
# "darkred",
|
||||
# "darkgoldenrod",
|
||||
]
|
||||
|
||||
fig1, ax1 = plt.subplots()
|
||||
@ -54,13 +55,13 @@ def plot_from_file():
|
||||
ax2.plot(t, magnetization, label=f"{label}", color=color)
|
||||
|
||||
ax1.set_xlabel("t")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle \ [J]$")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$")
|
||||
ax1.legend(title="Initial state", loc="upper right")
|
||||
fig1.savefig("../latex/images/burn_in_time_energy.pdf", bbox_inches="tight")
|
||||
fig1.savefig("../latex/images/burn_in_time_energy_2_4.pdf", bbox_inches="tight")
|
||||
ax2.set_ylabel(r"$\langle |m| \rangle$")
|
||||
ax2.set_xlabel("t")
|
||||
ax2.legend(title="Initial state", loc="upper right")
|
||||
fig2.savefig("../latex/images/burn_in_time_magnetization.pdf", bbox_inches="tight")
|
||||
fig2.savefig("../latex/images/burn_in_time_magnetization_2_4.pdf", bbox_inches="tight")
|
||||
|
||||
def main():
|
||||
plot_from_file()
|
||||
|
||||
@ -3,6 +3,21 @@ from pathlib import Path
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import seaborn as sns
|
||||
from scipy.stats import norm
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
|
||||
def plot(infile, outfile):
|
||||
@ -10,16 +25,26 @@ def plot(infile, outfile):
|
||||
os.makedirs(outdir)
|
||||
|
||||
figure1, ax1 = plt.subplots()
|
||||
arr = []
|
||||
eps = []
|
||||
with open(infile) as f:
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
vals = line.strip().split(",")
|
||||
arr.append(float(vals[0]))
|
||||
eps.append(float(vals[0]))
|
||||
|
||||
ax1.hist(arr, np.arange(min(arr), max(arr) + 0.02, 0.02), density=True, ec="black")
|
||||
ax1.hist(eps, np.arange(min(eps), max(eps) + 0.02, 0.02), color="steelblue", density=True, ec="white", lw=0.2)
|
||||
ax1.set_xlabel(r"$\epsilon$")
|
||||
ax1.set_ylabel("Density")
|
||||
|
||||
figure1.savefig(outfile)
|
||||
mu, sigma = np.mean(eps), np.std(eps)
|
||||
x = np.arange(min(eps), max(eps) + 0.02, 0.02)
|
||||
|
||||
stats = (f"$\\langle \\epsilon \\rangle$ = {np.mean(eps):.4f}\n"
|
||||
f"Var$(\\epsilon)$ = {np.var(eps):.4f}")
|
||||
bbox = dict(boxstyle="round", pad=0.3, fc="white", ec="white", alpha=0.5)
|
||||
ax1.text(0.95, 0.9, stats, bbox=bbox, transform=ax1.transAxes, ha="right", va="center")
|
||||
ax1.plot(x, norm.pdf(x, mu, sigma), color="mediumseagreen")
|
||||
figure1.savefig(outfile, bbox_inches="tight")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -3,6 +3,20 @@ from pathlib import Path
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from scipy.stats import linregress
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
params = {
|
||||
"font.family": "Serif",
|
||||
"font.serif": "Roman",
|
||||
"text.usetex": True,
|
||||
"axes.titlesize": "large",
|
||||
"axes.labelsize": "large",
|
||||
"xtick.labelsize": "large",
|
||||
"ytick.labelsize": "large",
|
||||
"legend.fontsize": "medium"
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
|
||||
def plot_phase_transition(indir, outdir):
|
||||
@ -14,11 +28,18 @@ def plot_phase_transition(indir, outdir):
|
||||
"size_100.txt",
|
||||
]
|
||||
labels = [
|
||||
"L = 20",
|
||||
"L = 40",
|
||||
"L = 60",
|
||||
"L = 80",
|
||||
"L = 100",
|
||||
"20",
|
||||
"40",
|
||||
"60",
|
||||
"80",
|
||||
"100",
|
||||
]
|
||||
colors = [
|
||||
"indianred",
|
||||
"sandybrown",
|
||||
"mediumseagreen",
|
||||
"steelblue",
|
||||
"mediumpurple"
|
||||
]
|
||||
|
||||
figure1, ax1 = plt.subplots()
|
||||
@ -32,7 +53,7 @@ def plot_phase_transition(indir, outdir):
|
||||
Tc = []
|
||||
size = 20
|
||||
|
||||
for file, label in zip(files, labels):
|
||||
for file, label, color in zip(files, labels, colors):
|
||||
t = []
|
||||
e = []
|
||||
m = []
|
||||
@ -56,29 +77,45 @@ def plot_phase_transition(indir, outdir):
|
||||
# Append the critical temp for the current lattice size
|
||||
Tc.append(t[X.index(max(X))])
|
||||
|
||||
ax1.plot(t, e, label=label)
|
||||
ax2.plot(t, m, label=label)
|
||||
ax3.plot(t, CV, label=label)
|
||||
ax4.plot(t, X, label=label)
|
||||
ax1.plot(t, e, label=label, color=color)
|
||||
ax2.plot(t, m, label=label, color=color)
|
||||
ax3.plot(t, CV, label=label, color=color)
|
||||
ax4.plot(t, X, label=label, color=color)
|
||||
|
||||
# Attempt linear regression
|
||||
x = np.linspace(0, 100, 1001)
|
||||
regression = linregress(L, Tc)
|
||||
x = np.linspace(0, 1/20, 1001)
|
||||
inv_L = [1/x for x in L]
|
||||
regression = linregress(inv_L, Tc)
|
||||
f = lambda x: regression[0] * x + regression[1]
|
||||
ax5.scatter(L, Tc)
|
||||
ax5.plot(x, f(x), label=f"m = {regression[0]}")
|
||||
|
||||
figure1.legend()
|
||||
figure2.legend()
|
||||
figure3.legend()
|
||||
figure4.legend()
|
||||
figure5.legend()
|
||||
stats = (f"$\\beta_0 = $ {regression[1]:.4f}\n"
|
||||
f"$\\beta_1 = $ {regression[0]:.4f}")
|
||||
bbox = dict(boxstyle="round", pad=0.3, fc="white", alpha=0.5)
|
||||
ax5.text(0.64, 0.64, stats, bbox=bbox, transform=ax1.transAxes, ha="right", va="center")
|
||||
ax5.scatter(inv_L, Tc, color="steelblue")
|
||||
# txt = f"$\\beta_1$ {regression[0]:.4f} \n$\\beta_0$ {regression[1]:.4f}"
|
||||
ax5.plot(x, f(x), color="mediumseagreen", linestyle="dashed")
|
||||
|
||||
figure1.savefig(Path(outdir, "energy.pdf"))
|
||||
figure2.savefig(Path(outdir, "magnetization.pdf"))
|
||||
figure3.savefig(Path(outdir, "heat_capacity.pdf"))
|
||||
figure4.savefig(Path(outdir, "susceptibility.pdf"))
|
||||
figure5.savefig(Path(outdir, "linreg.pdf"))
|
||||
ax1.legend(title="Lattice size", loc="upper right")
|
||||
ax1.set_xlabel(r"$T$ $[J / k_{B}]$")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$")
|
||||
ax2.legend(title="Lattice size", loc="upper right")
|
||||
ax2.set_xlabel(r"$T$ $[J / k_{B}]$")
|
||||
ax2.set_ylabel(r"$\langle |m| \rangle$")
|
||||
ax3.legend(title="Lattice size", loc="upper right")
|
||||
ax3.set_xlabel(r"$T$ $[J / k_{B}]$")
|
||||
ax2.set_ylabel(r"$C_{V}$ $[k_{B}]$")
|
||||
ax4.legend(title="Lattice size", loc="upper right")
|
||||
ax4.set_xlabel(r"$T$ $[J / k_{B}]$")
|
||||
ax4.set_ylabel(r"$\chi$ $[1 / J]$")
|
||||
ax5.set_xlabel(r"$1 / L$")
|
||||
ax5.set_ylabel(r"$T_C(L)$")
|
||||
|
||||
figure1.savefig(Path(outdir, "energy.pdf"), bbox_inches="tight")
|
||||
figure2.savefig(Path(outdir, "magnetization.pdf"), bbox_inches="tight")
|
||||
figure3.savefig(Path(outdir, "heat_capacity.pdf"), bbox_inches="tight")
|
||||
figure4.savefig(Path(outdir, "susceptibility.pdf"), bbox_inches="tight")
|
||||
figure5.savefig(Path(outdir, "linreg.pdf"), bbox_inches="tight")
|
||||
|
||||
plt.close(figure1)
|
||||
plt.close(figure2)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user