Penning Trap Simulation
Simulate particle behavior inside a Penning Trap
Loading...
Searching...
No Matches
plot_single_particle.py
Go to the documentation of this file.
1
12
13import matplotlib.pyplot as plt
14import numpy as np
15import seaborn as sns
16
17sns.set_theme()
18params = {
19 "font.family": "Serif",
20 "font.serif": "Roman",
21 "text.usetex": True,
22 "axes.titlesize": "large",
23 "axes.labelsize": "large",
24 "xtick.labelsize": "large",
25 "ytick.labelsize": "large",
26 "legend.fontsize": "medium"
27}
28plt.rcParams.update(params)
29
30def z(t):
31 V_0 = 25.*9.64852558 * 10**4
32 m = 40.
33 d = 500.
34 w_z = np.sqrt((2.*V_0)/(m*d*d))
35 return 20.*np.cos(w_z*t)
36
37def main():
38 filename = "output/simulate_single_particle/particle_0_r.txt"
39 r = t = []
40 with open(filename) as f:
41 lines = f.readlines()
42 t = np.linspace(0, 50, len(lines))
43 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
44
45 fig, ax = plt.subplots()
46 ax.plot(t, r[:, 2], label="approximation", color="mediumseagreen")
47 ax.plot(t, z(t), label="analytical", color="black", linestyle="dotted")
48 ax.set_xlabel(r"t $(\mu s)$")
49 ax.set_xlim((-5, 55))
50 ax.set_ylabel(r"z $(\mu m)$")
51 ax.set_ylim((-25, 25))
52 # plt.title(r"Movement of a single particle in the x direction")
53 ax.legend(loc="upper right")
54 fig.savefig("../latex/images/single_particle.pdf", bbox_inches="tight")
55 # plt.show()
56
57
58if __name__ == "__main__":
59 main()