示例#1
0
文件: _gtop.py 项目: xzflin/pagmo
def _mga_incipit_cstrs_ctor(self,
                            seq=[gtoc6('io'),
                                 gtoc6('io'),
                                 gtoc6('europa')],
                            t0=[epoch(7305.0), epoch(11323.0)],
                            tof=[[100, 200], [3, 200], [4, 100]],
                            Tmax=300.00,
                            Dmin=2.0):
    """
    USAGE: mga_incipit_cstrs(seq = [gtoc6('io'),gtoc6('io'),gtoc6('europa')], t0 = [epoch(6905.0),epoch(11323.0)], tof = [[100,200],[3,200],[4,100]], Tmax = 365.25, Dmin = 0.2)

    * seq: list of jupiter moons defining the trajectory incipit
    * t0:  list of two epochs defining the launch window
    * tof: list of n lists containing the lower and upper bounds for the legs flight times (days)
    """
    # We construct the arg list for the original constructor exposed by
    # boost_python
    arg_list = []
    arg_list.append(seq)
    arg_list.append(t0[0])
    arg_list.append(t0[1])
    arg_list.append(tof)
    arg_list.append(Tmax)
    arg_list.append(Dmin)
    self._orig_init(*arg_list)
示例#2
0
def _mga_1dsm_tof_ctor(
    self, seq=[
        jpl_lp('earth'), jpl_lp('venus'), jpl_lp('earth')], t0=[
        epoch(0), epoch(1000)], tof=[
        [
            50, 900], [
            50, 900]], vinf=[
        0.5, 2.5], multi_objective=False, add_vinf_dep=False, add_vinf_arr=True):
    """
    Constructs an mga_1dsm problem (tof-encoding)

    USAGE: problem.mga_1dsm(seq = [jpl_lp('earth'),jpl_lp('venus'),jpl_lp('earth')], t0 = [epoch(0),epoch(1000)], tof = [ [50, 900], [50, 900] ], vinf = [0.5, 2.5], multi_objective = False, add_vinf_dep = False, add_vinf_arr = True)

    * seq: list of PyKEP planets defining the encounter sequence (including the starting planet)
    * t0: list of two epochs defining the launch window
    * tof: list of intervals defining the times of flight (days)
    * vinf: list of two floats defining the minimum and maximum allowed initial hyperbolic velocity at launch (km/sec)
    * multi_objective: when True constructs a multiobjective problem (dv, T)
    * add_vinf_dep: when True the computed Dv includes the initial hyperbolic velocity (at launch)
    * add_vinf_arr: when True the computed Dv includes the final hyperbolic velocity (at arrival)
    """

    # We construct the arg list for the original constructor exposed by
    # boost_python
    arg_list = []
    arg_list.append(seq)
    arg_list.append(t0[0])
    arg_list.append(t0[1])
    arg_list.append(tof)
    arg_list.append(vinf[0])
    arg_list.append(vinf[1])
    arg_list.append(multi_objective)
    arg_list.append(add_vinf_dep)
    arg_list.append(add_vinf_arr)
    self._orig_init(*arg_list)
示例#3
0
文件: _gtop.py 项目: darioizzo/pagmo
def _mga_incipit_cstrs_ctor(
    self, seq=[
        gtoc6('io'), gtoc6('io'), gtoc6('europa')], t0=[
        epoch(7305.0), epoch(11323.0)], tof=[
        [
            100, 200], [
            3, 200], [
            4, 100]], Tmax=300.00, Dmin=2.0):
    """
    USAGE: mga_incipit_cstrs(seq = [gtoc6('io'),gtoc6('io'),gtoc6('europa')], t0 = [epoch(6905.0),epoch(11323.0)], tof = [[100,200],[3,200],[4,100]], Tmax = 365.25, Dmin = 0.2)

    * seq: list of jupiter moons defining the trajectory incipit
    * t0:  list of two epochs defining the launch window
    * tof: list of n lists containing the lower and upper bounds for the legs flight times (days)
    """
    # We construct the arg list for the original constructor exposed by
    # boost_python
    arg_list = []
    arg_list.append(seq)
    arg_list.append(t0[0])
    arg_list.append(t0[1])
    arg_list.append(tof)
    arg_list.append(Tmax)
    arg_list.append(Dmin)
    self._orig_init(*arg_list)
示例#4
0
文件: _gtop.py 项目: xzflin/pagmo
def _mga_1dsm_tof_plot(self, x):
    """
    Plots the trajectory represented by the decision vector x
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    axis = fig.gca(projection='3d')
    axis.scatter(0, 0, 0, color='y')

    seq = self.get_sequence()

    # 2 - We plot the first leg
    r_P0, v_P0 = seq[0].eph(epoch(x[0]))
    plot_planet(seq[0],
                t0=epoch(x[0]),
                color=(0.8, 0.6, 0.8),
                legend=True,
                units=AU,
                ax=axis)
    r_P1, v_P1 = seq[1].eph(epoch(x[0] + x[5]))
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2

    Vinfx = x[3] * cos(phi) * cos(theta)
    Vinfy = x[3] * cos(phi) * sin(theta)
    Vinfz = x[3] * sin(phi)

    v0 = [a + b for a, b in zip(v_P0, [Vinfx, Vinfy, Vinfz])]
    r, v = propagate_lagrangian(r_P0, v0, x[4] * x[5] * DAY2SEC,
                                seq[0].mu_central_body)
    plot_kepler(r_P0,
                v0,
                x[4] * x[5] * DAY2SEC,
                seq[0].mu_central_body,
                N=100,
                color='b',
                legend=False,
                units=AU,
                ax=axis)

    # Lambert arc to reach seq[1]
    dt = (1 - x[4]) * x[5] * DAY2SEC
    l = lambert_problem(r, r_P1, dt, seq[0].mu_central_body)
    plot_lambert(l, sol=0, color='r', legend=False, units=AU, ax=axis)
    v_end_l = l.get_v2()[0]
    vinf_in = [a - b for a, b in zip(v_end_l, v_P1)]
    _part_plot(x[6:], AU, axis, seq[1:], x[0] + x[5], vinf_in)
    return axis
示例#5
0
文件: _gtop.py 项目: darioizzo/pagmo
def _mga_1dsm_tof_plot(self, x):
    """
    Plots the trajectory represented by the decision vector x
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    axis = fig.gca(projection='3d')
    axis.scatter(0, 0, 0, color='y')

    seq = self.get_sequence()

    # 2 - We plot the first leg
    r_P0, v_P0 = seq[0].eph(epoch(x[0]))
    plot_planet(seq[0], t0=epoch(x[0]), color=(
        0.8, 0.6, 0.8), legend=True, units = AU, ax=axis)
    r_P1, v_P1 = seq[1].eph(epoch(x[0] + x[5]))
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2

    Vinfx = x[3] * cos(phi) * cos(theta)
    Vinfy = x[3] * cos(phi) * sin(theta)
    Vinfz = x[3] * sin(phi)

    v0 = [a + b for a, b in zip(v_P0, [Vinfx, Vinfy, Vinfz])]
    r, v = propagate_lagrangian(
        r_P0, v0, x[4] * x[5] * DAY2SEC, seq[0].mu_central_body)
    plot_kepler(
        r_P0,
        v0,
        x[4] *
        x[5] *
        DAY2SEC,
        seq[0].mu_central_body,
        N=100,
        color='b',
        legend=False,
        units=AU,
        ax=axis)

    # Lambert arc to reach seq[1]
    dt = (1 - x[4]) * x[5] * DAY2SEC
    l = lambert_problem(r, r_P1, dt, seq[0].mu_central_body)
    plot_lambert(l, sol=0, color='r', legend=False, units=AU, ax=axis)
    v_end_l = l.get_v2()[0]
    vinf_in = [a - b for a, b in zip(v_end_l, v_P1)]
    _part_plot(x[6:], AU, axis, seq[1:], x[0] + x[5], vinf_in)
    return axis
示例#6
0
def _pl2pl_fixed_time_ctor(self, ast0=gtoc7(7422), ast1=gtoc7(14254), t0=epoch(9818),
    t1=epoch(10118), sc=spacecraft(2000, 0.3, 3000), n_seg=5, obj="fin_m"):
    """
    Constructs a Planet 2 Planet problem with fixed time.
    Chromosome is defined as:

    x = [m_f, Th_0_x, Th_0_y, Th_0_z, .., Th_n_x, Th_n_y, Th_n_z]
    , where 'm_f' is the final mass, while 'Th_i_j' is the throttle component in direction 'j' (x,y,z) for the 'i'-th segment.

    USAGE: problem.pl2pl_fixed_time(ast0=gtoc7(7422), ast1=gtoc7(14254), t0=epoch(9818),
               t1=epoch(10118), sc=spacecraft(2000, 0.3, 3000), n_seg = 5)

    * ast0: first planet
    * ast0: second planet
    * t0: departure epoch (from planet ast0)
    * t1: arrival epoch (to planet ast1)
    * sc: spacecraft object
    * n_seg: number of segments

    """

    # We construct the arg list for the original constructor exposed by
    # boost_python
    from PyGMO.problem._problem import _pl2pl2_fixed_time_objective
    def objective(x):
        return {
            "fin_m": _pl2pl2_fixed_time_objective.FIN_M,
            "crit_m": _pl2pl2_fixed_time_objective.FIN_INI_M
        }[x]

    arg_list = []
    arg_list.append(ast0)
    arg_list.append(ast1)
    arg_list.append(t0)
    arg_list.append(t1)
    arg_list.append(sc)
    arg_list.append(n_seg)
    arg_list.append(objective(obj))
    self._orig_init(*arg_list)
示例#7
0
def _part_plot(x, units, axis, seq, start_mjd2000, vinf_in):
    """
    Plots the trajectory represented by a decision vector x = [beta,rp,eta,T] * N
    associated to a sequence seq, a start_mjd2000 and an incoming vinf_in
    """
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    legs = len(x) // 4
    common_mu = seq[0].mu_central_body

    # 1 -  we 'decode' the chromosome recording the various times of flight
    # (days) in the list T
    T = x[3::4]

    # 2 - We compute the epochs and ephemerides of the planetary encounters
    t_P = list([None] * (legs + 1))
    r_P = list([None] * (legs + 1))
    v_P = list([None] * (legs + 1))

    for i, planet in enumerate(seq):
        t_P[i] = epoch(start_mjd2000 + sum(T[:i]))
        r_P[i], v_P[i] = planet.eph(t_P[i])
        plot_planet(planet, t0=t_P[i], color=(
            0.8, 0.6, 0.8), legend=True, units = units, ax=axis)

    v_end_l = [a + b for a, b in zip(v_P[0], vinf_in)]
    # 4 - And we iterate on the legs
    for i in range(0, legs):
        # Fly-by
        v_out = fb_prop(v_end_l,
                        v_P[i],
                        x[1 + 4 * i] * seq[i].radius,
                        x[4 * i],
                        seq[i].mu_self)
        # s/c propagation before the DSM
        r, v = propagate_lagrangian(
            r_P[i], v_out, x[4 * i + 2] * T[i] * DAY2SEC, common_mu)
        plot_kepler(r_P[i], v_out, x[4 * i + 2] * T[i] * DAY2SEC,
                    common_mu, N=500, color='b', legend=False, units=units, ax=axis)
        # Lambert arc to reach Earth during (1-nu2)*T2 (second segment)
        dt = (1 - x[4 * i + 2]) * T[i] * DAY2SEC
        l = lambert_problem(r, r_P[i + 1], dt, common_mu, False, False)
        plot_lambert(
            l, sol=0, color='r', legend=False, units=units, N=500, ax=axis)
        v_end_l = l.get_v2()[0]
        v_beg_l = l.get_v1()[0]
示例#8
0
文件: _gtop.py 项目: darioizzo/pagmo
def _mga_incipit_plot(self, x, plot_leg_0=False):
    """
    Plots the trajectory represented by the decision vector x

    Example::

      prob.plot(x)
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d', aspect='equal')
    ax.scatter(0, 0, 0, color='y')

    JR = 71492000.0
    seq = self.get_sequence()
    common_mu = seq[0].mu_central_body
    r_P, v_P = seq[0].eph(epoch(x[0] + x[3]))

    # 3 - We start with the first leg: a lambert arc
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2
    # phi close to zero is in the moon orbit plane injection
    r = [cos(phi) * sin(theta), cos(phi) * cos(theta), sin(phi)]
    r = [JR * 1000 * d for d in r]

    l = lambert_problem(r, r_P, x[3] * DAY2SEC, common_mu, False, False)
    if (plot_leg_0):
        plot_lambert(ax, l, sol=0, color='k', legend=False, units=JR, N=500)

    # Lambert arc to reach seq[1]
    v_end_l = l.get_v2()[0]
    vinf_in = [a - b for a, b in zip(v_end_l, v_P)]
    _part_plot(x[4:], JR, ax, seq, x[0] + x[3], vinf_in)

    return ax
示例#9
0
文件: _gtop.py 项目: xzflin/pagmo
def _mga_incipit_plot(self, x, plot_leg_0=False):
    """
    Plots the trajectory represented by the decision vector x

    Example::

      prob.plot(x)
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d', aspect='equal')
    ax.scatter(0, 0, 0, color='y')

    JR = 71492000.0
    seq = self.get_sequence()
    common_mu = seq[0].mu_central_body
    r_P, v_P = seq[0].eph(epoch(x[0] + x[3]))

    # 3 - We start with the first leg: a lambert arc
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2
    # phi close to zero is in the moon orbit plane injection
    r = [cos(phi) * sin(theta), cos(phi) * cos(theta), sin(phi)]
    r = [JR * 1000 * d for d in r]

    l = lambert_problem(r, r_P, x[3] * DAY2SEC, common_mu, False, False)
    if (plot_leg_0):
        plot_lambert(ax, l, sol=0, color='k', legend=False, units=JR, N=500)

    # Lambert arc to reach seq[1]
    v_end_l = l.get_v2()[0]
    vinf_in = [a - b for a, b in zip(v_end_l, v_P)]
    _part_plot(x[4:], JR, ax, seq, x[0] + x[3], vinf_in)

    return ax
示例#10
0
文件: _gtop.py 项目: xzflin/pagmo
def _mga_part_ctor(self,
                   seq=[gtoc6('europa'),
                        gtoc6('europa'),
                        gtoc6('europa')],
                   tof=[[5, 50], [5, 50]],
                   t0=epoch(11000),
                   v_inf_in=[1500.0, 350.0, 145.0]):
    """
    USAGE: mga_part(seq = [gtoc6('europa'),gtoc6('europa'),gtoc6('europa')], tof = [[5,50],[5,50]], t0 = epoch(11000), v_inf_in[1500.0,350.0,145.0])

    * seq: list of jupiter moons defining the trajectory incipit
    * tof: list of n lists containing the lower and upper bounds for the legs flight times (days)
    * t0:  starting epoch
    * v_inf_in: Incoming spacecraft relative velocity
    """
    # We construct the arg list for the original constructor exposed by
    # boost_python
    arg_list = []
    arg_list.append(seq)
    arg_list.append(tof)
    arg_list.append(t0)
    arg_list.append(v_inf_in)
    self._orig_init(*arg_list)
示例#11
0
文件: _gtop.py 项目: darioizzo/pagmo
def _mga_part_ctor(
    self, seq=[
        gtoc6('europa'), gtoc6('europa'), gtoc6('europa')], tof=[
        [
            5, 50], [
            5, 50]], t0=epoch(11000), v_inf_in=[
        1500.0, 350.0, 145.0]):
    """
    USAGE: mga_part(seq = [gtoc6('europa'),gtoc6('europa'),gtoc6('europa')], tof = [[5,50],[5,50]], t0 = epoch(11000), v_inf_in[1500.0,350.0,145.0])

    * seq: list of jupiter moons defining the trajectory incipit
    * tof: list of n lists containing the lower and upper bounds for the legs flight times (days)
    * t0:  starting epoch
    * v_inf_in: Incoming spacecraft relative velocity
    """
    # We construct the arg list for the original constructor exposed by
    # boost_python
    arg_list = []
    arg_list.append(seq)
    arg_list.append(tof)
    arg_list.append(t0)
    arg_list.append(v_inf_in)
    self._orig_init(*arg_list)
示例#12
0
文件: _gtop.py 项目: xzflin/pagmo
def _mga_part_plot_old(self, x):
    """
    Plots the trajectory represented by the decision vector x

    Example::

      prob.plot(x)
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d', aspect='equal')
    ax.scatter(0, 0, 0, color='y')

    JR = 71492000.0
    legs = len(x) / 4
    seq = self.get_sequence()
    common_mu = seq[0].mu_central_body
    start_mjd2000 = self.t0.mjd2000

    # 1 -  we 'decode' the chromosome recording the various times of flight
    # (days) in the list T
    T = x[3::4]

    # 2 - We compute the epochs and ephemerides of the planetary encounters
    t_P = list([None] * (legs + 1))
    r_P = list([None] * (legs + 1))
    v_P = list([None] * (legs + 1))

    for i, planet in enumerate(seq):
        t_P[i] = epoch(start_mjd2000 + sum(T[:i]))
        r_P[i], v_P[i] = planet.eph(t_P[i])
        plot_planet(ax,
                    planet,
                    t0=t_P[i],
                    color=(0.8, 0.6, 0.8),
                    legend=True,
                    units=JR)

    v_end_l = [a + b for a, b in zip(v_P[0], self.vinf_in)]
    # 4 - And we iterate on the legs
    for i in range(0, legs):
        # Fly-by
        v_out = fb_prop(v_end_l, v_P[i], x[1 + 4 * i] * seq[i - 1].radius,
                        x[4 * i], seq[i].mu_self)
        # s/c propagation before the DSM
        r, v = propagate_lagrangian(r_P[i], v_out,
                                    x[4 * i + 2] * T[i] * DAY2SEC, common_mu)
        plot_kepler(ax,
                    r_P[i],
                    v_out,
                    x[4 * i + 2] * T[i] * DAY2SEC,
                    common_mu,
                    N=500,
                    color='b',
                    legend=False,
                    units=JR)
        # Lambert arc to reach Earth during (1-nu2)*T2 (second segment)
        dt = (1 - x[4 * i + 2]) * T[i] * DAY2SEC
        l = lambert_problem(r, r_P[i + 1], dt, common_mu, False, False)
        plot_lambert(ax, l, sol=0, color='r', legend=False, units=JR, N=500)
        v_end_l = l.get_v2()[0]
        v_beg_l = l.get_v1()[0]
    plt.show()
    return ax
示例#13
0
文件: _gtop.py 项目: xzflin/pagmo
def _mga_incipit_plot_old(self, x, plot_leg_0=False):
    """
    Plots the trajectory represented by the decision vector x

    Example::

      prob.plot(x)
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d', aspect='equal')
    ax.scatter(0, 0, 0, color='y')

    JR = 71492000.0
    legs = len(x) / 4
    seq = self.get_sequence()
    common_mu = seq[0].mu_central_body

    # 1 -  we 'decode' the chromosome recording the various times of flight
    # (days) in the list T
    T = x[3::4]

    # 2 - We compute the epochs and ephemerides of the planetary encounters
    t_P = list([None] * legs)
    r_P = list([None] * legs)
    v_P = list([None] * legs)
    DV = list([None] * legs)

    for i, planet in enumerate(seq):
        t_P[i] = epoch(x[0] + sum(T[:i + 1]))
        r_P[i], v_P[i] = planet.eph(t_P[i])
        plot_planet(ax,
                    planet,
                    t0=t_P[i],
                    color=(0.8, 0.6, 0.8),
                    legend=True,
                    units=JR)

    # 3 - We start with the first leg: a lambert arc
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2
    # phi close to zero is in the moon orbit plane injection
    r = [cos(phi) * sin(theta), cos(phi) * cos(theta), sin(phi)]
    r = [JR * 1000 * d for d in r]

    l = lambert_problem(r, r_P[0], T[0] * DAY2SEC, common_mu, False, False)
    if (plot_leg_0):
        plot_lambert(ax, l, sol=0, color='k', legend=False, units=JR, N=500)

    # Lambert arc to reach seq[1]
    v_end_l = l.get_v2()[0]
    v_beg_l = l.get_v1()[0]

    # 4 - And we proceed with each successive leg
    for i in range(1, legs):
        # Fly-by
        v_out = fb_prop(v_end_l, v_P[i - 1], x[1 + 4 * i] * seq[i - 1].radius,
                        x[4 * i], seq[i - 1].mu_self)
        # s/c propagation before the DSM
        r, v = propagate_lagrangian(r_P[i - 1], v_out,
                                    x[4 * i + 2] * T[i] * DAY2SEC, common_mu)
        plot_kepler(ax,
                    r_P[i - 1],
                    v_out,
                    x[4 * i + 2] * T[i] * DAY2SEC,
                    common_mu,
                    N=500,
                    color='b',
                    legend=False,
                    units=JR)
        # Lambert arc to reach Earth during (1-nu2)*T2 (second segment)
        dt = (1 - x[4 * i + 2]) * T[i] * DAY2SEC
        l = lambert_problem(r, r_P[i], dt, common_mu, False, False)
        plot_lambert(ax, l, sol=0, color='r', legend=False, units=JR, N=500)
        v_end_l = l.get_v2()[0]
        v_beg_l = l.get_v1()[0]
    plt.show()
    return ax
示例#14
0
文件: _gtop.py 项目: xzflin/pagmo
def _mga_1dsm_tof_plot_old(self, x):
    """
    Plots the trajectory represented by the decision vector x
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.scatter(0, 0, 0, color='y')

    seq = self.get_sequence()

    n = (len(seq) - 1)
    # 1 -  we 'decode' the chromosome recording the various times of flight
    # (days) in the list T
    T = x[5::4]

    # 2 - We compute the epochs and ephemerides of the planetary encounters
    t_P = list([None] * (n + 1))
    r_P = list([None] * (n + 1))
    v_P = list([None] * (n + 1))
    DV = list([None] * (n + 1))

    for i, planet in enumerate(seq):
        t_P[i] = epoch(x[0] + sum(T[0:i]))
        r_P[i], v_P[i] = planet.eph(t_P[i])
        plot_planet(ax,
                    planet,
                    t0=t_P[i],
                    color=(0.8, 0.6, 0.8),
                    legend=True,
                    units=AU)

    # 3 - We start with the first leg
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2

    Vinfx = x[3] * cos(phi) * cos(theta)
    Vinfy = x[3] * cos(phi) * sin(theta)
    Vinfz = x[3] * sin(phi)

    v0 = [a + b for a, b in zip(v_P[0], [Vinfx, Vinfy, Vinfz])]
    r, v = propagate_lagrangian(r_P[0], v0, x[4] * T[0] * DAY2SEC,
                                seq[0].mu_central_body)
    plot_kepler(ax,
                r_P[0],
                v0,
                x[4] * T[0] * DAY2SEC,
                seq[0].mu_central_body,
                N=100,
                color='b',
                legend=False,
                units=AU)

    # Lambert arc to reach seq[1]
    dt = (1 - x[4]) * T[0] * DAY2SEC
    l = lambert_problem(r, r_P[1], dt, seq[0].mu_central_body)
    plot_lambert(ax, l, sol=0, color='r', legend=False, units=AU)
    v_end_l = l.get_v2()[0]
    v_beg_l = l.get_v1()[0]

    # First DSM occuring at time nu1*T1
    DV[0] = norm([a - b for a, b in zip(v_beg_l, v)])

    # 4 - And we proceed with each successive leg
    for i in range(1, n):
        # Fly-by
        v_out = fb_prop(v_end_l, v_P[i], x[7 + (i - 1) * 4] * seq[i].radius,
                        x[6 + (i - 1) * 4], seq[i].mu_self)
        # s/c propagation before the DSM
        r, v = propagate_lagrangian(r_P[i], v_out,
                                    x[8 + (i - 1) * 4] * T[i] * DAY2SEC,
                                    seq[0].mu_central_body)
        plot_kepler(ax,
                    r_P[i],
                    v_out,
                    x[8 + (i - 1) * 4] * T[i] * DAY2SEC,
                    seq[0].mu_central_body,
                    N=100,
                    color='b',
                    legend=False,
                    units=AU)
        # Lambert arc to reach Earth during (1-nu2)*T2 (second segment)
        dt = (1 - x[8 + (i - 1) * 4]) * T[i] * DAY2SEC
        l = lambert_problem(r, r_P[i + 1], dt, seq[0].mu_central_body)
        plot_lambert(ax, l, sol=0, color='r', legend=False, units=AU)
        v_end_l = l.get_v2()[0]
        v_beg_l = l.get_v1()[0]
        # DSM occurring at time nu2*T2
        DV[i] = norm([a - b for a, b in zip(v_beg_l, v)])
    return ax
示例#15
0
文件: _gtop.py 项目: darioizzo/pagmo
def _mga_1dsm_tof_plot_old(self, x):
    """
    Plots the trajectory represented by the decision vector x
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.scatter(0, 0, 0, color='y')

    seq = self.get_sequence()

    n = (len(seq) - 1)
    # 1 -  we 'decode' the chromosome recording the various times of flight
    # (days) in the list T
    T = x[5::4]

    # 2 - We compute the epochs and ephemerides of the planetary encounters
    t_P = list([None] * (n + 1))
    r_P = list([None] * (n + 1))
    v_P = list([None] * (n + 1))
    DV = list([None] * (n + 1))

    for i, planet in enumerate(seq):
        t_P[i] = epoch(x[0] + sum(T[0:i]))
        r_P[i], v_P[i] = planet.eph(t_P[i])
        plot_planet(ax, planet, t0=t_P[i], color=(
            0.8, 0.6, 0.8), legend=True, units = AU)

    # 3 - We start with the first leg
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2

    Vinfx = x[3] * cos(phi) * cos(theta)
    Vinfy = x[3] * cos(phi) * sin(theta)
    Vinfz = x[3] * sin(phi)

    v0 = [a + b for a, b in zip(v_P[0], [Vinfx, Vinfy, Vinfz])]
    r, v = propagate_lagrangian(
        r_P[0], v0, x[4] * T[0] * DAY2SEC, seq[0].mu_central_body)
    plot_kepler(
        ax,
        r_P[0],
        v0,
        x[4] *
        T[0] *
        DAY2SEC,
        seq[0].mu_central_body,
        N=100,
        color='b',
        legend=False,
        units=AU)

    # Lambert arc to reach seq[1]
    dt = (1 - x[4]) * T[0] * DAY2SEC
    l = lambert_problem(r, r_P[1], dt, seq[0].mu_central_body)
    plot_lambert(ax, l, sol=0, color='r', legend=False, units=AU)
    v_end_l = l.get_v2()[0]
    v_beg_l = l.get_v1()[0]

    # First DSM occuring at time nu1*T1
    DV[0] = norm([a - b for a, b in zip(v_beg_l, v)])

    # 4 - And we proceed with each successive leg
    for i in range(1, n):
        # Fly-by
        v_out = fb_prop(v_end_l,
                        v_P[i],
                        x[7 + (i - 1) * 4] * seq[i].radius,
                        x[6 + (i - 1) * 4],
                        seq[i].mu_self)
        # s/c propagation before the DSM
        r, v = propagate_lagrangian(
            r_P[i], v_out, x[8 + (i - 1) * 4] * T[i] * DAY2SEC, seq[0].
            mu_central_body)
        plot_kepler(ax,
                    r_P[i],
                    v_out,
                    x[8 + (i - 1) * 4] * T[i] * DAY2SEC,
                    seq[0].mu_central_body,
                    N=100,
                    color='b',
                    legend=False,
                    units=AU)
        # Lambert arc to reach Earth during (1-nu2)*T2 (second segment)
        dt = (1 - x[8 + (i - 1) * 4]) * T[i] * DAY2SEC
        l = lambert_problem(r, r_P[i + 1], dt, seq[0].mu_central_body)
        plot_lambert(ax, l, sol=0, color='r', legend=False, units=AU)
        v_end_l = l.get_v2()[0]
        v_beg_l = l.get_v1()[0]
        # DSM occurring at time nu2*T2
        DV[i] = norm([a - b for a, b in zip(v_beg_l, v)])
    return ax
示例#16
0
文件: _gtop.py 项目: darioizzo/pagmo
def _mga_incipit_plot_old(self, x, plot_leg_0=False):
    """
    Plots the trajectory represented by the decision vector x

    Example::

      prob.plot(x)
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d', aspect='equal')
    ax.scatter(0, 0, 0, color='y')

    JR = 71492000.0
    legs = len(x) // 4
    seq = self.get_sequence()
    common_mu = seq[0].mu_central_body

    # 1 -  we 'decode' the chromosome recording the various times of flight
    # (days) in the list T
    T = x[3::4]

    # 2 - We compute the epochs and ephemerides of the planetary encounters
    t_P = list([None] * legs)
    r_P = list([None] * legs)
    v_P = list([None] * legs)
    DV = list([None] * legs)

    for i, planet in enumerate(seq):
        t_P[i] = epoch(x[0] + sum(T[:i + 1]))
        r_P[i], v_P[i] = planet.eph(t_P[i])
        plot_planet(ax, planet, t0=t_P[i], color=(
            0.8, 0.6, 0.8), legend=True, units = JR)

    # 3 - We start with the first leg: a lambert arc
    theta = 2 * pi * x[1]
    phi = acos(2 * x[2] - 1) - pi / 2
    # phi close to zero is in the moon orbit plane injection
    r = [cos(phi) * sin(theta), cos(phi) * cos(theta), sin(phi)]
    r = [JR * 1000 * d for d in r]

    l = lambert_problem(r, r_P[0], T[0] * DAY2SEC, common_mu, False, False)
    if (plot_leg_0):
        plot_lambert(ax, l, sol=0, color='k', legend=False, units=JR, N=500)

    # Lambert arc to reach seq[1]
    v_end_l = l.get_v2()[0]
    v_beg_l = l.get_v1()[0]

    # 4 - And we proceed with each successive leg
    for i in range(1, legs):
        # Fly-by
        v_out = fb_prop(v_end_l,
                        v_P[i - 1],
                        x[1 + 4 * i] * seq[i - 1].radius,
                        x[4 * i],
                        seq[i - 1].mu_self)
        # s/c propagation before the DSM
        r, v = propagate_lagrangian(
            r_P[i - 1], v_out, x[4 * i + 2] * T[i] * DAY2SEC, common_mu)
        plot_kepler(ax,
                    r_P[i - 1],
                    v_out,
                    x[4 * i + 2] * T[i] * DAY2SEC,
                    common_mu,
                    N=500,
                    color='b',
                    legend=False,
                    units=JR)
        # Lambert arc to reach Earth during (1-nu2)*T2 (second segment)
        dt = (1 - x[4 * i + 2]) * T[i] * DAY2SEC
        l = lambert_problem(r, r_P[i], dt, common_mu, False, False)
        plot_lambert(ax, l, sol=0, color='r', legend=False, units=JR, N=500)
        v_end_l = l.get_v2()[0]
        v_beg_l = l.get_v1()[0]
    plt.show()
    return ax
示例#17
0
文件: _gtop.py 项目: darioizzo/pagmo
def _mga_part_plot_old(self, x):
    """
    Plots the trajectory represented by the decision vector x

    Example::

      prob.plot(x)
    """
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    from PyKEP.orbit_plots import plot_planet, plot_lambert, plot_kepler
    from PyKEP import epoch, propagate_lagrangian, lambert_problem, fb_prop, AU, MU_SUN, DAY2SEC
    from math import pi, acos, cos, sin
    from scipy.linalg import norm

    mpl.rcParams['legend.fontsize'] = 10
    fig = plt.figure()
    ax = fig.gca(projection='3d', aspect='equal')
    ax.scatter(0, 0, 0, color='y')

    JR = 71492000.0
    legs = len(x) // 4
    seq = self.get_sequence()
    common_mu = seq[0].mu_central_body
    start_mjd2000 = self.t0.mjd2000

    # 1 -  we 'decode' the chromosome recording the various times of flight
    # (days) in the list T
    T = x[3::4]

    # 2 - We compute the epochs and ephemerides of the planetary encounters
    t_P = list([None] * (legs + 1))
    r_P = list([None] * (legs + 1))
    v_P = list([None] * (legs + 1))

    for i, planet in enumerate(seq):
        t_P[i] = epoch(start_mjd2000 + sum(T[:i]))
        r_P[i], v_P[i] = planet.eph(t_P[i])
        plot_planet(ax, planet, t0=t_P[i], color=(
            0.8, 0.6, 0.8), legend=True, units = JR)

    v_end_l = [a + b for a, b in zip(v_P[0], self.vinf_in)]
    # 4 - And we iterate on the legs
    for i in range(0, legs):
        # Fly-by
        v_out = fb_prop(v_end_l,
                        v_P[i],
                        x[1 + 4 * i] * seq[i - 1].radius,
                        x[4 * i],
                        seq[i].mu_self)
        # s/c propagation before the DSM
        r, v = propagate_lagrangian(
            r_P[i], v_out, x[4 * i + 2] * T[i] * DAY2SEC, common_mu)
        plot_kepler(ax, r_P[i], v_out, x[4 * i + 2] * T[i] * DAY2SEC,
                    common_mu, N=500, color='b', legend=False, units=JR)
        # Lambert arc to reach Earth during (1-nu2)*T2 (second segment)
        dt = (1 - x[4 * i + 2]) * T[i] * DAY2SEC
        l = lambert_problem(r, r_P[i + 1], dt, common_mu, False, False)
        plot_lambert(ax, l, sol=0, color='r', legend=False, units=JR, N=500)
        v_end_l = l.get_v2()[0]
        v_beg_l = l.get_v1()[0]
    plt.show()
    return ax