From e5c75334b08313de1a2bfbeda15dd22571120187 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Tue, 9 Apr 2024 17:59:22 +0200 Subject: [PATCH 1/4] ENH: use mass_flow_rate instead of differentiate --- rocketpy/simulation/flight.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 77632d2f2..6959c1698 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.total_mass.differentiate(t) - total_mass_ddot = self.rocket.total_mass.differentiate(t, order=2) + total_mass_dot = self.rocket.motor.total_mass_flow_rate(t) + total_mass_ddot = self.rocket.motor.total_mass_flow_rate.differentiate(t) ## CM position vector and time derivatives relative to CDM in body frame r_CM_z = ( -1 From e2a94c8577bf2f2bcfe19a167793cac6ea3b5f2b Mon Sep 17 00:00:00 2001 From: MateusStano Date: Tue, 9 Apr 2024 18:03:08 +0200 Subject: [PATCH 2/4] TST: fix tests --- tests/test_flight.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_flight.py b/tests/test_flight.py index db882e185..4fb4036eb 100644 --- a/tests/test_flight.py +++ b/tests/test_flight.py @@ -604,12 +604,12 @@ def test_max_values(flight_calisto_robust): calculated by hand, it was just copied from the test results. This is because the expected values are not easy to calculate by hand, and the results are not expected to change. If the results change, the test will - fail, and the expected values must be updated. If if want to update the - values, always double check if the results are really correct. Acceptable - reasons for changes in the results are: 1) changes in the code that - improve the accuracy of the simulation, 2) a bug was found and fixed. Keep - in mind that other tests may be more accurate than this one, for example, - the acceptance tests, which are based on the results of real flights. + fail, and the expected values must be updated. If the values are updated, + always double check if the results are really correct. Acceptable reasons + for changes in the results are: 1) changes in the code that improve the + accuracy of the simulation, 2) a bug was found and fixed. Keep in mind that + other tests may be more accurate than this one, for example, the acceptance + tests, which are based on the results of real flights. Parameters ---------- @@ -622,7 +622,7 @@ def test_max_values(flight_calisto_robust): assert pytest.approx(105.2774, abs=atol) == test.max_acceleration_power_on assert pytest.approx(105.2774, abs=atol) == test.max_acceleration assert pytest.approx(0.85999, abs=atol) == test.max_mach_number - assert pytest.approx(285.90240, abs=atol) == test.max_speed + assert pytest.approx(285.94948, abs=atol) == test.max_speed def test_rail_buttons_forces(flight_calisto_custom_wind): From 8ee2c95f6961e94f93ef569303588c643647778f Mon Sep 17 00:00:00 2001 From: MateusStano Date: Wed, 17 Apr 2024 22:16:59 +0200 Subject: [PATCH 3/4] 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 From 6b26f6153d070d269a872314f85d70f7a6d25443 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Wed, 17 Apr 2024 22:19:16 +0200 Subject: [PATCH 4/4] DEV: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8408aa368..b52d7d01d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- BUG: Swap rocket.total_mass.differentiate for motor.total_mass_flow rate [#585](https://github.com/RocketPy-Team/RocketPy/pull/585) - BUG: export_eng 'Motor' method would not work for liquid motors. [#559](https://github.com/RocketPy-Team/RocketPy/pull/559) ## [v1.2.2] - 2024-03-22