STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
ui.flight_sim Namespace Reference

Functions

 detect_tank_underfill_time (mdot, m_initial, burn_time, n_samples=5000)
 detect_lox_underfill_time (mdot_lox, m_lox0, burn_time, n_samples=5000)
 detect_fuel_underfill_time (mdot_fuel, m_fuel0, burn_time, n_samples=5000)
 truncate_thrust_curve (thrust_curve, cutoff_time)
 truncate_mdot_function (mdot_func, cutoff_time, burn_time)
 _sample (source, times)
 _cumulative (times, rates)
 _depletion_time (times, cumulative, m0)
 _on_grid (times, values, t_end)
 ullage_gas_density (tank_section)
 flight_report (flight, config, drag_curves=None, extra=None)
 setup_flight (config, thrust_curve, mdot_lox, mdot_fuel, plot_results=False, liftoff_mass=None, ullage_gas_kg=None)

Variables

 message
 category
float g0 = 9.80665
dict _GAS_LABEL = {"nitrogen": "N₂", "n2": "N₂", "helium": "He", "he": "He"}

Detailed Description

flight_sim.py
--------------
Reusable RocketPy-based liquid engine flight simulation module.

Function Documentation

◆ _cumulative()

ui.flight_sim._cumulative ( times,
rates )
protected

Definition at line 295 of file flight_sim.py.

Referenced by setup_flight().

◆ _depletion_time()

ui.flight_sim._depletion_time ( times,
cumulative,
m0 )
protected
First time the integral of mdot reaches m0, linear between samples; None if it never does.

Definition at line 299 of file flight_sim.py.

Referenced by setup_flight().

◆ _on_grid()

ui.flight_sim._on_grid ( times,
values,
t_end )
protected
(t, v) samples on [0, t_end], t_end included, for a RocketPy Function.

Definition at line 311 of file flight_sim.py.

◆ _sample()

ui.flight_sim._sample ( source,
times )
protected
Values of a thrust / mdot source (float, callable, RocketPy Function, (t, v) list) at times.

Definition at line 285 of file flight_sim.py.

Referenced by setup_flight().

◆ detect_fuel_underfill_time()

ui.flight_sim.detect_fuel_underfill_time ( mdot_fuel,
m_fuel0,
burn_time,
n_samples = 5000 )
Detect when fuel tank would get underfilled by integrating mdot_fuel over time.

Parameters:
-----------
mdot_fuel : float or Function
    Fuel mass flow rate. Can be a constant float or a RocketPy Function.
m_fuel0 : float
    Initial fuel mass [kg]
burn_time : float
    Total burn time [s]
n_samples : int
    Number of time samples for integration (default: 5000)

Returns:
--------
cutoff_time : float or None
    Time at which fuel would be depleted (None if it never depletes)

Definition at line 121 of file flight_sim.py.

References detect_tank_underfill_time().

◆ detect_lox_underfill_time()

ui.flight_sim.detect_lox_underfill_time ( mdot_lox,
m_lox0,
burn_time,
n_samples = 5000 )
Detect when LOX tank would get underfilled by integrating mdot_lox over time.

Parameters:
-----------
mdot_lox : float or Function
    LOX mass flow rate. Can be a constant float or a RocketPy Function.
m_lox0 : float
    Initial LOX mass [kg]
burn_time : float
    Total burn time [s]
n_samples : int
    Number of time samples for integration (default: 5000)

Returns:
--------
cutoff_time : float or None
    Time at which LOX would be depleted (None if it never depletes)

Definition at line 99 of file flight_sim.py.

References detect_tank_underfill_time().

◆ detect_tank_underfill_time()

ui.flight_sim.detect_tank_underfill_time ( mdot,
m_initial,
burn_time,
n_samples = 5000 )
Detect when a tank would get underfilled by integrating mdot over time.

Parameters:
-----------
mdot : float or Function
    Mass flow rate. Can be a constant float or a RocketPy Function.
m_initial : float
    Initial tank mass [kg]
burn_time : float
    Total burn time [s]
n_samples : int
    Number of time samples for integration (default: 5000)

Returns:
--------
cutoff_time : float or None
    Time at which tank would be depleted (None if it never depletes)

Definition at line 27 of file flight_sim.py.

Referenced by detect_fuel_underfill_time(), and detect_lox_underfill_time().

◆ flight_report()

ui.flight_sim.flight_report ( flight,
config,
drag_curves = None,
extra = None )
What a flight says about the vehicle beyond apogee: Mach, rail exit, static margin, the
ceiling datum, and the requirement checks the config declares. Pure: reads the flight.

Definition at line 337 of file flight_sim.py.

Referenced by setup_flight().

◆ setup_flight()

ui.flight_sim.setup_flight ( config,
thrust_curve,
mdot_lox,
mdot_fuel,
plot_results = False,
liftoff_mass = None,
ullage_gas_kg = None )
Build and fly the vehicle in RocketPy from a thrust curve and the two propellant flows.

``liftoff_mass`` [kg]: the vehicle as weighed on the rail, loaded and pressed. When given, the
airframe's mass is set so the vehicle lifts off at exactly this mass.

``ullage_gas_kg`` [kg]: the gas in the tanks' ullages at T-0 when the caller knows it better
than this config's tanks do (Layer X burns the drawing's tanks). The difference from the
config-sized ullage is carried as a lumped mass with the airframe: it stays aboard all flight.

Returns a dict: apogee (AGL), apogee_asl, max_velocity (vertical), flight (RocketPy Flight),
truncation_info, mass_caps, mass_budget, flight_report (see flight_report), params (the config).

Definition at line 408 of file flight_sim.py.

References _cumulative(), _depletion_time(), _sample(), flight_report(), max, min, truncate_thrust_curve(), and ullage_gas_density().

◆ truncate_mdot_function()

ui.flight_sim.truncate_mdot_function ( mdot_func,
cutoff_time,
burn_time )
Create a new mdot function that is 0 after cutoff_time.

Parameters:
-----------
mdot_func : float or Function
    Original mass flow rate
cutoff_time : float
    Time at which to cut off mass flow
burn_time : float
    Total burn time (for creating the function domain)

Returns:
--------
truncated_func : Function
    Function that returns mdot_func(t) for t <= cutoff_time, 0 otherwise

Definition at line 220 of file flight_sim.py.

References max.

◆ truncate_thrust_curve()

ui.flight_sim.truncate_thrust_curve ( thrust_curve,
cutoff_time )
Truncate thrust curve at cutoff_time, setting thrust to 0 after that point.

Parameters:
-----------
thrust_curve : list of (t, F) tuples or Function
    Original thrust curve
cutoff_time : float
    Time at which to cut off thrust

Returns:
--------
truncated_curve : list of (t, F) tuples
    Thrust curve with thrust=0 after cutoff_time

Definition at line 143 of file flight_sim.py.

References max.

Referenced by setup_flight().

◆ ullage_gas_density()

ui.flight_sim.ullage_gas_density ( tank_section)
Pressurant density in a tank's ullage at T-0 [kg/m3], CoolProp at the tank's
initial_pressure_psi (absolute, as the engine solver reads it) and ullage_gas_temperature_K.

Definition at line 324 of file flight_sim.py.

Referenced by setup_flight().

Variable Documentation

◆ _GAS_LABEL

dict ui.flight_sim._GAS_LABEL = {"nitrogen": "N₂", "n2": "N₂", "helium": "He", "he": "He"}
protected

Definition at line 321 of file flight_sim.py.

◆ category

ui.flight_sim.category

Definition at line 22 of file flight_sim.py.

◆ g0

float ui.flight_sim.g0 = 9.80665

Definition at line 25 of file flight_sim.py.

◆ message

ui.flight_sim.message

Definition at line 21 of file flight_sim.py.