def test_zonal_round_trip(self): X0_forward = rv_0 order_H = 6 kep_dyn_forward = rv.KeplerianDynamics() zon_grav = rv.ZonalGravity(order=order_H) sysfor = utl.SystemDynamics(kep_dyn_forward, zon_grav) segments = orbits * segs_per_orbit domains_for = [ k * period / segs_per_orbit for k in range(segments + 1) ] seg_number = len(domains_for) - 1 N = (order_mcpi, ) * seg_number mcpi_forward = mcpyi.MCPI(sysfor, domains_for, N, 'warm', X0_forward, tol) T_for = T X_for = mcpi_forward.solve_serial()(T_for) X0_bckward = X_for[-1:] kep_dyn_bckward = rv.KeplerianDynamics() sysbck = utl.SystemDynamics(kep_dyn_bckward, zon_grav) domains_bck = [-x for x in domains_for] mcpi_bckward = mcpyi.MCPI(sysbck, domains_bck, N, 'warm', X0_bckward, tol) T_bck = np.linspace(0, -10, num=m).reshape((m, 1)) X_bck = mcpi_bckward.solve_serial()(T_bck) np.testing.assert_allclose(X0_forward, X_bck[-1:], rtol=0, atol=tol * 10)
def test_compare_zonal_to_rv(self): X0_meeMl0 = meeMl0_0 X0_rv = rv_0 order_H = 6 kep_dyn_meeMl0 = meeMl0.KeplerianDynamics() zon_grav_meeMl0 = meeMl0.ZonalGravity(order=order_H) sysmeeMl0 = utl.SystemDynamics(kep_dyn_meeMl0, zon_grav_meeMl0) kep_dyn_rv = rv.KeplerianDynamics() zon_grav_rv = rv.ZonalGravity(order=order_H) sysrv = utl.SystemDynamics(kep_dyn_rv, zon_grav_rv) segs_per_orbit = 6 segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi_meeMl0 = mcpyi.MCPI(sysmeeMl0, domains, N, 'warm', X0_meeMl0, tol) mcpi_rv = mcpyi.MCPI(sysrv, domains, N, 'warm', X0_rv, tol) X_meeMl0 = mcpi_meeMl0.solve_serial()(T) X_rv = mcpi_rv.solve_serial()(T) np.testing.assert_allclose(X_rv, convert.rv_mee( convert.mee_meeMl0(T, X_meeMl0)), rtol=0, atol=tol * 10)
def test_compare_constant_theta_thrust_to_rv(self): X0_meeMl0 = meeMl0_0 X0_rv = rv_0 u = np.array([[0., 1e-6, 0.]]) kep_dyn_meeMl0 = meeMl0.KeplerianDynamics() conthrust_meeMl0 = meeMl0.ConstantThrust(u) sysmeeMl0 = utl.SystemDynamics(kep_dyn_meeMl0, conthrust_meeMl0) kep_dyn_rv = rv.KeplerianDynamics() conthrust_rv = rv.ConstantThrust(u) sysrv = utl.SystemDynamics(kep_dyn_rv, conthrust_rv) segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi_meeMl0 = mcpyi.MCPI(sysmeeMl0, domains, N, 'warm', X0_meeMl0, tol) mcpi_rv = mcpyi.MCPI(sysrv, domains, N, 'warm', X0_rv, tol) X_meeMl0 = mcpi_meeMl0.solve_serial()(T) X_rv = mcpi_rv.solve_serial()(T) np.testing.assert_allclose(X_rv, convert.rv_mee( convert.mee_meeMl0(T, X_meeMl0)), rtol=0, atol=tol * 10)
def test_compare_a_eci_to_rv(self): X0_mee = mee_0 X0_rv = rv_0 order_H = 6 kep_dyn_mee = mee.KeplerianDynamics() zon_grav_mee = mee.ZonalGravity(order=order_H) kep_dyn_rv = rv.KeplerianDynamics() zon_grav_rv = rv.ZonalGravity(order=order_H) segs_per_orbit = 6 segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi_mee = mcpyi.MCPI(kep_dyn_mee, domains, N, 'warm', X0_mee, tol) mcpi_rv = mcpyi.MCPI(kep_dyn_rv, domains, N, 'warm', X0_rv, tol) X_mee = mcpi_mee.solve_serial()(T) X_rv = mcpi_rv.solve_serial()(T) zon_grav_mee.eci_acceleration(T, convert.rv_mee(X_mee)) zon_grav_rv.eci_acceleration(T, X_rv) np.testing.assert_allclose(zon_grav_mee.a_eci, zon_grav_rv.a_eci, rtol=0, atol=tol)
def test_compare_a_eci_to_rv(self): X0_coe = coe_0 X0_rv = rv_0 order_H = 6 kep_dyn_coe = coe.KeplerianDynamics() zon_grav_coe = coe.ZonalGravity(order=order_H) syscoe = utl.SystemDynamics(kep_dyn_coe, zon_grav_coe) kep_dyn_rv = rv.KeplerianDynamics() zon_grav_rv = rv.ZonalGravity(order=order_H) sysrv = utl.SystemDynamics(kep_dyn_rv, zon_grav_rv) segs_per_orbit = 6 segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi_coe = mcpyi.MCPI(syscoe, domains, N, 'warm', X0_coe, tol) mcpi_rv = mcpyi.MCPI(sysrv, domains, N, 'warm', X0_rv, tol) mcpi_coe.solve_serial()(T) mcpi_rv.solve_serial()(T) np.testing.assert_allclose(zon_grav_coe.a_eci, zon_grav_rv.a_eci, rtol=0, atol=tol)
def test_hamiltonian_dynamics(self): X0 = rv_0 kep_dyn = rv.KeplerianDynamics() segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi = mcpyi.MCPI(kep_dyn, domains, N, 'warm', X0, tol) X = mcpi.solve_serial()(T) order_H = 1 H = rv.Hamiltonian(order=order_H)(T, X) np.testing.assert_allclose(H[0, 0], H, rtol=tol)
def test_compare_dynamics_to_solution(self): X0 = rv_0 Xsol = rv.KeplerianSolution(X0)(T) kep_dyn = rv.KeplerianDynamics() segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi = mcpyi.MCPI(kep_dyn, domains, N, 'warm', X0, tol) Xdyn = mcpi.solve_serial()(T) np.testing.assert_allclose(Xsol, Xdyn, rtol=0, atol=tol * 10)
def test_zonal_gravity(self): X0 = rv_0 order_H = 6 kep_dyn = rv.KeplerianDynamics() zon_grav = rv.ZonalGravity(order=order_H) system = utl.SystemDynamics(kep_dyn, zon_grav) segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi = mcpyi.MCPI(system, domains, N, 'warm', X0, tol) X = mcpi.solve_serial()(T) H = rv.Hamiltonian(order=order_H)(T, X) np.testing.assert_allclose(H[0, 0], H, rtol=tol)
def test_compare_dynamics_to_rv(self): X0_mee = mee_0 X0_rv = rv_0 mee_dyn = mee.KeplerianDynamics() rv_dyn = rv.KeplerianDynamics() segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi_mee = mcpyi.MCPI(mee_dyn, domains, N, 'warm', X0_mee, tol) mcpi_rv = mcpyi.MCPI(rv_dyn, domains, N, 'warm', X0_rv, tol) X_mee = mcpi_mee.solve_serial()(T) X_rv = mcpi_rv.solve_serial()(T) np.testing.assert_allclose(X_rv, convert.rv_mee(X_mee), rtol=0, atol=tol * 10)
def test_compare_keplerian_to_rv(self): X0_coe = coe_0 X0_rv = rv_0 X_coe = coe.KeplerianSolution(X0_coe)(T) kep_dyn = rv.KeplerianDynamics() segments = orbits * segs_per_orbit domains = [k * period / segs_per_orbit for k in range(segments + 1)] seg_number = len(domains) - 1 N = (order_mcpi, ) * seg_number mcpi = mcpyi.MCPI(kep_dyn, domains, N, 'warm', X0_rv, tol) X_rv = mcpi.solve_serial()(T) np.testing.assert_allclose(X_rv, convert.rv_coe(X_coe), rtol=0, atol=tol * 10)