Skip to content

Commit e4e83ae

Browse files
committed
MNT: change exhaust velocity to discretize on definition.
1 parent 9b169d1 commit e4e83ae

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

rocketpy/motors/hybrid_motor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ..mathutils.function import funcify_method, reset_funcified_methods
1+
from ..mathutils.function import Function, funcify_method, reset_funcified_methods
22
from ..plots.hybrid_motor_plots import _HybridMotorPlots
33
from ..prints.hybrid_motor_prints import _HybridMotorPrints
44
from .liquid_motor import LiquidMotor
@@ -372,7 +372,9 @@ def exhaust_velocity(self):
372372
self.exhaust_velocity : Function
373373
Gas exhaust velocity of the motor.
374374
"""
375-
return self.total_impulse / self.propellant_initial_mass
375+
return Function(
376+
self.total_impulse / self.propellant_initial_mass
377+
).set_discrete_based_on_model(self.thrust)
376378

377379
@funcify_method("Time (s)", "Mass (kg)")
378380
def propellant_mass(self):

rocketpy/motors/motor.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,7 @@ def total_mass_flow_rate(self):
450450
rate should not be greater than `total_mass_flow_rate`, otherwise the
451451
grains mass flow rate will be negative, losing physical meaning.
452452
"""
453-
return (
454-
-1
455-
* self.thrust
456-
/ self.exhaust_velocity.set_discrete_based_on_model(self.thrust)
457-
)
453+
return -1 * self.thrust / self.exhaust_velocity
458454

459455
@property
460456
@abstractmethod
@@ -1228,19 +1224,17 @@ def exhaust_velocity(self):
12281224
self.exhaust_velocity : Function
12291225
Gas exhaust velocity of the motor.
12301226
"""
1231-
return self.total_impulse / self.propellant_initial_mass
1227+
return Function(
1228+
self.total_impulse / self.propellant_initial_mass
1229+
).set_discrete_based_on_model(self.thrust)
12321230

12331231
@funcify_method("Time (s)", "Mass Flow Rate (kg/s)")
12341232
def mass_flow_rate(self):
12351233
"""Time derivative of propellant mass. Assumes constant exhaust
12361234
velocity. The formula used is the opposite of thrust divided by
12371235
exhaust velocity.
12381236
"""
1239-
return (
1240-
-1
1241-
* self.thrust
1242-
/ self.exhaust_velocity.set_discrete_based_on_model(self.thrust)
1243-
)
1237+
return -1 * self.thrust / self.exhaust_velocity
12441238

12451239
@funcify_method("Time (s)", "center of mass (m)")
12461240
def center_of_propellant_mass(self):

rocketpy/motors/solid_motor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ def exhaust_velocity(self):
381381
self.exhaust_velocity : Function
382382
Gas exhaust velocity of the motor.
383383
"""
384-
return self.total_impulse / self.propellant_initial_mass
384+
return Function(
385+
self.total_impulse / self.propellant_initial_mass
386+
).set_discrete_based_on_model(self.thrust)
385387

386388
@property
387389
def propellant_initial_mass(self):

0 commit comments

Comments
 (0)