Rocket Class#

class rocketpy.Rocket[source]#

Keeps rocket information.

Variables:
  • Rocket.radius (float) – Rocket’s largest radius in meters.

  • Rocket.area (float) – Rocket’s circular cross section largest frontal area in squared meters.

  • Rocket.center_of_dry_mass_position (float) – 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 Positions and Coordinate Systems for more information regarding the rocket’s coordinate system.

  • Rocket.coordinate_system_orientation (string) – 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.

  • Rocket.mass (float) – Rocket’s mass without propellant in kg.

  • Rocket.center_of_mass (Function) – Position of the rocket’s center of mass, including propellant, relative to the user defined rocket reference system. See Positions and Coordinate Systems for more information regarding the coordinate system. Expressed in meters as a function of time.

  • Rocket.reduced_mass (Function) – 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.

  • Rocket.total_mass (Function) – Function of time expressing the total mass of the rocket, defined as the sum of the propellant mass and the rocket mass without propellant.

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

  • Rocket.cp_eccentricity_x (float) – Center of pressure position relative to center of mass in the x axis, perpendicular to axis of cylindrical symmetry, in meters.

  • Rocket.cp_eccentricity_y (float) – Center of pressure position relative to center of mass in the y axis, perpendicular to axis of cylindrical symmetry, in meters.

  • Rocket.thrust_eccentricity_y (float) – Thrust vector position relative to center of mass in the y axis, perpendicular to axis of cylindrical symmetry, in meters.

  • Rocket.thrust_eccentricity_x (float) – Thrust vector position relative to center of mass in the x axis, perpendicular to axis of cylindrical symmetry, in meters.

  • Rocket.aerodynamic_surfaces (list) – Collection of aerodynamic surfaces of the rocket. Holds Nose cones, Fin sets, and Tails.

  • Rocket.cp_position (float) – Rocket’s center of pressure position relative to the user defined rocket reference system. See Positions and Coordinate Systems for more information regarding the reference system. Expressed in meters.

  • Rocket.static_margin (float) – Float value corresponding to rocket static margin when loaded with propellant in units of rocket diameter or calibers.

  • Rocket.power_off_drag (Function) – Rocket’s drag coefficient as a function of Mach number when the motor is off.

  • Rocket.power_on_drag (Function) – Rocket’s drag coefficient as a function of Mach number when the motor is on.

  • Rocket.rail_buttons (RailButtons) – RailButtons object containing the rail buttons information.

  • Rocket.motor (Motor) – Rocket’s motor. See Motor class for more details.

  • Rocket.motor_position (float) – Position, in m, of the motor’s nozzle exit area relative to the user defined rocket coordinate system. See Positions and Coordinate Systems for more information regarding the rocket’s coordinate system.

  • Rocket.center_of_propellant_position (Function) – Position of the propellant’s center of mass relative to the user defined rocket reference system. See Positions and Coordinate Systems for more information regarding the rocket’s coordinate system. Expressed in meters as a function of time.

__init__(radius, mass, inertia, power_off_drag, power_on_drag, center_of_mass_without_motor, coordinate_system_orientation='tail_to_nose')[source]#

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 Positions and Coordinate Systems 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.

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:

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.

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:

Function

evaluate_center_of_mass()[source]#

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

Returns:

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

Return type:

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.

Returns:

self.center_of_dry_mass_position – Rocket’s center of dry mass position relative to user defined rocket reference system. See Positions and Coordinate Systems 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.

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.

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².

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.

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².

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.

add_motor(motor, position)[source]#

Adds a motor to the rocket.

Parameters:
  • motor (Motor, SolidMotor, HybridMotor, LiquidMotor, GenericMotor) – Motor to be added to the rocket.

  • position (int, float) – Position, in meters, of the motor’s coordinate system origin relative to the user defined rocket coordinate system.

See also

add_surfaces

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.

  • positions (int, float, list) – Position, in m, of the aerodynamic surface’s center of pressure relative to the user defined rocket 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.

See also

add_surfaces

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. the point closest to the nose cone).

See also

add_surfaces

Returns:

tail – Tail object created.

Return type:

Tail

add_nose(length, kind, position, bluffness=0, name='Nose Cone')[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.

  • bluffness (float, optional) – Ratio between the radius of the circle on the tip of the ogive and the radius of the base of the ogive.

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

See also

add_surfaces

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. the point closest to the nose cone tip).

    See also

    add_surfaces

  • 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. the point closest to the nose cone tip).

    See also

    add_surfaces

  • 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) –

    This parameter defines the trigger condition for the parachute ejection system. It can be one of the following:

    • A callable function that takes three arguments:
      1. Freestream pressure in pascals.

      2. Height in meters above ground level.

      3. The state vector of the simulation, which is defined as:

        [x, y, z, vx, vy, vz, e0, e1, e2, e3, wx, wy, wz].

    The function should return True if the parachute ejection system should be triggered and False otherwise.

    • A float value, representing an absolute height in meters. In this

    case, the parachute will be ejected when the rocket reaches this height above ground level.

    • The string “apogee,” which triggers the parachute at apogee, i.e.,

    when the rocket reaches its highest point and starts descending.

    Note: The function will be called according to the sampling rate specified next.

  • 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 Positions and Coordinate Systems 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 Positions and Coordinate Systems 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.

See also

add_surfaces

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.

Return type:

None

all_info()[source]#

Prints out all data and graphs available about the Rocket.

Return type:

None