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.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. This does not include the motor or propellant mass.

  • Rocket.motor_center_of_mass_position (Function) – Position, in meters, of the motor’s center of mass relative to the user defined rocket coordinate system. This is a function of time since the propellant mass decreases with time. For more information, see the Positions and Coordinate Systems.

  • Rocket.motor_center_of_dry_mass_position (float) – Position, in meters, of the motor’s center of dry mass (i.e. center of mass without propellant) relative to the user defined rocket coordinate system. This is constant since the motor dry mass is constant.

  • 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 motor and propellant, measured in kg.

  • Rocket.dry_mass (float) – Rocket’s mass without propellant, measured in kg. It does include the motor mass.

  • 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.parachutes (list) – Collection of parachutes of the rocket.

  • Rocket.air_brakes (list) – Collection of air brakes of the rocket.

  • Rocket._controllers (list) – Collection of controllers of the rocket.

  • Rocket.cp_position (Function) – Function of Mach number expressing the rocket’s center of pressure position relative to user defined rocket reference system. See Positions and Coordinate Systems for more information.

  • Rocket.stability_margin (Function) – Stability margin of the rocket, in calibers, as a function of mach number and time. Stability margin is defined as the distance between the center of pressure and the center of mass, divided by the rocket’s diameter.

  • Rocket.static_margin (float) – Static margin of the rocket, in calibers, as a function of time. Static margin is defined as the distance between the center of pressure and the center of mass, divided by the rocket’s diameter.

  • Rocket.static_margin – 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 meters, of the motor’s coordinate system origin relative to the user defined rocket coordinate system. See Positions and Coordinate Systems for more information. regarding the rocket’s coordinate system.

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

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

  • Rocket.I_11_without_motor (float) – Rocket’s inertia tensor 11 component without any motors, in kg*m^2. This is the same value that is passed in the Rocket.__init__() method.

  • Rocket.I_22_without_motor (float) – Rocket’s inertia tensor 22 component without any motors, in kg*m^2. This is the same value that is passed in the Rocket.__init__() method.

  • Rocket.I_33_without_motor (float) – Rocket’s inertia tensor 33 component without any motors, in kg*m^2. This is the same value that is passed in the Rocket.__init__() method.

  • Rocket.I_12_without_motor (float) – Rocket’s inertia tensor 12 component without any motors, in kg*m^2. This is the same value that is passed in the Rocket.__init__() method.

  • Rocket.I_13_without_motor (float) – Rocket’s inertia tensor 13 component without any motors, in kg*m^2. This is the same value that is passed in the Rocket.__init__() method.

  • Rocket.I_23_without_motor (float) – Rocket’s inertia tensor 23 component without any motors, in kg*m^2. This is the same value that is passed in the Rocket.__init__() method.

  • Rocket.dry_I_11 (float) – Rocket’s inertia tensor 11 component with unloaded motor,in kg*m^2.

  • Rocket.dry_I_22 (float) – Rocket’s inertia tensor 22 component with unloaded motor,in kg*m^2.

  • Rocket.dry_I_33 (float) – Rocket’s inertia tensor 33 component with unloaded motor,in kg*m^2.

  • Rocket.dry_I_12 (float) – Rocket’s inertia tensor 12 component with unloaded motor,in kg*m^2.

  • Rocket.dry_I_13 (float) – Rocket’s inertia tensor 13 component with unloaded motor,in kg*m^2.

  • Rocket.dry_I_23 (float) – Rocket’s inertia tensor 23 component with unloaded motor,in kg*m^2.

__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 inertia tensor components, in kg*m^2. This should be measured without motor and propellant so that the inertia reference point is the center_of_mass_without_motor. 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 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. This can also be called as “rocket dry inertia tensor”.

  • 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

property nosecones#

A list containing all the nose cones currently added to the rocket.

property fins#

A list containing all the fins currently added to the rocket.

property tails#

A list with all the tails currently added to the rocket

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.

Returns:

self.dry_mass – Rocket’s dry mass (Rocket + Motor) (kg)

Return type:

float

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 the rocket’s center of dry mass (i.e. rocket with motor but without propellant) position relative to user defined rocket reference system.

Returns:

self.center_of_dry_mass_position – Rocket’s center of dry mass position (with unloaded motor)

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 rocket dry mass (i.e. with unloaded motor), divided by the loaded 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.

Return type:

Function

evaluate_thrust_to_weight()[source]#

Evaluates thrust to weight as a Function of time. This is defined as the motor thrust force divided by rocket weight. The gravitational acceleration is assumed constant and equals to 9.80665 m/s^2.

Return type:

None

evaluate_center_of_pressure()[source]#

Evaluates rocket center of pressure position relative to user defined rocket reference system. It can be called as many times as needed, as it will update the center of pressure function every time it is called. The code will iterate through all aerodynamic surfaces and consider each of their center of pressure position and derivative of the coefficient of lift as a function of Mach number.

Returns:

self.cp_position – Function of Mach number expressing the rocket’s center of pressure position relative to user defined rocket reference system. See Positions and Coordinate Systems for more information.

Return type:

Function

evaluate_stability_margin()[source]#

Calculates the stability margin of the rocket as a function of mach number and time.

Returns:

stability_margin – Stability margin of the rocket, in calibers, as a function of mach number and time. Stability margin is defined as the distance between the center of pressure and the center of mass, divided by the rocket’s diameter.

Return type:

Function

evaluate_static_margin()[source]#

Calculates the static margin of the rocket as a function of time.

Returns:

static_margin – Static margin of the rocket, in calibers, as a function of time. Static margin is defined as the distance between the center of pressure and the center of mass, divided by the rocket’s diameter.

Return type:

Function

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². This does not consider propellant mass but does take into account the motor dry mass.

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_controllers(controllers)[source]#

Adds a controller to the rocket.

Parameters:

controllers (list of Controller objects) – List of controllers to be added to the rocket. If a single Controller object is passed, outside of a list, a try/except block will be used to try to append the controller to the list.

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', base_radius=None)[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”.

  • base_radius (int, float, optional) – Nose cone base radius in meters. If not given, the rocket radius will be used.

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 fuselage radius where the fins are located. This is used to calculate lift coefficient and to draw the rocket. If None, which is default, the rocket radius will be used.

  • 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 can contain a single line header 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 fuselage radius where the fins are located. This is used to calculate lift coefficient and to draw the rocket. If None, which is default, the rocket radius will be used.

  • 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 can contain a single line header 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

add_air_brakes(drag_coefficient_curve, controller_function, sampling_rate, clamp=True, reference_area=None, initial_observed_variables=None, override_rocket_drag=False, return_controller=False, name='AirBrakes', controller_name='AirBrakes Controller')[source]#

Creates a new air brakes system, storing its parameters such as drag coefficient curve, controller function, sampling rate, and reference area.

Parameters:
  • drag_coefficient_curve (int, float, callable, array, string, Function) –

    This parameter represents the drag coefficient associated with the air brakes and/or the entire rocket, depending on the value of override_rocket_drag.

    • If a constant, it should be an integer or a float representing a fixed drag coefficient value.

    • If a function, it must take two parameters: deployment level and Mach number, and return the drag coefficient. This function allows for dynamic computation based on deployment and Mach number.

    • If an array, it should be a 2D array with three columns: the first column for deployment level, the second for Mach number, and the third for the corresponding drag coefficient.

    • If a string, it should be the path to a .csv or .txt file. The file must contain three columns: the first for deployment level, the second for Mach number, and the third for the drag coefficient.

    • If a Function, it must take two parameters: deployment level and Mach number, and return the drag coefficient.

    Note

    For override_rocket_drag = False, at deployment level 0, the drag coefficient is assumed to be 0, independent of the input drag coefficient curve. This means that the simulation always considers that at a deployment level of 0, the air brakes are completely retracted and do not contribute to the drag of the rocket.

  • controller_function (function, callable) –

    An user-defined function responsible for controlling the simulation. This function is expected to take the following arguments, in order:

    1. time (float): The current simulation time in seconds.

    2. sampling_rate (float): The rate at which the controller function is called, measured in Hertz (Hz).

    3. state (list): The state vector of the simulation, structured as [x, y, z, vx, vy, vz, e0, e1, e2, e3, wx, wy, wz].

    4. state_history (list): A record of the rocket’s state at each step throughout the simulation. The state_history is organized as a list of lists, with each sublist containing a state vector. The last item in the list always corresponds to the previous state vector, providing a chronological sequence of the rocket’s evolving states.

    5. observed_variables (list): A list containing the variables that the controller function returns. The initial value in the first step of the simulation of this list is provided by the initial_observed_variables argument.

    6. interactive_objects (list): A list containing the objects that the controller function can interact with. The objects are listed in the same order as they are provided in the interactive_objects

    This function will be called during the simulation at the specified sampling rate. The function should evaluate and change the observed objects as needed. The function should return None.

    Note

    The function will be called according to the sampling rate

    specified.

  • sampling_rate (float) – The sampling rate of the controller function in Hertz (Hz). This means that the controller function will be called every 1/sampling_rate seconds.

  • clamp (bool, optional) – If True, the simulation will clamp the deployment level to 0 or 1 if the deployment level is out of bounds. If False, the simulation will not clamp the deployment level and will instead raise a warning if the deployment level is out of bounds. Default is True.

  • reference_area (float, optional) – Reference area used to calculate the drag force of the air brakes from the drag coefficient curve. If None, which is default, use rocket section area. Must be given in squared meters.

  • initial_observed_variables (list, optional) – A list of the initial values of the variables that the controller function returns. This list is used to initialize the observed_variables argument of the controller function. The default value is None, which initializes the list as an empty list.

  • override_rocket_drag (bool, optional) – If False, the air brakes drag coefficient will be added to the rocket’s power off drag coefficient curve. If True, during the simulation, the rocket’s power off drag will be ignored and the air brakes drag coefficient will be used for the entire rocket instead. Default is False.

  • return_controller (bool, optional) – If True, the function will return the controller object created. Default is False.

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

  • controller_name (string, optional) – Controller name. Has no impact in simulation, as it is only used to display data in a more organized matter.

Returns:

  • air_brakes (AirBrakes) – AirBrakes object created.

  • controller (Controller) – Controller object created.

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.

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

Notes

Should not be used together with add_cp_eccentricity and add_thrust_eccentricity.

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

draw(vis_args=None)[source]#

Draws the rocket in a matplotlib figure.

Parameters:

vis_args (dict, optional) –

Determines the visual aspects when drawing the rocket. If None, default values are used. Default values are: {

”background”: “#EEEEEE”, “tail”: “black”, “nose”: “black”, “body”: “dimgrey”, “fins”: “black”, “motor”: “black”, “buttons”: “black”, “line_width”: 2.0,

} A full list of color names can be found at: https://matplotlib.org/stable/gallery/color/named_colors

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