Skip to content

Commit c674725

Browse files
ENH: Introduce Net Thrust with pressure corrections (#789)
* wind factor bug corrected the wind factor wasn't applied to the env.wind_velocity properties * BUG: StochasticModel visualize attributes of a uniform distribution It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in * variable names corrections * Corrections requested by the pylint test * ENH: Add pressure corrections for thrust in SolidMotor The thrust generated by a SolidMotor is now adjusted for the atmospheric pressure. To achieve that, a new attribute, 'vacuum_thrust', has been created. The 'net_thrust' is the result of 'vacuum_thrust' minus the atmospheric pressure multiplied by the nozzle area. * ENH: pylint recommendations done * ENH: net thrust method extended to the rest of the motor classes * BUG: __post_processed_variables inconsistent array * ENH: ruff reformatting * Update rocketpy/motors/motor.py Co-authored-by: Gui-FernandesBR <[email protected]> * ENH: Avoid breaking change * ENH: Pressure Thrust method added * BUG: call to the thrust function wrong * BUG: pressure thrust evaluated when motor is turned off * ENH: CHANGELOG updated * DOC: definition of exhaust velocity improved --------- Co-authored-by: Gui-FernandesBR <[email protected]>
1 parent 9f2644a commit c674725

File tree

7 files changed

+214
-34
lines changed

7 files changed

+214
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Attention: The newest changes should be on top -->
3535
- ENH: Implement Multivariate Rejection Sampling (MRS) [#738] (https://github.com/RocketPy-Team/RocketPy/pull/738)
3636
- ENH: Create a rocketpy file to store flight simulations [#800](https://github.com/RocketPy-Team/RocketPy/pull/800)
3737
- ENH: Support for the RSE file format has been added to the library [#798](https://github.com/RocketPy-Team/RocketPy/pull/798)
38+
- ENH: Introduce Net Thrust with pressure corrections [#789](https://github.com/RocketPy-Team/RocketPy/pull/789)
3839

3940
### Changed
4041

rocketpy/motors/empty_motor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def __init__(self):
1919
reshape_thrust_curve=False,
2020
interpolation_method="linear",
2121
coordinate_system_orientation="nozzle_to_combustion_chamber",
22+
reference_pressure=0,
2223
)
2324

2425
# Mass properties

rocketpy/motors/hybrid_motor.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class HybridMotor(Motor):
2929
"combustion_chamber_to_nozzle".
3030
HybridMotor.nozzle_radius : float
3131
Radius of motor nozzle outlet in meters.
32+
HybridMotor.nozzle_area : float
33+
Area of motor nozzle outlet in square meters.
3234
HybridMotor.nozzle_position : float
3335
Motor's nozzle outlet position in meters, specified in the motor's
3436
coordinate system. See
@@ -147,7 +149,11 @@ class HybridMotor(Motor):
147149
HybridMotor.propellant_I_22 and HybridMotor.propellant_I_33 for
148150
more information.
149151
HybridMotor.thrust : Function
150-
Motor thrust force, in Newtons, as a function of time.
152+
Motor thrust force obtained from thrust source, in Newtons, as a
153+
function of time.
154+
HybridMotor.vacuum_thrust : Function
155+
Motor thrust force when the rocket is in a vacuum. In Newtons, as a
156+
function of time.
151157
HybridMotor.total_impulse : float
152158
Total impulse of the thrust curve in N*s.
153159
HybridMotor.max_thrust : float
@@ -167,7 +173,10 @@ class HybridMotor(Motor):
167173
Total motor burn duration, in seconds. It is the difference between the
168174
``burn_out_time`` and the ``burn_start_time``.
169175
HybridMotor.exhaust_velocity : Function
170-
Propulsion gases exhaust velocity, assumed constant, in m/s.
176+
Effective exhaust velocity of the propulsion gases in m/s. Computed
177+
as the thrust divided by the mass flow rate. This corresponds to the
178+
actual exhaust velocity only when the nozzle exit pressure equals the
179+
atmospheric pressure.
171180
HybridMotor.burn_area : Function
172181
Total burn area considering all grains, made out of inner
173182
cylindrical burn area and grain top and bottom faces. Expressed
@@ -181,6 +190,9 @@ class HybridMotor(Motor):
181190
Method of interpolation used in case thrust curve is given
182191
by data set in .csv or .eng, or as an array. Options are 'spline'
183192
'akima' and 'linear'. Default is "linear".
193+
HybridMotor.reference_pressure : int, float
194+
Atmospheric pressure in Pa at which the thrust data was recorded.
195+
It will allow to obtain the net thrust in the Flight class.
184196
"""
185197

186198
def __init__( # pylint: disable=too-many-arguments
@@ -203,6 +215,7 @@ def __init__( # pylint: disable=too-many-arguments
203215
reshape_thrust_curve=False,
204216
interpolation_method="linear",
205217
coordinate_system_orientation="nozzle_to_combustion_chamber",
218+
reference_pressure=None,
206219
):
207220
"""Initialize Motor class, process thrust curve and geometrical
208221
parameters and store results.
@@ -298,6 +311,8 @@ class Function. Thrust units are Newtons.
298311
positions specified. Options are "nozzle_to_combustion_chamber" and
299312
"combustion_chamber_to_nozzle". Default is
300313
"nozzle_to_combustion_chamber".
314+
reference_pressure : int, float, optional
315+
Atmospheric pressure in Pa at which the thrust data was recorded.
301316
302317
Returns
303318
-------
@@ -314,6 +329,7 @@ class Function. Thrust units are Newtons.
314329
reshape_thrust_curve=reshape_thrust_curve,
315330
interpolation_method=interpolation_method,
316331
coordinate_system_orientation=coordinate_system_orientation,
332+
reference_pressure=reference_pressure,
317333
)
318334
self.liquid = LiquidMotor(
319335
thrust_source,
@@ -326,6 +342,7 @@ class Function. Thrust units are Newtons.
326342
reshape_thrust_curve,
327343
interpolation_method,
328344
coordinate_system_orientation,
345+
reference_pressure,
329346
)
330347
self.solid = SolidMotor(
331348
thrust_source,
@@ -346,6 +363,7 @@ class Function. Thrust units are Newtons.
346363
reshape_thrust_curve,
347364
interpolation_method,
348365
coordinate_system_orientation,
366+
reference_pressure,
349367
)
350368

351369
self.positioned_tanks = self.liquid.positioned_tanks
@@ -371,6 +389,11 @@ def exhaust_velocity(self):
371389
-------
372390
self.exhaust_velocity : Function
373391
Gas exhaust velocity of the motor.
392+
393+
Notes
394+
-----
395+
This corresponds to the actual exhaust velocity only when the nozzle
396+
exit pressure equals the atmospheric pressure.
374397
"""
375398
return Function(
376399
self.total_impulse / self.propellant_initial_mass
@@ -676,6 +699,7 @@ def from_dict(cls, data):
676699
grains_center_of_mass_position=data["grains_center_of_mass_position"],
677700
nozzle_position=data["nozzle_position"],
678701
throat_radius=data["throat_radius"],
702+
reference_pressure=data["reference_pressure"],
679703
)
680704

681705
for tank in data["positioned_tanks"]:

rocketpy/motors/liquid_motor.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class LiquidMotor(Motor):
2929
"combustion_chamber_to_nozzle".
3030
LiquidMotor.nozzle_radius : float
3131
Radius of motor nozzle outlet in meters.
32+
LiquidMotor.nozzle_area : float
33+
Area of motor nozzle outlet in square meters.
3234
LiquidMotor.nozzle_position : float
3335
Motor's nozzle outlet position in meters, specified in the motor's
3436
coordinate system. See
@@ -122,7 +124,11 @@ class LiquidMotor(Motor):
122124
LiquidMotor.propellant_I_22 and LiquidMotor.propellant_I_33 for
123125
more information.
124126
LiquidMotor.thrust : Function
125-
Motor thrust force, in Newtons, as a function of time.
127+
Motor thrust force obtained from thrust source, in Newtons, as a
128+
function of time.
129+
LiquidMotor.vacuum_thrust : Function
130+
Motor thrust force when the rocket is in a vacuum. In Newtons, as a
131+
function of time.
126132
LiquidMotor.total_impulse : float
127133
Total impulse of the thrust curve in N*s.
128134
LiquidMotor.max_thrust : float
@@ -142,7 +148,13 @@ class LiquidMotor(Motor):
142148
Total motor burn duration, in seconds. It is the difference between the
143149
burn_out_time and the burn_start_time.
144150
LiquidMotor.exhaust_velocity : Function
145-
Propulsion gases exhaust velocity in m/s.
151+
Effective exhaust velocity of the propulsion gases in m/s. Computed
152+
as the thrust divided by the mass flow rate. This corresponds to the
153+
actual exhaust velocity only when the nozzle exit pressure equals the
154+
atmospheric pressure.
155+
LiquidMotor.reference_pressure : int, float
156+
Atmospheric pressure in Pa at which the thrust data was recorded.
157+
It will allow to obtain the net thrust in the Flight class.
146158
"""
147159

148160
def __init__(
@@ -157,6 +169,7 @@ def __init__(
157169
reshape_thrust_curve=False,
158170
interpolation_method="linear",
159171
coordinate_system_orientation="nozzle_to_combustion_chamber",
172+
reference_pressure=None,
160173
):
161174
"""Initialize LiquidMotor class, process thrust curve and geometrical
162175
parameters and store results.
@@ -230,6 +243,8 @@ class Function. Thrust units are Newtons.
230243
positions specified. Options are "nozzle_to_combustion_chamber"
231244
and "combustion_chamber_to_nozzle". Default is
232245
"nozzle_to_combustion_chamber".
246+
reference_pressure : int, float, optional
247+
Atmospheric pressure in Pa at which the thrust data was recorded.
233248
"""
234249
super().__init__(
235250
thrust_source=thrust_source,
@@ -242,6 +257,7 @@ class Function. Thrust units are Newtons.
242257
reshape_thrust_curve=reshape_thrust_curve,
243258
interpolation_method=interpolation_method,
244259
coordinate_system_orientation=coordinate_system_orientation,
260+
reference_pressure=reference_pressure,
245261
)
246262

247263
self.positioned_tanks = []
@@ -264,7 +280,8 @@ def exhaust_velocity(self):
264280
-----
265281
The exhaust velocity is computed as the ratio of the thrust and the
266282
mass flow rate. Therefore, this will vary with time if the mass flow
267-
rate varies with time.
283+
rate varies with time. This corresponds to the actual exhaust velocity
284+
only when the nozzle exit pressure equals the atmospheric pressure.
268285
"""
269286
times, thrusts = self.thrust.source[:, 0], self.thrust.source[:, 1]
270287
mass_flow_rates = self.mass_flow_rate(times)
@@ -511,6 +528,7 @@ def from_dict(cls, data):
511528
nozzle_position=data["nozzle_position"],
512529
interpolation_method=data["interpolate"],
513530
coordinate_system_orientation=data["coordinate_system_orientation"],
531+
reference_pressure=data["reference_pressure"],
514532
)
515533

516534
for tank in data["positioned_tanks"]:

0 commit comments

Comments
 (0)