-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
executable file
·85 lines (53 loc) · 1.7 KB
/
plot.py
File metadata and controls
executable file
·85 lines (53 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! venv/bin/python3
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
from matplotlib.markers import MarkerStyle
import yaml
from glob import glob
if __name__ == "__main__":
"""
Script for visualizing the results of Sitnikov problem simulations.
This script loads simulation data and generates phase portraits showing
the relationship between position (z) and velocity (dz/dt) of the third body
in the Sitnikov problem.
"""
try:
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": "serif",
"font.size" : 12
})
except:
print("TeX font is not availible")
with open("config.yaml", "r") as stream:
conf = yaml.safe_load(stream)
rev_min = conf["plotter"]["rev_min"]
xmin = conf["plotter"]["zmin"]
xmax = conf["plotter"]["zmax"]
ymin = conf["plotter"]["dotzmin"]
ymax = conf["plotter"]["dotzmax"]
dpi = conf["plotter"]["dpi"]
track = conf["parallel"]["track"]
res_list = glob("result/*t.dat")
size = len(res_list)
plt.figure(figsize = (6, 6))
plt.title("Phase portrait")
plt.xlabel(r"$z$")
plt.ylabel(r"$\dot z$")
plt.xlim(xmin, xmax)
plt.ylim(ymin, ymax)
for i in range(size):
print(f"\rProcessing thread {i+1}", end = "")
ts = np.loadtxt(f"result/{i+1}t.dat")
zs = np.loadtxt(f"result/{i+1}zs.dat")
vs = np.loadtxt(f"result/{i+1}vs.dat")
zs = np.atleast_2d(zs)
vs = np.atleast_2d(vs)
plt.plot(zs, vs,
",",
color = "black"
)
print("")
plt.savefig("123.png", dpi = dpi)