Пример #1
0
    def __init__(self, arrival_time):
        # Start with earth parking orbit
        leo = Orbit.circular(PatchedConic.mu_earth, 6378136.6 + 185000.0)

        # Get the state of the moon at arrival so we know how far out
        # we need to go and how fast.
        x_moon_arrive = spice.spkez(301, arrival_time, 'J2000', 'NONE',
                                    399)[0] * 1000.0

        # Produce patched conic
        x, pcx = pc.optimize_deltav(np.array(
            [49.9 * np.pi / 180.0, leo.v + 3200.0]),
                                    1837400.0,
                                    leo.r,
                                    leo.phi,
                                    norm(x_moon_arrive[0:3]),
                                    norm(x_moon_arrive[3:6]),
                                    conjugate=True)

        depart_time = arrival_time - pcx.tof
        free_flight_sweep_angle = pcx.nu1 - pcx.nu0

        # Get state of moon at departure so we can figure out the
        # plane of our trajectory.
        x_moon_depart = spice.spkez(301, depart_time, 'J2000', 'NONE',
                                    399)[0] * 1000.0

        # Get earth--moon frame at SOI arrival time
        rm0 = x_moon_depart[:3]
        rm0hat = rm0 / norm(rm0)
        rm1 = x_moon_arrive[:3]
        rm1hat = rm1 / norm(rm1)
        hhat = np.cross(rm0hat, rm1hat)
        hhat /= norm(hhat)
        T_eci_to_pqw = spice.twovec(rm1hat, 1, hhat, 3)

        # Get directions to initial and final vectors
        r1hat = T_eci_to_pqw.T.dot(
            rotate_z(pcx.gam1).dot(np.array([1.0, 0, 0])))
        r0hat = T_eci_to_pqw.T.dot(
            rotate_z(pcx.gam1 - free_flight_sweep_angle).dot(
                np.array([1.0, 0.0, 0.0])))
        v0hat = np.cross(hhat, r0hat)

        # post delta-v state:
        r0 = r0hat * leo.r
        v0 = v0hat * x[1]
        # pre delta-v state:
        v0m = v0hat * leo.v

        # arrival state:
        # r1 = r1hat * pcx.arrive.r
        # v1 = ?

        self.free_flight_sweep_angle = free_flight_sweep_angle
        self.depart_time = depart_time
        self.arrival_time = arrival_time
        self.x_depart_post = np.hstack((r0, v0))
        self.x_depart_pre = np.hstack((r0, v0m))
        self.x_moon_depart = x_moon_depart
        self.x_moon_arrive = x_moon_arrive
        self.deltav = v0 - v0m
Пример #2
0
                                            conjugate=conjugate,
                                            maxiter=alpha_maxiter,
                                            alphatol=alphatol,
                                            plot=plot_alpha,
                                            disp=disp)

    print("Warning: exceeded max iterations (gradient phase)")

    return x, pcx


if __name__ == '__main__':

    D = 384402000.0
    V = 2.649e-6 * D
    leo = Orbit.circular(PatchedConic.mu_earth,
                         6378136.6 + 185000.0)  # earth parking

    XS = []
    YS = []

    optimize_deltav(np.array([49.9 * np.pi / 180.0, leo.v + 3200.0]),
                    1837400.0,
                    leo.r,
                    leo.phi,
                    D,
                    V,
                    conjugate=True)

    YS = np.vstack(YS)
    import matplotlib.pyplot as plt
    fig = plt.figure()