-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_file.py
120 lines (107 loc) · 2.96 KB
/
main_file.py
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import math
import matplotlib.pyplot as plt
import numpy as np
from scipy import integrate
import orbits
from constants import M_P, M_S, ORBIT_NUM, PRECISION, G, R # User defined constants
from constants import solar_rad, planet_rad, period, time_span # Derived constants
# ROTATING FRAME
orbit_sol = orbits.rotating_frame()
# for i in range(len(orbit_sol.t)):
# print(orbit_sol.t[i], orbit_sol.y[0, i], orbit_sol.y[1, i])
# DEVIATION FROM LAGRANGE POINT
lagrange_x = planet_rad - R / 2
# plt.plot(time_span, (np.abs(lagrange_x - orbit_sol.y[0, :])))
plt.plot(time_span, ((lagrange_x - orbit_sol.y[0, :])))
# plt.yscale("log", basey=10)
plt.ticklabel_format(axis="y", style="", scilimits=None)
plt.ylabel("Magnitude of Deviation /AU")
plt.xlabel("Time /years")
plt.title("Asteroid Deviation from Lagrange point")
# plt.savefig("asteroid_deviation_linear.png")
plt.show()
# MOTION IN ROTATING FRAME
plt.plot(
orbits.solar_pos(0)[0],
0,
label="Sun",
color="yellow",
markersize=12,
marker="o",
linestyle="None",
)
plt.plot(
orbits.planet_pos(0)[0],
0,
label="Jupiter",
color="red",
markersize=8,
marker="o",
linestyle="None",
)
plt.plot(orbit_sol.y[0, :], orbit_sol.y[1, :], label="Greeks")
plt.legend()
plt.title("Rotating Frame")
plt.show()
plt.plot(orbit_sol.y[0, :], orbit_sol.y[1, :], label="Greeks")
plt.title("Rotating Frame just Greeks")
plt.show()
#################################################################
# STATIONARY FRAME
orbit_sol2 = orbits.stationary_frame()
# for i in range(len(orbit_sol2.t)):
# print(orbit_sol2.t[i], orbit_sol2.y[0, i], orbit_sol.y[1, i])
# STATIONARY FRAME
plt.plot(0, 0, label="CoM", color="black", marker="x", linestyle="None")
plt.plot(
orbits.solar_pos(time_span)[0],
orbits.solar_pos(time_span)[1],
label="Sun",
color="yellow",
# markersize=12,
# marker="o",
linestyle="dotted",
)
plt.plot(
orbits.planet_pos(time_span)[0],
orbits.planet_pos(time_span)[1],
label="Jupiter",
color="red",
# markersize=8,
# marker="o",
linestyle="dotted",
)
plt.plot(orbit_sol2.y[0, :], orbit_sol2.y[1, :], label="Greeks")
plt.title("Stationary Frame")
plt.legend()
plt.show()
plt.plot(
time_span,
np.linalg.norm(
[
(orbit_sol2.y[0, :] - orbits.planet_pos(time_span)[0]),
(orbit_sol2.y[1, :] - orbits.planet_pos(time_span)[1]),
],
axis=0,
),
)
plt.title("Separtion between Jupiter and Greeks in Rotating Frame")
plt.ylabel("Separation / AU")
plt.xlabel("Time / years")
# plt.savefig("longseparation.png")
plt.show()
plt.plot(
time_span,
np.linalg.norm(
[
(orbit_sol2.y[0, :] - orbits.lagrange_pos(time_span)[0]),
(orbit_sol2.y[1, :] - orbits.lagrange_pos(time_span)[1]),
],
axis=0,
),
)
plt.title("Deviation of Greeks from Lagrange Point")
plt.ylabel("Separation / AU")
plt.xlabel("Time / years")
plt.savefig("asteroid_deviation_stat.png")
plt.show()