Example #1
0
    def test_rv_mee_rv(self):
        mee = convert.mod_angles(convert.mee_coe(coe_sltn))
        rv = convert.rv_mee(mee)
        mee = convert.mee_rv(rv)
        rv2 = convert.rv_mee(mee)

        np.testing.assert_allclose(rv, rv2, rtol=0, atol=tol)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
    def __call__(self, T, X):
        """Calculate zonal gravity perturations in MEEs.

        Args:
            T: ndarray
                (m, 1) array of times.
            X: ndarray
                (m, 6) array of modified equinoctial elements ordered as
                (p, f, g, h, k, L), 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 ascending node vector in equinoctial frame
                k = 2-component of ascending node vector in equinoctial frame
                L = true longitude

        Returns:
            Xdot: ndarray
                (m, 6) array of state derivatives.
        """
        super().lvlh_acceleration(T, convert.rv_mee(X))
        G = GVE()(T, X)
        m = T.shape[0]

        return (G @ self.a_lvlh.reshape((m, 3, 1))).reshape((m, 6))
Example #6
0
    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)
Example #7
0
    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)
Example #8
0
    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, L), 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
                L = true longitude

        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(X))