Utilities functions#
At RocketPy projects, utilities are functions that:
Depends on rocketpy classes, i.e. imports rocketpy classes
Are not directly related to rocketpy classes,
Performs a specific task, and
Are not a part of a class.
Below you have a list of all utilities functions available in rocketpy.
- rocketpy.utilities.compute_cd_s_from_drop_test(terminal_velocity, rocket_mass, air_density=1.225, g=9.80665)[source]#
Returns the parachute’s cd_s calculated through its final speed, air density in the landing point, the rocket’s mass and the force of gravity in the landing point.
- Parameters:
terminal_velocity (
float
) – Rocket’s speed in m/s when landing.rocket_mass (
float
) – Rocket’s dry mass in kg.air_density (
float
, optional) – Air density, in kg/m^3, right before the rocket lands. Default value is 1.225.g (
float
, optional) – Gravitational acceleration experienced by the rocket and parachute during descent in m/s^2. Default value is the standard gravity, 9.80665.
- Returns:
cd_s – Number equal to drag coefficient times reference area for parachute.
- Return type:
float
- rocketpy.utilities.calculate_equilibrium_altitude(rocket_mass, cd_s, z0, v0=0, env=None, eps=0.001, max_step=0.1, see_graphs=True, g=9.80665, estimated_final_time=10)[source]#
Returns a dictionary containing the time, altitude and velocity of the system rocket-parachute in which the terminal velocity is reached.
- Parameters:
rocket_mass (
float
) – Rocket’s mass in kg.cd_s (
float
) – Number equal to drag coefficient times reference area for parachute.z0 (
float
) – Initial altitude of the rocket in meters.v0 (
float
, optional) – Rocket’s initial speed in m/s. Must be negativeenv (
Environment
, optional) – Environmental conditions at the time of the launch.eps (
float
, optional) – acceptable error in meters.max_step (
float
, optional) – maximum allowed time step size to solve the integrationsee_graphs (
boolean
, optional) – True if you want to see time vs altitude and time vs speed graphs, False otherwise.g (
float
, optional) – Gravitational acceleration experienced by the rocket and parachute during descent in m/s^2. Default value is the standard gravity, 9.80665.estimated_final_time (
float
, optional) – Estimative of how much time (in seconds) will spend until vertical terminal velocity is reached. Must be positive. Default is 10. It can affect the final result if the value is not high enough. Increase the estimative in case the final solution is not founded.
- Returns:
altitude_function (
Function
) – Altitude as a function of time. Always a Function object.velocity_function
– Vertical velocity as a function of time. Always a Function object.final_sol (
dictionary
) – Dictionary containing the values for time, altitude and speed of the rocket when it reaches terminal velocity.
- rocketpy.utilities.fin_flutter_analysis(fin_thickness, shear_modulus, flight, see_prints=True, see_graphs=True)[source]#
Calculate and plot the Fin Flutter velocity using the pressure profile provided by the selected atmospheric model. It considers the Flutter Boundary Equation that published in NACA Technical Paper 4197. These results are only estimates of a real problem and may not be useful for fins made from non-isotropic materials. Currently, this function works if only a single set of fins is added, otherwise it will use the last set of fins added to the rocket.
- Parameters:
fin_thickness (
float
) – The fin thickness, in metersshear_modulus (
float
) – Shear Modulus of fins’ material, must be given in Pascalflight (
Flight
) – Flight object containing the rocket’s flight datasee_prints (
boolean
, optional) – True if you want to see the prints, False otherwise.see_graphs (
boolean
, optional) – True if you want to see the graphs, False otherwise. If False, the function will return the vectors containing the data for the graphs.
- Return type:
None
- rocketpy.utilities._flutter_safety_factor(flight, flutter_mach)[source]#
Calculates the safety factor for the fin flutter analysis.
- Parameters:
flight (
rocketpy.Flight
) – Flight object containing the rocket’s flight dataflutter_mach (
rocketpy.Function
) – Mach Number at which the fin flutter occurs. See the fin_flutter_analysis function for more details.
- Returns:
The safety factor for the fin flutter analysis.
- Return type:
- rocketpy.utilities._flutter_plots(flight, flutter_mach, safety_factor)[source]#
Plot the Fin Flutter Mach Number and the Safety Factor for the flutter.
- Parameters:
flight (
rocketpy.Flight
) – Flight object containing the rocket’s flight dataflutter_mach (
rocketpy.Function
) – Function containing the Fin Flutter Mach Number, see fin_flutter_analysis for more details.safety_factor (
rocketpy.Function
) – Function containing the Safety Factor for the fin flutter. See fin_flutter_analysis for more details.
- Return type:
None
- rocketpy.utilities._flutter_prints(fin_thickness, shear_modulus, s, ar, la, flutter_mach, safety_factor, flight)[source]#
Prints out the fin flutter analysis results. See fin_flutter_analysis for more details.
- Parameters:
fin_thickness (
float
) – The fin thickness, in metersshear_modulus (
float
) – Shear Modulus of fins’ material, must be given in Pascals (
float
) – Fin surface area, in squared metersar (
float
) – Fin aspect ratiola (
float
) – Fin lambda, defined as the tip_chord / root_chord ratioflutter_mach (
rocketpy.Function
) – The Mach Number at which the fin flutter occurs, considering the variation of the speed of sound with altitude. See fin_flutter_analysis for more details.safety_factor (
rocketpy.Function
) – The Safety Factor for the fin flutter. Defined as the Fin Flutter Mach Number divided by the Freestream Mach Number.flight (
rocketpy.Flight
) – Flight object containing the rocket’s flight data
- Return type:
None
- rocketpy.utilities.create_dispersion_dictionary(filename)[source]#
Creates a dictionary with the rocket data provided by a .csv file. File should be organized in four columns: attribute_class, parameter_name, mean_value, standard_deviation. The first row should be the header. It is advised to use “;” as separator, but “,” should work on most of cases. The “,” separator might cause problems if the data set contains lists where the items are separated by commas.
- Parameters:
filename (
string
) –String with the path to the .csv file. The file should follow the following structure:
attribute_class; parameter_name; mean_value; standard_deviation; environment; ensemble_member; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];; motor; impulse; 1415.15; 35.3; motor; burn_time; 5.274; 1; motor; nozzle_radius; 0.021642; 0.0005; motor; throat_radius; 0.008; 0.0005; motor; grain_separation; 0.006; 0.001; motor; grain_density; 1707; 50;
- Returns:
Dictionary with all rocket data to be used in dispersion analysis. The dictionary will follow the following structure:
analysis_parameters = { 'environment': { 'ensemble_member': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] }, 'motor': { 'impulse': (1415.15, 35.3), 'burn_time': (5.274, 1), 'nozzle_radius': (0.021642, 0.0005), 'throat_radius': (0.008, 0.0005), 'grain_separation': (0.006, 0.001), 'grain_density': (1707, 50), } }
- Return type:
dictionary
- rocketpy.utilities.apogee_by_mass(flight, min_mass, max_mass, points=10, plot=True)[source]#
Returns a Function object that estimates the apogee of a rocket given its mass (no motor). The function will use the rocket’s mass as the independent variable and the estimated apogee as the dependent variable. The function will use the rocket’s environment and inclination to estimate the apogee. This is useful when you want to adjust the rocket’s mass to reach a specific apogee.
- Parameters:
flight (
rocketpy.Flight
) – Flight object containing the rocket’s flight datamin_mass (
float
) – The minimum value for the rocket’s mass to calculate the apogee, given in kilograms (kg). This value should be the minimum rocket’s mass, therefore, a positive value is expected. See the Rocket.mass attribute for more details.max_mass (
float
) – The maximum value for the rocket’s mass to calculate the apogee, given in kilograms (kg). This value should be the maximum rocket’s mass, therefore, a positive value is expected and it should be higher than the min_mass attribute. See the Rocket.mass attribute for more details.points (
int
, optional) – The number of points to calculate the apogee between the mass boundaries, by default 10. Increasing this value will refine the results, but will also increase the computational time.plot (
bool
, optional) – If True, the function will plot the results, by default True.
- Returns:
Function object containing the estimated apogee as a function of the rocket’s mass (without motor nor propellant).
- Return type:
- rocketpy.utilities.liftoff_speed_by_mass(flight, min_mass, max_mass, points=10, plot=True)[source]#
Returns a Function object that estimates the liftoff speed of a rocket given its mass (without motor). The function will use the rocket’s mass as the independent variable and the estimated liftoff speed as the dependent variable. The function will use the rocket’s environment and inclination to estimate the liftoff speed. This is useful when you want to adjust the rocket’s mass to reach a specific liftoff speed.
- Parameters:
flight (
rocketpy.Flight
) – Flight object containing the rocket’s flight datamin_mass (
float
) – The minimum value for the rocket’s mass to calculate the out of rail speed, given in kilograms (kg). This value should be the minimum rocket’s mass, therefore, a positive value is expected. See the Rocket.mass attribute for more details.max_mass (
float
) – The maximum value for the rocket’s mass to calculate the out of rail speed, given in kilograms (kg). This value should be the maximum rocket’s mass, therefore, a positive value is expected and it should be higher than the min_mass attribute. See the Rocket.mass attribute for more details.points (
int
, optional) – The number of points to calculate the liftoff speed between the mass boundaries, by default 10. Increasing this value will refine the results, but will also increase the computational time.plot (
bool
, optional) – If True, the function will plot the results, by default True.
- Returns:
Function object containing the estimated liftoff speed as a function of the rocket’s mass (without motor nor propellant).
- Return type: