ensim.core.staging#
Multi-stage sizing with the rocket equation. Thrust is given per engine; a stage's thrust is that times its engine count, scaled between sea level and vacuum with the US Standard Atmosphere pressure.
Multi-stage vehicle bookkeeping: stage masses, thrust, staging events and ideal (Tsiolkovsky) delta-v.
Engine thrust varies linearly with ambient pressure between the sea-level and vacuum values, F(h) = F_vac - (F_vac - F_sl) p(h) / p0, which is exact for a fixed nozzle running full. p(h) comes from the US Standard Atmosphere 1976.
References
Sutton & Biblarz, "Rocket Propulsion Elements", 9th ed., ch. 4.
StageEngine
dataclass
#
Engine cluster of one stage.
Thrust is per engine; cluster values are multiplied by
num_engines. Vacuum-only engines may leave the sea-level values at zero.
Attributes:
| Name | Type | Description |
|---|---|---|
thrust_sl_per_engine |
float
|
Sea-level thrust of one engine, N. |
thrust_vac_per_engine |
float
|
Vacuum thrust of one engine, N. |
isp_sl |
float
|
Sea-level specific impulse, s. |
isp_vac |
float
|
Vacuum specific impulse, s. |
num_engines |
int
|
Engines in the cluster. |
throttle_min |
float
|
Deepest throttle setting while running, fraction. |
throttle_max |
float
|
Highest throttle setting, fraction. |
gimbal_range_deg |
float
|
Gimbal range, deg. |
ignition_time |
float
|
Delay between staging and full thrust, s. |
shutdown_time |
float
|
Thrust tail-off duration, s. |
get_thrust #
Cluster thrust at an altitude and throttle setting, N.
A throttle of zero or less shuts the engines down; other values are clamped to the throttle limits.
get_mass_flow_rate #
Cluster propellant mass flow, kg/s.
altitude is accepted for symmetry with :meth:get_thrust; for a
nozzle running full the flow does not depend on ambient pressure.
Stage
dataclass
#
One stage of the stack.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Stage identifier |
dry_mass |
float
|
Stage dry mass without propellant (kg) |
propellant_mass |
float
|
Total propellant mass (kg) |
engine |
StageEngine
|
Engine parameters |
staging_trigger |
StagingTrigger
|
What triggers separation |
trigger_value |
float | None
|
Value for time/altitude/velocity triggers |
fairing_mass |
float
|
Payload fairing mass if attached (kg) |
fairing_jettison_alt |
float | None
|
Altitude to jettison fairing (m), None to keep |
interstage_mass |
float
|
Interstage adapter mass (kg) |
separation_impulse |
float
|
Separation system impulse (N·s) |
ullage_thrust |
float
|
Ullage motor thrust for settling (N) |
ullage_duration |
float
|
Ullage motor burn duration (s) |
propellant_fraction
property
#
Remaining propellant as fraction of initial.
get_ideal_delta_v #
Calculate ideal delta-v using Tsiolkovsky equation.
ΔV = Isp × g0 × ln(m_initial / m_final)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload_mass
|
float
|
Additional payload mass (kg) |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Ideal delta-v (m/s) |
consume_propellant #
Consume propellant over timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass_flow
|
float
|
Mass flow rate (kg/s) |
required |
dt
|
float
|
Timestep (s) |
required |
Returns:
| Type | Description |
|---|---|
float
|
Actual mass consumed (kg) |
MultiStageVehicle
dataclass
#
Multi-stage launch vehicle model.
Handles staging logic, mass tracking, and thrust calculations for vehicles with arbitrary number of stages.
Stages are numbered from bottom (1) to top (N), with the payload on top of stage N.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Vehicle name |
stages |
list[Stage]
|
List of stages (index 0 = bottom stage) |
payload_mass |
float
|
Payload mass on top (kg) |
launch_site_altitude |
float
|
Launch site altitude MSL (m) |
total_mass
property
#
Total vehicle mass including all attached stages and payload.
get_thrust #
Get current total thrust.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Current altitude (m) |
required |
throttle
|
float
|
Throttle setting (0-1) |
1.0
|
Returns:
| Type | Description |
|---|---|
float
|
Total thrust (N) |
get_mass_flow #
Get current mass flow rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Current altitude (m) |
required |
throttle
|
float
|
Throttle setting (0-1) |
1.0
|
Returns:
| Type | Description |
|---|---|
float
|
Mass flow rate (kg/s) |
step #
Advance vehicle state by one timestep.
Handles propellant consumption, staging checks, and fairing jettison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
float
|
Timestep (s) |
required |
altitude
|
float
|
Current altitude (m) |
required |
velocity
|
float
|
Current velocity magnitude (m/s) |
required |
throttle
|
float
|
Throttle setting (0-1) |
1.0
|
Returns:
| Type | Description |
|---|---|
list[StagingEvent]
|
List of staging events that occurred |
get_total_delta_v #
Calculate total ideal delta-v of the vehicle.
Uses serial staging calculation where each stage carries upper stages as payload.
Returns:
| Type | Description |
|---|---|
float
|
Total delta-v (m/s) |
get_stage_delta_v_breakdown #
Get delta-v contribution of each stage.
Returns:
| Type | Description |
|---|---|
list[tuple[str, float]]
|
List of (stage_name, delta_v) tuples |
StagingEvent
dataclass
#
Record of a staging event.
StagingTrigger #
Bases: Enum
Conditions that trigger stage separation.
StageStatus #
Bases: Enum
Stage operational status.
create_medium_lift_reference #
Create an editable two-stage reference vehicle.
create_heavy_lift_reference #
Create an editable three-stage reference vehicle.
create_custom_vehicle #
create_custom_vehicle(stage_configs: list[dict], payload_mass: float = 0.0, name: str = 'Custom Vehicle') -> MultiStageVehicle
Build a vehicle from plain dictionaries, bottom stage first.
Keys per stage: name, dry_mass (kg), propellant_mass (kg),
thrust_sl_per_engine and thrust_vac_per_engine (N), isp_sl and
isp_vac (s), num_engines, throttle_min, throttle_max,
fairing_mass (kg) and fairing_jettison_alt (m). Masses, vacuum
thrust and vacuum Isp are required.