Merge branch 'janitaws/latex-setup' into coryab/code
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
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 main():
|
||||
files = [
|
||||
@@ -9,30 +23,34 @@ def main():
|
||||
"output/simulate_2_particles/with_interaction/particle_1_r.txt"
|
||||
]
|
||||
labels = [
|
||||
"particle 1 no interaction",
|
||||
"particle 2 no interaction",
|
||||
"particle 1 with interaction",
|
||||
"particle 2 with interaction",
|
||||
r"$p_1$",
|
||||
r"$p_2$",
|
||||
r"$\hat{p}_1$",
|
||||
r"$\hat{p}_2$",
|
||||
]
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"lightskyblue",
|
||||
"mediumaquamarine",
|
||||
"salmon",
|
||||
"salmon"
|
||||
"seagreen",
|
||||
"darkred"
|
||||
]
|
||||
start_pos = set()
|
||||
for label, color, file in zip(labels, colors, files):
|
||||
with open(file) as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
plt.plot(r[:,0], r[:,1], label=label, color=color)
|
||||
start_pos.add((r[0,0],r[0,1]))
|
||||
|
||||
for pos in start_pos:
|
||||
plt.plot(*pos, "o", color="black")
|
||||
|
||||
plt.xlabel(r"x $(\mu m)$")
|
||||
plt.ylabel(r"y $(\mu m)$")
|
||||
plt.title(r"2 particles with and without interactions.")
|
||||
# plt.legend()
|
||||
# plt.show()
|
||||
plt.savefig("../latex/images/plot_2_particles_xy.pdf")
|
||||
plt.legend(loc="upper right")
|
||||
plt.axis("equal")
|
||||
plt.savefig("../latex/images/plot_2_particles_xy.pdf", bbox_inches="tight")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
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",
|
||||
"figure.autolayout": True
|
||||
}
|
||||
plt.rcParams.update(params)
|
||||
|
||||
def main():
|
||||
files = [
|
||||
@@ -9,15 +24,15 @@ def main():
|
||||
"output/simulate_2_particles/with_interaction/particle_1_r.txt"
|
||||
]
|
||||
labels = [
|
||||
"particle 1 no interaction",
|
||||
"particle 2 no interaction",
|
||||
"particle 1 with interaction",
|
||||
"particle 2 with interaction",
|
||||
r"$p_1$",
|
||||
r"$p_2$",
|
||||
r"$\hat{p}_1$",
|
||||
r"$\hat{p}_2$",
|
||||
]
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"deepskyblue",
|
||||
"mediumaquamarine",
|
||||
"salmon",
|
||||
"seagreen",
|
||||
"darkred"
|
||||
]
|
||||
ax = plt.figure().add_subplot(projection="3d")
|
||||
@@ -31,6 +46,8 @@ def main():
|
||||
ax.set_xlabel(r"x $(\mu m)$")
|
||||
ax.set_ylabel(r"y $(\mu m)$")
|
||||
ax.set_zlabel(r"z $(\mu m)$")
|
||||
ax.view_init(10,-35)
|
||||
|
||||
plt.title(r"2 particles with and without interactions.")
|
||||
plt.legend()
|
||||
plt.savefig("../latex/images/3d_plot.pdf")
|
||||
|
||||
@@ -29,9 +29,9 @@ def main():
|
||||
"output/time_dependent_potential/narrow_sweep_interactions.txt",
|
||||
]
|
||||
outputs = [
|
||||
"../latex/images/wide_sweep.pdf",
|
||||
"../latex/images/narrow_sweep.pdf",
|
||||
"../latex/images/narrow_sweep_interactions.pdf",
|
||||
"../latex/images/particles_left_wide_sweep.pdf",
|
||||
"../latex/images/particles_left_narrow_sweep.pdf",
|
||||
"../latex/images/particles_left_narrow_sweep_interactions.pdf",
|
||||
]
|
||||
for file, output in zip(files, outputs):
|
||||
with open(file) as f:
|
||||
|
||||
@@ -1,52 +1,75 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
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 main():
|
||||
directories = {
|
||||
"output/simulate_2_particles/no_interaction/",
|
||||
"output/simulate_2_particles/with_interaction/",
|
||||
}
|
||||
titles = {
|
||||
"particles without interaction",
|
||||
"particles with interaction"
|
||||
}
|
||||
files = [
|
||||
"particle_0_r.txt",
|
||||
"particle_0_v.txt",
|
||||
"particle_1_r.txt",
|
||||
"particle_1_v.txt",
|
||||
"particle_0",
|
||||
"particle_1",
|
||||
]
|
||||
labels = [
|
||||
r"particle 1 r",
|
||||
r"particle 1 v",
|
||||
r"particle 2 r",
|
||||
r"particle 2 v",
|
||||
]
|
||||
[r"$p_1$", r"$\hat{p}_1$"],
|
||||
[r"$p_2$", r"$\hat{p}_2$"]
|
||||
]
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"deepskyblue",
|
||||
"salmon",
|
||||
"tomato",
|
||||
]
|
||||
fig1, axs1 = plt.subplots(2,1)
|
||||
fig2, axs2 = plt.subplots(2,1)
|
||||
for i, (dir, title) in enumerate(zip(directories, titles)):
|
||||
for label, color, file in zip(labels, colors, files):
|
||||
with open(dir+file) as f:
|
||||
linestyles = [
|
||||
"solid",
|
||||
"dotted"
|
||||
]
|
||||
fig1, axs1 = plt.subplots(2,1,sharex=True)
|
||||
fig2, axs2 = plt.subplots(2,1,sharex=True)
|
||||
for i, (file, label) in enumerate(zip(files, labels)):
|
||||
for j, (dir, linestyle) in enumerate(zip(directories, linestyles)):
|
||||
r = []
|
||||
v = []
|
||||
with open(dir+file+"_r.txt") as f:
|
||||
lines = f.readlines()
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
axs1[i].plot(t, r[:,0], label=label, color=color)
|
||||
axs2[i].plot(t, r[:,2], label=label, color=color)
|
||||
|
||||
axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"z $(\mu m)$")
|
||||
|
||||
axs1[i].legend()
|
||||
axs1[i].set_title(title)
|
||||
|
||||
with open(dir+file+"_v.txt") as f:
|
||||
lines = f.readlines()
|
||||
v = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
axs1[i].plot(r[:,0], v[:,0], label=label[j])
|
||||
axs2[i].plot(r[:,2], v[:,2], label=label[j])
|
||||
axs1[i].axis("equal")
|
||||
axs2[i].axis("equal")
|
||||
|
||||
|
||||
axs1[1].set(xlabel=r"t $(\mu s)$", ylabel = r"x $(\mu m)$")
|
||||
axs1[0].set(ylabel = r"x $(\mu m)$")
|
||||
axs2[1].set(xlabel=r"t $(\mu s)$", ylabel = r"z $(\mu m)$")
|
||||
axs2[0].set(ylabel = r"z $(\mu m)$")
|
||||
|
||||
axs1[i].legend(loc="upper right")
|
||||
# axs1[i].set_title(title)
|
||||
axs2[i].legend(loc="upper right")
|
||||
# axs2[i].set_title(title)
|
||||
|
||||
fig1.savefig("../latex/images/phase_space_2_particles_x.pdf", bbox_inches="tight")
|
||||
fig2.savefig("../latex/images/phase_space_2_particles_z.pdf", bbox_inches="tight")
|
||||
# plt.show()
|
||||
fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
|
||||
fig2.savefig("../latex/images/phase_space_2_particles_z.pdf")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
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 main():
|
||||
directories = [
|
||||
@@ -13,10 +27,10 @@ def main():
|
||||
"32000_steps.txt",
|
||||
]
|
||||
labels = [
|
||||
r"4000 steps",
|
||||
r"8000 steps",
|
||||
r"16000 steps",
|
||||
r"32000 steps",
|
||||
r"$n_1$",
|
||||
r"$n_2$",
|
||||
r"$n_3$",
|
||||
r"$n_4$",
|
||||
]
|
||||
titles = [
|
||||
"Relative error for the RK4 method",
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
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 z(t):
|
||||
V_0 = 25.*9.64852558 * 10**4
|
||||
@@ -9,6 +23,14 @@ def z(t):
|
||||
return 20.*np.cos(w_z*t)
|
||||
|
||||
def main():
|
||||
colors = [
|
||||
"lightskyblue",
|
||||
"deepskyblue",
|
||||
"salmon",
|
||||
"tomato",
|
||||
"mediumaquamarine",
|
||||
"mediumseagreen"
|
||||
]
|
||||
filename = "output/simulate_single_particle/particle_0_r.txt"
|
||||
r = t = []
|
||||
with open(filename) as f:
|
||||
@@ -16,14 +38,17 @@ def main():
|
||||
t = np.linspace(0, 50, len(lines))
|
||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||
|
||||
plt.plot(t, r[:, 2], label="approximation")
|
||||
plt.plot(t, z(t), label="analytical")
|
||||
plt.xlabel(r"time $(\mu s)$")
|
||||
plt.ylabel(r"z $(\mu m)$")
|
||||
plt.title(r"Movement of a single particle in the x direction")
|
||||
plt.legend()
|
||||
# plt.savefig("../latex/images/single_particle.pdf")
|
||||
plt.show()
|
||||
fig, ax = plt.subplots()
|
||||
ax.plot(t, r[:, 2], label="approximation", color="mediumseagreen")
|
||||
ax.plot(t, z(t), label="analytical", color="black", linestyle="dotted")
|
||||
ax.set_xlabel(r"t $(\mu s)$")
|
||||
ax.set_xlim((-5, 55))
|
||||
ax.set_ylabel(r"z $(\mu m)$")
|
||||
ax.set_ylim((-25, 25))
|
||||
# plt.title(r"Movement of a single particle in the x direction")
|
||||
ax.legend(loc="upper right")
|
||||
fig.savefig("../latex/images/single_particle.pdf", bbox_inches="tight")
|
||||
# plt.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user