Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def test_compare_zonal_to_coe(self):
        X0_mee = mee_0
        X0_coe = coe_0
        order_H = 6
        kep_dyn_mee = mee.KeplerianDynamics()
        zon_grav_mee = mee.ZonalGravity(order=order_H)
        sysmee = utl.SystemDynamics(kep_dyn_mee, zon_grav_mee)
        kep_dyn_coe = coe.KeplerianDynamics()
        zon_grav_coe = coe.ZonalGravity(order=order_H)
        syscoe = utl.SystemDynamics(kep_dyn_coe, zon_grav_coe)

        segs_per_orbit = 6
        orbits = 1
        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(sysmee, domains, N, 'warm', X0_mee, tol)
        mcpi_coe = mcpyi.MCPI(syscoe, domains, N, 'warm', X0_coe, tol)
        X_mee = mcpi_mee.solve_serial()(T)
        X_coe = mcpi_coe.solve_serial()(T)

        diff = convert.mod_angles(np.abs(X_coe - convert.coe_mee(X_mee)))
        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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    def test_system_dynamics(self):
        def plant(T, X):
            return T + X

        sys = utl.SystemDynamics(plant, [plant, plant, plant])
        y = sys(2, 3)

        self.assertEqual(y, 20)
Ejemplo n.º 7
0
    def test_zonal_gravity(self):
        X0 = coe_0
        order_H = 6
        kep_dyn = coe.KeplerianDynamics()
        zon_grav = coe.ZonalGravity(order=order_H)
        system = utl.SystemDynamics(kep_dyn, perturbations=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 = coe.Hamiltonian(order=order_H)(T, X)

        np.testing.assert_allclose(H[0, 0], H, rtol=tol)