Flight Class#
- class rocketpy.Flight[source]#
Keeps all flight information and has a method to simulate flight.
- Variables:
Flight.env (
Environment
) – Environment object describing rail length, elevation, gravity and weather condition. See Environment class for more details.Flight.rocket (
Rocket
) – Rocket class describing rocket. See Rocket class for more details.Flight.parachutes (
Parachute
) – Direct link to parachutes of the Rocket. See Rocket class for more details.Flight.frontal_surface_wind (
float
) – Surface wind speed in m/s aligned with the launch rail.Flight.lateral_surface_wind (
float
) – Surface wind speed in m/s perpendicular to launch rail.Flight.FlightPhases (
Flight.FlightPhases
) – Helper class to organize and manage different flight phases.Flight.TimeNodes (
class
) – Helper class to manage time discretization during simulation.Flight.time_iterator (
function
) – Helper iterator function to generate time discretization points.Flight.rail_length (
float
,int
) – Launch rail length in meters.Flight.effective_1rl (
float
) – Original rail length minus the distance measured from nozzle exit to the upper rail button. It assumes the nozzle to be aligned with the beginning of the rail.Flight.effective_2rl (
float
) – Original rail length minus the distance measured from nozzle exit to the lower rail button. It assumes the nozzle to be aligned with the beginning of the rail.Flight.name (
str
) – Name of the flight.Flight._controllers (
list
) – List of controllers to be used during simulation.Flight.max_time (
int
,float
) – Maximum simulation time allowed. Refers to physical time being simulated, not time taken to run simulation.Flight.max_time_step (
int
,float
) – Maximum time step to use during numerical integration in seconds.Flight.min_time_step (
int
,float
) – Minimum time step to use during numerical integration in seconds.Flight.rtol (
int
,float
) – Maximum relative error tolerance to be tolerated in the numerical integration scheme.Flight.atol (
int
,float
) – Maximum absolute error tolerance to be tolerated in the integration scheme.Flight.time_overshoot (
bool
, optional) – If True, decouples ODE time step from parachute trigger functions sampling rate. The time steps can overshoot the necessary trigger function evaluation points and then interpolation is used to calculate them and feed the triggers. Can greatly improve run time in some cases.Flight.terminate_on_apogee (
bool
) – Whether to terminate simulation when rocket reaches apogee.Flight.solver (
scipy.integrate.LSODA
) – Scipy LSODA integration scheme.Flight.x (
Function
) – Rocket’s X coordinate (positive east) as a function of time.Flight.y (
list
) – Rocket’s Y coordinate (positive north) as a function of time.Flight.z (
Function
) – Rocket’s z coordinate (positive up) as a function of time.Flight.vx (
Function
) – Rocket’s X velocity as a function of time.Flight.vy (
Function
) – Rocket’s Y velocity as a function of time.Flight.vz (
Function
) – Rocket’s Z velocity as a function of time.Flight.e0 (
Function
) – Rocket’s Euler parameter 0 as a function of time.Flight.e1 (
Function
) – Rocket’s Euler parameter 1 as a function of time.Flight.e2 (
Function
) – Rocket’s Euler parameter 2 as a function of time.Flight.e3 (
Function
) – Rocket’s Euler parameter 3 as a function of time.Flight.w1 (
Function
) – Rocket’s angular velocity Omega 1 as a function of time. Direction 1 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry.Flight.w2 (
Function
) – Rocket’s angular velocity Omega 2 as a function of time. Direction 2 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry and direction 1.Flight.w3 (
Function
) – Rocket’s angular velocity Omega 3 as a function of time. Direction 3 is in the rocket’s body axis and points in the direction of cylindrical symmetry.Flight.latitude (
Function
) – Rocket’s latitude coordinates (positive North) as a function of time. The Equator has a latitude equal to 0, by convention.Flight.longitude (
Function
) – Rocket’s longitude coordinates (positive East) as a function of time. Greenwich meridian has a longitude equal to 0, by convention.Flight.inclination (
int
,float
) – Launch rail inclination angle relative to ground, given in degrees.Flight.heading (
int
,float
) – Launch heading angle relative to north given in degrees.Flight.initial_solution (
list
) – List defines initial condition - [tInit, x_init, y_init, z_init, vx_init, vy_init, vz_init, e0_init, e1_init, e2_init, e3_init, w1_init, w2_init, w3_init]Flight.t_initial (
int
,float
) – Initial simulation time in seconds. Usually 0.Flight.solution (
list
) – Solution array which keeps results from each numerical integration.Flight.t (
float
) – Current integration time.Flight.y – Current integration state vector u.
Flight.post_processed (
bool
) – Defines if solution data has been post processed.Flight.initial_solution – List defines initial condition - [tInit, x_init, y_init, z_init, vx_init, vy_init, vz_init, e0_init, e1_init, e2_init, e3_init, w1_init, w2_init, w3_init]
Flight.out_of_rail_time (
int
,float
) – Time, in seconds, in which the rocket completely leaves the rail.Flight.out_of_rail_state (
list
) – State vector u corresponding to state when the rocket completely leaves the rail.Flight.out_of_rail_velocity (
int
,float
) – Velocity, in m/s, with which the rocket completely leaves the rail.Flight.apogee_state (
array
) – State vector u corresponding to state when the rocket’s vertical velocity is zero in the apogee.Flight.apogee_time (
int
,float
) – Time, in seconds, in which the rocket’s vertical velocity reaches zero in the apogee.Flight.apogee_x (
int
,float
) – X coordinate (positive east) of the center of mass of the rocket when it reaches apogee.Flight.apogee_y (
int
,float
) – Y coordinate (positive north) of the center of mass of the rocket when it reaches apogee.Flight.apogee (
int
,float
) – Z coordinate, or altitude, of the center of mass of the rocket when it reaches apogee.Flight.x_impact (
int
,float
) – X coordinate (positive east) of the center of mass of the rocket when it impacts ground.Flight.y_impact (
int
,float
) – Y coordinate (positive east) of the center of mass of the rocket when it impacts ground.Flight.impact_velocity (
int
,float
) – Velocity magnitude of the center of mass of the rocket when it impacts ground.Flight.impact_state (
array
) – State vector u corresponding to state when the rocket impacts the ground.Flight.parachute_events (
array
) – List that stores parachute events triggered during flight.Flight.function_evaluations (
array
) – List that stores number of derivative function evaluations during numerical integration in cumulative manner.Flight.function_evaluations_per_time_step (
array
) – List that stores number of derivative function evaluations per time step during numerical integration.Flight.time_steps (
array
) – List of time steps taking during numerical integration in seconds.Flight.FlightPhases – Stores and manages flight phases.
Flight.wind_velocity_x (
Function
) – Wind velocity X (East) experienced by the rocket as a function of time. Can be called or accessed as array.Flight.wind_velocity_y (
Function
) – Wind velocity Y (North) experienced by the rocket as a function of time. Can be called or accessed as array.Flight.density (
Function
) – Air density experienced by the rocket as a function of time. Can be called or accessed as array.Flight.pressure (
Function
) – Air pressure experienced by the rocket as a function of time. Can be called or accessed as array.Flight.dynamic_viscosity (
Function
) – Air dynamic viscosity experienced by the rocket as a function of time. Can be called or accessed as array.Flight.speed_of_sound (
Function
) – Speed of Sound in air experienced by the rocket as a function of time. Can be called or accessed as array.Flight.ax (
Function
) – Rocket’s X (East) acceleration as a function of time, in m/s². Can be called or accessed as array.Flight.ay (
Function
) – Rocket’s Y (North) acceleration as a function of time, in m/s². Can be called or accessed as array.Flight.az (
Function
) – Rocket’s Z (Up) acceleration as a function of time, in m/s². Can be called or accessed as array.Flight.alpha1 (
Function
) – Rocket’s angular acceleration Alpha 1 as a function of time. Direction 1 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry. Units of rad/s². Can be called or accessed as array.Flight.alpha2 (
Function
) – Rocket’s angular acceleration Alpha 2 as a function of time. Direction 2 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry and direction 1. Units of rad/s². Can be called or accessed as array.Flight.alpha3 (
Function
) – Rocket’s angular acceleration Alpha 3 as a function of time. Direction 3 is in the rocket’s body axis and points in the direction of cylindrical symmetry. Units of rad/s². Can be called or accessed as array.Flight.speed (
Function
) – Rocket velocity magnitude in m/s relative to ground as a function of time. Can be called or accessed as array.Flight.max_speed (
float
) – Maximum velocity magnitude in m/s reached by the rocket relative to ground during flight.Flight.max_speed_time (
float
) – Time in seconds at which rocket reaches maximum velocity magnitude relative to ground.Flight.horizontal_speed (
Function
) – Rocket’s velocity magnitude in the horizontal (North-East) plane in m/s as a function of time. Can be called or accessed as array.Flight.acceleration (
Function
) – Rocket acceleration magnitude in m/s² relative to ground as a function of time. Can be called or accessed as array.Flight.max_acceleration (
float
) – Maximum acceleration magnitude in m/s² reached by the rocket relative to ground during flight.Flight.max_acceleration_time (
float
) – Time in seconds at which rocket reaches maximum acceleration magnitude relative to ground.Flight.path_angle (
Function
) – Rocket’s flight path angle, or the angle that the rocket’s velocity makes with the horizontal (North-East) plane. Measured in degrees and expressed as a function of time. Can be called or accessed as array.Flight.attitude_vector_x (
Function
) – Rocket’s attitude vector, or the vector that points in the rocket’s axis of symmetry, component in the X direction (East) as a function of time. Can be called or accessed as array.Flight.attitude_vector_y (
Function
) – Rocket’s attitude vector, or the vector that points in the rocket’s axis of symmetry, component in the Y direction (East) as a function of time. Can be called or accessed as array.Flight.attitude_vector_z (
Function
) – Rocket’s attitude vector, or the vector that points in the rocket’s axis of symmetry, component in the Z direction (East) as a function of time. Can be called or accessed as array.Flight.attitude_angle (
Function
) – Rocket’s attitude angle, or the angle that the rocket’s axis of symmetry makes with the horizontal (North-East) plane. Measured in degrees and expressed as a function of time. Can be called or accessed as array.Flight.lateral_attitude_angle (
Function
) – Rocket’s lateral attitude angle, or the angle that the rocket’s axis of symmetry makes with plane defined by the launch rail direction and the Z (up) axis. Measured in degrees and expressed as a function of time. Can be called or accessed as array.Flight.phi (
Function
) – Rocket’s Spin Euler Angle, φ, according to the 3-2-3 rotation system (NASA Standard Aerospace). Measured in degrees and expressed as a function of time. Can be called or accessed as array.Flight.theta (
Function
) – Rocket’s Nutation Euler Angle, θ, according to the 3-2-3 rotation system (NASA Standard Aerospace). Measured in degrees and expressed as a function of time. Can be called or accessed as array.Flight.psi (
Function
) – Rocket’s Precession Euler Angle, ψ, according to the 3-2-3 rotation system (NASA Standard Aerospace). Measured in degrees and expressed as a function of time. Can be called or accessed as array.Flight.R1 (
Function
) – Resultant force perpendicular to rockets axis due to aerodynamic forces as a function of time. Units in N. Expressed as a function of time. Can be called or accessed as array. Direction 1 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry.Flight.R2 (
Function
) – Resultant force perpendicular to rockets axis due to aerodynamic forces as a function of time. Units in N. Expressed as a function of time. Can be called or accessed as array. Direction 2 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry and direction 1.Flight.R3 (
Function
) – Resultant force in rockets axis due to aerodynamic forces as a function of time. Units in N. Usually just drag. Expressed as a function of time. Can be called or accessed as array. Direction 3 is in the rocket’s body axis and points in the direction of cylindrical symmetry.Flight.M1 (
Function
) – Resultant moment (torque) perpendicular to rockets axis due to aerodynamic forces and eccentricity as a function of time. Units in N*m. Expressed as a function of time. Can be called or accessed as array. Direction 1 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry.Flight.M2 (
Function
) – Resultant moment (torque) perpendicular to rockets axis due to aerodynamic forces and eccentricity as a function of time. Units in N*m. Expressed as a function of time. Can be called or accessed as array. Direction 2 is in the rocket’s body axis and points perpendicular to the rocket’s axis of cylindrical symmetry and direction 1.Flight.M3 (
Function
) – Resultant moment (torque) in rockets axis due to aerodynamic forces and eccentricity as a function of time. Units in N*m. Expressed as a function of time. Can be called or accessed as array. Direction 3 is in the rocket’s body axis and points in the direction of cylindrical symmetry.Flight.aerodynamic_lift (
Function
) – Resultant force perpendicular to rockets axis due to aerodynamic effects as a function of time. Units in N. Expressed as a function of time. Can be called or accessed as array.Flight.aerodynamic_drag (
Function
) – Resultant force aligned with the rockets axis due to aerodynamic effects as a function of time. Units in N. Expressed as a function of time. Can be called or accessed as array.Flight.aerodynamic_bending_moment (
Function
) – Resultant moment perpendicular to rocket’s axis due to aerodynamic effects as a function of time. Units in N m. Expressed as a function of time. Can be called or accessed as array.Flight.aerodynamic_spin_moment (
Function
) – Resultant moment aligned with the rockets axis due to aerodynamic effects as a function of time. Units in N m. Expressed as a function of time. Can be called or accessed as array.Flight.rail_button1_normal_force (
Function
) – Upper rail button normal force in N as a function of time. Can be called or accessed as array.Flight.max_rail_button1_normal_force (
float
) – Maximum upper rail button normal force experienced during rail flight phase in N.Flight.rail_button1_shear_force (
Function
) – Upper rail button shear force in N as a function of time. Can be called or accessed as array.Flight.max_rail_button1_shear_force (
float
) – Maximum upper rail button shear force experienced during rail flight phase in N.Flight.rail_button2_normal_force (
Function
) – Lower rail button normal force in N as a function of time. Can be called or accessed as array.Flight.max_rail_button2_normal_force (
float
) – Maximum lower rail button normal force experienced during rail flight phase in N.Flight.rail_button2_shear_force (
Function
) – Lower rail button shear force in N as a function of time. Can be called or accessed as array.Flight.max_rail_button2_shear_force (
float
) – Maximum lower rail button shear force experienced during rail flight phase in N.Flight.rotational_energy (
Function
) – Rocket’s rotational kinetic energy as a function of time. Units in J.Flight.translational_energy (
Function
) – Rocket’s translational kinetic energy as a function of time. Units in J.Flight.kinetic_energy (
Function
) – Rocket’s total kinetic energy as a function of time. Units in J.Flight.potential_energy (
Function
) – Rocket’s gravitational potential energy as a function of time. Units in J.Flight.total_energy (
Function
) – Rocket’s total mechanical energy as a function of time. Units in J.Flight.thrust_power (
Function
) – Rocket’s engine thrust power output as a function of time in Watts. Can be called or accessed as array.Flight.drag_power (
Function
) – Aerodynamic drag power output as a function of time in Watts. Can be called or accessed as array.Flight.attitude_frequency_response (
Function
) – Fourier Frequency Analysis of the rocket’s attitude angle. Expressed as the absolute vale of the magnitude as a function of frequency in Hz. Can be called or accessed as array.Flight.omega1_frequency_response (
Function
) – Fourier Frequency Analysis of the rocket’s angular velocity omega 1. Expressed as the absolute vale of the magnitude as a function of frequency in Hz. Can be called or accessed as array.Flight.omega2_frequency_response (
Function
) – Fourier Frequency Analysis of the rocket’s angular velocity omega 2. Expressed as the absolute vale of the magnitude as a function of frequency in Hz. Can be called or accessed as array.Flight.omega3_frequency_response (
Function
) – Fourier Frequency Analysis of the rocket’s angular velocity omega 3. Expressed as the absolute vale of the magnitude as a function of frequency in Hz. Can be called or accessed as array.Flight.static_margin (
Function
) – Rocket’s static margin during flight in calibers.Flight.stability_margin (
Function
) – Rocket’s stability margin during flight, in calibers.Flight.stream_velocity_x (
Function
) – Freestream velocity x (East) component, in m/s, as a function of time. Can be called or accessed as array.Flight.stream_velocity_y (
Function
) – Freestream velocity y (North) component, in m/s, as a function of time. Can be called or accessed as array.Flight.stream_velocity_z (
Function
) – Freestream velocity z (up) component, in m/s, as a function of time. Can be called or accessed as array.Flight.free_stream_speed (
Function
) – Freestream velocity magnitude, in m/s, as a function of time. Can be called or accessed as array.Flight.apogee_freestream_speed (
float
) – Freestream speed of the rocket at apogee in m/s.Flight.mach_number (
Function
) – Rocket’s Mach number defined as its freestream speed divided by the speed of sound at its altitude. Expressed as a function of time. Can be called or accessed as array.Flight.max_mach_number (
float
) – Rocket’s maximum Mach number experienced during flight.Flight.max_mach_number_time (
float
) – Time at which the rocket experiences the maximum Mach number.Flight.reynolds_number (
Function
) – Rocket’s Reynolds number, using its diameter as reference length and free_stream_speed as reference velocity. Expressed as a function of time. Can be called or accessed as array.Flight.max_reynolds_number (
float
) – Rocket’s maximum Reynolds number experienced during flight.Flight.max_reynolds_number_time (
float
) – Time at which the rocket experiences the maximum Reynolds number.Flight.dynamic_pressure (
Function
) – Dynamic pressure experienced by the rocket in Pa as a function of time, defined by 0.5*rho*V^2, where rho is air density and V is the freestream speed. Can be called or accessed as array.Flight.max_dynamic_pressure (
float
) – Maximum dynamic pressure, in Pa, experienced by the rocket.Flight.max_dynamic_pressure_time (
float
) – Time at which the rocket experiences maximum dynamic pressure.Flight.total_pressure (
Function
) – Total pressure experienced by the rocket in Pa as a function of time. Can be called or accessed as array.Flight.max_total_pressure (
float
) – Maximum total pressure, in Pa, experienced by the rocket.Flight.max_total_pressure_time (
float
) – Time at which the rocket experiences maximum total pressure.Flight.angle_of_attack (
Function
) – Rocket’s angle of attack in degrees as a function of time. Defined as the minimum angle between the attitude vector and the freestream velocity vector. Can be called or accessed as array.
- __init__(rocket, environment, rail_length, inclination=80, heading=90, initial_solution=None, terminate_on_apogee=False, max_time=600, max_time_step=inf, min_time_step=0, rtol=1e-06, atol=[0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 1e-06, 1e-06, 1e-06, 1e-06, 0.001, 0.001, 0.001], time_overshoot=True, verbose=False, name='Flight', equations_of_motion='standard')[source]#
Run a trajectory simulation.
- Parameters:
rocket (
Rocket
) – Rocket to simulate.environment (
Environment
) – Environment to run simulation on.rail_length (
int
,float
) – Length in which the rocket will be attached to the rail, only moving along a fixed direction, that is, the line parallel to the rail. Currently, if the an initial_solution is passed, the rail length is not used.inclination (
int
,float
, optional) – Rail inclination angle relative to ground, given in degrees. Default is 80.heading (
int
,float
, optional) – Heading angle relative to north given in degrees. Default is 90, which points in the x direction.initial_solution (
array
,Flight
, optional) –Initial solution array to be used. Format is:
initial_solution = [ self.t_initial, x_init, y_init, z_init, vx_init, vy_init, vz_init, e0_init, e1_init, e2_init, e3_init, w1_init, w2_init, w3_init ]
If a Flight object is used, the last state vector will be used as initial solution. If None, the initial solution will start with all null values, except for the euler parameters which will be calculated based on given values of inclination and heading. Default is None.
terminate_on_apogee (
boolean
, optional) – Whether to terminate simulation when rocket reaches apogee. Default is False.max_time (
int
,float
, optional) – Maximum time in which to simulate trajectory in seconds. Using this without setting a max_time_step may cause unexpected errors. Default is 600.max_time_step (
int
,float
, optional) – Maximum time step to use during integration in seconds. Default is 0.01.min_time_step (
int
,float
, optional) – Minimum time step to use during integration in seconds. Default is 0.01.rtol (
float
,array
, optional) – Maximum relative error tolerance to be tolerated in the integration scheme. Can be given as array for each state space variable. Default is 1e-3.atol (
float
, optional) – Maximum absolute error tolerance to be tolerated in the integration scheme. Can be given as array for each state space variable. Default is 6*[1e-3] + 4*[1e-6] + 3*[1e-3].time_overshoot (
bool
, optional) – If True, decouples ODE time step from parachute trigger functions sampling rate. The time steps can overshoot the necessary trigger function evaluation points and then interpolation is used to calculate them and feed the triggers. Can greatly improve run time in some cases. Default is True.verbose (
bool
, optional) – If true, verbose mode is activated. Default is False.name (
str
, optional) – Name of the flight. Default is “Flight”.equations_of_motion (
str
, optional) – Type of equations of motion to use. Can be “standard” or “solid_propulsion”. Default is “standard”. Solid propulsion is a more restricted set of equations of motion that only works for solid propulsion rockets. Such equations were used in RocketPy v0 and are kept here for backwards compatibility.
- Return type:
None
- property effective_1rl#
Original rail length minus the distance measured from nozzle exit to the upper rail button. It assumes the nozzle to be aligned with the beginning of the rail.
- property effective_2rl#
Original rail length minus the distance measured from nozzle exit to the lower rail button. It assumes the nozzle to be aligned with the beginning of the rail.
- udot_rail1(t, u, post_processing=False)[source]#
Calculates derivative of u state vector with respect to time when rocket is flying in 1 DOF motion in the rail.
- Parameters:
t (
float
) – Time in secondsu (
list
) – State vector defined by u = [x, y, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3].post_processing (
bool
, optional) – If True, adds flight data information directly to self variables such as self.angle_of_attack. Default is False.
- Returns:
u_dot – State vector defined by u_dot = [vx, vy, vz, ax, ay, az, e0dot, e1dot, e2dot, e3dot, alpha1, alpha2, alpha3].
- Return type:
list
- udot_rail2(t, u, post_processing=False)[source]#
[Still not implemented] Calculates derivative of u state vector with respect to time when rocket is flying in 3 DOF motion in the rail.
- Parameters:
t (
float
) – Time in secondsu (
list
) – State vector defined by u = [x, y, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3].post_processing (
bool
, optional) – If True, adds flight data information directly to self variables such as self.angle_of_attack, by default False
- Returns:
u_dot – State vector defined by u_dot = [vx, vy, vz, ax, ay, az, e0dot, e1dot, e2dot, e3dot, alpha1, alpha2, alpha3].
- Return type:
list
- u_dot(t, u, post_processing=False)[source]#
Calculates derivative of u state vector with respect to time when rocket is flying in 6 DOF motion during ascent out of rail and descent without parachute.
- Parameters:
t (
float
) – Time in secondsu (
list
) – State vector defined by u = [x, y, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3].post_processing (
bool
, optional) – If True, adds flight data information directly to self variables such as self.angle_of_attack, by default False
- Returns:
u_dot – State vector defined by u_dot = [vx, vy, vz, ax, ay, az, e0dot, e1dot, e2dot, e3dot, alpha1, alpha2, alpha3].
- Return type:
list
- u_dot_generalized(t, u, post_processing=False)[source]#
Calculates derivative of u state vector with respect to time when the rocket is flying in 6 DOF motion in space and significant mass variation effects exist. Typical flight phases include powered ascent after launch rail.
- Parameters:
t (
float
) – Time in secondsu (
list
) – State vector defined by u = [x, y, z, vx, vy, vz, q0, q1, q2, q3, omega1, omega2, omega3].post_processing (
bool
, optional) – If True, adds flight data information directly to self variables such as self.angle_of_attack, by default False.
- Returns:
u_dot – State vector defined by u_dot = [vx, vy, vz, ax, ay, az, e0_dot, e1_dot, e2_dot, e3_dot, alpha1, alpha2, alpha3].
- Return type:
list
- u_dot_parachute(t, u, post_processing=False)[source]#
Calculates derivative of u state vector with respect to time when rocket is flying under parachute. A 3 DOF approximation is used.
- Parameters:
t (
float
) – Time in secondsu (
list
) – State vector defined by u = [x, y, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3].post_processing (
bool
, optional) – If True, adds flight data information directly to self variables such as self.angle_of_attack. Default is False.
- Returns:
u_dot – State vector defined by u_dot = [vx, vy, vz, ax, ay, az, e0dot, e1dot, e2dot, e3dot, alpha1, alpha2, alpha3].
- Return type:
list
- property solution_array#
Returns solution array of the rocket flight.
- property time#
Returns time array from solution.
- get_solution_at_time(t, atol=0.001)[source]#
Returns the solution state vector at a given time. If the time is not found in the solution, the closest time is used and a warning is raised.
- Parameters:
t (
float
) – Time in seconds.atol (
float
, optional) – Absolute tolerance for time comparison. Default is 1e-3. If the difference between the time and the closest time in the solution is greater than this value, a warning is raised.
- Returns:
solution – Solution state at time t. The array follows the format of the solution array, with the first column being time like this: [t, x, y, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3].
- Return type:
np.array
- x#
Rocket x position as a Function of time.
- y#
Rocket y position as a Function of time.
- z#
Rocket z position as a Function of time.
- altitude#
Rocket altitude above ground level as a Function of time.
- vx#
Rocket x velocity as a Function of time.
- vy#
Rocket y velocity as a Function of time.
- vz#
Rocket z velocity as a Function of time.
- e0#
Rocket quaternion e0 as a Function of time.
- e1#
Rocket quaternion e1 as a Function of time.
- e2#
Rocket quaternion e2 as a Function of time.
- e3#
Rocket quaternion e3 as a Function of time.
- w1#
Rocket angular velocity ω1 as a Function of time.
- w2#
Rocket angular velocity ω2 as a Function of time.
- w3#
Rocket angular velocity ω3 as a Function of time.
- ax#
Rocket x acceleration as a Function of time.
- ay#
Rocket y acceleration as a Function of time.
- az#
Rocket z acceleration as a Function of time.
- alpha1#
Rocket angular acceleration α1 as a Function of time.
- alpha2#
Rocket angular acceleration α2 as a Function of time.
- alpha3#
Rocket angular acceleration α3 as a Function of time.
- R1#
Aerodynamic force along the first axis that is perpendicular to the rocket’s axis of symmetry as a Function of time.
- R2#
Aerodynamic force along the second axis that is perpendicular to the rocket’s axis of symmetry as a Function of time.
- R3#
Aerodynamic force along the rocket’s axis of symmetry as a Function of time.
- M1#
Aerodynamic bending moment in the same direction as the axis that is perpendicular to the rocket’s axis of symmetry as a Function of time.
- M2#
Aerodynamic bending moment in the same direction as the axis that is perpendicular to the rocket’s axis of symmetry as a Function of time.
- M3#
Aerodynamic bending moment in the same direction as the rocket’s axis of symmetry as a Function of time.
- pressure#
Air pressure felt by the rocket as a Function of time.
- density#
Air density felt by the rocket as a Function of time.
- dynamic_viscosity#
Air dynamic viscosity felt by the rocket as a Function of time.
- speed_of_sound#
Speed of sound in the air felt by the rocket as a Function of time.
- wind_velocity_x#
Wind velocity in the X direction (east) as a Function of time.
- wind_velocity_y#
Wind velocity in the y direction (north) as a Function of time.
- speed#
Rocket speed, or velocity magnitude, as a Function of time.
- property max_speed_time#
Time at which the rocket reaches its maximum speed.
- property max_speed#
Maximum speed reached by the rocket.
- acceleration#
Rocket acceleration magnitude as a Function of time.
- property max_acceleration_power_on_time#
Time at which the rocket reaches its maximum acceleration during motor burn.
- property max_acceleration_power_on#
Maximum acceleration reached by the rocket during motor burn.
- property max_acceleration_power_off_time#
Time at which the rocket reaches its maximum acceleration after motor burn.
- property max_acceleration_power_off#
Maximum acceleration reached by the rocket after motor burn.
- property max_acceleration_time#
Time at which the rocket reaches its maximum acceleration.
- property max_acceleration#
Maximum acceleration reached by the rocket.
- horizontal_speed#
Rocket horizontal speed as a Function of time.
- path_angle#
Rocket path angle as a Function of time.
- attitude_vector_x#
Rocket attitude vector X component as a Function of time.
- attitude_vector_y#
Rocket attitude vector Y component as a Function of time.
- attitude_vector_z#
Rocket attitude vector Z component as a Function of time.
- attitude_angle#
Rocket attitude angle as a Function of time.
- lateral_attitude_angle#
Rocket lateral attitude angle as a Function of time.
- psi#
Precession angle as a Function of time.
- phi#
Spin angle as a Function of time.
- theta#
Nutation angle as a Function of time.
- stream_velocity_x#
Freestream velocity X component as a Function of time.
- stream_velocity_y#
Freestream velocity Y component as a Function of time.
- stream_velocity_z#
Freestream velocity Z component as a Function of time.
- free_stream_speed#
Freestream speed as a Function of time.
- property apogee_freestream_speed#
Freestream speed at apogee in m/s.
- mach_number#
Mach number as a Function of time.
- property max_mach_number_time#
Time of maximum Mach number.
- property max_mach_number#
Maximum Mach number.
- property max_stability_margin_time#
Time of maximum stability margin.
- property max_stability_margin#
Maximum stability margin.
- property min_stability_margin_time#
Time of minimum stability margin.
- property min_stability_margin#
Minimum stability margin.
- reynolds_number#
Reynolds number as a Function of time.
- property max_reynolds_number_time#
Time of maximum Reynolds number.
- property max_reynolds_number#
Maximum Reynolds number.
- dynamic_pressure#
Dynamic pressure as a Function of time.
- property max_dynamic_pressure_time#
Time of maximum dynamic pressure.
- property max_dynamic_pressure#
Maximum dynamic pressure.
- property max_total_pressure_time#
Time of maximum total pressure.
- property max_total_pressure#
Maximum total pressure.
- aerodynamic_lift#
Aerodynamic lift force as a Function of time.
- aerodynamic_drag#
Aerodynamic drag force as a Function of time.
- aerodynamic_bending_moment#
Aerodynamic bending moment as a Function of time.
- aerodynamic_spin_moment#
Aerodynamic spin moment as a Function of time.
- translational_energy#
Translational kinetic energy as a Function of time.
- kinetic_energy#
Total kinetic energy as a Function of time.
- potential_energy#
Potential energy as a Function of time in relation to sea level.
- total_energy#
Total mechanical energy as a Function of time.
- thrust_power#
thrust power as a Function of time.
- drag_power#
Drag power as a Function of time.
- angle_of_attack#
Angle of attack of the rocket with respect to the freestream velocity vector.
- omega1_frequency_response#
Angular velocity 1 frequency response as a Function of frequency, as the rocket leaves the launch rail for 5 seconds of flight.
- omega2_frequency_response#
Angular velocity 2 frequency response as a Function of frequency, as the rocket leaves the launch rail for 5 seconds of flight.
- omega3_frequency_response#
Angular velocity 3 frequency response as a Function of frequency, as the rocket leaves the launch rail for 5 seconds of flight.
- attitude_frequency_response#
Attitude frequency response as a Function of frequency, as the rocket leaves the launch rail for 5 seconds of flight.
- property static_margin#
Static margin of the rocket.
- stability_margin#
Stability margin of the rocket along the flight, it considers the variation of the center of pressure position according to the mach number, as well as the variation of the center of gravity position according to the propellant mass evolution.
- Parameters:
None –
- Returns:
stability – Stability margin as a rocketpy.Function of time. The stability margin is defined as the distance between the center of pressure and the center of gravity, divided by the rocket diameter.
- Return type:
- rail_button1_normal_force#
Upper rail button normal force as a Function of time. If there’s no rail button defined, the function returns a null Function.
- rail_button1_shear_force#
Upper rail button shear force as a Function of time. If there’s no rail button defined, the function returns a null Function.
- rail_button2_normal_force#
Lower rail button normal force as a Function of time. If there’s no rail button defined, the function returns a null Function.
- rail_button2_shear_force#
Lower rail button shear force as a Function of time. If there’s no rail button defined, the function returns a null Function.
- property max_rail_button1_normal_force#
Maximum upper rail button normal force, in Newtons.
- property max_rail_button1_shear_force#
Maximum upper rail button shear force, in Newtons.
- property max_rail_button2_normal_force#
Maximum lower rail button normal force, in Newtons.
- property max_rail_button2_shear_force#
Maximum lower rail button shear force, in Newtons.
- drift#
Rocket horizontal distance to tha launch point, in meters, as a Function of time.
- bearing#
Rocket bearing compass, in degrees, as a Function of time.
- latitude#
Rocket latitude coordinate, in degrees, as a Function of time.
- longitude#
Rocket longitude coordinate, in degrees, as a Function of time.
- property retrieve_acceleration_arrays#
Retrieve acceleration arrays from the integration scheme
- Returns:
ax (
list
) – acceleration in x directionay (
list
) – acceleration in y directionaz (
list
) – acceleration in z directionalpha1 (
list
) – angular acceleration in x directionalpha2 (
list
) – angular acceleration in y directionalpha3 (
list
) – angular acceleration in z direction
- property retrieve_temporary_values_arrays#
Retrieve temporary values arrays from the integration scheme. Currently, the following temporary values are retrieved:
R1
,R2
R3
,M1
,M2
,M3
,pressure
,density
,dynamic_viscosity
,speed_of_sound
.- Returns:
self.R1_list (
list
) – R1 values.self.R2_list (
list
) – R2 values.self.R3_list (
list
) – R3 values are the aerodynamic force values in the rocket’s axis direction.self.M1_list (
list
) – M1 values.self.M2_list (
list
) – Aerodynamic bending moment in e2 direction at each time step.self.M3_list (
list
) – Aerodynamic bending moment in e3 direction at each time step.self.pressure_list (
list
) – Air pressure at each time step.self.density_list (
list
) – Air density at each time step.self.dynamic_viscosity_list (
list
) – Dynamic viscosity at each time step.self.speed_of_sound_list (
list
) – Speed of sound at each time step.self.wind_velocity_x_list (
list
) – Wind velocity in x direction at each time step.self.wind_velocity_y_list (
list
) – Wind velocity in y direction at each time step.
- get_controller_observed_variables()[source]#
Retrieve the observed variables related to air brakes from the controllers. If there is only one set of observed variables, it is returned as a list. If there are multiple sets, the list containing all sets is returned.
- _calculate_pressure_signal()[source]#
Calculate the pressure signal from the pressure sensor. It creates a signal_function attribute in the parachute object. Parachute works as a subclass of Rocket class.
- Return type:
None
- post_process(interpolation='spline', extrapolation='natural')[source]#
This method is deprecated and is only kept here for backwards compatibility. All attributes that need to be post processed are computed just in time.
Post-process all Flight information produced during simulation. Includes the calculation of maximum values, calculation of secondary values such as energy and conversion of lists to Function objects to facilitate plotting.
- Return type:
None
- calculate_stall_wind_velocity(stall_angle)[source]#
Function to calculate the maximum wind velocity before the angle of attack exceeds a desired angle, at the instant of departing rail launch. Can be helpful if you know the exact stall angle of all aerodynamics surfaces.
- Parameters:
stall_angle (
float
) – Angle, in degrees, for which you would like to know the maximum wind speed before the angle of attack exceeds it- Return type:
None
- export_pressures(file_name, time_step)[source]#
Exports the pressure experienced by the rocket during the flight to an external file, the ‘.csv’ format is recommended, as the columns will be separated by commas. It can handle flights with or without parachutes, although it is not possible to get a noisy pressure signal if no parachute is added.
If a parachute is added, the file will contain 3 columns: time in seconds, clean pressure in Pascals and noisy pressure in Pascals. For flights without parachutes, the third column will be discarded
This function was created especially for the ‘Projeto Jupiter’ Electronics Subsystems team and aims to help in configuring micro-controllers.
- Parameters:
file_name (
string
) – The final file name,time_step (
float
) – Time step desired for the final file
- Return type:
None
- export_data(file_name, *variables, time_step=None)[source]#
Exports flight data to a comma separated value file (.csv).
Data is exported in columns, with the first column representing time steps. The first line of the file is a header line, specifying the meaning of each column and its units.
- Parameters:
file_name (
string
) – The file name or path of the exported file. Example: flight_data.csv Do not use forbidden characters, such as / in Linux/Unix and <, >, :, “, /, , | ?, * in Windows.variables (
strings
, optional) – Names of the data variables which shall be exported. Must be Flight class attributes which are instances of the Function class. Usage example: test_flight.export_data(‘test.csv’, ‘z’, ‘angle_of_attack’, ‘mach_number’).time_step (
float
, optional) – Time step desired for the data. If None, all integration time steps will be exported. Otherwise, linear interpolation is carried out to calculate values at the desired time steps. Example: 0.001.
- export_kml(file_name='trajectory.kml', time_step=None, extrude=True, color='641400F0', altitude_mode='absolute')[source]#
Exports flight data to a .kml file, which can be opened with Google Earth to display the rocket’s trajectory.
- Parameters:
file_name (
string
) – The file name or path of the exported file. Example: flight_data.csv Do not use forbidden characters, such as ‘/’ in Linux/Unix and ‘<, >, :, “, /, , | ?, *’ in Windows.time_step (
float
, optional) – Time step desired for the data. If None, all integration time steps will be exported. Otherwise, linear interpolation is carried out to calculate values at the desired time steps. Example: 0.001.extrude (
bool
, optional) – To be used if you want to project the path over ground by using an extruded polygon. In case False only the linestring containing the flight path will be created. Default is True.color (
str
, optional) – Color of your trajectory path, need to be used in specific kml format. Refer to http://www.zonums.com/gmaps/kml_color/ for more info.altitude_mode (
str
) – Select elevation values format to be used on the kml file. Use ‘relativetoground’ if you want use Above Ground Level elevation, or ‘absolute’ if you want to parse elevation using Above Sea Level. Default is ‘relativetoground’. Only works properly if the ground level is flat. Change to ‘absolute’ if the terrain is to irregular or contains mountains.
- Return type:
None
- class FlightPhases[source]#
Class to handle flight phases. It is used to store the derivatives and callbacks for each flight phase. It is also used to handle the insertion of flight phases in the correct order, according to their initial time.
- Variables:
list (
list
) – A list of FlightPhase objects. See FlightPhase subclass.
- add(flight_phase, index=None)[source]#
Add a flight phase to the list. It will be inserted in the correct position, according to its initial time. If no index is provided, it will be appended to the end of the list. If by any reason the flight phase cannot be inserted in the correct position, a warning will be displayed and the flight phase will be inserted in the closest position possible.
- Parameters:
flight_phase (
FlightPhase
) – The flight phase object to be added. See FlightPhase class.index (
int
, optional) – The index of the flight phase to be added. If no index is provided, the flight phase will be appended to the end of the list. Default is None.
- Return type:
None
- add_phase(t, derivatives=None, callback=None, clear=True, index=None)[source]#
Add a new flight phase to the list, with the specified characteristics. This method creates a new FlightPhase instance and adds it to the flight phases list, either at the specified index position or appended to the end. See FlightPhases.add() for more information.
- Parameters:
t (
float
) – The initial time of the new flight phase.derivatives (
function
, optional) – A function representing the derivatives of the flight phase. Default is None.callback (
list
offunctions
, optional) – A list of callback functions to be executed during the flight phase. Default is None. You can also pass an empty list.clear (
bool
, optional) – A flag indicating whether to clear the solution after the phase. Default is True.index (
int
, optional) – The index at which the new flight phase should be inserted. If not provided, the flight phase will be appended to the end of the list. Default is None.
- Return type:
None
- flush_after(index)[source]#
This function deletes all flight phases after a given index.
- Parameters:
index (
int
) – The index of the last flight phase to be kept.- Return type:
None
- class FlightPhase[source]#
Class to store a flight phase. It stores the initial time, the derivative function, the callback functions and a flag to clear the solution after the phase.
- Variables:
t (
float
) – The initial time of the flight phase.derivative (
function
) – A function representing the derivatives of the flight phase.callbacks (
list
offunctions
) – A list of callback functions to be executed during the flight phase.clear (
bool
) – A flag indicating whether to clear the solution after the phase.