GenericMotor Class#

class rocketpy.GenericMotor[source]#

Class that represents a simple motor defined mainly by its thrust curve. There is no distinction between the propellant types (e.g. Solid, Liquid). This class is meant for rough estimations of the motor performance, therefore for more accurate results, use the SolidMotor, HybridMotor or LiquidMotor classes.

__init__(thrust_source, burn_time, chamber_radius, chamber_height, chamber_position, propellant_initial_mass, nozzle_radius, dry_mass=0, center_of_dry_mass_position=None, dry_inertia=(0, 0, 0), nozzle_position=0, reshape_thrust_curve=False, interpolation_method='linear', coordinate_system_orientation='nozzle_to_combustion_chamber', reference_pressure=None)[source]#

Initialize GenericMotor class, process thrust curve and geometrical parameters and store results.

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

    Motor’s thrust curve. Can be given as an int or float, in which case the thrust will be considered constant in time. It can also be given as a callable function, whose argument is time in seconds and returns the thrust supplied by the motor in the instant. If a string is given, it must point to a .csv or .eng file. The .csv file can contain a single line header and the first column must specify time in seconds, while the second column specifies thrust. Arrays may also be specified, following rules set by the class Function. Thrust units are Newtons.

  • chamber_radius (int, float) – The radius of a overall cylindrical chamber of propellant in meters. This is a rough estimate for the motor’s propellant chamber or tanks.

  • chamber_height (int, float) – The height of a overall cylindrical chamber of propellant in meters. This is a rough estimate for the motor’s propellant chamber or tanks.

  • chamber_position (int, float) – The position, in meters, of the centroid (half height) of the motor’s overall cylindrical chamber of propellant with respect to the motor’s coordinate system. See Positions and Coordinate Systems

  • dry_mass (int, float) – Same as in Motor class. See the Motor docs

  • propellant_initial_mass (int, float) – The initial mass of the propellant in the motor.

  • center_of_dry_mass_position (int, float, optional) – The position, in meters, of the motor’s center of mass with respect to the motor’s coordinate system when it is devoid of propellant. If not specified, automatically sourced as the chamber position. See Positions and Coordinate Systems

  • dry_inertia (tuple, list) – Tuple or list containing the motor’s dry mass inertia tensor components, in kg*m^2. This inertia is defined with respect to the the center_of_dry_mass_position position. 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.

  • nozzle_radius (int, float, optional) – Motor’s nozzle outlet radius in meters.

  • burn_time (float, tuple of float, optional) – Motor’s burn time. If a float is given, the burn time is assumed to be between 0 and the given float, in seconds. If a tuple of float is given, the burn time is assumed to be between the first and second elements of the tuple, in seconds. If not specified, automatically sourced as the range between the first and last-time step of the motor’s thrust curve. This can only be used if the motor’s thrust is defined by a list of points, such as a .csv file, a .eng file or a Function instance whose source is a list.

  • nozzle_position (int, float, optional) – Motor’s nozzle outlet position in meters, in the motor’s coordinate system. See Positions and Coordinate Systems for details. Default is 0, in which case the origin of the coordinate system is placed at the motor’s nozzle outlet.

  • reshape_thrust_curve (boolean, tuple, optional) – If False, the original thrust curve supplied is not altered. If a tuple is given, whose first parameter is a new burn out time and whose second parameter is a new total impulse in Ns, the thrust curve is reshaped to match the new specifications. May be useful for motors whose thrust curve shape is expected to remain similar in case the impulse and burn time varies slightly. Default is False. Note that the Motor burn_time parameter must include the new reshaped burn time.

  • interpolation_method (string, optional) – Method of interpolation to be used in case thrust curve is given by data set in .csv or .eng, or as an array. Options are ‘spline’ ‘akima’ and ‘linear’. Default is “linear”.

  • coordinate_system_orientation (string, optional) – Orientation of the motor’s coordinate system. The coordinate system is defined by the motor’s axis of symmetry. The origin of the coordinate system may be placed anywhere along such axis, such as at the nozzle area, and must be kept the same for all other positions specified. Options are “nozzle_to_combustion_chamber” and “combustion_chamber_to_nozzle”. Default is “nozzle_to_combustion_chamber”.

  • reference_pressure (int, float, optional) – Atmospheric pressure in Pa at which the thrust data was recorded.

property propellant_initial_mass#

Calculates the initial mass of the propellant.

Returns:

Initial mass of the propellant.

Return type:

float

exhaust_velocity#

Exhaust velocity by assuming it as a constant. The formula used is total impulse/propellant initial mass.

Returns:

self.exhaust_velocity – Gas exhaust velocity of the motor.

Return type:

Function

Notes

This corresponds to the actual exhaust velocity only when the nozzle exit pressure equals the atmospheric pressure.

mass_flow_rate#

Time derivative of propellant mass. Assumes constant exhaust velocity. The formula used is the opposite of thrust divided by exhaust velocity.

center_of_propellant_mass#

Estimates the propellant center of mass as fixed in the chamber position. For a more accurate evaluation, use the classes SolidMotor, LiquidMotor or HybridMotor.

Returns:

Function representing the center of mass of the motor.

Return type:

Function

propellant_I_11#

Inertia tensor 11 component of the propellant, the inertia is relative to the e_1 axis, centered at the instantaneous propellant center of mass.

Returns:

Propellant inertia tensor 11 component at time t.

Return type:

Function

Notes

The e_1 direction is assumed to be the direction perpendicular to the motor body axis.

propellant_I_22#

Inertia tensor 22 component of the propellant, the inertia is relative to the e_2 axis, centered at the instantaneous propellant center of mass.

Returns:

Propellant inertia tensor 22 component at time t.

Return type:

Function

Notes

The e_2 direction is assumed to be the direction perpendicular to the motor body axis, and perpendicular to e_1.

propellant_I_33#

Inertia tensor 33 component of the propellant, the inertia is relative to the e_3 axis, centered at the instantaneous propellant center of mass.

Returns:

Propellant inertia tensor 33 component at time t.

Return type:

Function

Notes

The e_3 direction is assumed to be the axial direction of the rocket motor.

propellant_I_12#
propellant_I_13#
propellant_I_23#
static load_from_eng_file(file_name, nozzle_radius=None, chamber_radius=None, chamber_height=None, chamber_position=0, propellant_initial_mass=None, dry_mass=None, burn_time=None, center_of_dry_mass_position=None, dry_inertia=(0, 0, 0), nozzle_position=0, reshape_thrust_curve=False, interpolation_method='linear', coordinate_system_orientation='nozzle_to_combustion_chamber', reference_pressure=None)[source]#

Loads motor data from a .eng file and processes it.

Parameters:
  • file_name (string) – Name of the .eng file. E.g. ‘test.eng’.

  • nozzle_radius (int, float) – Motor’s nozzle outlet radius in meters.

  • chamber_radius (int, float, optional) – The radius of a overall cylindrical chamber of propellant in meters.

  • chamber_height (int, float, optional) – The height of a overall cylindrical chamber of propellant in meters.

  • chamber_position (int, float, optional) – The position, in meters, of the centroid (half height) of the motor’s overall cylindrical chamber of propellant with respect to the motor’s coordinate system.

  • propellant_initial_mass (int, float, optional) – The initial mass of the propellant in the motor.

  • dry_mass (int, float, optional) – Same as in Motor class. See the Motor docs

  • burn_time (float, tuple of float, optional) – Motor’s burn time. If a float is given, the burn time is assumed to be between 0 and the given float, in seconds. If a tuple of float is given, the burn time is assumed to be between the first and second elements of the tuple, in seconds. If not specified, automatically sourced as the range between the first and last-time step of the motor’s thrust curve. This can only be used if the motor’s thrust is defined by a list of points, such as a .csv file, a .eng file or a Function instance whose source is a list.

  • center_of_dry_mass_position (int, float, optional) – The position, in meters, of the motor’s center of mass with respect to the motor’s coordinate system when it is devoid of propellant. If not specified, automatically sourced as the chamber position.

  • dry_inertia (tuple, list) – Tuple or list containing the motor’s dry mass inertia tensor

  • nozzle_position (int, float, optional) – Motor’s nozzle outlet position in meters, in the motor’s coordinate system. Default is 0, in which case the origin of the coordinate system is placed at the motor’s nozzle outlet.

  • reshape_thrust_curve (boolean, tuple, optional) – If False, the original thrust curve supplied is not altered. If a tuple is given, whose first parameter is a new burn out time and whose second parameter is a new total impulse in Ns, the thrust curve is reshaped to match the new specifications. May be useful for motors whose thrust curve shape is expected to remain similar in case the impulse and burn time varies slightly. Default is False. Note that the Motor burn_time parameter must include the new reshaped burn time.

  • interpolation_method (string, optional) – Method of interpolation to be used in case thrust curve is given

  • coordinate_system_orientation (string, optional) – Orientation of the motor’s coordinate system. The coordinate system is defined by the motor’s axis of symmetry. The origin of the coordinate system may be placed anywhere along such axis, such as at the nozzle area, and must be kept the same for all other positions specified. Options are “nozzle_to_combustion_chamber” and “combustion_chamber_to_nozzle”. Default is “nozzle_to_combustion_chamber”.

  • reference_pressure (int, float, optional) – Atmospheric pressure in Pa at which the thrust data was recorded.

Return type:

Generic Motor object

static load_from_rse_file(file_name, nozzle_radius=None, chamber_radius=None, chamber_height=None, chamber_position=0, propellant_initial_mass=None, dry_mass=None, burn_time=None, center_of_dry_mass_position=None, dry_inertia=(0, 0, 0), nozzle_position=0, reshape_thrust_curve=False, interpolation_method='linear', coordinate_system_orientation='nozzle_to_combustion_chamber')[source]#

Loads motor data from a .rse file and processes it.

Parameters:
  • file_name (string) – Name of the .eng file. E.g. ‘test.eng’.

  • nozzle_radius (int, float) – Motor’s nozzle outlet radius in meters.

  • chamber_radius (int, float, optional) – The radius of a overall cylindrical chamber of propellant in meters.

  • chamber_height (int, float, optional) – The height of a overall cylindrical chamber of propellant in meters.

  • chamber_position (int, float, optional) – The position, in meters, of the centroid (half height) of the motor’s overall cylindrical chamber of propellant with respect to the motor’s coordinate system.

  • propellant_initial_mass (int, float, optional) – The initial mass of the propellant in the motor.

  • dry_mass (int, float, optional) – Same as in Motor class. See the Motor docs

  • burn_time (float, tuple of float, optional) – Motor’s burn time. If a float is given, the burn time is assumed to be between 0 and the given float, in seconds. If a tuple of float is given, the burn time is assumed to be between the first and second elements of the tuple, in seconds. If not specified, automatically sourced as the range between the first and last-time step of the motor’s thrust curve. This can only be used if the motor’s thrust is defined by a list of points, such as a .csv file, a .eng file or a Function instance whose source is a list.

  • center_of_dry_mass_position (int, float, optional) – The position, in meters, of the motor’s center of mass with respect to the motor’s coordinate system when it is devoid of propellant. If not specified, automatically sourced as the chamber position.

  • dry_inertia (tuple, list) – Tuple or list containing the motor’s dry mass inertia tensor

  • nozzle_position (int, float, optional) – Motor’s nozzle outlet position in meters, in the motor’s coordinate system. Default is 0, in which case the origin of the coordinate system is placed at the motor’s nozzle outlet.

  • reshape_thrust_curve (boolean, tuple, optional) – If False, the original thrust curve supplied is not altered. If a tuple is given, whose first parameter is a new burn out time and whose second parameter is a new total impulse in Ns, the thrust curve is reshaped to match the new specifications. May be useful for motors whose thrust curve shape is expected to remain similar in case the impulse and burn time varies slightly. Default is False. Note that the Motor burn_time parameter must include the new reshaped burn time.

  • interpolation_method (string, optional) – Method of interpolation to be used in case thrust curve is given

  • coordinate_system_orientation (string, optional) – Orientation of the motor’s coordinate system. The coordinate system is defined by the motor’s axis of symmetry. The origin of the coordinate system may be placed anywhere along such axis, such as at the nozzle area, and must be kept the same for all other positions specified. Options are “nozzle_to_combustion_chamber” and “combustion_chamber_to_nozzle”. Default is “nozzle_to_combustion_chamber”.

Return type:

Generic Motor object

static _call_thrustcurve_api(name, no_cache=False)[source]#

Download a .eng file from the ThrustCurve API based on the given motor name.

Parameters:
  • name (str) – The motor name according to the API (e.g., “Cesaroni_M1670” or “M1670”). Both manufacturer-prefixed and shorthand names are commonly used; if multiple motors match the search, the first result is used.

  • no_cache (bool, optional) – If True, forces a new API fetch even if the motor is cached.

Returns:

data_base64 – The .eng file of the motor in base64

Return type:

str

Raises:
  • ValueError – If no motor is found or if the downloaded .eng data is missing.

  • requests.exceptions.Timeout – If a search or download request to the ThrustCurve API exceeds the timeout limit (5 s connect / 30 s read).

  • requests.exceptions.RequestException – If any other network or HTTP error occurs during the API call.

Notes

  • The cache prevents multiple network requests for the same motor name across sessions.

  • Cached files are stored in ~/.rocketpy_cache and reused unless no_cache=True.

  • Filenames are sanitized to avoid invalid characters.

static load_from_thrustcurve_api(name, no_cache=False, **kwargs)[source]#

Creates a Motor instance by downloading a .eng file from the ThrustCurve API based on the given motor name.

Parameters:
  • name (str) – The motor name according to the API (e.g., “Cesaroni_M1670” or “M1670”). Both manufacturer-prefixed and shorthand names are commonly used; if multiple motors match the search, the first result is used.

  • **kwargs – Additional arguments passed to the Motor constructor or loader, such as dry_mass, nozzle_radius, etc.

  • no_cache (bool)

Returns:

instance – A new GenericMotor instance initialized using the downloaded .eng file.

Return type:

GenericMotor

Raises:
  • ValueError – If no motor is found or if the downloaded .eng data is missing.

  • requests.exceptions.RequestException – If a network or HTTP error occurs during the API call.

all_info()[source]#

Prints out all data and graphs available about the Motor.