Penning Trap Simulation
Simulate particle behavior inside a Penning Trap
Loading...
Searching...
No Matches
plot_3d.py
Go to the documentation of this file.
1
11
12import matplotlib.pyplot as plt
13import numpy as np
14import seaborn as sns
15
16sns.set_theme()
17params = {
18 "font.family": "Serif",
19 "font.serif": "Roman",
20 "text.usetex": True,
21 "axes.titlesize": "large",
22 "axes.labelsize": "large",
23 "xtick.labelsize": "large",
24 "ytick.labelsize": "large",
25 "legend.fontsize": "medium",
26 "figure.autolayout": True
27}
28plt.rcParams.update(params)
29
30def main():
31 files = [
32 "output/simulate_2_particles/no_interaction/particle_0_r.txt",
33 "output/simulate_2_particles/no_interaction/particle_1_r.txt",
34 "output/simulate_2_particles/with_interaction/particle_0_r.txt",
35 "output/simulate_2_particles/with_interaction/particle_1_r.txt"
36 ]
37 labels = [
38 r"$p_1$",
39 r"$p_2$",
40 r"$\hat{p}_1$",
41 r"$\hat{p}_2$",
42 ]
43 colors = [
44 "mediumaquamarine",
45 "salmon",
46 "seagreen",
47 "darkred"
48 ]
49 ax = plt.figure().add_subplot(projection="3d")
50 for label, color, file in zip(labels, colors, files):
51 with open(file) as f:
52 lines = f.readlines()
53 t = np.linspace(0, 50, len(lines))
54 r = np.array([list(map(float, line.strip().split(","))) for line in lines])
55 ax.plot(r[:,0], r[:,1], r[:,2], label=label, color=color)
56
57 ax.set_xlabel(r"x $(\mu m)$")
58 ax.set_ylabel(r"y $(\mu m)$")
59 ax.set_zlabel(r"z $(\mu m)$")
60 ax.view_init(10,-35)
61
62 plt.legend()
63 plt.savefig("../latex/images/3d_plot.pdf")
64
65
66if __name__ == "__main__":
67 main()