From 8ee2c95f6961e94f93ef569303588c643647778f Mon Sep 17 00:00:00 2001 From: MateusStano Date: Wed, 17 Apr 2024 22:16:59 +0200 Subject: [PATCH] ENH: create rocket total_mass_flow_rate attribute --- rocketpy/rocket/rocket.py | 4 ++++ rocketpy/simulation/flight.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index aaf585091..c074afc8d 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -81,6 +81,9 @@ class Rocket: Function of time expressing the total mass of the rocket, defined as the sum of the propellant mass and the rocket mass without propellant. + Rocket.total_mass_flow_rate : Function + Time derivative of rocket's total mass in kg/s as a function + of time as obtained by the thrust source of the added motor. Rocket.thrust_to_weight : Function Function of time expressing the motor thrust force divided by rocket weight. The gravitational acceleration is assumed as 9.80665 m/s^2. @@ -764,6 +767,7 @@ def add_motor(self, motor, position): self.motor.center_of_dry_mass_position * _ + self.motor_position ) self.nozzle_position = self.motor.nozzle_position * _ + self.motor_position + self.total_mass_flow_rate = self.motor.total_mass_flow_rate self.evaluate_dry_mass() self.evaluate_total_mass() self.evaluate_center_of_dry_mass() diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 6959c1698..badbc31e4 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1645,8 +1645,8 @@ def u_dot_generalized(self, t, u, post_processing=False): # Retrieve necessary quantities rho = self.env.density.get_value_opt(z) total_mass = self.rocket.total_mass.get_value_opt(t) - total_mass_dot = self.rocket.motor.total_mass_flow_rate(t) - total_mass_ddot = self.rocket.motor.total_mass_flow_rate.differentiate(t) + total_mass_dot = self.rocket.total_mass_flow_rate.get_value_opt(t) + total_mass_ddot = self.rocket.total_mass_flow_rate.differentiate(t) ## CM position vector and time derivatives relative to CDM in body frame r_CM_z = ( -1