Rocket Class#

class rocketpy.Rocket.Rocket(radius, mass, inertia, power_off_drag, power_on_drag, center_of_mass_without_motor, coordinate_system_orientation='tail_to_nose')[source]#

Keeps rocket information.

Geometrical attributes
radius#

Rocket’s largest radius in meters.

Type:

float

area#

Rocket’s circular cross section largest frontal area in squared meters.

Type:

float

center_of_dry_mass_position#

Position, in m, of the rocket’s center of dry mass (i.e. center of mass without propellant) relative to the rocket’s coordinate system. See Rocket.coordinate_system_orientation for more information regarding the rocket’s coordinate system.

Type:

float

coordinate_system_orientation#

String defining the orientation of the rocket’s coordinate system. The coordinate system is defined by the rocket’s axis of symmetry. The system’s origin may be placed anywhere along such axis, such as in the nozzle or in the nose cone, and must be kept the same for all other positions specified. If “tail_to_nose”, the coordinate system is defined with the rocket’s axis of symmetry pointing from the rocket’s tail to the rocket’s nose cone. If “nose_to_tail”, the coordinate system is defined with the rocket’s axis of symmetry pointing from the rocket’s nose cone to the rocket’s tail.

Type:

string

Mass and Inertia attributes
mass#

Rocket’s mass without propellant in kg.

Type:

float

center_of_mass#

Position of the rocket’s center of mass, including propellant, relative to the user defined rocket reference system. See Rocket.coordinate_system_orientation for more information regarding the coordinate system. Expressed in meters as a function of time.

Type:

Function

reduced_mass#

Function of time expressing the reduced mass of the rocket, defined as the product of the propellant mass and the mass of the rocket without propellant, divided by the sum of the propellant mass and the rocket mass.

Type:

Function

total_mass#

Function of time expressing the total mass of the rocket, defined as the sum of the propellant mass and the rocket mass without propellant.

Type:

Function

thrust_to_weight#

Function of time expressing the motor thrust force divided by rocket weight. The gravitational acceleration is assumed as 9.80665 m/s^2.

Type:

Function

Eccentricity attributes
cp_eccentricity_x#

Center of pressure position relative to center of mass in the x axis, perpendicular to axis of cylindrical symmetry, in meters.

Type:

float

cp_eccentricity_y#

Center of pressure position relative to center of mass in the y axis, perpendicular to axis of cylindrical symmetry, in meters.

Type:

float

thrust_eccentricity_y#

Thrust vector position relative to center of mass in the y axis, perpendicular to axis of cylindrical symmetry, in meters.

Type:

float

thrust_eccentricity_x#

Thrust vector position relative to center of mass in the x axis, perpendicular to axis of cylindrical symmetry, in meters.

Type:

float

Aerodynamic attributes
aerodynamic_surfaces#

Collection of aerodynamic surfaces of the rocket. Holds Nose cones, Fin sets, and Tails.

Type:

list

cp_position#

Rocket’s center of pressure position relative to the user defined rocket reference system. See Rocket.coordinate_system_orientation for more information regarding the reference system. Expressed in meters.

Type:

float

static_margin#

Float value corresponding to rocket static margin when loaded with propellant in units of rocket diameter or calibers.

Type:

float

power_off_drag#

Rocket’s drag coefficient as a function of Mach number when the motor is off.

Type:

Function

power_on_drag#

Rocket’s drag coefficient as a function of Mach number when the motor is on.

Type:

Function

rail_buttons#

RailButtons object containing the rail buttons information.

Type:

RailButtons

Motor attributes
motor#

Rocket’s motor. See Motor class for more details.

Type:

Motor

motor_position#

Position, in m, of the motor’s nozzle exit area relative to the user defined rocket coordinate system. See Rocket.coordinate_system_orientation for more information regarding the rocket’s coordinate system.

Type:

float

center_of_propellant_position#

Position of the propellant’s center of mass relative to the user defined rocket reference system. See Rocket.coordinate_system_orientation for more information regarding the rocket’s coordinate system. Expressed in meters as a function of time.

Type:

Function

Initializes Rocket class, process inertial, geometrical and aerodynamic parameters.

Parameters:
  • radius (int, float) – Rocket largest outer radius in meters.

  • mass (int, float) – Rocket total mass without motor in kg.

  • inertia (tuple, list) – Tuple or list containing the rocket’s dry mass inertia tensor components, in kg*m^2. Assuming e_3 is the rocket’s axis of symmetry, e_1 and e_2 are orthogonal and form a plane perpendicular to e_3, the dry mass inertia tensor components must be given in the following order: (I_11, I_22, I_33, I_12, I_13, I_23), where I_ij is the component of the inertia tensor in the direction of e_i x e_j. Alternatively, the inertia tensor can be given as (I_11, I_22, I_33), where I_12 = I_13 = I_23 = 0.

  • power_off_drag (int, float, callable, string, array) – Rocket’s drag coefficient when the motor is off. Can be given as an entry to the Function class. See help(Function) for more information. If int or float is given, it is assumed constant. If callable, string or array is given, it must be a function of Mach number only.

  • power_on_drag (int, float, callable, string, array) – Rocket’s drag coefficient when the motor is on. Can be given as an entry to the Function class. See help(Function) for more information. If int or float is given, it is assumed constant. If callable, string or array is given, it must be a function of Mach number only.

  • center_of_mass_without_motor (int, float) – Position, in m, of the rocket’s center of mass without motor relative to the rocket’s coordinate system. Default is 0, which means the center of dry mass is chosen as the origin, to comply with the legacy behavior of versions 0.X.Y. See Rocket.coordinate_system_orientation for more information regarding the rocket’s coordinate system.

  • coordinate_system_orientation (string, optional) – String defining the orientation of the rocket’s coordinate system. The coordinate system is defined by the rocket’s axis of symmetry. The system’s origin may be placed anywhere along such axis, such as in the nozzle or in the nose cone, and must be kept the same for all other positions specified. The two options available are: “tail_to_nose” and “nose_to_tail”. The first defines the coordinate system with the rocket’s axis of symmetry pointing from the rocket’s tail to the rocket’s nose cone. The second option defines the coordinate system with the rocket’s axis of symmetry pointing from the rocket’s nose cone to the rocket’s tail. Default is “tail_to_nose”.

Return type:

None

evaluate_total_mass()[source]#

Calculates and returns the rocket’s total mass. The total mass is defined as the sum of the motor mass with propellant and the rocket mass without propellant. The function returns an object of the Function class and is defined as a function of time.

Parameters:

None

Returns:

self.total_mass – Function of time expressing the total mass of the rocket, defined as the sum of the propellant mass and the rocket mass without propellant.

Return type:

rocketpy.Function

evaluate_dry_mass()[source]#

Calculates and returns the rocket’s dry mass. The dry mass is defined as the sum of the motor’s dry mass and the rocket mass without motor. The function returns an object of the Function class and is defined as a function of time.

Parameters:

None

Returns:

self.total_mass – Function of time expressing the total mass of the rocket, defined as the sum of the propellant mass and the rocket mass without propellant.

Return type:

rocketpy.Function

evaluate_center_of_mass()[source]#

Evaluates rocket center of mass position relative to user defined rocket reference system.

Parameters:

None

Returns:

self.center_of_mass – Function of time expressing the rocket’s center of mass position relative to user defined rocket reference system. See Rocket.coordinate_system_orientation for more information.

Return type:

rocketpy.Function

evaluate_center_of_dry_mass()[source]#

Evaluates rocket center dry of mass (i.e. without propellant) position relative to user defined rocket reference system.

Parameters:

None

Returns:

self.center_of_dry_mass – Rocket’s center of dry mass position relative to user defined rocket reference system. See Rocket.coordinate_system_orientation for more information.

Return type:

int, float

evaluate_reduced_mass()[source]#

Calculates and returns the rocket’s total reduced mass. The reduced mass is defined as the product of the propellant mass and the mass of the rocket without propellant, divided by the sum of the propellant mass and the rocket mass. The function returns an object of the Function class and is defined as a function of time.

Parameters:

None

Returns:

self.reduced_mass – Function of time expressing the reduced mass of the rocket, defined as the product of the propellant mass and the mass of the rocket without propellant, divided by the sum of the propellant mass and the rocket mass.

Return type:

Function

evaluate_thrust_to_weight()[source]#

Evaluates thrust to weight as a Function of time.

Uses g = 9.80665 m/s² as nominal gravity for weight calculation.

Return type:

None

evaluate_static_margin()[source]#

Calculates and returns the rocket’s static margin when loaded with propellant. The static margin is saved and returned in units of rocket diameter or calibers. This function also calculates the rocket center of pressure and total lift coefficients.

Parameters:

None

Returns:

self.static_margin – Float value corresponding to rocket static margin when loaded with propellant in units of rocket diameter or calibers.

Return type:

float

evaluate_dry_inertias()[source]#

Calculates and returns the rocket’s dry inertias relative to the rocket’s center of mass. The inertias are saved and returned in units of kg*m².

Parameters:

None

Returns:

  • self.dry_I_11 (float) – Float value corresponding to rocket inertia tensor 11 component, which corresponds to the inertia relative to the e_1 axis, centered at the instantaneous center of mass.

  • self.dry_I_22 (float) – Float value corresponding to rocket inertia tensor 22 component, which corresponds to the inertia relative to the e_2 axis, centered at the instantaneous center of mass.

  • self.dry_I_33 (float) – Float value corresponding to rocket inertia tensor 33 component, which corresponds to the inertia relative to the e_3 axis, centered at the instantaneous center of mass.

  • self.dry_I_12 (float) – Float value corresponding to rocket inertia tensor 12 component, which corresponds to the inertia relative to the e_1 and e_2 axes, centered at the instantaneous center of mass.

  • self.dry_I_13 (float) – Float value corresponding to rocket inertia tensor 13 component, which corresponds to the inertia relative to the e_1 and e_3 axes, centered at the instantaneous center of mass.

  • self.dry_I_23 (float) – Float value corresponding to rocket inertia tensor 23 component, which corresponds to the inertia relative to the e_2 and e_3 axes, centered at the instantaneous center of mass.

Notes

The e_1 and e_2 directions are assumed to be the directions perpendicular to the rocket axial direction. The e_3 direction is assumed to be the direction parallel to the axis of symmetry of the rocket. RocketPy follows the definition of the inertia tensor as in [1], which includes the minus sign for all products of inertia.

References

evaluate_inertias()[source]#

Calculates and returns the rocket’s inertias relative to the rocket’s center of mass. The inertias are saved and returned in units of kg*m².

Parameters:

None

Returns:

  • self.I_11 (float) – Float value corresponding to rocket inertia tensor 11 component, which corresponds to the inertia relative to the e_1 axis, centered at the instantaneous center of mass.

  • self.I_22 (float) – Float value corresponding to rocket inertia tensor 22 component, which corresponds to the inertia relative to the e_2 axis, centered at the instantaneous center of mass.

  • self.I_33 (float) – Float value corresponding to rocket inertia tensor 33 component, which corresponds to the inertia relative to the e_3 axis, centered at the instantaneous center of mass.

Notes

The e_1 and e_2 directions are assumed to be the directions perpendicular to the rocket axial direction. The e_3 direction is assumed to be the direction parallel to the axis of symmetry of the rocket. RocketPy follows the definition of the inertia tensor as in [1], which includes the minus sign for all products of inertia.

References

add_motor(motor, position)[source]#

Adds a motor to the rocket.

Parameters:
  • motor (Motor, SolidMotor, HybridMotor, EmptyMotor) – Motor to be added to the rocket. See Motor class for more information.

  • position (int, float) – Position, in m, of the motor’s nozzle exit area relative to the user defined rocket coordinate system. See Rocket.coordinate_system_orientation for more information regarding the rocket’s coordinate system.

Return type:

None

add_surfaces(surfaces, positions)[source]#

Adds one or more aerodynamic surfaces to the rocket. The aerodynamic surface must be an instance of a class that inherits from the AeroSurface (e.g. NoseCone, TrapezoidalFins, etc.)

Parameters:
  • surfaces (list, AeroSurface, NoseCone, TrapezoidalFins, EllipticalFins, Tail) – Aerodynamic surface to be added to the rocket. Can be a list of AeroSurface if more than one surface is to be added. See AeroSurface class for more information.

  • positions (int, float, list) – Position, in m, of the aerodynamic surface’s center of pressure relative to the user defined rocket coordinate system. See Rocket.coordinate_system_orientation for more information regarding the rocket’s coordinate system. If a list is passed, it will correspond to the position of each item in the surfaces list. For NoseCone type, position is relative to the nose cone tip. For Fins type, position is relative to the point belonging to the root chord which is highest in the rocket coordinate system. For Tail type, position is relative to the point belonging to the tail which is highest in the rocket coordinate system.

Return type:

None

add_tail(top_radius, bottom_radius, length, position, radius=None, name='Tail')[source]#

Create a new tail or rocket diameter change, storing its parameters as part of the aerodynamic_surfaces list. Its parameters are the axial position along the rocket and its derivative of the coefficient of lift in respect to angle of attack.

Parameters:
  • top_radius (int, float) – Tail top radius in meters, considering positive direction from center of mass to nose cone.

  • bottom_radius (int, float) – Tail bottom radius in meters, considering positive direction from center of mass to nose cone.

  • length (int, float) – Tail length or height in meters. Must be a positive value.

  • position (int, float) – Tail position relative to the rocket’s coordinate system. By tail position, understand the point belonging to the tail which is highest in the rocket coordinate system (i.e. generally the point closest to the nose cone). See Rocket.coordinate_system_orientation for more information.

Returns:

tail – Tail object created.

Return type:

Tail

add_nose(length, kind, position, name='Nosecone')[source]#

Creates a nose cone, storing its parameters as part of the aerodynamic_surfaces list. Its parameters are the axial position along the rocket and its derivative of the coefficient of lift in respect to angle of attack.

Parameters:
  • length (int, float) – Nose cone length or height in meters. Must be a positive value.

  • kind (string) – Nose cone type. Von Karman, conical, ogive, and lvhaack are supported.

  • position (int, float) – Nose cone tip coordinate relative to the rocket’s coordinate system. See Rocket.coordinate_system_orientation for more information.

  • name (string) – Nose cone name. Default is “Nose Cone”.

Returns:

nose – Nose cone object created.

Return type:

Nose

add_fins(*args, **kwargs)[source]#

See Rocket.add_trapezoidal_fins for documentation. This method is set to be deprecated in version 1.0.0 and fully removed by version 2.0.0. Use Rocket.add_trapezoidal_fins instead. It keeps the same arguments and signature.

add_trapezoidal_fins(n, root_chord, tip_chord, span, position, cant_angle=0, sweep_length=None, sweep_angle=None, radius=None, airfoil=None, name='Fins')[source]#

Create a trapezoidal fin set, storing its parameters as part of the aerodynamic_surfaces list. Its parameters are the axial position along the rocket and its derivative of the coefficient of lift in respect to angle of attack.

Parameters:
  • n (int) – Number of fins, from 2 to infinity.

  • span (int, float) – Fin span in meters.

  • root_chord (int, float) – Fin root chord in meters.

  • tip_chord (int, float) – Fin tip chord in meters.

  • position (int, float) – Fin set position relative to the rocket’s coordinate system. By fin set position, understand the point belonging to the root chord which is highest in the rocket coordinate system (i.e. generally the point closest to the nose cone tip). See Rocket.coordinate_system_orientation for more information.

  • cant_angle (int, float, optional) – Fins cant angle with respect to the rocket centerline. Must be given in degrees.

  • sweep_length (int, float, optional) – Fins sweep length in meters. By sweep length, understand the axial distance between the fin root leading edge and the fin tip leading edge measured parallel to the rocket centerline. If not given, the sweep length is assumed to be equal the root chord minus the tip chord, in which case the fin is a right trapezoid with its base perpendicular to the rocket’s axis. Cannot be used in conjunction with sweep_angle.

  • sweep_angle (int, float, optional) – Fins sweep angle with respect to the rocket centerline. Must be given in degrees. If not given, the sweep angle is automatically calculated, in which case the fin is assumed to be a right trapezoid with its base perpendicular to the rocket’s axis. Cannot be used in conjunction with sweep_length.

  • radius (int, float, optional) – Reference radius to calculate lift coefficient. If None, which is default, use rocket radius.

  • airfoil (tuple, optional) – Default is null, in which case fins will be treated as flat plates. Otherwise, if tuple, fins will be considered as airfoils. The tuple’s first item specifies the airfoil’s lift coefficient by angle of attack and must be either a .csv, .txt, ndarray or callable. The .csv and .txt files must contain no headers and the first column must specify the angle of attack, while the second column must specify the lift coefficient. The ndarray should be as [(x0, y0), (x1, y1), (x2, y2), …] where x0 is the angle of attack and y0 is the lift coefficient. If callable, it should take an angle of attack as input and return the lift coefficient at that angle of attack. The tuple’s second item is the unit of the angle of attack, accepting either “radians” or “degrees”.

Returns:

fin_set – Fin set object created.

Return type:

TrapezoidalFins

add_elliptical_fins(n, root_chord, span, position, cant_angle=0, radius=None, airfoil=None, name='Fins')[source]#

Create an elliptical fin set, storing its parameters as part of the aerodynamic_surfaces list. Its parameters are the axial position along the rocket and its derivative of the coefficient of lift in respect to angle of attack.

Parameters:
  • n (int) – Number of fins, from 2 to infinity.

  • root_chord (int, float) – Fin root chord in meters.

  • span (int, float) – Fin span in meters.

  • position (int, float) – Fin set position relative to the rocket’s coordinate system. By fin set position, understand the point belonging to the root chord which is highest in the rocket coordinate system (i.e. generally the point closest to the nose cone tip). See Rocket.coordinate_system_orientation for more information.

  • cant_angle (int, float, optional) – Fins cant angle with respect to the rocket centerline. Must be given in degrees.

  • radius (int, float, optional) – Reference radius to calculate lift coefficient. If None, which is default, use rocket radius.

  • airfoil (tuple, optional) – Default is null, in which case fins will be treated as flat plates. Otherwise, if tuple, fins will be considered as airfoils. The tuple’s first item specifies the airfoil’s lift coefficient by angle of attack and must be either a .csv, .txt, ndarray or callable. The .csv and .txt files must contain no headers and the first column must specify the angle of attack, while the second column must specify the lift coefficient. The ndarray should be as [(x0, y0), (x1, y1), (x2, y2), …] where x0 is the angle of attack and y0 is the lift coefficient. If callable, it should take an angle of attack as input and return the lift coefficient at that angle of attack. The tuple’s second item is the unit of the angle of attack, accepting either “radians” or “degrees”.

Returns:

fin_set – Fin set object created.

Return type:

EllipticalFins

add_parachute(name, cd_s, trigger, sampling_rate=100, lag=0, noise=(0, 0, 0))[source]#

Creates a new parachute, storing its parameters such as opening delay, drag coefficients and trigger function.

Parameters:
  • name (string) – Parachute name, such as drogue and main. Has no impact in simulation, as it is only used to display data in a more organized matter.

  • cd_s (float) – Drag coefficient times reference area for parachute. It is used to compute the drag force exerted on the parachute by the equation F = ((1/2)*rho*V^2)*cd_s, that is, the drag force is the dynamic pressure computed on the parachute times its cd_s coefficient. Has units of area and must be given in squared meters.

  • trigger (function, float, string) – Trigger for the parachute deployment. Can be a float with the height in which the parachute is ejected (ejection happens after apogee); or the string “apogee”, for ejection at apogee. Can also be a function which defines if the parachute ejection system is to be triggered. It must take as input the freestream pressure in pascal, the height in meters (above ground level), and the state vector of the simulation, which is defined by [x, y, z, vx, vy, vz, e0, e1, e2, e3, wx, wy, wz]. The trigger will be called according to the sampling rate given next. It should return True if the parachute ejection system is to be triggered and False otherwise.

  • sampling_rate (float, optional) – Sampling rate in which the trigger function works. It is used to simulate the refresh rate of onboard sensors such as barometers. Default value is 100. Value must be given in hertz.

  • lag (float, optional) – Time between the parachute ejection system is triggered and the parachute is fully opened. During this time, the simulation will consider the rocket as flying without a parachute. Default value is 0. Must be given in seconds.

  • noise (tuple, list, optional) – List in the format (mean, standard deviation, time-correlation). The values are used to add noise to the pressure signal which is passed to the trigger function. Default value is (0, 0, 0). Units are in pascal.

Returns:

parachute – Parachute containing trigger, sampling_rate, lag, cd_s, noise and name. Furthermore, it stores clean_pressure_signal, noise_signal and noisyPressureSignal which are filled in during Flight simulation.

Return type:

Parachute

set_rail_buttons(upper_button_position, lower_button_position, angular_position=45)[source]#

Adds rail buttons to the rocket, allowing for the calculation of forces exerted by them when the rocket is sliding in the launch rail. For the simulation, only two buttons are needed, which are the two closest to the nozzle.

Parameters:
  • upper_button_position (int, float) – Position of the rail button furthest from the nozzle relative to the rocket’s coordinate system, in meters. See Rocket.coordinate_system_orientation for more information.

  • lower_button_position (int, float) – Position of the rail button closest to the nozzle relative to the rocket’s coordinate system, in meters. See Rocket.coordinate_system_orientation for more information.

  • angular_position (float, optional) – Angular position of the rail buttons in degrees measured as the rotation around the symmetry axis of the rocket relative to one of the other principal axis. Default value is 45 degrees, generally used in rockets with 4 fins.

Returns:

rail_buttons – RailButtons object created

Return type:

RailButtons

add_cm_eccentricity(x, y)[source]#

Moves line of action of aerodynamic and thrust forces by equal translation amount to simulate an eccentricity in the position of the center of mass of the rocket relative to its geometrical center line. Should not be used together with add_cp_eccentricity and add_thrust_eccentricity.

Parameters:
  • x (float) – Distance in meters by which the CM is to be translated in the x direction relative to geometrical center line.

  • y (float) – Distance in meters by which the CM is to be translated in the y direction relative to geometrical center line.

Returns:

self – Object of the Rocket class.

Return type:

Rocket

add_cp_eccentricity(x, y)[source]#

Moves line of action of aerodynamic forces to simulate an eccentricity in the position of the center of pressure relative to the center of mass of the rocket.

Parameters:
  • x (float) – Distance in meters by which the CP is to be translated in the x direction relative to the center of mass axial line.

  • y (float) – Distance in meters by which the CP is to be translated in the y direction relative to the center of mass axial line.

Returns:

self – Object of the Rocket class.

Return type:

Rocket

add_thrust_eccentricity(x, y)[source]#

Moves line of action of thrust forces to simulate a misalignment of the thrust vector and the center of mass.

Parameters:
  • x (float) – Distance in meters by which the line of action of the thrust force is to be translated in the x direction relative to the center of mass axial line.

  • y (float) – Distance in meters by which the line of action of the thrust force is to be translated in the x direction relative to the center of mass axial line.

Returns:

self – Object of the Rocket class.

Return type:

Rocket

info()[source]#

Prints out a summary of the data and graphs available about the Rocket.

Parameters:

None

Return type:

None

all_info()[source]#

Prints out all data and graphs available about the Rocket.

Parameters:

None

Return type:

None

add_fin(number_of_fins=4, cl=6.283185307179586, cpr=1, cpz=1, gammas=[0, 0, 0, 0], angular_positions=None)[source]#

Hey! I will document this function later