SolidMotor Class Usage#

Here we explore different features of the SolidMotor class.

Let’s start by importing the SolidMotor class.

[ ]:
from rocketpy import SolidMotor
[ ]:
# These lines are here for debugging purposes only.
%load_ext autoreload
%autoreload 2

Thrust Source#

The thrust source is of most importance when analyzing several trajectory attributes, including the out of rail velocity, thrust to weight ratio, apogee and many others. Let’s create a new motor and take a closer look at this functionality.

Constant Thrust#

When passing an int or float, the thrust will be considered constant in time.

[ ]:
solid_constant = SolidMotor(
    thrust_source=1500,
    dry_mass=1.815,
    dry_inertia=(0.125, 0.125, 0.002),
    center_of_dry_mass=0.317,
    grains_center_of_mass_position=0.397,
    burn_time=3.9,
    grain_number=5,
    grain_separation=5 / 1000,
    grain_density=1815,
    grain_outer_radius=33 / 1000,
    grain_initial_inner_radius=15 / 1000,
    grain_initial_height=120 / 1000,
    nozzle_radius=33 / 1000,
    throat_radius=11 / 1000,
    interpolation_method="linear",
    nozzle_position=0,
    coordinate_system_orientation="nozzle_to_combustion_chamber",
)

Let’s call the info() method to see what kind of information we get. Alternatively, we could use the all_info() method to get a more complete output.

[ ]:
solid_constant.info()

Thrust From Static Firings (CSV Files)#

Usually one has much more precise information about the motor and wishes to specify a directory containing a .csv file (the file shall contain no headers), which contains thrust (Newtons) as a function of time (seconds).

That can be done as follows:

[ ]:
solid_csv = SolidMotor(
    thrust_source=r"../../data/motors/keron/thrustCurve.csv",
    dry_mass=1.815,
    dry_inertia=(0.125, 0.125, 0.002),
    center_of_dry_mass=0.317,
    grains_center_of_mass_position=0.397,
    burn_time=3.9,
    grain_number=5,
    grain_separation=5 / 1000,
    grain_density=1815,
    grain_outer_radius=33 / 1000,
    grain_initial_inner_radius=15 / 1000,
    grain_initial_height=120 / 1000,
    nozzle_radius=33 / 1000,
    throat_radius=11 / 1000,
    interpolation_method="linear",
    nozzle_position=0,
    coordinate_system_orientation="nozzle_to_combustion_chamber",
)
[ ]:
solid_csv.info()

Eng Files Are Also Supported! (RASP)#

Most rocket motors providers share the thrust curve from their motors using the RASP file format (.eng files). RocketPy can import such files as the thrust source. Furthermore, if you have a thrust curve in a .csvfile, RocketPy can also read your data and exported as a .eng file.

[ ]:
solid_eng = SolidMotor(
    thrust_source="../../data/motors/Cesaroni_M1670.eng",
    dry_mass=1.815,
    dry_inertia=(0.125, 0.125, 0.002),
    center_of_dry_mass=0.317,
    grains_center_of_mass_position=0.397,
    burn_time=3.9,
    grain_number=5,
    grain_separation=5 / 1000,
    grain_density=1815,
    grain_outer_radius=33 / 1000,
    grain_initial_inner_radius=15 / 1000,
    grain_initial_height=120 / 1000,
    nozzle_radius=33 / 1000,
    throat_radius=11 / 1000,
    interpolation_method="linear",
    nozzle_position=0,
    coordinate_system_orientation="nozzle_to_combustion_chamber",
)

This time we want to try the all_info() to capture more details about the motor.

[ ]:
solid_eng.all_info()

One More Option…#

There is also a fourth option where one specifies the thrust source parameter by passing a callable function like below.

Lambda functions are particularly useful in Python, and therefore the SolidMotor class also supports them. Let’s see how to use it.

[ ]:
solid_lambda = SolidMotor(
    thrust_source=lambda x: 1 / (x + 1),
    dry_mass=1.815,
    dry_inertia=(0.125, 0.125, 0.002),
    center_of_dry_mass=0.317,
    grains_center_of_mass_position=0.397,
    burn_time=3.9,
    grain_number=5,
    grain_separation=5 / 1000,
    grain_density=1815,
    grain_outer_radius=33 / 1000,
    grain_initial_inner_radius=15 / 1000,
    grain_initial_height=120 / 1000,
    nozzle_radius=33 / 1000,
    throat_radius=11 / 1000,
    interpolation_method="linear",
    nozzle_position=0,
    coordinate_system_orientation="nozzle_to_combustion_chamber",
)
[ ]:
solid_lambda.info()

Reshaping and interpolating the thrust curve#

We know explore the reshape feature concerning the thrust curve and the interpolation method. Sometimes is useful to rescale a given curve to match new specifications when impulse and burn out time are expected to vary only slightly. That can be done how we know exemplify by setting the new burn out time in seconds to be ten and the new total impulse to be 6000 Ns.

[ ]:
solid_reshaped = SolidMotor(
    thrust_source=r"../../data/motors/keron/thrustCurve.csv",
    dry_mass=1.815,
    dry_inertia=(0.125, 0.125, 0.002),
    reshape_thrust_curve=[10, 6000],
    center_of_dry_mass=0.317,
    grains_center_of_mass_position=0.397,
    burn_time=3.9,
    grain_number=5,
    grain_separation=5 / 1000,
    grain_density=1815,
    grain_outer_radius=33 / 1000,
    grain_initial_inner_radius=15 / 1000,
    grain_initial_height=120 / 1000,
    nozzle_radius=33 / 1000,
    throat_radius=11 / 1000,
    interpolation_method="linear",
    nozzle_position=0,
    coordinate_system_orientation="nozzle_to_combustion_chamber",
)

Pay close attention to the newly generated curve and be aware of the changes the rescale has produced regarding the physical quantities.

[ ]:
solid_reshaped.all_info()

Also one is able to specify a certain interpolation method. That can be done by simply changing the ‘interpolation_method’ parameter to ‘spline’ , ‘akima’ or ‘linear’. Default is set to linear.

Key Assumptions and Grain Configurations#

One might wonder how some parameters were calculated and what key assumptions were made. Regarding grain configuration one should pay close attention to the fact that only BATES grain configuration is supported.

Finally, another key physical assumption is that constant exhaust velocity is assumed to be the case at all times which is in fact equivalent to saying that specific impulse is constant.