Coryab/code #10

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

View File

@ -42,19 +42,19 @@ def main():
fig2, axs2 = plt.subplots(2,1,sharex=True) fig2, axs2 = plt.subplots(2,1,sharex=True)
for i, (file, label) in enumerate(zip(files, labels)): for i, (file, label) in enumerate(zip(files, labels)):
for j, (dir, linestyle) in enumerate(zip(directories, linestyles)): for j, (dir, linestyle) in enumerate(zip(directories, linestyles)):
r = []
v = []
with open(dir+file+"_r.txt") as f: with open(dir+file+"_r.txt") as f:
lines = f.readlines() lines = f.readlines()
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=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: with open(dir+file+"_v.txt") as f:
lines = f.readlines() lines = f.readlines()
t = np.linspace(0, 50, len(lines)) v = 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(r[:,0], v[:,0], label=label[j])
axs1[i].plot(t, r[:,0], label=f"{label[j]} v", linestyle=linestyle) axs2[i].plot(r[:,2], v[:,2], label=label[j])
axs2[i].plot(t, r[:,2], label=f"{label[j]} v", linestyle=linestyle) axs1[i].axis("equal")
axs2[i].axis("equal")
axs1[1].set(xlabel=r"t $(\mu s)$", ylabel = r"x $(\mu m)$") axs1[1].set(xlabel=r"t $(\mu s)$", ylabel = r"x $(\mu m)$")