GenericMotor Class Usage#
Here we explore different features of the GenericMotor class.
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.
Creating a Generic Motor#
To define a generic motor, we will need a few information about our motor:
The thrust source file, which is a file containing the thrust curve of the motor. This file can be a .eng file, a .rse file, or a .csv file. See more details in Thrust Source Details
- A few physical parameters, which the most important are:
The burn time of the motor.
The combustion chamber radius;
The combustion chamber height;
The combustion chamber position;
The propellant initial mass;
The nozzle radius;
The motor dry mass.
The usage of the GenericMotor class is very similar to the other motor classes. See more details in the SolidMotor Class Usage, LiquidMotor Class Usage, and HybridMotor Class Usage pages.
from rocketpy.motors import GenericMotor
# Define the motor parameters
motor = GenericMotor(
thrust_source = "../data/motors/cesaroni/Cesaroni_M1670.eng",
burn_time = 3.9,
chamber_radius = 33 / 100,
chamber_height = 600 / 1000,
chamber_position = 0,
propellant_initial_mass = 2.5,
nozzle_radius = 33 / 1000,
dry_mass = 1.815,
center_of_dry_mass_position = 0,
dry_inertia = (0.125, 0.125, 0.002),
nozzle_position = 0,
reshape_thrust_curve = False,
interpolation_method = "linear",
coordinate_system_orientation = "nozzle_to_combustion_chamber",
)
# Print the motor information
motor.info()
Motor Details
Total Burning Time: 3.9 s
Total Propellant Mass: 2.500 kg
Structural Mass Ratio: 0.421
Average Propellant Exhaust Velocity: 2410.540 m/s
Average Thrust: 1545.218 N
Maximum Thrust: 2200.0 N at 0.15 s after ignition.
Total Impulse: 6026.350 Ns
Note
The GenericMotor is a simplified model of a rocket motor. If you need more accurate results, use the SolidMotor, HybridMotor or LiquidMotor classes.
The load_from_eng_file method#
The GenericMotor class has a method called load_from_eng_file that allows
the user to build a GenericMotor object by providing just the path to an .eng file.
The parameters available in the method are the same as the ones used in the constructor of the GenericMotor class. But the method will automatically read the .eng file and extract the required information if the user does not provide it. In this case, the following assumptions about the most relevant parameters are made:
The
chamber_radiusis assumed to be the same as the motor diameter in the .eng file;The
chamber_heightis assumed to be the same as the motor length in the .eng file;The
chamber_positionis assumed to be 0;The
propellant_initial_massis assumed to be the same as the propellant mass in the .eng file;The
nozzle_radiusis assumed to be 85% of thechamber_radius;The
dry_massis assumed to be the total mass minus the propellant mass in the .eng file;
As an example, we can demonstrate:
from rocketpy.motors import GenericMotor
# Load the motor from an .eng file
motor = GenericMotor.load_from_eng_file("../data/motors/cesaroni/Cesaroni_M1670.eng")
# Print the motor information
motor.info()
Motor Details
Total Burning Time: 3.9 s
Total Propellant Mass: 3.101 kg
Structural Mass Ratio: 0.407
Average Propellant Exhaust Velocity: 1943.357 m/s
Average Thrust: 1545.218 N
Maximum Thrust: 2200.0 N at 0.15 s after ignition.
Total Impulse: 6026.350 Ns
Although the load_from_eng_file method is very useful, it is important to
note that the user can still provide the parameters manually if needed.
Tip
The load_from_eng_file method is a very useful tool for simulating motors when the user does not have all the information required to build a SolidMotor yet.
The load_from_thrustcurve_api method#
The GenericMotor class provides a convenience loader that downloads an
.eng file from the ThrustCurve.org public API and builds a GenericMotor
instance from it. This is useful when you know a motor designation (for example
"M1670") but do not want to manually download and save the .eng file.
The method also includes automatic caching for faster repeated usage.
Downloaded .eng files are stored in the user’s RocketPy cache folder
(~/.rocketpy_cache). When a subsequent request is made for the same motor,
the cached copy is used instead of performing another network request.
You can bypass the cache by setting no_cache=True:
no_cache=False(default): Use a cached file if available; otherwise download and store it.no_cache=True: Always fetch a fresh version from the API and overwrite the cache.
Note
This method performs network requests to the ThrustCurve API unless a cached
version exists. For automated testing or fully reproducible workflows, prefer
local .eng files or set no_cache=True explicitly.
Example#
from rocketpy.motors import GenericMotor
# Build a motor by name (requires network access unless cached)
motor = GenericMotor.load_from_thrustcurve_api("M1670")
# Print the motor information
motor.info()
Motor Details
Total Burning Time: 3.9 s
Total Propellant Mass: 3.101 kg
Structural Mass Ratio: 0.407
Average Propellant Exhaust Velocity: 1943.357 m/s
Average Thrust: 1545.218 N
Maximum Thrust: 2200.0 N at 0.15 s after ignition.
Total Impulse: 6026.350 Ns
Using the no_cache option#
If you want to force RocketPy to ignore the cache and download a fresh copy every time, use:
motor = GenericMotor.load_from_thrustcurve_api("M1670", no_cache=True)
motor.info()
Motor Details
Total Burning Time: 3.9 s
Total Propellant Mass: 3.101 kg
Structural Mass Ratio: 0.407
Average Propellant Exhaust Velocity: 1943.357 m/s
Average Thrust: 1545.218 N
Maximum Thrust: 2200.0 N at 0.15 s after ignition.
Total Impulse: 6026.350 Ns