-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorbital_mechanics.py
47 lines (38 loc) · 1.18 KB
/
orbital_mechanics.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
import numpy as np
def compute_position(t, a, b, omega):
"""
Compute the position of the gravity anchor in an elliptical orbit.
Args:
t (float): Time (s)
a (float): Semi-major axis (m)
b (float): Semi-minor axis (m)
omega (float): Angular velocity (rad/s)
Returns:
tuple: (x, y, z) coordinates (m)
"""
x = a * np.cos(omega * t)
y = b * np.sin(omega * t)
z = 0
return x, y, z
def compute_potential(x, y, z, M, G):
"""
Compute the gravitational potential at the center due to the anchor.
Args:
x, y, z (float): Position of the anchor (m)
M (float): Mass of the anchor (kg)
G (float): Gravitational constant (m^3 kg^-1 s^-2)
Returns:
float: Gravitational potential (m^2 s^-2)
"""
r = np.sqrt(x**2 + y**2 + z**2)
return -G * M / r if r > 0 else 0
def compute_time_dilation(Phi, c):
"""
Compute the gravitational time dilation factor.
Args:
Phi (float): Gravitational potential (m^2 s^-2)
c (float): Speed of light (m/s)
Returns:
float: Time dilation factor
"""
return np.sqrt(1 + 2 * Phi / c**2)