Develop #14

Merged
coryab merged 124 commits from develop into main 2023-10-24 20:43:56 +00:00
2 changed files with 44 additions and 33 deletions
Showing only changes of commit b985a2c25f - Show all commits

View File

@ -23,35 +23,46 @@ def main():
"mediumaquamarine",
"mediumseagreen"
]
with open("output/time_dependent_potential/res.txt") as f:
lines = f.readlines()
x = []
y1 = []
y2 = []
y3 = []
for line in lines:
l = line.strip().split(",")
x.append(float(l[0]))
y1.append(float(l[1]))
y2.append(float(l[2]))
y3.append(float(l[3]))
files = [
"output/time_dependent_potential/wide_sweep.txt",
"output/time_dependent_potential/narrow_sweep.txt",
"output/time_dependent_potential/narrow_sweep_interactions.txt",
]
outputs = [
"particles_left_wide_sweep.pdf",
"particles_left_narrow_sweep.pdf",
"particles_left_narrow_sweep_interactions.pdf",
]
for file, output in zip(files, outputs):
with open(file) as f:
lines = f.readlines()
x = []
y1 = []
y2 = []
y3 = []
for line in lines:
l = line.strip().split(",")
x.append(float(l[0]))
y1.append(float(l[1]))
y2.append(float(l[2]))
y3.append(float(l[3]))
fig, ax = plt.subplots()
ax.plot(x, y1, label=r"$f_{1} = 0.1$", color=colors[0])
ax.plot(x, y2, label=r"$f_{2} = 0.4$", color=colors[2])
ax.plot(x, y3, label=r"$f_{3} = 0.7$", color=colors[4])
fig, ax = plt.subplots()
ax.plot(x, y1, label=r"$f_{1} = 0.1$", color=colors[0])
ax.plot(x, y2, label=r"$f_{2} = 0.4$", color=colors[2])
ax.plot(x, y3, label=r"$f_{3} = 0.7$", color=colors[4])
ax.set_xlabel(r"Frequency $\omega_V$ (MHz)")
ax.set_xlim((0, 2.8))
ax.set_ylabel(r"Fraction of particles left")
ax.set_ylim((-0.1, 1.1))
# plt.title(r"The fraction of particles left in the Penning trap "
# "after 500 microseconds for different amplitudes and frequencies")
ax.legend(loc="upper right")
ax.set_xlabel(r"Frequency $\omega_V$ (MHz)")
# ax.set_xlim((0, 2.8))
ax.set_ylabel(r"Fraction of particles left")
# ax.set_ylim((-0.1, 1.1))
# plt.title(r"The fraction of particles left in the Penning trap "
# "after 500 microseconds for different amplitudes and frequencies")
ax.legend(loc="upper right")
# plt.show()
fig.savefig("../latex/images/particles_left.pdf", bbox_inches="tight")
# plt.show()
fig.savefig(f"../latex/images/{output}", bbox_inches="tight")
if __name__ == "__main__":
main()

View File

@ -42,19 +42,19 @@ def main():
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=f"{label[j]} r", linestyle=linestyle)
axs2[i].plot(t, r[:,2], label=f"{label[j]} r", linestyle=linestyle)
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)
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)$")