Update plots
This commit is contained in:
parent
e42c108d20
commit
8373deea81
@ -20,21 +20,13 @@ def main():
|
|||||||
"output/simulate_2_particles/no_interaction/",
|
"output/simulate_2_particles/no_interaction/",
|
||||||
"output/simulate_2_particles/with_interaction/",
|
"output/simulate_2_particles/with_interaction/",
|
||||||
}
|
}
|
||||||
titles = {
|
|
||||||
"particles without interaction",
|
|
||||||
"particles with interaction"
|
|
||||||
}
|
|
||||||
files = [
|
files = [
|
||||||
"particle_0_r.txt",
|
"particle_0",
|
||||||
"particle_0_v.txt",
|
"particle_1",
|
||||||
"particle_1_r.txt",
|
|
||||||
"particle_1_v.txt",
|
|
||||||
]
|
]
|
||||||
labels = [
|
labels = [
|
||||||
r"particle 1 r",
|
[r"$p_1$", r"$\hat{p}_1$"],
|
||||||
r"particle 1 v",
|
[r"$p_2$", r"$\hat{p}_2$"]
|
||||||
r"particle 2 r",
|
|
||||||
r"particle 2 v",
|
|
||||||
]
|
]
|
||||||
colors = [
|
colors = [
|
||||||
"lightskyblue",
|
"lightskyblue",
|
||||||
@ -42,25 +34,42 @@ def main():
|
|||||||
"salmon",
|
"salmon",
|
||||||
"tomato",
|
"tomato",
|
||||||
]
|
]
|
||||||
fig1, axs1 = plt.subplots(2,1)
|
linestyles = [
|
||||||
fig2, axs2 = plt.subplots(2,1)
|
"solid",
|
||||||
for i, (dir, title) in enumerate(zip(directories, titles)):
|
"dotted"
|
||||||
for label, color, file in zip(labels, colors, files):
|
]
|
||||||
with open(dir+file) as f:
|
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)):
|
||||||
|
with open(dir+file+"_r.txt") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
t = np.linspace(0, 50, len(lines))
|
t = np.linspace(0, 50, len(lines))
|
||||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||||
axs1[i].plot(t, r[:,0], label=label, color=color)
|
axs1[i].plot(t, r[:,0], label=f"{label[j]} r", linestyle=linestyle)
|
||||||
axs2[i].plot(t, r[:,2], label=label, color=color)
|
axs2[i].plot(t, r[:,2], label=f"{label[j]} r", linestyle=linestyle)
|
||||||
|
|
||||||
axs1[i].set(xlabel=r"t $(\mu s)$", ylabel = r"z $(\mu m)$")
|
with open(dir+file+"_v.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=f"{label[j]} v", linestyle=linestyle)
|
||||||
|
axs2[i].plot(t, r[:,2], label=f"{label[j]} v", linestyle=linestyle)
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
axs1[i].legend()
|
||||||
axs1[i].set_title(title)
|
# axs1[i].set_title(title)
|
||||||
|
axs2[i].legend()
|
||||||
|
# axs2[i].set_title(title)
|
||||||
|
|
||||||
fig1.savefig("../latex/images/phase_space_2_particles_x.pdf")
|
fig1.savefig("../latex/images/phase_space_2_particles_x.pdf", bbox_inches="tight")
|
||||||
fig2.savefig("../latex/images/phase_space_2_particles_z.pdf")
|
fig2.savefig("../latex/images/phase_space_2_particles_z.pdf", bbox_inches="tight")
|
||||||
plt.show()
|
# plt.show()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@ -39,9 +39,9 @@ def main():
|
|||||||
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
ax.plot(t, r[:, 2], label="approximation", color=colors[3])
|
ax.plot(t, r[:, 2], label="approximation", color="mediumseagreen")
|
||||||
ax.plot(t, z(t), label="analytical", color=colors[5], linestyle="dotted")
|
ax.plot(t, z(t), label="analytical", color="black", linestyle="dotted")
|
||||||
ax.set_xlabel(r"Time $(\mu s)$")
|
ax.set_xlabel(r"t $(\mu s)$")
|
||||||
ax.set_xlim((-5, 55))
|
ax.set_xlim((-5, 55))
|
||||||
ax.set_ylabel(r"z $(\mu m)$")
|
ax.set_ylabel(r"z $(\mu m)$")
|
||||||
ax.set_ylim((-25, 25))
|
ax.set_ylim((-25, 25))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user