Thrust Direction And Kinematic Attitude
Finite-thrust phases use Phase.thrust_control to separate propulsion from
the choice of direction variables. The translational force and propellant
model remain unchanged.
Free Vector-Throttle Control
The default is a dimensionless three-component vector. Its norm is throttle and is bounded by one; its direction is the thrust direction.
from octavian import ThrustControl
inertial_control = ThrustControl.vector(frame="inertial")
ric_control = ThrustControl.vector(frame="ric")
An RIC vector is rotated into inertial coordinates from the propagated state at every collocation point. For an inertial mission, RIC is defined by that spacecraft's position and velocity. For exact relative motion, it is defined by the propagated chief.
Use this representation when the optimizer should choose both throttle and direction freely.
Prescribed Direction
Fixed control removes direction from the decision vector and leaves only scalar throttle:
constant_inertial = ThrustControl.fixed(
[1.0, 0.0, 0.0],
frame="inertial",
)
always_in_track = ThrustControl.fixed(
[0.0, 1.0, 0.0],
frame="ric",
)
Input vectors are normalized. A fixed inertial direction remains constant in inertial space. A fixed RIC direction follows the local orbital frame.
Euler-Angle Kinematics
Euler control adds yaw, pitch, and roll states. It uses a 3-2-1 convention relative to the selected frame, and the body +X axis is the thrust direction. The controls are scalar throttle plus yaw, pitch, and roll rates.
import numpy as np
from octavian import ThrustControl
attitude = ThrustControl.euler(
frame="ric",
initial_angles_rad=np.deg2rad([90.0, 0.0, 0.0]),
max_slew_rate_radps=np.deg2rad(0.5),
yaw_bounds_rad=np.deg2rad([-180.0, 180.0]),
pitch_bounds_rad=np.deg2rad([-80.0, 80.0]),
roll_bounds_rad=np.deg2rad([-180.0, 180.0]),
)
This is a kinematic attitude model. It does not introduce torque, inertia, reaction wheels, or full six-degree-of-freedom dynamics. Roll is carried so attitude can remain continuous even though rotation about body +X does not change the translational thrust direction.
The maximum slew rate bounds the magnitude of the Euler-rate vector, not each axis independently. Internally, Octavian normalizes the optimizer variables for conditioning; returned histories are always in physical radians per second.
Attach Control To A Phase
from octavian import Phase
burn = Phase(
name="departure_burn",
mode="finite_thrust",
spacecraft=spacecraft,
dynamics=dynamics,
thrust_control=attitude,
# states, time bounds, and constraints...
)
The same declarations work for ordinary inertial dynamics and exact
Dynamics.relative(..., propagation_mode="coupled_eci") deputy burns.
Continuous Burn-Coast-Burn Attitude
In a powered chain, a kinematic attitude can continue through an intermediate coast:
departure = Phase(
name="departure",
mode="finite_thrust",
spacecraft=spacecraft,
dynamics=dynamics,
thrust_control=attitude,
)
coast = Phase(
name="coast",
mode="coast",
previous=departure,
)
arrival = Phase(
name="arrival",
mode="finite_thrust",
previous=coast,
)
The later phases inherit thrust_control. Octavian carries mass and attitude
through the coast and links yaw, pitch, and roll continuously at both
boundaries. Every phase from the first through the last powered phase must use
the same Euler reference frame. Set thrust_control explicitly on a later
phase only when changing another compatible setting such as its angle bounds.
Read The Result
solution = mission.solve()
for control_history in solution.phase_control_trajectories:
# [time, controls...]
print(control_history.shape)
for attitude_history in solution.attitude_phase_trajectories:
# [yaw, pitch, roll, time, yaw_rate, pitch_rate, roll_rate]
print(attitude_history[-1])
For powered Euler phases, phase_control_trajectories contains
[time, throttle, yaw_rate, pitch_rate, roll_rate]. Euler coasts contain
[time, yaw_rate, pitch_rate, roll_rate]. Rates are radians per second.
solution.result.info["thrust_controls"] records the declaration used by each
powered phase for reproducible output.
See
examples/composable/earth_centered/12_thrust_frames_and_attitude.py
for a complete executable mission.
Low-thrust Q-law guesses and firing plots
Use a Q-law guess when an inertial low-thrust transfer changes the orbit's size, eccentricity vector, or plane:
initial_guess = guesses.low_thrust_qlaw(throttle=0.85, plane_tol_deg=0.05)
Attach it as Phase.initial_guess and provide Phase.final_state on the
desired orbit. That state's position and velocity define the complete seed
target, including the orbital plane; its orbital phase is not targeted.
Declare terminal constraints separately, for example semi-major axis,
eccentricity, and inclination. Constraints may leave the ascending node free
even though the seed steers toward the anchor's particular plane.
This is a numerical equinoctial proximity-quotient variant of Q-law. Squared
errors in [p, f, g] are normalized by maximum Gauss element rates per unit
acceleration, sampled around the target orbit. The plane term is the squared
angle between the current and target angular-momentum normals, normalized by
the target orbit's maximum plane-rotation rate per unit acceleration. All
reference rates stay fixed during steering. This prevents reducing the error
metric merely by raising the orbit or approaching the equinoctial coordinate
singularity while leaving a large plane error unchanged. It also makes the
plane error independent of ascending-node wrapping.
Thrust minimizes the instantaneous derivative of that quotient using analytic gradients. A working frame centered on the two orbit normals keeps the short plane-change path away from the equinoctial chart's pole; returned states and controls remain in the input inertial frame. Exactly opposed normals have multiple equally short paths, so the seed chooses one deterministically. Circular, equatorial, and retrograde-equatorial input orbits are supported; unbound input orbits are rejected. This variant has no periapsis penalty or efficiency-based coasting and does not reproduce the original classical-element quotient. See the NASA comparison of Q-law guidance for the original classical-element formulation.
The default seed integrates osculating equinoctial elements, avoiding secular Cartesian energy drift on long arcs. Cartesian positions and velocities are resampled together with Hermite interpolation rather than cutting across orbital arcs with straight lines. Step sizes decrease near the target to avoid repeatedly overshooting tight arrival tolerances.
For many-revolution, small-acceleration transfers, explicitly choose an orbit-averaged guess:
initial_guess = guesses.low_thrust_qlaw(averaged=True, orbit_samples=64)
This time-averages the Gauss rates using Keplerian residence-time weights and
propagates mean longitude, with at most a quarter-orbit step. It reconstructs
Cartesian samples by solving Kepler's equation. orbit_samples controls both
the maximum-rate sampling and the averaging quadrature; steps_per_orbit
controls only the default osculating integration. Averaging neglects short-period
oscillations and produces an approximate seed, so use the osculating mode when
those oscillations matter. The subsequent direct solver still uses the full
phase dynamics and needs sufficient mesh resolution for every revolution;
fast seed generation does not remove that optimization cost.
seed_averaged, seed_control_evaluations, and seed_estimated_revolutions
identify the computation performed in the guess metadata.
Neither seed mode solves a fuel-minimization problem. Q-law applies the
specified fixed throttle while steering toward the target, then stops thrusting
when the target tolerances are met. A larger plane change may require more time
or propellant; the seed does not increase throttle automatically to meet a
deadline. The later ASSET solve uses the objectives declared on the mission.
For a fixed departure mass, objectives.minimize_propellant() minimizes consumed
propellant by maximizing arrival mass. It does not minimize spacecraft dry mass
or choose the propellant load. A successful feasibility recovery alone does not
establish that the fuel objective has converged to a local optimum.
Large-angle regression cases cover 40°, 60°, 120°, 170°, and 180° inclination changes,
inclination decreases, large ascending-node changes, antipodal normals, and
combined eccentricity/plane changes in both seed modes. These tests supply
adequate thrust duration, propellant, and at least 16 output intervals per
revolution. They establish seed targeting for those cases, not convergence for
every orbit or every subsequent optimization. Direct collocation also needs
sufficient segments per revolution, with accuracy checked by mesh refinement
or independent propagation; nsegs + 1 sparse seed samples cannot reconstruct
a spiral containing hundreds of revolutions.
The seed propagates two-body dynamics with constant thrust and Isp. It is
currently available for a single inertial low_thrust phase using vector
controls in either the inertial or RIC frame. The optimized phase still uses
its declared force model and constraints. Seed tolerances determine when
steering ends, not solver accuracy. If arrival precedes the minimum duration,
the seed coasts to that minimum. If the maximum duration is reached first, the
partial seed is returned with seed_target_reached=False. When compiling a
vector-control seed, coast nodes receive a 1e-4 throttle warm-start vector
because the mass-flow norm is nondifferentiable at zero. The floor is recorded
as seed_optimizer_throttle_floor; it does not constrain optimized throttle
and is not applied to the standalone propagated seed. Propellant exhaustion
raises an error. Inspect result.info["phase_guess_info"] for arrival errors.
Continue a solved low-thrust trajectory with perturbations
Q-law guesses currently propagate two-body dynamics even when the phase enables perturbations. The subsequent optimizer uses the phase's declared dynamics, including Earth harmonics and Sun/Moon gravity. To reduce the initial mismatch, solve a simpler model first and reuse its complete phase history:
nominal = mission.solve()
phase.initial_guess = nominal.trajectory_guess(phase_index=0)
phase.dynamics = Dynamics(
perturbations=Perturbations(
spherical_harmonics=SphericalHarmonics.earth(degree=8, order=8),
sun=True,
moon=True,
),
)
mission.initial_epoch = "2026-01-01T00:00:00Z"
perturbed = mission.solve()
Solution.trajectory_guess() preserves mass, time, attitude states, and controls
in the compiler's input conventions. In contrast, solution.traj is a plotting
history [R,V,t] and omits mass and controls. For manually supplied complete
Cartesian mass/thrust rows [R,V,M,t,U], use
guesses.trajectory(rows, time_column=7). Full-history time columns and widths
must match the destination layout; keep the coordinate frame, control frame,
vehicle, and time origin consistent. Euler slew controls in a reusable guess
retain their solver normalization; the reporting accessor continues to return
physical rates. The configured mission mesh is respected, independently of the
number of collocation samples in the preceding solution. This transfers a
primal trajectory, not optimizer multipliers or a solver factorization.
Example
11c_low_thrust_perturbation_continuation.py
uses four solves of the same 100 mN transfer: two-body, J2, 8×8 Earth gravity,
then 8×8 plus Sun/Moon gravity. Every stage reuses the preceding solved history
and retains the same epoch, central GM, vehicle, targets, and time window. These
are successive model refinements, not consecutive flight phases. Large model
changes may require additional intermediate stages; continuation does not
guarantee convergence. Arrival element constraints refer to osculating elements
at the final epoch, not a mean orbit or long-term station-keeping condition.
Prefer the structured Dynamics(perturbations=Perturbations(...)) interface.
When present, that object replaces all top-level perturbation flags. For
example, Dynamics(sun=True, perturbations=Perturbations(moon=True)) enables only
lunar gravity; an empty Perturbations() disables all perturbations regardless
of the top-level flags. Without the object, the top-level flags remain supported.
Within Perturbations, sun/moon and third_bodies combine and deduplicate.
Solar radiation pressure is controlled independently through srp.
Throttle and firing plots
Solver results distinguish feasibility from objective convergence:
solution.feasible (also solution.ok) accepts a feasible or acceptable
returned iterate, while solution.optimality_converged requires ASSET's
CONVERGED flag from the objective optimization. Every enum in the pinned
ASSET release is truthy, so Octavian compares named flags explicitly. A final
feasibility recovery never establishes fuel optimality. Summaries label these
outcomes separately. result.info["solve_report"] records each solver stage's
flag, iterations, objective, and elapsed time; mesh convergence is None when
adaptive refinement was disabled. SolverOptions exposes max_iterations,
feasibility_tolerance, and optimality_tolerance in addition to line-search
settings. Backend-scaled tolerances are not physical propagation tolerances.
Use solution.validate_dynamics(max_step_s=10) to reintegrate each solved
phase's compiled ODE under its control interpolant with independent RK4. The
result reports native endpoint state errors. Supply component-wise
state_tolerances in native units to get a pass/fail check. Each phase starts
at its own solved front state, respecting impulsive links. Halve the step to
check numerical integration convergence. This checks dynamics rather than
certifying optimality or every path constraint.
solution.costate_trajectories contains ASSET estimates sampled at optimization
termination, paired with solution.optimization_trajectories. These snapshots
precede recovery and use the native differential-state order followed by time.
Unavailable costates are None with an explicit backend error in
result.info["optimization_phases"]. Estimates from an unconverged objective
are not certified indirect solutions. Frames, scaling, and state-layout names
remain in result metadata; ASSET's state/costate conventions are retained.
Raw defect histories are also retained; they are not physical mesh-error or
KKT-residual estimates. Live phases are accessible through
solution.asset_phases, for example
solution.asset_phases[0].returnEqualConLmults(constraint_index). Live phases
represent the final iterate and are not serialized, so their multipliers can
differ from the optimization snapshots after recovery.
Example 11c additionally saves a propulsion time-history figure, CSV, and paired optimization-state/costate NPZ. For any mass-carrying solution:
solution.viz().save_propulsion_html("propulsion.html")
solution.save_propulsion_csv("propulsion.csv")
The figure plots throttle, thrust, mass, propellant used in each phase, and thrust acceleration over time. Phase boundaries are drawn separately. The CSV includes a phase index and physical SI units; coasts carrying mass have zero thrust, and phases without a mass state have no propulsion history.
To show actual throttle or firing intervals, including coasts inside a powered phase:
solution.viz().save_html("throttle.html", color_by="throttle")
solution.viz().save_html("firing.html", color_by="firing", firing_threshold=0.001)
The default color_by="phase" preserves phase colors. Throttle plots use a
fixed 0–1 colorbar. Firing plots use orange above the threshold and gray at or
below it, with boundaries interpolated from sampled throttle. Hover labels
show physical time, throttle, and thrust in newtons. Histories are handled
separately by phase so thrust discontinuities at links are preserved.
Both inertial and relative Plotly views support these options. Lower-level
plotters accept thrust_histories=solution.phase_thrust_trajectories; each
history contains [time_s, throttle, thrust_N]. Vector norms and scalar
throttles are converted by the solver, so Euler slew rates are never mistaken
for throttle. Explicit coast phases have zero thrust. These plots show the
sampled/interpolated solved control, not an independently validated switching
schedule.
See examples/composable/earth_centered/11b_low_thrust_plane_change.py for a
100 mN, 23 kg small-satellite orbit raise from 7,000 to 7,200 km with a
two-degree inclination change, reference orbits, and both throttle and firing
views. Semi-major axis and inclination are equality targets, while arrival
phase and ascending node remain free. It uses a scheduled 32–32.2 hour arrival window and 120 fixed LGL5 segments for a
quick tutorial. Select the collocation order explicitly with
SolverOptions(transcription_mode="LGL5"); LGL3 remains the default and LGL7
is also available. The configuration-file key is transcription_mode. Broad free-time searches, larger changes, and lower
thrust-to-mass ratios require longer trajectories and larger direct solves.
An ASSET feasibility recovery can return a constraint-satisfying trajectory
without establishing optimality; inspect the optimizer output when judging
fuel optimality.