Trajectory Optimization#

In pykep both direct and indirect optimization transcriptions as well as evolutionary encodings are provided to perform spacecraft trajectory optimization. Most direct techniques provided are based on the “Sims” transcription [SF97], while indirect techniques are based on some version of Pontryagin Maximum Principle. The evolutionary encoding are mostly based on the work performed at ESA’ Advanced Concepts Team ([Izz10], [ISM+13]).

Most of the classes in this Trajectory Optimization module are provided as optimization problems (NLPs) in the for of User Defined Problems (UDP) compatible with the pygmo [BI20] python package.

Direct#

When solving optimal control problems (OCPs), the unknown is a function (i.e. the control), hence one is dealing with an infinite dimensional search space. A common approach to overcome this difficulty is to use direct methods. These are based on the idea of discretizing the problem introducing some time grid and thus transforming the OCP into a NLP (Non Linear Programming) problem to then solve it using numerical solvers available for the task.


class pykep.trajopt.direct_point2point(rvs=[array([1.49597871e+11, 1.49597871e+10, -1.49597871e+10]), array([5956.93836686, 29784.69183431, -5956.93836686])], rvf=[array([-1.79517445e+11, -1.49597871e+10, 1.49597871e+10]), array([5956.93836686, -30469.7397465, 13105.2644071])], ms=1000, mu=1.3271244004127942e+20, max_thrust=0.12, isp=3000, tof_bounds=[80, 400], mf_bounds=[200.0, 1000.0], nseg=10, cut=0.6, mass_scaling=1000, r_scaling=149597870700.0, v_scaling=29784.69183430911, with_gradient=True)#

Represents the optimal low-thrust transfer between two fixed points using a direct method.

This problem works internally using the sims_flanagan and manipulates its transfer time T, final mass mf and the controls as to link two fixed points in space with a low-thrust trajectory.

It can be used to better profile and understand performances of optimizers on this type of direct approach, but has a limited use in the design of interplanetary trajectories as per the fixed point limitation.

The decision vector is:

z = [mf, throttles, tof]

where throttles is a vector of throttles structures as [u0x, u0y,u0z, …]. By throttles we intend non dimensiona thrust levels in [0,1].

Initializes the direct_point2point instance with given parameters.

Args:

rvs (list): Initial position and velocity vectors. Defaults to two vectors scaled by AU and Earth’s velocity.

rvf (list): Final position and velocity vectors. Defaults to two vectors scaled by AU and Earth’s velocity.

ms (float): Initial spacecraft mass in kg. Defaults to 1000 kg.

mu (float): Gravitational parameter, default is for the Sun (MU_SUN).

max_thrust (float): Maximum thrust in Newtons. Defaults to 0.12 N.

isp (float): Specific impulse in seconds. Defaults to 3000 s.

tof_bounds (list): Bounds for time of flight in days. Defaults to [0, 400] days.

mf_bounds (list): Bounds for final mass in kg. Defaults to [200.0, 1000.0] kg.

nseg (int): Number of segments for the trajectory. Defaults to 10.

cut (float): Cut parameter for the sims_flanagan. Defaults to 0.6.

mass_scaling (float): Scaling factor for mass (used to scale constraints). Defaults to 1000.

r_scaling (float): Scaling factor for distance, (used to scale constraints). Defaults AU (AU).

v_scaling (float): Scaling factor for velocity (used to scale constraints). Defaults the Earth’s velocity (EARTH_VELOCITY).

with_gradient (bool): Indicates if gradient information should be used. Defaults True.

plot(x, ax=None, units=149597870700.0, show_midpoints=False, show_gridpoints=False, show_throttles=False, length=0.1, arrow_length_ratio=0.05, **kwargs)#

Plots the trajectory leg 3D axes.

Args:

x (list): The decision vector containing final mass, thrust direction, and time of flight.

ax (mpl_toolkits.mplot3d.axes3d.Axes3D, optional): The 3D axis to plot on. Defaults to None.

units (float, optional): The unit scale for the plot. Defaults to _pk.AU.

show_midpoints (bool, optional): Whether to show midpoints on the trajectory. Defaults to False.

show_gridpoints (bool, optional): Whether to show grid points on the trajectory. Defaults to False.

show_throttles (bool, optional): Whether to show throttle vectors. Defaults to False.

length (float, optional): Length of the throttle vectors. Defaults to 0.1.

arrow_length_ratio (float, optional): Arrow length ratio for the throttle vectors. Defaults to 0.05.

**kwargs: Additional keyword arguments for the plot.

Returns:

mpl_toolkits.mplot3d.axes3d.Axes3D: The 3D axis with the plotted trajectory.

pretty(x)#

Prints a detailed representation of the Point to point problem.

Args:

x (list): The decision vector containing final mass, thrust direction, and time of flight.


class pykep.trajopt.direct_pl2pl(pls, plf, ms=1500, mu=_pk.MU_SUN, max_thrust=0.12, isp=3000, t0_bounds=[6700.0, 6800.0], tof_bounds=[200.0, 300.0], mf_bounds=[1300.0, 1500.0], vinfs=3.0, vinff=0.0, nseg=10, cut=0.6, mass_scaling=1500, r_scaling=pk.AU, v_scaling=pk.EARTH_VELOCITY, with_gradient=True)#

Represents the optimal low-thrust transfer between two planet using a direct method.

This problem works internally using the sims_flanagan and manipulates its initial and final states, as well as its transfer time T, final mass mf and the controls as to link the two planets with a low-thrust trajectory.

The particular transcription used is suitable only for few revolutions, after which convergence will start to be problematic.

The decision vector is:

z = [t0, mf, Vsx, Vsy, Vsz, Vfx, Vfy, Vfz, throttles, tof] - all in S.I. units except t0 and tof in days

where throttles is a vector of throttles structured as [u0x, u0y,u0z, …]. By throttles we intend non dimensiona thrust levels in [0,1].

Args:

pls (planet): Initial planet. Defaults to jpl_lp Earth.

plf (planet): Final planet. Defaults to jpl_lp Mars.

ms (float): Initial spacecraft mass in kg. Defaults to 1000 kg.

mu (float): Gravitational parameter, default is for the Sun (MU_SUN).

max_thrust (float): Maximum thrust in Newtons. Defaults to 0.12 N.

isp (float): Specific impulse in seconds. Defaults to 3000 s.

t0_bounds (list): Bounds for departure epoch in MJD2000. Defaults to [6700.0, 6800.0].

tof_bounds (list): Bounds for time of flight in days. Defaults to [200, 300] days.

mf_bounds (list): Bounds for final mass in kg. Defaults to [1300.0, 1500.0] kg.

vinfs (float): Allowed magnitude for the departure’s relative velocity in km/s. Defaults to 3.

vinff (float): Allowed magnitude for the arrival’s relative velocity in km/s. Defaults to 0.

nseg (int): Number of segments for the trajectory. Defaults to 10.

cut (float): Cut parameter for the sims_flanagan. Defaults to 0.6.

mass_scaling (float): Scaling factor for mass (used to scale constraints). Defaults to 1500.

r_scaling (float): Scaling factor for distance, (used to scale constraints). Defaults AU (AU).

v_scaling (float): Scaling factor for velocity (used to scale constraints). Defaults the Earth’s velocity (EARTH_VELOCITY).

with_gradient (bool): Indicates if gradient information should be used. Defaults True.

plot(x, ax=None, units=149597870700.0, show_midpoints=False, show_gridpoints=False, show_throttles=False, length=0.1, arrow_length_ratio=0.05, **kwargs)#

Plots the trajectory leg 3D axes.

Args:

x (list): The decision vector containing final mass, thrust direction, and time of flight.

ax (mpl_toolkits.mplot3d.axes3d.Axes3D, optional): The 3D axis to plot on. Defaults to None.

units (float, optional): The unit scale for the plot. Defaults to _pk.AU.

show_midpoints (bool, optional): Whether to show midpoints on the trajectory. Defaults to False.

show_gridpoints (bool, optional): Whether to show grid points on the trajectory. Defaults to False.

show_throttles (bool, optional): Whether to show throttle vectors. Defaults to False.

length (float, optional): Length of the throttle vectors. Defaults to 0.1.

arrow_length_ratio (float, optional): Arrow length ratio for the throttle vectors. Defaults to 0.05.

**kwargs: Additional keyword arguments for the plot.

Returns:

mpl_toolkits.mplot3d.axes3d.Axes3D: The 3D axis with the plotted trajectory.

pretty(x)#

Prints a human readable representation of the transfer.

Args:

x (list): The decision vector containing final mass, thrust direction, and time of flight.


Indirect#

Indirect methods are based on the Pontryagin Maximum Principle (PMP), which provides necessary conditions for optimality. These methods involve deriving the optimal control laws and the corresponding state trajectories by solving a two point boundary value problem (TPBVP) derived from the PMP.


class pykep.trajopt.pontryagin_cartesian_mass(posvel0=[[34110913367.783306, -139910016918.87585, -14037825669.025244], [29090.9902134693, 10000.390168313803, 1003.3858682643288]], posvelf=[[-159018773159.22266, -18832495968.945133, 15781467087.350443], [2781.182556622003, -28898.40730995848, -483.4533989771214]], tof=250, mu=1.3271244004127942e+20, eps=0.0001, T_max=0.6, Isp=3000, m0=1500, L=149597870700.0, TIME=31557600.0, MASS=1500, with_gradient=False)#

This class is a pygmo (http://esa.github.io/pygmo/) UDP representing a single-shooting indirect method for the minimum mass, fixed time, optimization of a low-thrust trajectory.

The decision vector is:

x = [lx, ly, lz, lvx, lvy, lvz, lm, l0]

Note

Gradients are also provided via the variational version of the augmented dynamics.

pykep.trajopt.pontryagin_cartesian(start=default, target=default, tof=250, mu=1.32712440018e+20, eps=1e-4, T_max=0.6, Isp=3000, m0=1500, L=1.495978707e+11, TIME=31557600.0, MASS=1500, with_gradient=False)

Args:

posvel0 (list): the initial position and velocity of the spacecraft.

posvelf (list): the final position and velocity of the spacecraft.

tof (float): the time of flight of the trajectory (in days).

mu (float): the gravitational parameter of the central body.

eps (float): the accuracy of the numerical integrator.

T_max (float): the maximum thrust of the spacecraft.

Isp (float): the specific impulse of the spacecraft.

m0 (float): the initial mass of the spacecraft.

L (float): units for length. All inputs will be scaled to these units and must be of the same order as to obtain a well scaled problem.

TIME (float): units for time. All inputs will be scaled to these units and should be of the same order as to obtain a well scaled problem.

MASS (float): units for mass. All inputs will be scaled to these units and should be of the same order as to obtain a well scaled problem.

with_gradient (bool): whether to use the gradient of the constraints or not.

plot(x, N=100, ax3D=None)#

This function plots the trajectory encoded in the decision vector x.

Args:

x (list): the decision vector. N (int): the number of points to use in the plot. ax3D (matplotlib.axes._axes.Axes): the axis to use for the plot. If None, a new axis is created.

Returns:

ax3D (matplotlib.axes._axes.Axes): the axis of the plot.

plot_misc(x, N=100)#

This function plots the throttle, thrust direction, switching function, mass costate and Hamiltonian of the trajectory encoded in the decision vector x.

Args:

x (list): the decision vector. N (int): the number of points to use in the plot.

Returns:

axs (list): the list of axis of the plots.

class pykep.trajopt.pontryagin_cartesian_time(source=unknown UDPLA, target=unknown UDPLA, t0=2000-01-01T00:00:00.000000, tof_guess=250, T_max=0.6, Isp=3000, m0=1500, L=149597870700.0, TIME=31557600.0, MASS=1500, with_gradient=False)#

This class is a pygmo (http://esa.github.io/pygmo/) UDP representing a single-shooting indirect method for the minimum time, optimization of a low-thrust trajectory.

The decision vector is:

x = [lx, ly, lz, lvx, lvy, lvz, lm, lJ, tof]

Note

Gradients are also provided via the variational version of the augmented dynamics.

pykep.trajopt.pontryagin_cartesian(start=default, target=default, tof=250, mu=1.32712440018e+20, eps=1e-4, T_max=0.6, Isp=3000, m0=1500, L=1.495978707e+11, TIME=31557600.0, MASS=1500, with_gradient=False)

Args:

source (list): the initial planet.

target (list): the final planet.

t0 (epoch): the initial epoch.

tof_guess (float): a guess for the time of flight. Bound will be defined as tof_guess/2 and 2*tof_guess.

T_max (float): the maximum thrust of the spacecraft.

Isp (float): the specific impulse of the spacecraft.

m0 (float): the initial mass of the spacecraft.

L (float): units for length. All inputs will be scaled to these units and must be of the same order as to obtain a well scaled problem.

TIME (float): units for time. All inputs will be scaled to these units and should be of the same order as to obtain a well scaled problem.

MASS (float): units for mass. All inputs will be scaled to these units and should be of the same order as to obtain a well scaled problem.

with_gradient (bool): whether to use the gradient of the constraints or not.

plot(x, ax3D=None, N=100, **kwargs)#

This function plots the trajectory encoded in the decision vector x.

Args:

x (list): the decision vector. ax3D (matplotlib.axes._axes.Axes): the axis to use for the plot. If None, a new axis is created. N (int): the number of points to use in the plot. **kwargs: Additional keyword arguments to pass to the trajectory plot.

Returns:

ax3D (matplotlib.axes._axes.Axes): the axis of the plot.

plot_misc(x, N=100, **kwargs)#

This function plots the throttle, switching function and Hamiltonian of the trajectory encoded in the decision vector x.

Args:

x (list): the decision vector. N (int): the number of points to use in the plot. **kwargs: Additional keyword arguments to pass to the plt.subplots function.

Returns:

axs (list): the list of axis of the plots.


Evolutionary Encodings#

Some type of interplanetary trajectories can be evolved: shocking?. This AI approach to trajectory design resulted in two silver ([TAF+05], [PGJ+18]) and one gold ([ISM+13]) Humies award for human-competitive results that were produced by any form of genetic and evolutionary computation. In pykep we offer some classes that help instantiating these type of transfers amenable to evolutionary techniques.


class pykep.trajopt.mga(seq, t0, tof, vinf, multi_objective=False, tof_encoding="direct"", orbit_insertion=False, e_target=None, rp_target=None)#

The Multiple Gravity Assist (MGA) encoding of an interplanetary trajectory.

This class may be used as a User Defined Problem (UDP) for the pygmo (http://esa.github.io/pygmo/) optimisation suite.

The decision vector (chromosome) is:

direct encoding: z = [t0, T1, T2 ... ] in [mjd2000, days, days ... ]
alpha encoding: z = [t0, T, a1, a2 ...] in [mjd2000, days, nd, nd ... ]
eta encoding: z = [t0, n1, n2, n3 ...] in [mjd2000, nd, nd ...]

Note

The time of flights of a MGA trajectory (and in general) can be encoded in different ways. When they are directly present in the decision vector, we talk about a direct encoding. This is the most ‘evolvable’ encoding but also the one that requires the most problem knowledge (e.g. to define the bounds on each leg) and is not very flexible in dealing with constraints on the total time of flight. The alpha and eta encodings, instead, allow to only specify bounds on the time of flight of the entire trajectory, and not on the single legs: a property that is attractive for multi-objective optimization, for example.

In the alpha encoding each leg time-of-flight is decoded as follows,

\(T_i = T \log\alpha_i / \sum_n\log\alpha_n\).

In the eta encoding each leg time-of-flight is decoded as follows,

\(T_i = (T_{max} - \sum_{j=0}^{(i-1)}T_j) \eta_i\)

The chromosome dimension for the direct and eta encoding is the same, while the alpha encoding requires one more gene.

Note

The resulting problem is box-bounded (unconstrained).

Args:

seq (list [planet]): sequence of planetary encounters including the departure body.

t0 (list [float or epoch]): lower and upper bounds for the launch epoch. When floats are used MJD2000 is assumed.

tof (list or float): defines the bounds on the time of flight. If tof_encoding is ‘direct’, this contains a list of 2D lists defining the upper and lower bounds on each leg. If tof_encoding is ‘alpha’, this contains a 2D list with the lower and upper bounds on the total time-of-flight. If tof_encoding is ‘eta’ tof is a float defining an upper bound for the time-of-flight.

vinf (float): the vinf provided at launch for free

multi_objective (bool): when True constructs a multiobjective problem (dv, T). In this case, ‘alpha’ or eta encodings are recommended

tof_encoding (str): one of ‘direct’, ‘alpha’ or ‘eta’. Selects the encoding for the time of flights

orbit_insertion (bool): when True the arrival dv is computed as that required to acquire a target orbit defined by e_target and rp_target

e_target (float): if orbit_insertion is True this defines the target orbit eccentricity around the final planet

rp_target (float): if orbit_insertion is True this defines the target orbit pericenter around the final planet (in m)

max_revs (int): maximal number of revolutions for lambert transfer

plot(x, ax=None, units=149597870700.0, N=60, c_orbit='dimgray', c_lambert='indianred', leg_ids=[], figsize=(5, 5), **kwargs)#

Plots the trajectory encoded into x in 3D axes.

Args:

x (list): The decision vector in the correct tof encoding.

ax (mpl_toolkits.mplot3d.axes3d.Axes3D, optional): The 3D axis to plot on. Defaults to None.

units (float, optional): The unit scale for the plot. Defaults to pk.AU.

N (int, optional): The number of points to use when plotting the trajectory. Defaults to 60.

c_orbit (str, optional): The color of the planet orbits. Defaults to ‘dimgray’.

c (str, optional): The color of the trajectory. Defaults to ‘indianred’.

figsize (tuple): The figure size (only used if a*ax* is None and axis have to be created.), Defaults to (5, 5).

leg_ids (list): selects the legs to plot. Optional, defaults to all legs.

**kwargs: Additional keyword arguments to pass to the trajectory plot (all Lambert arcs)

Returns:

mpl_toolkits.mplot3d.axes3d.Axes3D: The 3D axis where the trajectory was plotted.

pretty(x)#

Prints a human readable representation of the transfer.

Args:

x (list): The decision vector in the correct tof encoding.

to_planet(x: List[float])#

Returns a planet representing the spacecraft trajectory encoded into x.

Args:

x (list): The decision vector in the correct tof encoding.

Example:

sc = mga_udp.to_planet(population.champion_x) r, v = sc.eph(7000.)

class pykep.trajopt.mga_1dsm(seq, t0, tof, vinf_bounds=[0.5, 2.5], add_vinf_dep=False, add_vinf_arr=True, tof_encoding='direct', multi_objective=False, orbit_insertion=False, e_target=None, rp_target=None, eta_bounds=[0.01, 0.99], rp_ub=30)#

This class transcribes a Multiple Gravity Assist trajectory with one deep space maneuver per leg (MGA-1DSM) into an optimisation problem. It may be used as a User Defined Problem (UDP) for the pygmo (http://esa.github.io/pygmo/) optimisation suite.

  • Izzo, Dario. “Global optimization and space pruning for spacecraft trajectory design.” Spacecraft Trajectory Optimization 1 (2010): 178-200.

The decision vector (chromosome) is:

direct encoding: [t0] + [u, v, Vinf, eta1, T1] + [beta, rp/rV, eta2, T2] + ...
alpha encoding:  [t0] + [u, v, Vinf, eta1, a1] + [beta, rp/rV, eta2, a2] + ... + [T]
eta encoding:    [t0] + [u, v, Vinf, eta1, n1] + [beta, rp/rV, eta2, n2] + ...

where t0 is a mjd2000, Vinf is in km/s, T in days, beta in radians and the rest non dimensional.

Note

The time of flights of a MGA-1DSM trajectory (and in general) can be encoded in different ways. When they are directly present in the decision vector, we have a direct encoding. This is the most ‘evolvable’ encoding but also the one that requires the most problem knowledge (e.g. to define the bounds on each leg) and is not very flexible in dealing with constraints on the total time of flight. The alpha and eta encodings, instead, allow to only specify bounds on the time of flight of the entire trajectory, and not on the single legs: a property that is attractive for multi-objective optimization, for example.

In the alpha encoding each leg time-of-flight is decoded as follows, T_i = T log(alpha_i) / sum_n(log(alpha_n)). In the eta encoding each leg time-of-flight is decoded as follows, T_i = (tof_max - sum_0^(i-1)(T_j)) * eta_i

The chromosome dimension for the direct and eta encoding is the same, while the alpha encoding requires one more gene.

Note

The resulting problem is box-bounded (unconstrained).

seq (list [planet]): sequence of planetary encounters including the departure body.

t0 (list [float or epoch]): lower and upper bounds for the launch epoch. When floats are used MJD2000 is assumed.

tof (list or float): defines the bounds on the time of flight. If tof_encoding is ‘direct’, this contains a list of 2D lists defining the upper and lower bounds on each leg. If tof_encoding is ‘alpha’, this contains a 2D list with the lower and upper bounds on the total time-of-flight. If tof_encoding is ‘eta’, tof is a float defining an upper bound for the time-of-flight.

vinf_bounds (list [float]): the minimum and maximum allowed initial hyperbolic velocity (at launch), in km/sec.

add_vinf_dep (bool): when True the computed Dv includes the initial hyperbolic velocity (at launch).

add_vinf_arr (bool): when True the computed Dv includes the final hyperbolic velocity (at the last planet).

tof_encoding (str): one of ‘direct’, ‘alpha’ or ‘eta’. Selects the encoding for the time of flights.

multi_objective (bool): when True constructs a multiobjective problem (dv, T).

orbit_insertion (bool): when True the arrival dv is computed as that required to acquire a target orbit defined by e_target and rp_target.

e_target (float): if orbit_insertion is True this defines the target orbit eccentricity around the final planet.

rp_target (float): if orbit_insertion is True this defines the target orbit pericenter around the final planet (in m).

eta_bounds (list [float]): lower and upper bounds for the eta variable (defining the position of the DSM).

rp_ub (float): upper bound for the pericenter radius of the flybys (in planetary radii).

plot(x, ax=None, units=149597870700.0, N=60, c_orbit='dimgray', c_lambert='indianred', c_ballistic='royalblue', leg_ids=[], figsize=(5, 5), **kwargs)#

Plots the trajectory encoded into x in 3D axes.

Args:

x (list): The decision vector in the correct tof encoding.

ax (mpl_toolkits.mplot3d.axes3d.Axes3D, optional): the 3D axis. If None a new one is created.

units (float, optional): length units to be used. Defaults to pk.AU.

N (int, optional): number of points to be used in the plots. Defaults to 60.

c_orbit (str, optional): color of the planetary orbits. Defaults to ‘dimgray’.

c (str, optional): color of the trajectory. Defaults to ‘indianred’.

figsize (tuple, optional): size of the figure. Defaults to (5, 5).

**kwargs: Additional keyword arguments to pass to the trajectory plotting functions.

pretty(x)#
  • x: encoded trajectory

Prints human readable information on the trajectory represented by the decision vector x

Example:

print(prob.pretty(x))
class pykep.trajopt.pl2pl_N_impulses(start='earth', target='venus', N_max=3, tof=[20., 400.], vinf=[0., 4.], phase_free=True, multi_objective=False, t0=None)#

This class is a pygmo (http://esa.github.io/pygmo/) UDP representing a single leg transfer between two planets allowing up to a maximum number of impulsive Deep Space Maneuvers.

The decision vector is:

[t0,T] + [alpha,u,v,V_inf] * (N-2) + [alpha] + ([tf])

… in the units: [mjd2000, days] + [nd, nd, m/sec, nd] + [nd] + [mjd2000]

Each time-of-flight can be decoded as follows, T_n = T log(alpha_n) / sum_i(log(alpha_i))

Note

The resulting problem is box-bounded (unconstrained). The resulting trajectory is time-bounded.

Args:

start (planet): initial body.

target (planet): target body.

N_max (int): maximum number of impulses.

tof_bounds (list): the box bounds [lower,upper] for the total time of flight (days).

DV_max_bounds (list): the box bounds [lower,upper] for each DV magnitude (km/sec).

phase_free (bool): when True, no rendezvous condition are enforced and start and arrival anomalies will be free.

multi_objective (bool): when True, a multi-objective problem is constructed with DV and time of flight as objectives.

t0_bounds (list): the box bounds on the launch window containing two pykep.epoch. This is not needed if phase_free is True.

plot(x, ax=None, units=149597870700.0, N=60, c_orbit='dimgray', c_segments=['royalblue', 'indianred'], figsize=(5, 5), **kwargs)#

Plots the trajectory encoded into x in 3D axes.

Args:

x (list): The decision vector in the correct tof encoding.

ax (mpl_toolkits.mplot3d.axes3d.Axes3D, optional): The 3D axis to plot on. Defaults to None.

units (float, optional): The unit scale for the plot. Defaults to pk.AU.

N (int, optional): The number of points to use when plotting the trajectory. Defaults to 60.

c_orbit (str, optional): The color of the planet orbits. Defaults to ‘dimgray’.

c_segments (list, optional): The colors to alternate the various trajectory segments (inbetween DSMs). Defaults to [“royalblue”, “indianred”].

figsize (tuple): The figure size (only used if a*ax* is None and axis have to be created.), Defaults to (5, 5).

**kwargs: Additional keyword arguments to pass to the trajectory plot (common to Lambert arcs and ballistic arcs)

Returns:

mpl_toolkits.mplot3d.axes3d.Axes3D: The 3D axis where the trajectory was plotted.

plot_primer_vector(x, N=200, ax=None)#

Plots the primer vector magnitude along the trajectory encoded in x.

Args:

x (list): The decision vector in the correct tof encoding.

N (int, optional): The number of points to use when plotting the primer vector. Defaults to 200.

ax (matplotlib.axes.Axes, optional): The axis to plot on. Defaults to None.

Returns:

matplotlib.axes.Axes: The axis where the primer vector was plotted. tuple: A tuple containing the grid and the primer vector magnitude.

Utilities#

In order to facilitate the use of the classes in this module, some utilities are provided.


pykep.trajopt.primer_vector(DVi, DVj, Mji, Mjk)#

This function computes the primer vector in a point k, relative to finite impulses in i and j.

Args:

DVi (ndarray - (3,)): the impulse at point i.

DVj (ndarray - (3,)): the impulse at point j.

Mji (ndarray - (6,6)): the state transition matrix from i to j (dxj = Mji dxi).

Mjk (ndarray - (6,6)): the state transition matrix from k to j (dxj = Mji dxi).

Returns:

tuple: The primer vector, the Aik matrix, the Ajk matrix.

Note:

The impulse transfer matrix Anm is defined as those matrices that allow to compute the variation of the impulse at point n given the variation of the impulse at point m. In formal terms, dDVn = Anm dDVm. All variations are such that the terminal state is kept fixed.

pykep.trajopt.primer_vector_surrogate(DVk, Mki, Mkj)#

This function computes the surrogate primer vector at two points i and j, corresponding to a single finite impulse at point k.

Args:

DVk (ndarray - (3,)): the impulse at point k.

Mki (ndarray - (6,6)): the state transition matrix from i to k (dxk = Mki dxi).

Mkj (ndarray - (6,6)): the state transition matrix from j to k (dxk = Mkj dxj).

Returns:

tuple: The surrogate primer vector, the Aij matrix, the Akj matrix.

Note:

The impulse transfer matrix Anm is defined as that matrix that allows to compute (in this surrogate case) the variation of the impulse at point n given the variation of the impulse at point m. In formal terms, dDVn = Anm dDVm. All variations are such that the terminal state is kept fixed.

class pykep.trajopt._launchers#

This class contains an API to access the tabulated data on the mass launchers can deliver to a certain declination / vinf.

Note

In pykep the object pykep.trajopt.launchers is an instance of this class created upon import and is used to access launchers data.

Examples:
>>> import pykep as pk
>>> mass = pk.trajopt.launchers.soyuzf(4.5, 33.21)
>>> mass2 = pk.trajopt.launchers.atlas501(4.5, 33.21)
ariane5(vinfs, decls)#

Estimates the mass that the Ariane5 launcher can deliver to a certain vinf and declination, assuming a launch from Kourou. Data provided to ESOC by Arianespace when Ariane launch for ExoMars was an option. If the inputs are arrays, then a mesh is constructed and the mass is returned on all points of the mesh.

Args:

vinfs (float or numpy.ndarray (N)): the hyperbolic escape velocities in km/s.

decls (float or numpy.ndarray (N)):: the declinations in degrees (in the ECF frame).

Returns:

numpy.ndarray (N, N): masses delivered to escape with said declinations and magnitudes.

atlas501(vinfs, decls)#

Estimates the mass that the Atlas 501 launcher can deliver to a certain vinf and declination. If the inputs are arrays, then a mesh is constructed and the mass is returned on all points of the mesh.

Args:

vinfs (float or numpy.ndarray (N)): the hyperbolic escape velocities in km/s.

decls (float or numpy.ndarray (N)):: the declinations in degrees (in the ECF frame).

Returns:

numpy.ndarray (N, N): masses delivered to escape with said declinations and magnitudes.

atlas551(vinfs)#

Estimates the mass that the Atlas 551 launcher can deliver to a certain vinf

Args:

vinfs (float or numpy.ndarray (N)): the hyperbolic escape velocities in km/s.

Returns:

numpy.ndarray (N): masses delivered to escape with said vinf magnitudes.

soyuzf(vinfs, decls)#

Estimates the mass that the Soyutz-Fregat launcher can deliver to a certain vinf and declination. If the inputs are arrays, then a mesh is constructed and the mass is returned on all points of the mesh.

Args:

vinfs (float or numpy.ndarray (N)): the hyperbolic escape velocities in km/s.

decls (float or numpy.ndarray (N)):: the declinations in degrees (in the ECF frame).

Returns:

numpy.ndarray (N, N): masses delivered to escape with said declinations and magnitudes.