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_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 __call__(self, T, X): """Calculate zonal gravity perturations for MEEs with Ml0. Args: T: ndarray (m, 1) array of times. X: ndarray (m, 6) array of modified equinoctial elements ordered as (p, f, g, h, k, Ml0), where p = semi-latus rectum f = 1-component of eccentricity vector in perifocal frame g = 2-component of eccentricity vector in perifocal frame h = 1-component of the ascending node vector in equ. frame k = 2-component of the ascending node vector in equ. frame Ml0 = mean longitude at epoch Returns: Xdot: ndarray (m, 6) array of state derivatives. """ super().lvlh_acceleration(T, convert.rv_mee(convert.mee_meeMl0(T, X))) G = GVE()(T, X) m = T.shape[0] return (G @ self.a_lvlh.reshape((m, 3, 1))).reshape((m, 6))
def test_mee_meeMl0_mee(self): T = np.linspace(0, 10, num=m) mee = convert.mod_angles(convert.mee_coe(coe_sltn)) meeMl0 = convert.meeMl0_mee(T, mee) mee2 = convert.mod_angles(convert.mee_meeMl0(T, meeMl0)) diff = convert.mod_angles(np.abs(mee - mee2), angle_indices=[5]) indices_2pi = np.where(2 * np.pi - tol < diff) diff[indices_2pi] -= 2 * np.pi np.testing.assert_allclose(diff, 0., rtol=0, atol=tol)
def test_compare_keplerian_to_rv(self): X0_meeMl0 = meeMl0_0 X0_rv = rv_0 X_meeMl0 = meeMl0.KeplerianSolution(X0_meeMl0)(T) X_rv = rv.KeplerianSolution(X0_rv)(T) np.testing.assert_allclose(convert.rv_mee( convert.mee_meeMl0(T, X_meeMl0)), X_rv, rtol=0, atol=tol * 10)
def test_compare_dynamics_to_rv(self): X0_meeMl0 = meeMl0_0 X0_rv = rv_0 meeMl0_dyn = meeMl0.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_meeMl0 = mcpyi.MCPI(meeMl0_dyn, domains, N, 'warm', X0_meeMl0, tol) mcpi_rv = mcpyi.MCPI(rv_dyn, 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 __call__(self, T, X): """Calculate Hamiltonian. Args: T: ndarray (m, 1) array of times. X: ndarray (m, 6) array of modified equinoctial elements ordered as (p, f, g, h, k, Ml0), where p = semi-latus rectum f = 1-component of eccentricity vector in perifocal frame g = 2-component of eccentricity vector in perifocal frame h = 1-component of the ascending node vector in equ. frame k = 2-component of the ascending node vector in equ. frame Ml0 = mean longitude at epoch Returns: H_rel: ndarray (m, 1) array of Hamiltonian over time. """ Hamiltonian = rvHam(mu=self.mu, order=self.order, r_earth=self.r_earth) return Hamiltonian( T, convert.rv_mee(convert.mee_meeMl0(T, X, mu=self.mu)))