Merge branch 'janitaws/latex' into coryab/code
This commit is contained in:
@@ -17,8 +17,10 @@ plt.rcParams.update(params)
|
||||
|
||||
def plot_1_0():
|
||||
files = [
|
||||
"data/hp/burn_in_time/unordered_1_0_1421110368.txt",
|
||||
"data/hp/burn_in_time/ordered_1_0_611577739.txt",
|
||||
# "data/hp/burn_in_time/unordered_1_0_1421110368.txt",
|
||||
# "data/hp/burn_in_time/ordered_1_0_611577739.txt",
|
||||
"data/hp/burn_in_time/unordered_1_0.txt",
|
||||
"data/hp/burn_in_time/ordered_1_0.txt",
|
||||
]
|
||||
labels = [
|
||||
"Unordered",
|
||||
@@ -48,13 +50,13 @@ def plot_1_0():
|
||||
ax1.plot(t, energy, label=f"{label}", color=color)
|
||||
ax2.plot(t, magnetization, label=f"{label}", color=color)
|
||||
|
||||
ax1.set_xlabel("t")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$")
|
||||
ax1.set_xlabel("t (MC cycles)")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$ $(J)$")
|
||||
ax1.legend(title="Initial state", loc="upper right")
|
||||
|
||||
fig1.savefig("./latex/images/burn_in_time_energy_1_0.pdf", bbox_inches="tight")
|
||||
ax2.set_ylabel(r"$\langle |m| \rangle$")
|
||||
ax2.set_xlabel("t")
|
||||
|
||||
ax2.set_ylabel(r"$\langle |m| \rangle$ (unitless)")
|
||||
ax2.set_xlabel("t (MC cycles)")
|
||||
ax2.legend(title="Initial state", loc="upper right")
|
||||
fig2.savefig(
|
||||
"./latex/images/burn_in_time_magnetization_1_0.pdf", bbox_inches="tight"
|
||||
@@ -63,8 +65,10 @@ def plot_1_0():
|
||||
|
||||
def plot_2_4():
|
||||
files = [
|
||||
"data/hp/burn_in_time/unordered_2_4_1212892317.txt",
|
||||
"data/hp/burn_in_time/ordered_2_4_2408603856.txt",
|
||||
# "data/hp/burn_in_time/unordered_2_4_1212892317.txt",
|
||||
# "data/hp/burn_in_time/ordered_2_4_2408603856.txt",
|
||||
"data/hp/burn_in_time/unordered_2_4.txt",
|
||||
"data/hp/burn_in_time/ordered_2_4.txt",
|
||||
]
|
||||
labels = [
|
||||
"Unordered",
|
||||
@@ -94,13 +98,13 @@ def plot_2_4():
|
||||
ax1.plot(t, energy, label=f"{label}", color=color)
|
||||
ax2.plot(t, magnetization, label=f"{label}", color=color)
|
||||
|
||||
ax1.set_xlabel("t")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$")
|
||||
ax1.set_xlabel("t (MC cycles)")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$ $(J)$")
|
||||
ax1.legend(title="Initial state", loc="upper right")
|
||||
|
||||
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.set_ylabel(r"$\langle |m| \rangle$ (unitless)")
|
||||
ax2.set_xlabel("t (MC cycles)")
|
||||
ax2.legend(title="Initial state", loc="upper right")
|
||||
fig2.savefig(
|
||||
"./latex/images/burn_in_time_magnetization_2_4.pdf", bbox_inches="tight"
|
||||
|
||||
@@ -40,7 +40,7 @@ def plot(infile, outfile):
|
||||
ec="white",
|
||||
lw=0.2,
|
||||
)
|
||||
ax1.set_xlabel(r"$\epsilon$")
|
||||
ax1.set_xlabel(r"$\epsilon$ $(J)$")
|
||||
ax1.set_ylabel("Density")
|
||||
|
||||
mu, sigma = np.mean(eps), np.std(eps)
|
||||
|
||||
@@ -4,6 +4,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_alt(indir, outdir):
|
||||
@@ -65,20 +79,40 @@ def plot_phase_transition_alt(indir, outdir):
|
||||
x = np.linspace(0, 1 / 20, 1001)
|
||||
regression = linregress(inv_L, Tc)
|
||||
f = lambda x: regression[0] * x + regression[1]
|
||||
stats = (
|
||||
f"$\\beta_{0}$ = {regression[1]:.4f}\n"
|
||||
f"$\\beta_{1}$ = {regression[0]:.4f}"
|
||||
)
|
||||
bbox = dict(boxstyle="round", pad=0.3, fc="white", ec="white", alpha=0.5)
|
||||
ax5.text(
|
||||
0.6, 0.6, stats, bbox=bbox, transform=ax1.transAxes, ha="right", va="center"
|
||||
)
|
||||
ax5.scatter(inv_L, Tc)
|
||||
ax5.plot(x, f(x), label=f"m = {regression[0]}, i = {regression[1]}")
|
||||
ax5.plot(x, f(x))
|
||||
|
||||
figure1.legend()
|
||||
figure2.legend()
|
||||
figure3.legend()
|
||||
figure4.legend()
|
||||
figure5.legend()
|
||||
ax1.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$ $(J)$")
|
||||
ax1.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
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"))
|
||||
ax2.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax2.set_ylabel(f"$\\langle |m| \\rangle$ (unitless)")
|
||||
ax2.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
ax3.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax3.set_ylabel(r"$C_{V}$ $(k_{B})$")
|
||||
ax3.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
ax4.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax4.set_ylabel(r"$\chi$ $(1/J)$")
|
||||
ax4.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
# ax5.legend()
|
||||
|
||||
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)
|
||||
@@ -99,11 +133,11 @@ 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",
|
||||
]
|
||||
|
||||
figure1, ax1 = plt.subplots()
|
||||
@@ -151,20 +185,40 @@ def plot_phase_transition(indir, outdir):
|
||||
x = np.linspace(0, 1 / 20, 1001)
|
||||
regression = linregress(inv_L, Tc)
|
||||
f = lambda x: regression[0] * x + regression[1]
|
||||
stats = (
|
||||
f"$\\beta_{0}$ = {regression[1]:.4f}\n"
|
||||
f"$\\beta_{1}$ = {regression[0]:.4f}"
|
||||
)
|
||||
bbox = dict(boxstyle="round", pad=0.3, fc="white", ec="white", alpha=0.5)
|
||||
ax5.text(
|
||||
0.6, 0.6, stats, bbox=bbox, transform=ax1.transAxes, ha="right", va="center"
|
||||
)
|
||||
ax5.scatter(inv_L, Tc)
|
||||
ax5.plot(x, f(x), label=f"m = {regression[0]}, i = {regression[1]}")
|
||||
ax5.plot(x, f(x))
|
||||
|
||||
figure1.legend()
|
||||
figure2.legend()
|
||||
figure3.legend()
|
||||
figure4.legend()
|
||||
figure5.legend()
|
||||
ax1.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$ $(J)$")
|
||||
ax1.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
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"))
|
||||
ax2.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax2.set_ylabel(r"$\langle |m| \rangle$ (unitless)")
|
||||
ax2.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
ax3.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax3.set_ylabel(r"$C_{V}$ $(k_{B})$")
|
||||
ax3.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
ax4.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax4.set_ylabel(r"$\chi$ $(1/J)$")
|
||||
ax4.legend(title="Lattice size", loc="upper right")
|
||||
|
||||
# print(Tc)
|
||||
|
||||
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)
|
||||
@@ -174,7 +228,7 @@ def plot_phase_transition(indir, outdir):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot_phase_transition_alt(
|
||||
plot_phase_transition(
|
||||
"data/fox/phase_transition/wide/10M/",
|
||||
"latex/images/phase_transition/fox/wide/10M/",
|
||||
)
|
||||
|
||||
@@ -2,6 +2,20 @@ from os import makedirs
|
||||
from pathlib import Path
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
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(indir, outdir):
|
||||
@@ -13,8 +27,12 @@ def plot(indir, outdir):
|
||||
"burn_in.txt",
|
||||
]
|
||||
labels = [
|
||||
"Without burn-in time",
|
||||
"With burn-in time",
|
||||
"Without",
|
||||
"With",
|
||||
]
|
||||
colors = [
|
||||
"darkred",
|
||||
"seagreen",
|
||||
]
|
||||
|
||||
figure1, ax1 = plt.subplots()
|
||||
@@ -22,7 +40,7 @@ def plot(indir, outdir):
|
||||
figure3, ax3 = plt.subplots()
|
||||
figure4, ax4 = plt.subplots()
|
||||
|
||||
for file, label in zip(files, labels):
|
||||
for file, label, color in zip(files, labels, colors):
|
||||
t = []
|
||||
e = []
|
||||
m = []
|
||||
@@ -39,20 +57,31 @@ def plot(indir, outdir):
|
||||
CV.append(float(l[3]))
|
||||
X.append(float(l[4]))
|
||||
|
||||
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)
|
||||
|
||||
figure1.legend()
|
||||
figure2.legend()
|
||||
figure3.legend()
|
||||
figure4.legend()
|
||||
ax1.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax1.set_ylabel(r"$\langle \epsilon \rangle$ $(J)$")
|
||||
ax1.legend(title="Burn-in time", loc="upper right")
|
||||
|
||||
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"))
|
||||
ax2.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax2.set_ylabel(r"$\langle |m| \rangle$ $(unitless)$")
|
||||
ax2.legend(title="Burn-in time", loc="upper right")
|
||||
|
||||
ax3.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax3.set_ylabel(r"$C_{V}$ $(k_{B})$")
|
||||
ax3.legend(title="Burn-in time", loc="upper right")
|
||||
|
||||
ax4.set_xlabel(r"T $(J/k_{B})$")
|
||||
ax4.set_ylabel(r"$\chi$ $(1/J)$")
|
||||
ax4.legend(title="Burn-in time", loc="upper right")
|
||||
|
||||
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")
|
||||
|
||||
plt.close(figure1)
|
||||
plt.close(figure2)
|
||||
|
||||
@@ -51,9 +51,9 @@ def plot_timing(indir, outdir):
|
||||
ax1.set_xlabel(xlabel)
|
||||
ax1.set_ylabel("time (seconds)")
|
||||
|
||||
figure1.legend()
|
||||
ax1.legend()
|
||||
|
||||
figure1.savefig(Path(outdir, outfile))
|
||||
figure1.savefig(Path(outdir, outfile), bbox_inches="tight")
|
||||
|
||||
plt.close(figure1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user