def wander_wrapper(m):
    """Wrapper to find wander for given planet mass m, for asteroid starting 1e-4 au radially outwards of L4"""
    ast = RotatingAsteroid(M_P=m)
    # 100 samples per year for 100 planetary orbits
    end_time = 100 * ast.T
    points_per_year = 100
    ts = np.linspace(0, end_time, int(end_time * points_per_year))
    return ast.wander(
        ts,
        r_0=ast.L4 * (1 + 1e-4 / np.linalg.norm(ast.L4)),
        v_0=np.array([0, 0, 0]),
        stability_point=ast.L4,
    )
"""
Generates plot for wander for velocity perturbations tangent to the planet's
orbital circle.
Note that v is positive going away from the planet, towards L3.
"""
import numpy as np
import matplotlib.pyplot as plt
from rotatingframe import RotatingAsteroid
import multiprocessing
from scipy.optimize import curve_fit

ast = RotatingAsteroid()

# 100 samples per year for 100 planetary orbits
end_time = 100 * ast.T
points_per_year = 100
ts = np.linspace(0, end_time, int(end_time * points_per_year))

v_spread = 0.05
points = 100
vs = np.linspace(-v_spread, v_spread, points)


def wander_wrapper(v_offset):
    """Wrapper to put the correct arguments into wander method for given tangential velocity perturbation"""
    return ast.wander(
        ts,
        r_0=ast.L4,
        v_0=np.array([-ast.L4[1], ast.L4[0], 0]) / np.linalg.norm(ast.L4) * v_offset,
        stability_point=ast.L4,
    )
"""
Comparing the solving methods DOP853, Radau, BDF and LSODA included in 
scipy.integrate.solve_ivp

For each solver, the wander from L4 was found in both the stationary
and rotating frames.
"""
import numpy as np
from stationaryframe import StationaryAsteroid
from rotatingframe import RotatingAsteroid

# Instantiate asteroids for both frames
ast0 = StationaryAsteroid()
ast1 = RotatingAsteroid()

# 100 samples per year for 100 planetary orbits
end_time = 100 * ast0.T
points_per_year = 100
ts = np.linspace(0, end_time, int(end_time * points_per_year))

methods = ["DOP853", "Radau", "BDF", "LSODA"]
wanders = np.zeros((2, len(methods)))

for i in range(len(methods)):
    wanders[0, i] = ast0.wander(ts,
                                r_0=ast0.l4(0),
                                v_0=ast0.omega_cross(ast0.l4(0)),
                                method=methods[i])

    wanders[1, i] = ast1.wander(
        ts,
Exemplo n.º 4
0
"""
Plots for various initial conditions in the rotating frame, resulting in
tadpole, curved tadpole, horseshoe and passing orbits.

Note: the simulations are all run for shorter times than 100 years to avoid
the plots becoming unclear.
"""
import numpy as np
import matplotlib.pyplot as plt
from constants import M_SUN
from rotatingframe import RotatingAsteroid

ast = RotatingAsteroid()

points_per_year = 1000

# Approximate radius of L3 for plotting
L3 = ast.R_P + 7 * ast.R * ast.M_P / (12 * M_SUN)

fig, ax = plt.subplots(2, 2, figsize=(7, 8))

### Tadpole ###

# 100 samples per year for 15 planetary orbits
end_time = 15 * ast.T
ts = np.linspace(0, end_time, int(end_time * points_per_year))

tadpole_sol = ast.trajectory(t_eval=ts, r_0=ast.L4 * 1.001, v_0=np.array([0, 0, 0]))

ax[0, 0].plot(
    tadpole_sol.y[0], tadpole_sol.y[1], label="asteroid", color="green", linestyle="-"
Exemplo n.º 5
0
"""
Generates plots investigating oscillations in the z direction

Uses the rotating frame to plot the oscillating behaviour of an asteroid perturbed
in the z direction, then plots time period for varying perturbations.
"""
import numpy as np
import matplotlib.pyplot as plt
from rotatingframe import RotatingAsteroid
import multiprocessing

ast = RotatingAsteroid()

# 100 samples per year for 100 planetary orbits
end_time = 10 * ast.T
points_per_year = 100
ts = np.linspace(0, end_time, int(end_time * points_per_year))

z_min = 0.01
z_max = 1.0
points = 50
zs = np.linspace(z_min, z_max, points)


def zero(t, y):
    """Event to find when the asteroid passes through the orbital plane"""
    return y[2]


def time_period_wrapper(z):
    """Wrapper to find time period for given z position perturbation"""