Penning Trap Simulation Simulate particle behavior inside a Penning Trap

Loading...
Searching...
No Matches
plot_2_particles.py
1 import matplotlib.pyplot as plt
2 import numpy as np
3
4 def main():
5 files = [
6 "output/simulate_2_particles/no_interaction/particle_0_r.txt",
7 "output/simulate_2_particles/no_interaction/particle_1_r.txt",
8 "output/simulate_2_particles/with_interaction/particle_0_r.txt",
9 "output/simulate_2_particles/with_interaction/particle_1_r.txt"
10 ]
11 labels = [
12 "particle 1 no interaction",
13 "particle 2 no interaction",
14 "particle 1 with interaction",
15 "particle 2 with interaction",
16 ]
17 colors = [
18 "lightskyblue",
19 "lightskyblue",
20 "salmon",
21 "salmon"
22 ]
23 for label, color, file in zip(labels, colors, files):
24 with open(file) as f:
25 lines = f.readlines()
26 t = np.linspace(0, 50, len(lines))
27 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
28 plt.plot(r[:,0], r[:,1], label=label, color=color)
29
30 plt.xlabel(r"x $(\mu m)$")
31 plt.ylabel(r"y $(\mu m)$")
32 plt.title(r"2 particles with and without interactions.")
33 # plt.legend()
34 # plt.show()
35 plt.savefig("../latex/images/plot_2_particles_xy.pdf")
36
37
38 if __name__ == "__main__":
39 main()