Exemplo n.º 1
0
def test_atmospheric_demise():
    # Test an orbital decay that hits Earth. No analytic solution.
    R = Earth.R.to(u.km).value

    orbit = Orbit.circular(Earth, 230 * u.km)
    t_decay = 48.2179 * u.d  # not an analytic value

    # parameters of a body
    C_D = 2.2  # dimentionless (any value would do)
    A_over_m = ((np.pi / 4.0) * (u.m**2) / (100 * u.kg)).to_value(
        u.km**2 / u.kg)  # km^2/kg

    # parameters of the atmosphere
    rho0 = rho0_earth.to(u.kg / u.km**3).value  # kg/km^3
    H0 = H0_earth.to(u.km).value  # km

    tofs = [365] * u.d  # actually hits the ground a bit after day 48

    lithobrake_event = LithobrakeEvent(R)
    events = [lithobrake_event]

    rr, _ = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
        ad=atmospheric_drag_exponential,
        R=R,
        C_D=C_D,
        A_over_m=A_over_m,
        H0=H0,
        rho0=rho0,
        events=events,
    )

    assert_quantity_allclose(norm(rr[0].to(u.km).value), R,
                             atol=1)  # below 1km

    assert_quantity_allclose(lithobrake_event.last_t, t_decay, rtol=1e-2)

    # make sure having the event not firing is ok
    tofs = [1] * u.d
    lithobrake_event = LithobrakeEvent(R)
    events = [lithobrake_event]

    rr, _ = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
        ad=atmospheric_drag_exponential,
        R=R,
        C_D=C_D,
        A_over_m=A_over_m,
        H0=H0,
        rho0=rho0,
        events=events,
    )

    assert lithobrake_event.last_t == tofs[-1]
Exemplo n.º 2
0
def test_atmospheric_demise_coesa76():
    # Test an orbital decay that hits Earth. No analytic solution.
    R = Earth.R.to(u.km).value

    orbit = Orbit.circular(Earth, 250 * u.km)
    t_decay = 7.17 * u.d

    # Parameters of a body
    C_D = 2.2  # Dimensionless (any value would do)
    A_over_m = ((np.pi / 4.0) * (u.m**2) / (100 * u.kg)).to_value(
        u.km**2 / u.kg)  # km^2/kg

    tofs = [365] * u.d

    lithobrake_event = LithobrakeEvent(R)
    events = [lithobrake_event]

    coesa76 = COESA76()

    def f(t0, u_, k):
        du_kep = func_twobody(t0, u_, k)

        # Avoid undershooting H below attractor radius R
        H = max(norm(u_[:3]), R)
        rho = coesa76.density((H - R) * u.km).to_value(u.kg / u.km**3)

        ax, ay, az = atmospheric_drag(
            t0,
            u_,
            k,
            C_D=C_D,
            A_over_m=A_over_m,
            rho=rho,
        )
        du_ad = np.array([0, 0, 0, ax, ay, az])
        return du_kep + du_ad

    rr, _ = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
        events=events,
        f=f,
    )

    assert_quantity_allclose(norm(rr[0].to(u.km).value), R,
                             atol=1)  # Below 1km

    assert_quantity_allclose(lithobrake_event.last_t, t_decay, rtol=1e-2)
Exemplo n.º 3
0
def test_atmospheric_demise_coesa76():
    # Test an orbital decay that hits Earth. No analytic solution.
    R = Earth.R.to(u.km).value

    orbit = Orbit.circular(Earth, 250 * u.km)
    t_decay = 7.17 * u.d

    # parameters of a body
    C_D = 2.2  # dimentionless (any value would do)
    A_over_m = ((np.pi / 4.0) * (u.m**2) / (100 * u.kg)).to_value(
        u.km**2 / u.kg)  # km^2/kg

    tofs = [365] * u.d

    lithobrake_event = LithobrakeEvent(R)
    events = [lithobrake_event]

    coesa76 = COESA76()

    def f(t0, u_, k):
        du_kep = func_twobody(t0, u_, k)
        ax, ay, az = atmospheric_drag_model(t0,
                                            u_,
                                            k,
                                            R=R,
                                            C_D=C_D,
                                            A_over_m=A_over_m,
                                            model=coesa76)
        du_ad = np.array([0, 0, 0, ax, ay, az])
        return du_kep + du_ad

    rr, _ = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
        events=events,
        f=f,
    )

    assert_quantity_allclose(norm(rr[0].to(u.km).value), R,
                             atol=1)  # below 1km

    assert_quantity_allclose(lithobrake_event.last_t, t_decay, rtol=1e-2)
Exemplo n.º 4
0
def test_atmospheric_demise():
    # Test an orbital decay that hits Earth. No analytic solution.
    R = Earth.R.to(u.km).value

    orbit = Orbit.circular(Earth, 230 * u.km)
    t_decay = 48.2179 * u.d

    # parameters of a body
    C_D = 2.2  # dimentionless (any value would do)
    A = ((np.pi / 4.0) * (u.m**2)).to(u.km**2).value  # km^2
    m = 100  # kg

    # parameters of the atmosphere
    rho0 = rho0_earth.to(u.kg / u.km**3).value  # kg/km^3
    H0 = H0_earth.to(u.km).value  # km

    tofs = [365] * u.d  # actually hits the ground a bit after day 48

    lithobrake_event = LithobrakeEvent(R)
    events = [lithobrake_event]

    rr, _ = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
        ad=atmospheric_drag,
        R=R,
        C_D=C_D,
        A=A,
        m=m,
        H0=H0,
        rho0=rho0,
        events=events,
    )

    assert_quantity_allclose(norm(rr[0].to(u.km).value), R,
                             atol=1)  # below 1km

    # last_t is not an analytic value
    assert_quantity_allclose(lithobrake_event.last_t, t_decay, rtol=1e-2)
Exemplo n.º 5
0
def test_atmospheric_demise_coesa76():
    # Test an orbital decay that hits Earth. No analytic solution.
    R = Earth.R.to(u.km).value

    orbit = Orbit.circular(Earth, 250 * u.km)
    t_decay = 7.17 * u.d

    # parameters of a body
    C_D = 2.2  # dimentionless (any value would do)
    A = ((np.pi / 4.0) * (u.m**2)).to(u.km**2).value  # km^2
    m = 100  # kg

    tofs = [365] * u.d

    lithobrake_event = LithobrakeEvent(R)
    events = [lithobrake_event]

    coesa76 = COESA76()

    rr, _ = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
        ad=atmospheric_drag_model,
        R=R,
        C_D=C_D,
        A=A,
        m=m,
        model=coesa76,
        events=events,
    )

    assert_quantity_allclose(norm(rr[0].to(u.km).value), R,
                             atol=1)  # below 1km

    assert_quantity_allclose(lithobrake_event.last_t, t_decay, rtol=1e-2)
Exemplo n.º 6
0
def test_LOS_event_with_lithobrake_event_raises_warning_when_satellite_cuts_attractor(
):
    r2 = np.array([-500, 1500, 4012.09]) << u.km
    v2 = np.array([5021.38, -2900.7, 1000.354]) << u.km / u.s
    orbit = Orbit.from_vectors(Earth, r2, v2)

    tofs = [100, 500, 1000, 2000] << u.s
    # Propagate the secondary body to generate its position coordinates.
    rr, vv = cowell(
        Earth.k,
        orbit.r,
        orbit.v,
        tofs,
    )
    pos_coords = rr  # Trajectory of the secondary body.

    r1 = np.array([0, -5010.696, -5102.509]) << u.km
    v1 = np.array([736.138, 2989.7, 164.354]) << u.km / u.s
    orb = Orbit.from_vectors(Earth, r1, v1)

    los_event = LosEvent(Earth, pos_coords, terminal=True)
    tofs = [
        0.003, 0.004, 0.01, 0.02, 0.03, 0.04, 0.07, 0.1, 0.2, 0.3, 0.4, 1, 3
    ] << u.s

    lithobrake_event = LithobrakeEvent(Earth.R.to_value(u.km))
    events = [lithobrake_event, los_event]
    r, v = cowell(
        Earth.k,
        orb.r,
        orb.v,
        tofs,
        events=events,
    )

    assert lithobrake_event.last_t < los_event.last_t
Exemplo n.º 7
0
C_D = 2.2
A_over_m = (((4 * np.pi * 0.0144) / 4.0) * (u.m**2) / (48 * u.kg)).to_value(
    u.km**2 / u.kg)
B = C_D * A_over_m
rho0 = rho0_earth.to(u.kg / u.km**3).value
H0 = H0_earth.to(u.km).value

orbit = Orbit.circular(Earth,
                       200 * u.km,
                       epoch=Time(0.0, format="jd", scale="tdb"))
tofs = TimeDelta(np.linspace(0 * u.h, 100000000 * u.d, num=200))

from poliastro.twobody.events import LithobrakeEvent

lithobrake_event = LithobrakeEvent(R)
events = [lithobrake_event]

rr = propagate(
    orbit,
    tofs,
    method=cowell,
    ad=atmospheric_drag_exponential,
    R=R,
    C_D=C_D,
    A_over_m=A_over_m,
    H0=H0,
    rho0=rho0,
    events=events,
)