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