Interplanetary transfer legs#
- class pykep.leg.sims_flanagan(rvs=[[1, 0, 0], [0, 1, 0]], ms=1., throttles=[0, 0, 0, 0, 0, 0], rvf=[[0, 1, 0], [-1, 0, 0]], mf=1., tof=pi / 2, max_thrust=1., veff=1., mu=1., cut=0.5)#
This class represents an interplanetary low-thrust transfer between a starting and a final point in the augmented state-space \([\mathbf r, \mathbf v, m]\). The low-thrust transfer is described by a sequence of equally spaced impulses as described in:
Sims, J., Finlayson, P., Rinderle, E., Vavrina, M. and Kowalkowski, T., 2006, August. Implementation of a low-thrust trajectory optimization algorithm for preliminary design. In AIAA/AAS Astrodynamics specialist conference and exhibit (p. 6746).
The low-thrust transfer will be feasible is the state mismatch equality constraints and the throttle mismatch inequality constraints are satisfied.
- Args:
rvs (2D array-like): Cartesian components of the initial position vector and velocity [[xs, ys, zs], [vxs, vys, vzs]]. Defaults to [[1,0,0], [0,1,0]].
ms (
float
): initial mass. Defaults to 1.throttles (1D array-like): the Cartesan components of the throttle history [ux1, uy1, uz1, ux2, uy2, uz2, …..]. Defaults to a ballistic, two segments profile [0,0,0,0,0,0].
rvf (2D array-like): Cartesian components of the final position vector and velocity [[xf, yf, zf], [vxf, vyf, vzf]]. Defaults to [[0,1,0], [-1,0,0]].
mf (
float
): final mass. Defaults to 1.tof (
float
): time of flight. Defaults to \(\frac{\pi}{2}\).max_thrust (
float
): maximum level for the spacecraft thrust. Defaults to 1.veff (
float
): effective velocity of the propulsion system. Defaults to 1.mu (
float
): gravitational parameter. Defaults to 1.cut (
float
): the leg cut, in [0,1]. It determines the number of forward and backward segments. Defaults to 0.5.
Note
Units need to be consistent.
- Examples:
>>> import pykep as pk >>> import numpy as np >>> sf = pk.leg.sims_flanagan()
- compute_mc_grad()#
Computes the gradients of the mismatch constraints. Indicating the initial augmented state with \(\mathbf x_s = [\mathbf r_s, \mathbf v_s, m_s]\), the final augmented state with \(\mathbf x_f = [\mathbf r_f, \mathbf v_f, m_f]\), the total time of flight with \(T\) and introducing the throttle vector \(\mathbf u = [u_{x0}, u_{y0}, u_{z0}, u_{x1}, u_{y1}, u_{z1} ]\) and \(\mathbf {\tilde u} = [\mathbf u, T]\) (note the time of flight at the end), this method computes the following gradients:
\[\frac{\partial \mathbf {mc}}{\partial \mathbf x_s} \rightarrow (7\times7)\]\[\frac{\partial \mathbf {mc}}{\partial \mathbf x_f} \rightarrow (7\times7)\]\[\frac{\partial \mathbf {mc}}{\partial \mathbf {\tilde u}} \rightarrow (7\times(3\mathbf{nseg} + 1))\]- Returns:
tuple
[numpy.ndarray
,numpy.ndarray
,numpy.ndarray
]: The three gradients. sizes will be (7,7), (7,7) and (7, nseg*3 + 1)- Examples:
>>> import pykep as pk >>> import numpy as np >>> sf = pk.leg.sims_flanagan() >> sf.throttles = [0.8]*3 >>> sf.compute_mc_grad()
- compute_mismatch_constraints()#
In the Sims-Flanagan trajectory leg model, a forward propagation is performed from the starting state as well as a backward from the final state. The state values thus computed need to match in some middle control point. This is typically imposed as 7 independent constraints called mismatch-constraints computed by this method.
- compute_tc_grad()#
Computes the gradients of the throttles constraints. Indicating the total time of flight with \(T\) and introducing the throttle vector \(\mathbf u = [u_{x0}, u_{y0}, u_{z0}, u_{x1}, u_{y1}, u_{z1} ]\), this method computes the following gradient:
\[\frac{\partial \mathbf {tc}}{\partial \mathbf u} \rightarrow (\mathbf{nseg} \times3\mathbf{nseg})\]- Returns:
tuple
[numpy.ndarray
]: The gradient. Size will be (nseg,nseg*3).- Examples:
>>> import pykep as pk >>> import numpy as np >>> sf = pk.leg.sims_flanagan() >> sf.throttles = [0.8]*3 >>> sf.compute_tc_grad()
- compute_throttle_constraints()#
In the Sims-Flanagan trajectory leg model implemented in pykep, we introduce the concept of throttles. Each throttle is defined by three numbers \([u_x, u_y, u_z] \in [0,1]\) indicating that a certain component of the thrust vector has reached a fraction of its maximum allowed value. As a consequence, along the segment along which the throttle is applied, the constraint \(u_x ^2 + u_y ^2 + u_z^2 = 1\), called a throttle constraint, has to be met.
- property cut#
The leg cut: it determines the number of forward and backward segments.
- property max_thrust#
Maximum spacecraft thruet.
- property mf#
Final mass.
- property ms#
Initial mass.
- property mu#
Central body gravitational parameter.
- property nseg#
The total number of segments
- property nseg_bck#
The total number of backward segments
- property nseg_fwd#
The total number of forward segments
- property rvf#
The final position vector and velocity: [[xs, ys, zs], [vxs, vys, vzs]].
- property rvs#
The initial position vector and velocity: [[xs, ys, zs], [vxs, vys, vzs]].
- property throttles#
The Cartesan components of the throttle history [ux1, uy1, uz1, ux2, uy2, uz2, …..].
- property tof#
Time of flight.
- property veff#
Effective velocity of the propulsion system (Isp*G0 in the V units of the dynamics)
- class pykep.leg.sims_flanagan_hf(state_s=[1, 0, 0, 0, 1, 0, 1.], throttles=[0, 0, 0, 0, 0, 0], state_f=[1, 0, 0, 0, 1, 0, 1.], tof=pi / 2, max_thrust=1., veff=1., mu=1., cut=0.5, tol=1e-16, tas=None)#
Secondary constructor available:
pykep.leg.sims_flanagan_hf (rvs = [[1,0,0], [0,1,0]], ms = 1., throttles = [0,0,0,0,0,0], rvf = [[0,1,0], [-1,0,0]], mf = 1., tof = pi/2, max_thrust = 1., veff = 1., mu**=1., **cut = 0.5, tol**=1e-16, **tas = None)
This class represents an interplanetary low-thrust transfer between a starting and a final point. It makes use of a fwd-bck zero-hold transcription which can be usefully seen as a generalization of the
sims_flanagan()
methodology.The low-thrust transfer will thus be feasible if the state mismatch equality constraints and the throttle mismatch inequality constraints are satisfied.
The dynamics, by default, is that of a
get_zero_hold_kep()
, but the user can pass any zero_hold taylor adaptive integrator, e.g.: for exampleget_zero_hold_cr3bp()
, as far as it includes seven states (mass being the last) and 5 parameters \(\mu, v_{eff}, T_1, T_2, T_3\). In this case the user must also provide the variational version of the numerical integrator with variational parameters being the state and the three parameters \(T_1, T_2, T_3\).- Args:
state_s (1D array-like): Flattened initial state vector. Defaults to [1,0,0,0,1,0,1.].
rvs (2D array-like): Cartesian components of the initial position vector and velocity [[xs, ys, zs], [vxs, vys, vzs]]. Defaults to [[1,0,0], [0,1,0]].
ms (
float
): initial mass. Defaults to 1.throttles (1D array-like): the Cartesian components of the throttle history [ux1, uy1, uz1, ux2, uy2, uz2, …..]. Defaults to [0,0,0,0,0,0].
state_f (1D array-like): Flattened final state vector. Defaults to [1,0,0,0,1,0,1.].
rvf (2D array-like): Cartesian components of the final position vector and velocity [[xf, yf, zf], [vxf, vyf, vzf]]. Defaults to [[0,1,0], [-1,0,0]].
mf (
float
): final mass. Defaults to 1.tof (
float
): time of flight. Defaults to \(\frac{\pi}{2}\).max_thrust (
float
): maximum thrust. Defaults to 1.veff (
float
): effective exhaust velocity. Defaults to 1.mu (
float
): gravitational parameter. Defaults to 1.cut (
float
): the leg cut, in [0,1]. Defaults to 0.5.tol (
float
): tolerance for the Taylor integrator. Defaults to 1e-16.tas (
tuple
): Tuple of (hy::taylor_adaptive
,hy::taylor_adaptive
). If None, zero hold Keplerian dynamics is used.
Note
The parameters
rvs
,rvf
,ms
andmf
are used only in the secondary constructor;state_s
andstate_f
are used only in the second constructor.Note
Units need to be consistent. (may not be straight-forward, e.g. in cr3bp zero-hold dynamics)
- Examples:
>>> import pykep as pk >>> sf_hf = pk.leg.sims_flanagan_hf() >>> sf_hf2 = pk.leg.sims_flanagan_hf(state_s=[1,0,0,0,1,0,1.])
- compute_mc_grad()#
Computes the gradients of the mismatch constraints. Indicating the initial augmented state with \(\mathbf x_s = [\mathbf r_s, \mathbf v_s, m_s]\), the final augmented state with \(\mathbf x_f = [\mathbf r_f, \mathbf v_f, m_f]\), the total time of flight with \(T\) and the introducing the augmented throttle vector \(\mathbf u = [u_{x0}, u_{y0}, u_{z0}, u_{x1}, u_{y1}, u_{z1} ..., T]\) (note the time of flight at the end), this method computes the following gradients:
\[\frac{\partial \mathbf {mc}}{\partial \mathbf x_s}\]\[\frac{\partial \mathbf {mc}}{\partial \mathbf x_f}\]\[\frac{\partial \mathbf {mc}}{\partial \mathbf u}\]- Returns:
tuple
[numpy.ndarray
,numpy.ndarray
,numpy.ndarray
]: The three gradients. sizes will be (7,7), (7,7) and (7,nseg*3)- Examples:
>>> import pykep as pk >>> import numpy as np >>> sf_hf = pk.leg.sims_flanagan_hf() >> sf_hf.throttles = [0.8]*3 >>> sf_hf.compute_mc_grad()
- compute_mismatch_constraints()#
In the Sims-Flanagan trajectory leg model, a forward propagation is performed from the starting state as well as a backward from the final state. The state values thus computed need to match in some middle control point. This is typically imposed as 7 independent constraints called mismatch-constraints computed by this method.
- compute_tc_grad()#
Computes the gradients of the throttles constraints. Indicating the total time of flight with \(T\) and introducing the augmented throttle vector \(\mathbf u = [u_{x0}, u_{y0}, u_{z0}, u_{x1}, u_{y1}, u_{z1} ..., T]\) (note the time of flight at the end), this method computes the following gradient:
\[\frac{\partial \mathbf {tc}}{\partial \mathbf u}\]- Returns:
tuple
[numpy.ndarray
]: The gradient. Size will be (nseg,nseg*3).- Examples:
>>> import pykep as pk >>> import numpy as np >>> sf_hf = pk.leg.sims_flanagan_hf() >> sf_hf.throttles = [0.8]*3 >>> sf_hf.compute_tc_grad()
- compute_throttle_constraints()#
In the Sims-Flanagan trajectory leg model implemented in pykep, we introduce the concept of throttles. Each throttle is defined by three numbers \([u_x, u_y, u_z] \in [0,1]\) indicating that a certain component of the thrust vector has reached a fraction of its maximum allowed value. As a consequence, along the segment along which the throttle is applied, the constraint \(u_x ^2 + u_y ^2 + u_z^2 = 1\), called a throttle constraint, has to be met.
- property cut#
The leg cut: it determines the number of forward and backward segments.
- get_state_history()#
Retrieves the state history of the Sims-Flanagan leg at specified times defined by the grid_points_per_segment argument. This defines how many points are saved per segment: if grid_points_per_segment=4, then each segment will include its initial and final state as well as two temporally equidistant points.
- Returns:
tuple
[numpy.ndarray
]: The state history. Size will be (nseg,grid_points_per_segment*7).- Examples:
>>> import pykep as pk >>> import numpy as np >>> sf_hf = pk.leg.sims_flanagan_hf() >>> grid_points_per_segment = 10 >>> sf_hf.get_state_history(grid_points_per_segment)
- property max_thrust#
Maximum spacecraft thruet.
- property mf#
Final mass.
- property ms#
Initial mass.
- property mu#
Central body gravitational parameter.
- property nseg#
The total number of segments
- property nseg_bck#
The total number of backward segments
- property nseg_fwd#
The total number of forward segments
- property rvf#
The final position vector and velocity: [[xs, ys, zs], [vxs, vys, vzs]].
- property rvmf#
The final position vector, velocity, and mass: [xf, yf, zf, vxf, vyf, vzf, mf].
- property rvms#
The initial position vector, velocity, and mass: [xs, ys, zs, vxs, vys, vzs, ms].
- property rvs#
The initial position vector and velocity: [[xs, ys, zs], [vxs, vys, vzs]].
- property throttles#
The Cartesan components of the throttle history [ux1, uy1, uz1, ux2, uy2, uz2, …..].
- property tof#
Time of flight.
- property tol#
The tolerance of the Taylor adaptive integrator.
- property veff#
Effective velocity of the propulsion system (Isp*G0 in the V units of the dynamics)