Penning Trap Simulation
Simulate particle behavior inside a Penning Trap
Loading...
Searching...
No Matches
plot_particles_left.py
Go to the documentation of this file.
1
12
13
import
matplotlib.pyplot
as
plt
14
import
seaborn
as
sns
15
16
sns.set_theme()
17
params = {
18
"font.family"
:
"Serif"
,
19
"font.serif"
:
"Roman"
,
20
"text.usetex"
:
True
,
21
"axes.titlesize"
:
"large"
,
22
"axes.labelsize"
:
"large"
,
23
"xtick.labelsize"
:
"large"
,
24
"ytick.labelsize"
:
"large"
,
25
"legend.fontsize"
:
"medium"
26
}
27
plt.rcParams.update(params)
28
29
def
main():
30
colors = [
31
"mediumseagreen"
,
32
"darkred"
,
33
"darkgoldenrod"
34
]
35
files = [
36
"output/time_dependent_potential/wide_sweep.txt"
,
37
"output/time_dependent_potential/narrow_sweep.txt"
,
38
"output/time_dependent_potential/narrow_sweep_fine.txt"
,
39
"output/time_dependent_potential/narrow_sweep_interactions.txt"
,
40
"output/time_dependent_potential/narrow_sweep_interactions_fine.txt"
,
41
]
42
outputs = [
43
"../latex/images/particles_left_wide_sweep.pdf"
,
44
"../latex/images/particles_left_narrow_sweep.pdf"
,
45
"../latex/images/particles_left_narrow_sweep_fine.pdf"
,
46
"../latex/images/particles_left_narrow_sweep_interactions.pdf"
,
47
"../latex/images/particles_left_narrow_sweep_interactions_fine.pdf"
,
48
]
49
for
file, output
in
zip(files, outputs):
50
with
open(file)
as
f:
51
lines = f.readlines()
52
x = []
53
y1 = []
54
y2 = []
55
y3 = []
56
for
line
in
lines:
57
l = line.strip().split(
","
)
58
x.append(float(l[0]))
59
y1.append(float(l[1]))
60
y2.append(float(l[2]))
61
y3.append(float(l[3]))
62
63
fig, ax = plt.subplots()
64
ax.plot(x, y1, label=
r"$f_{1} = 0.1$"
, color=colors[0])
65
ax.plot(x, y2, label=
r"$f_{2} = 0.4$"
, color=colors[1])
66
ax.plot(x, y3, label=
r"$f_{3} = 0.7$"
, color=colors[2])
67
68
ax.set_xlabel(
r"Angular frequency $\omega_V$ (MHz)"
)
69
# ax.set_xlim((0, 2.8))
70
ax.set_ylabel(
r"Fraction of particles left"
)
71
# ax.set_ylim((-0.1, 1.1))
72
# plt.title(r"The fraction of particles left in the Penning trap "
73
# "after 500 microseconds for different amplitudes and frequencies")
74
75
ax.legend(loc=
"upper right"
)
76
77
# plt.show()
78
fig.savefig(output, bbox_inches=
"tight"
)
79
80
if
__name__ ==
"__main__"
:
81
main()
src
scripts
plot_particles_left.py
Generated by
1.9.6