Penning Trap Simulation Simulate particle behavior inside a Penning Trap

Loading...
Searching...
No Matches
plot_single_particle.py
1 import matplotlib.pyplot as plt
2 import numpy as np
3
4 def z(t):
5 V_0 = 25.*9.64852558 * 10**4
6 m = 40.
7 d = 500.
8 w_z = np.sqrt((2.*V_0)/(m*d*d))
9 return 20.*np.cos(w_z*t)
10
11 def main():
12 filename = "output/simulate_single_particle/particle_0_r.txt"
13 r = t = []
14 with open(filename) as f:
15 lines = f.readlines()
16 t = np.linspace(0, 50, len(lines))
17 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
18
19 plt.plot(t, r[:, 2], label="approximation")
20 plt.plot(t, z(t), label="analytical")
21 plt.xlabel(r"time $(\mu s)$")
22 plt.ylabel(r"z $(\mu m)$")
23 plt.title(r"Movement of a single particle in the x direction")
24 plt.legend()
25 # plt.savefig("../latex/images/single_particle.pdf")
26 plt.show()
27
28
29 if __name__ == "__main__":
30 main()