Penning Trap Simulation
Simulate particle behavior inside a Penning Trap
Loading...
Searching...
No Matches
plot_2_particles.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 main():
31 directories = {
32 "output/simulate_2_particles/no_interaction/",
33 "output/simulate_2_particles/with_interaction/",
34 }
35 files = [
36 "particle_0_r.txt",
37 "particle_1_r.txt",
38 ]
39 outputs = [
40 "../latex/images/simulate_2_particles_no_interaction_xy.pdf",
41 "../latex/images/simulate_2_particles_interaction_xy.pdf",
42 ]
43 labels = [
44 r"$p_1$",
45 r"$p_2$",
46 r"$\hat{p}_1$",
47 r"$\hat{p}_2$",
48 ]
49 colors = [
50 "seagreen",
51 "darkred"
52 ]
53 start_pos = set()
54 for dir, output in zip(directories, outputs):
55 fig, ax = plt.subplots()
56 for label, color, file in zip(labels, colors, files):
57 with open(dir+file) as f:
58 lines = f.readlines()
59 t = np.linspace(0, 50, len(lines))
60 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
61 ax.plot(r[:,0], r[:,1], label=label, color=color)
62 start_pos.add((r[0,0],r[0,1]))
63
64 for pos in start_pos:
65 ax.plot(*pos, "o", color="black")
66
67 ax.set_xlabel(r"x $(\mu m)$")
68 ax.set_ylabel(r"y $(\mu m)$")
69 ax.legend(loc="upper right")
70 ax.axis("equal")
71 fig.savefig(output, bbox_inches="tight")
72
73
74if __name__ == "__main__":
75 main()