Utilities functions#

At RocketPy projects, utilities are functions that:

1 - Depends on rocketpy classes, i.e. imports rocketpy classes 2 - Are not directly related to rocketpy classes, 3 - Performs a specific task, and 4 - 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 negative

  • env (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 integration

  • see_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 meters

  • shear_modulus (float) – Shear Modulus of fins’ material, must be given in Pascal

  • flight (rocketpy.Flight) – Flight object containing the rocket’s flight data

  • see_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.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 dry mass. 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 data

  • min_mass (int) – The minimum value of mass to calculate the apogee, by default 3. This value should be the minimum dry mass of the rocket, therefore, a positive value is expected.

  • max_mass (int) – The maximum value of mass to calculate the apogee, by default 30.

  • 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 dry mass.

Return type:

rocketpy.Function

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 dry mass. 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 data

  • min_mass (int) – The minimum value of mass to calculate the liftoff speed, by default 3. This value should be the minimum dry mass of the rocket, therefore, a positive value is expected.

  • max_mass (int) – The maximum value of mass to calculate the liftoff speed, by default 30.

  • 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 dry mass.

Return type:

rocketpy.Function