Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Six component state vector [x, y, z, vx, vy, vz] (km, km/s).
k : float
gravitational constant, (km^3/s^2)
J2: float
oblateness factor
R: float
attractor radius
Note
----
The J2 accounts for the oblateness of the attractor. The formula is given in
Howard Curtis, (12.30)
"""
r_vec = state[:3]
r = norm(r_vec)
factor = (3.0 / 2.0) * k * J2 * (R ** 2) / (r ** 5)
a_x = 5.0 * r_vec[2] ** 2 / r ** 2 - 1
a_y = 5.0 * r_vec[2] ** 2 / r ** 2 - 1
a_z = 5.0 * r_vec[2] ** 2 / r ** 2 - 3
return np.array([a_x, a_y, a_z]) * r_vec * factor
def a_d(t0, u_, k):
r = u_[:3]
v = u_[3:]
nu = rv2coe(k, r, v)[-1]
beta_ = beta_0_ * np.sign(
np.cos(nu)
) # The sign of ß reverses at minor axis crossings
w_ = cross(r, v) / norm(cross(r, v))
accel_v = f * (np.cos(beta_) * thrust_unit + np.sin(beta_) * w_)
return accel_v
H0 : float
atmospheric scale height, (km)
rho0: float
the exponent density pre-factor, (kg / m^3)
Note
----
This function provides the acceleration due to atmospheric drag. We follow
Howard Curtis, section 12.4
the atmospheric density model is rho(H) = rho0 x exp(-H / H0)
"""
H = norm(state[:3])
v_vec = state[3:]
v = norm(v_vec)
B = C_D * A / m
rho = rho0 * np.exp(-(H - R) / H0)
return -(1.0 / 2.0) * rho * B * v * v_vec
mass of the spacecraft (kg)
Wdivc_s : float
total star emitted power divided by the speed of light (W * s / km)
star: a callable object returning the position of star in attractor frame
star position
Note
----
This function provides the acceleration due to star light pressure. We follow
Howard Curtis, section 12.9
"""
r_star = star(t0)
r_sat = state[:3]
P_s = Wdivc_s / (norm(r_star) ** 2)
nu = float(shadow_function(r_sat, r_star, R))
return -nu * P_s * (C_R * A / m) * r_star / norm(r_star)
star: a callable object returning the position of star in attractor frame
star position
Note
----
This function provides the acceleration due to star light pressure. We follow
Howard Curtis, section 12.9
"""
r_star = star(t0)
r_sat = state[:3]
P_s = Wdivc_s / (norm(r_star) ** 2)
nu = float(shadow_function(r_sat, r_star, R))
return -nu * P_s * (C_R * A / m) * r_star / norm(r_star)
ecc_f : float
Final eccentricity.
inc_f : float
Final inclination.
f : float
Magnitude of constant acceleration.
"""
# We fix the inertial direction at the beginning
ecc_0 = ss_0.ecc.value
if ecc_0 > 0.001: # Arbitrary tolerance
ref_vec = ss_0.e_vec / ecc_0
else:
ref_vec = ss_0.r / norm(ss_0.r)
h_unit = ss_0.h_vec / norm(ss_0.h_vec)
thrust_unit = cross(h_unit, ref_vec) * np.sign(ecc_f - ecc_0)
inc_0 = ss_0.inc.to(u.rad).value
argp = ss_0.argp.to(u.rad).value
beta_0_ = beta(ecc_0, ecc_f, inc_0, inc_f, argp)
def a_d(t0, u_, k):
r = u_[:3]
v = u_[3:]
nu = rv2coe(k, r, v)[-1]
beta_ = beta_0_ * np.sign(
np.cos(nu)
) # The sign of ß reverses at minor axis crossings
w_ = cross(r, v) / norm(cross(r, v))
def a_d(t0, u_, k):
r = u_[:3]
v = u_[3:]
nu = rv2coe(k, r, v)[-1]
alpha_ = nu - np.pi / 2
r_ = r / norm(r)
w_ = cross(r, v) / norm(cross(r, v))
s_ = cross(w_, r_)
accel_v = f * (np.cos(alpha_) * s_ + np.sin(alpha_) * r_)
return accel_v
Six component state vector [x, y, z, vx, vy, vz] (km, km/s).
k : float
gravitational constant, (km^3/s^2)
third_body: a callable object returning the position of 3rd body
third body that causes the perturbation
Note
----
This formula is taken from Howard Curtis, section 12.10. As an example, a third body could be
the gravity from the Moon acting on a small satellite.
"""
body_r = third_body(t0)
delta_r = body_r - state[:3]
return k_third * delta_r / norm(delta_r) ** 3 - k_third * body_r / norm(body_r) ** 3
frontal area of the spacecraft (km^2)
m: float
mass of the spacecraft (kg)
H0 : float
atmospheric scale height, (km)
rho0: float
the exponent density pre-factor, (kg / m^3)
Note
----
This function provides the acceleration due to atmospheric drag. We follow
Howard Curtis, section 12.4
the atmospheric density model is rho(H) = rho0 x exp(-H / H0)
"""
H = norm(state[:3])
v_vec = state[3:]
v = norm(v_vec)
B = C_D * A / m
rho = rho0 * np.exp(-(H - R) / H0)
return -(1.0 / 2.0) * rho * B * v * v_vec
k : float
gravitational constant, (km^3/s^2)
J3: float
oblateness factor
R: float
attractor radius
Note
----
The J3 accounts for the oblateness of the attractor. The formula is given in
Howard Curtis, problem 12.8
This perturbation has not been fully validated, see https://github.com/poliastro/poliastro/pull/398
"""
r_vec = state[:3]
r = norm(r_vec)
factor = (1.0 / 2.0) * k * J3 * (R ** 3) / (r ** 5)
cos_phi = r_vec[2] / r
a_x = 5.0 * r_vec[0] / r * (7.0 * cos_phi ** 3 - 3.0 * cos_phi)
a_y = 5.0 * r_vec[1] / r * (7.0 * cos_phi ** 3 - 3.0 * cos_phi)
a_z = 3.0 * (35.0 / 3.0 * cos_phi ** 4 - 10.0 * cos_phi ** 2 + 1)
return np.array([a_x, a_y, a_z]) * factor