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)
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)
def test_propagate_instance(): tof = 1.0 * u.min ss0 = Orbit.from_classical( Earth, 1000 * u.km, 0.75 * u.one, 63.4 * u.deg, 0 * u.deg, 270 * u.deg, 80 * u.deg, ) C_D = 2.2 * u.one # dimentionless (any value would do) A = ((np.pi / 4.0) * (u.m**2)).to(u.km**2) m = 100 * u.kg spacecraft = Spacecraft(A, C_D, m) earth_satellite = EarthSatellite(ss0, spacecraft) orbit_with_j2 = earth_satellite.propagate(tof=tof, gravity=EarthGravity.J2) orbit_without_perturbation = earth_satellite.propagate(tof) orbit_with_atmosphere_and_j2 = earth_satellite.propagate( tof=tof, gravity=EarthGravity.J2, atmosphere=COESA76()) assert isinstance(orbit_with_j2, EarthSatellite) assert isinstance(orbit_with_atmosphere_and_j2, EarthSatellite) assert isinstance(orbit_without_perturbation, EarthSatellite)
import pytest from astropy import units as u from astropy.tests.helper import assert_quantity_allclose from poliastro.earth.atmosphere import COESA76 from poliastro.earth.atmosphere.coesa76 import p_coeff, rho_coeff coesa76 = COESA76() def test_outside_altitude_range_coesa76(): with pytest.raises(ValueError) as excinfo: r0 = 6356.766 * u.km coesa76._check_altitude(1001 * u.km, r0) assert ( "ValueError: Geometric altitude must be in range [0.0 km, 1000.0 km]" in excinfo.exconly()) def test_get_index_coesa76(): expected_i = 7 z = 86 * u.km i = coesa76._get_index(z, coesa76.zb_levels) assert i == expected_i def test_coefficients_over_86km(): # Expected pressure coefficients expected_p = [ 9.814674e-11, -1.654439e-07, 1.148115e-04, -0.05431334, -2.011365 ]