Skip to content

Commit ed296d6

Browse files
phmbressanGui-FernandesBR
authored andcommitted
BUG: Zero mass flow rates being ignored on LiquidMotors.
1 parent 251cf93 commit ed296d6

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Attention: The newest changes should be on top -->
4343

4444
### Fixed
4545

46+
- BUG: Zero Mass Flow Rate in Liquid Motors breaks Exhaust Velocity [#677](https://github.com/RocketPy-Team/RocketPy/pull/677)
4647
- DOC: Fix documentation dependencies [#651](https://github.com/RocketPy-Team/RocketPy/pull/651)
4748
- DOC: Fix documentation warnings [#645](https://github.com/RocketPy-Team/RocketPy/pull/645)
4849
- BUG: Rotational EOMs Not Relative To CDM [#674](https://github.com/RocketPy-Team/RocketPy/pull/674)

rocketpy/motors/liquid_motor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ def exhaust_velocity(self):
266266
"""
267267
times, thrusts = self.thrust.source[:, 0], self.thrust.source[:, 1]
268268
mass_flow_rates = self.mass_flow_rate(times)
269+
exhaust_velocity = np.zeros_like(mass_flow_rates)
269270

270271
# Compute exhaust velocity only for non-zero mass flow rates
271272
valid_indices = mass_flow_rates != 0
272-
valid_times = times[valid_indices]
273-
valid_thrusts = thrusts[valid_indices]
274-
valid_mass_flow_rates = mass_flow_rates[valid_indices]
275273

276-
ext_vel = -valid_thrusts / valid_mass_flow_rates
274+
exhaust_velocity[valid_indices] = (
275+
-thrusts[valid_indices] / mass_flow_rates[valid_indices]
276+
)
277277

278-
return np.column_stack([valid_times, ext_vel])
278+
return np.column_stack([times, exhaust_velocity])
279279

280280
@funcify_method("Time (s)", "Propellant Mass (kg)")
281281
def propellant_mass(self):

rocketpy/motors/motor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ def total_mass_flow_rate(self):
483483
rate should not be greater than `total_mass_flow_rate`, otherwise the
484484
grains mass flow rate will be negative, losing physical meaning.
485485
"""
486-
return -1 * self.thrust / self.exhaust_velocity
486+
average_exhaust_velocity = self.total_impulse / self.propellant_initial_mass
487+
return self.thrust / -average_exhaust_velocity
487488

488489
@property
489490
@abstractmethod

0 commit comments

Comments
 (0)