Rocket Class#
- class rocketpy.Rocket.Rocket(motor, mass, inertiaI, inertiaZ, radius, distanceRocketNozzle, distanceRocketPropellant, powerOffDrag, powerOnDrag)[source]#
Keeps all rocket and parachute 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
- distanceRocketNozzle#
Distance between rocket’s center of mass, without propellant, to the exit face of the nozzle, in meters. Always positive.
- Type:
float
- distanceRocketPropellant#
Distance between rocket’s center of mass, without propellant, to the motor reference point, which for solid and hybrid motors is the center of mass of solid propellant, in meters. Always positive.
- Type:
float
- Mass and Inertia attributes
- mass#
Rocket’s mass without propellant in kg.
- Type:
float
- inertiaI#
Rocket’s moment of inertia, without propellant, with respect to to an axis perpendicular to the rocket’s axis of cylindrical symmetry, in kg*m^2.
- Type:
float
- inertiaZ#
Rocket’s moment of inertia, without propellant, with respect to the rocket’s axis of cylindrical symmetry, in kg*m^2.
- Type:
float
- centerOfMass#
Distance of the rocket’s center of mass, including propellant, to rocket’s center of mass without propellant, in meters. Expressed as a function of time.
- Type:
- reducedMass#
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:
- totalMass#
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:
- thrustToWeight#
Function of time expressing the motor thrust force divided by rocket weight. The gravitational acceleration is assumed as 9.80665 m/s^2.
- Type:
- Eccentricity attributes
- cpEccentricityX#
Center of pressure position relative to center of mass in the x axis, perpendicular to axis of cylindrical symmetry, in meters.
- Type:
float
- cpEccentricityY#
Center of pressure position relative to center of mass in the y axis, perpendicular to axis of cylindrical symmetry, in meters.
- Type:
float
- thrustEccentricityY#
Thrust vector position relative to center of mass in the y axis, perpendicular to axis of cylindrical symmetry, in meters.
- Type:
float
- thrustEccentricityX#
Thrust vector position relative to center of mass in the x axis, perpendicular to axis of cylindrical symmetry, in meters.
- Type:
float
- Aerodynamic attributes
- aerodynamicSurfaces#
List of aerodynamic surfaces of the rocket.
- Type:
list
- staticMargin#
Float value corresponding to rocket static margin when loaded with propellant in units of rocket diameter or calibers.
- Type:
float
- powerOffDrag#
Rocket’s drag coefficient as a function of Mach number when the motor is off.
- Type:
- powerOnDrag#
Rocket’s drag coefficient as a function of Mach number when the motor is on.
- Type:
- Motor attributes
- motor#
Rocket’s motor. See Motor class for more details.
- Type:
Motor
Initializes Rocket class, process inertial, geometrical and aerodynamic parameters.
- Parameters:
motor (Motor) – Motor used in the rocket. See Motor class for more information.
mass (int, float) – Unloaded rocket total mass (without propellant) in kg.
inertiaI (int, float) – Unloaded rocket lateral (perpendicular to axis of symmetry) moment of inertia (without propellant) in kg m^2.
inertiaZ (int, float) – Unloaded rocket axial moment of inertia (without propellant) in kg m^2.
radius (int, float) – Rocket largest outer radius in meters.
distanceRocketNozzle (int, float) – Distance from rocket’s unloaded center of mass to nozzle outlet, in meters. Generally negative, meaning a negative position in the z axis which has an origin in the rocket’s center of mass (without propellant) and points towards the nose cone.
distanceRocketPropellant (int, float) – Distance from rocket’s unloaded center of mass to the motor reference point, which for solid and hybrid motor the is the center of mass of solid propellant, in meters. Generally negative, meaning a negative position in the z axis which has an origin in the rocket’s center of mass (with out propellant) and points towards the nose cone.
powerOffDrag (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.
powerOnDrag (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.
- Return type:
None
- evaluateReducedMass()[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.reducedMass – 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:
- evaluateTotalMass()[source]#
Calculates and returns the rocket’s total mass. The total mass is defined as the sum of the propellant mass 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.totalMass – 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:
- evaluateStaticMargin()[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.staticMargin – Float value corresponding to rocket static margin when loaded with propellant in units of rocket diameter or calibers.
- Return type:
float
- addTail(topRadius, bottomRadius, length, distanceToCM, radius=None, name='Tail')[source]#
Create a new tail or rocket diameter change, storing its parameters as part of the aerodynamicSurfaces list. Its parameters are the axial position along the rocket and its derivative of the coefficient of lift in respect to angle of attack. :param topRadius: Tail top radius in meters, considering positive direction
from center of mass to nose cone.
- Parameters:
bottomRadius (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.
distanceToCM (int, float) – Tail position relative to rocket unloaded center of mass, considering positive direction from center of mass to nose cone. Consider the point belonging to the tail which is closest to the unloaded center of mass to calculate distance.
- Returns:
cl (Function) – Function of the angle of attack (Alpha) and the mach number (Mach) expressing the tail’s lift coefficient. The inputs are the angle of attack (in radians) and the mach number. The output is the tail’s lift coefficient. In the current implementation, the tail’s lift coefficient does not vary with mach.
self (Rocket) – Object of the Rocket class.
- addNose(length, kind, distanceToCM, name='Nose Cone')[source]#
Creates a nose cone, storing its parameters as part of the aerodynamicSurfaces 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.
distanceToCM (int, float) – Nose cone position relative to rocket unloaded center of mass, considering positive direction from center of mass to nose cone. Consider the center point belonging to the nose cone base to calculate distance.
name (string) – Nose cone name. Default is “Nose Cone”.
- Returns:
cl (Function) – Function of the angle of attack (Alpha) and the mach number (Mach) expressing the nose cone’s lift coefficient. The inputs are the angle of attack (in radians) and the mach number. The output is the nose cone’s lift coefficient. In the current implementation, the nose cone’s lift coefficient does not vary with mach
self (Rocket) – Object of the Rocket class.
- addFins(*args, **kwargs)[source]#
See Rocket.addTrapezoidalFins for documentation. This method is set to be deprecated in version 1.0.0 and fully removed by version 2.0.0. Use Rocket.addTrapezoidalFins instead. It keeps the same arguments and signature.
- addTrapezoidalFins(n, rootChord, tipChord, span, distanceToCM, cantAngle=0, sweepLength=None, sweepAngle=None, radius=None, airfoil=None, name='Fins')[source]#
Create a trapezoidal fin set, storing its parameters as part of the aerodynamicSurfaces list. Its parameters are the axial position along the rocket and its derivative of the coefficient of lift in respect to angle of attack. :param n: Number of fins, from 2 to infinity. :type n: int :param span: Fin span in meters. :type span: int, float :param rootChord: Fin root chord in meters. :type rootChord: int, float :param tipChord: Fin tip chord in meters. :type tipChord: int, float :param distanceToCM: Fin set position relative to rocket unloaded center of
mass, considering positive direction from center of mass to nose cone. Consider the center point belonging to the top of the fins to calculate distance.
- Parameters:
cantAngle (int, float, optional) – Fins cant angle with respect to the rocket centerline. Must be given in degrees.
sweepLength (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 sweepAngle.
sweepAngle (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 sweepLength.
radius (int, float, optional) – Reference radius to calculate lift coefficient. If None, which is default, use rocket radius. Otherwise, enter the radius of the rocket in the section of the fins, as this impacts its lift coefficient.
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:
cl (Function) – Function of the angle of attack (Alpha) and the mach number (Mach) expressing the fin’s lift coefficient. The inputs are the angle of attack (in radians) and the mach number. The output is the fin’s lift coefficient.
self (Rocket) – Object of the Rocket class.
- addEllipticalFins(n, rootChord, span, distanceToCM, cantAngle=0, radius=None, airfoil=None, name='Fins')[source]#
Create an elliptical fin set, storing its parameters as part of the aerodynamicSurfaces list. Its parameters are the axial position along the rocket and its derivative of the coefficient of lift in respect to angle of attack. :param type: Type of fin selected to the rocket. Must be either “trapezoid”
or “elliptical”.
- Parameters:
span (int, float) – Fin span in meters.
rootChord (int, float) – Fin root chord in meters.
n (int) – Number of fins, from 2 to infinity.
distanceToCM (int, float) – Fin set position relative to rocket unloaded center of mass, considering positive direction from center of mass to nose cone. Consider the center point belonging to the top of the fins to calculate distance.
cantAngle (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. Otherwise, enter the radius of the rocket in the section of the fins, as this impacts its lift coefficient.
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:
cl (Function) – Function of the angle of attack (Alpha) and the mach number (Mach) expressing the fin’s lift coefficient. The inputs are the angle of attack (in radians) and the mach number. The output is the fin’s lift coefficient.
self (Rocket) – Object of the Rocket class.
- addParachute(name, CdS, trigger, samplingRate=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.
CdS (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)*CdS, that is, the drag force is the dynamic pressure computed on the parachute times its CdS coefficient. Has units of area and must be given in squared meters.
trigger (function) – Function which defines if the parachute ejection system is to be triggered. It must take as input the freestream pressure in pascal and the state vector of the simulation, which is defined by [x, y, z, vx, vy, vz, e0, e1, e2, e3, wx, wy, wz]. It 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.
samplingRate (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, samplingRate, lag, CdS, noise and name. Furthermore, it stores cleanPressureSignal, noiseSignal and noisyPressureSignal which are filled in during Flight simulation.
- Return type:
Parachute
- setRailButtons(distanceToCM, angularPosition=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. Furthermore, rail buttons are also needed for the simulation of the planar flight phase, when the rocket experiences 3 degrees of freedom motion while only one rail button is still in the launch rail.
- Parameters:
distanceToCM (tuple, list, array) – Two values organized in a tuple, list or array which represent the distance of each of the two rail buttons to the center of mass of the rocket without propellant. If the rail button is positioned above the center of mass, its distance should be a positive value. If it is below, its distance should be a negative value. The order does not matter. All values should be in meters.
angularPosition (float) – 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.
- Return type:
None
- addCMEccentricity(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 addCPEccentricity and addThrustEccentricity.
- 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:
- addCPEccentricity(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:
- addThrustEccentricity(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:
- info()[source]#
Prints out a summary of the data and graphs available about the Rocket.
- Parameters:
None –
- Return type:
None
- allInfo()[source]#
Prints out all data and graphs available about the Rocket.
- Parameters:
None –
- Return type:
None