From e62f249dbed46174f355f31b2fefd19e614e03aa Mon Sep 17 00:00:00 2001 From: Ishan Date: Fri, 5 Dec 2025 01:50:23 +0530 Subject: [PATCH 1/6] MNT: updated flight.py 3dof for net_thrust - MNT: added net_thrust to u_dot_generalized_3dof in flight.py --- rocketpy/simulation/flight.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 84ab880dc..3e0204ece 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -2041,11 +2041,20 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False): R3 += fz # Thrust and weight - thrust = self.rocket.motor.thrust.get_value_opt(t) + # Calculate net thrust including pressure thrust correction if motor is burning + if self.rocket.motor.burn_start_time < t < self.rocket.motor.burn_out_time: + pressure = self.env.pressure.get_value_opt(z) + net_thrust = max( + self.rocket.motor.thrust.get_value_opt(t) + + self.rocket.motor.pressure_thrust(pressure), + 0, + ) + else: + net_thrust = 0 gravity = self.env.gravity.get_value_opt(z) weight_body = Kt @ Vector([0, 0, -total_mass * gravity]) - total_force = Vector([0, 0, thrust]) + weight_body + Vector([R1, R2, R3]) + total_force = Vector([0, 0, net_thrust]) + weight_body + Vector([R1, R2, R3]) # Dynamics v_dot = K @ (total_force / total_mass) @@ -2133,7 +2142,7 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False): if post_processing: self.__post_processed_variables.append( - [t, *v_dot, *w_dot, R1, R2, R3, 0, 0, 0] + [t, *v_dot, *w_dot, R1, R2, R3, 0, 0, 0, net_thrust] ) return u_dot From 379119f67cfec76dffc7cf340eef6c09b08fc97d Mon Sep 17 00:00:00 2001 From: Ishan Date: Fri, 5 Dec 2025 02:00:25 +0530 Subject: [PATCH 2/6] TST: net_thrust availability test on 3 dof flight --- .../simulation/test_flight_3dof.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/simulation/test_flight_3dof.py b/tests/integration/simulation/test_flight_3dof.py index ef4c35c14..ddb2269f2 100644 --- a/tests/integration/simulation/test_flight_3dof.py +++ b/tests/integration/simulation/test_flight_3dof.py @@ -301,3 +301,25 @@ def test_weathercock_anti_aligned_uses_perp_axis_and_evolves(flight_weathercock_ assert e_dot_magnitude > 1e-6, ( "Quaternion derivatives should be non-zero for anti-aligned" ) + + +def test_3dof_net_thrust_available(flight_3dof): + """Tests that net_thrust property is available in 3 DOF mode. + The net_thrust property is required for energy plots and should be + available in both 3 DOF and 6 DOF modes. + Parameters + ---------- + flight_3dof : rocketpy.simulation.flight.Flight + A Flight object configured for 3-DOF simulation. + """ + # Check that net_thrust can be accessed + assert hasattr(flight_3dof, "net_thrust"), "net_thrust attribute not found" + + # Check that it returns a Function object with data + net_thrust = flight_3dof.net_thrust + assert len(net_thrust) > 0, "net_thrust should have data points" + + # Verify that thrust_power can be computed (uses net_thrust internally) + assert hasattr(flight_3dof, "thrust_power"), "thrust_power attribute not found" + thrust_power = flight_3dof.thrust_power + assert len(thrust_power) > 0, "thrust_power should have data points" From d532eb8c99350f5a6954c20a65337231d3d18e07 Mon Sep 17 00:00:00 2001 From: Ishan Date: Fri, 5 Dec 2025 02:12:57 +0530 Subject: [PATCH 3/6] MNT: docstring adjustment in net_thrust test in test_flight_3dof.py --- tests/integration/simulation/test_flight_3dof.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/simulation/test_flight_3dof.py b/tests/integration/simulation/test_flight_3dof.py index ddb2269f2..288caf882 100644 --- a/tests/integration/simulation/test_flight_3dof.py +++ b/tests/integration/simulation/test_flight_3dof.py @@ -307,6 +307,7 @@ def test_3dof_net_thrust_available(flight_3dof): """Tests that net_thrust property is available in 3 DOF mode. The net_thrust property is required for energy plots and should be available in both 3 DOF and 6 DOF modes. + Parameters ---------- flight_3dof : rocketpy.simulation.flight.Flight From 13a3ac1270b8fe58a83358d22c00a41e91c0c582 Mon Sep 17 00:00:00 2001 From: Ishan Date: Fri, 5 Dec 2025 02:16:00 +0530 Subject: [PATCH 4/6] MNT: lint check update --- tests/integration/simulation/test_flight_3dof.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/simulation/test_flight_3dof.py b/tests/integration/simulation/test_flight_3dof.py index 288caf882..94a4e33eb 100644 --- a/tests/integration/simulation/test_flight_3dof.py +++ b/tests/integration/simulation/test_flight_3dof.py @@ -307,7 +307,7 @@ def test_3dof_net_thrust_available(flight_3dof): """Tests that net_thrust property is available in 3 DOF mode. The net_thrust property is required for energy plots and should be available in both 3 DOF and 6 DOF modes. - + Parameters ---------- flight_3dof : rocketpy.simulation.flight.Flight From d3dc0d622b988487c9be43ccb061e66d4fe0591c Mon Sep 17 00:00:00 2001 From: Ishan Date: Fri, 5 Dec 2025 02:35:40 +0530 Subject: [PATCH 5/6] DOC: changelog.md update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75e20416e..1a772b28f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Attention: The newest changes should be on top --> ### Added +- MNT: net thrust addition to 3 dof in flight class [#907] (https://github.com/RocketPy-Team/RocketPy/pull/907) - ENH: 3-dof lateral motion improvement [#883](https://github.com/RocketPy-Team/RocketPy/pull/883) - ENH: Add multi-dimensional drag coefficient support (Cd as function of M, Re, α) [#875](https://github.com/RocketPy-Team/RocketPy/pull/875) - ENH: Add save functionality to `_MonteCarloPlots.all` method [#848](https://github.com/RocketPy-Team/RocketPy/pull/848) From 5104be45d664646b7070d0f7d87faad0106deb70 Mon Sep 17 00:00:00 2001 From: Ishan Date: Fri, 5 Dec 2025 02:39:09 +0530 Subject: [PATCH 6/6] DOC: bug changelog update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a772b28f..abca56e18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Attention: The newest changes should be on top --> ### Fixed +- BUG: energy_data plot not working for 3 dof sims [[#906](https://github.com/RocketPy-Team/RocketPy/issues/906)] - BUG: Fix CSV column header spacing in FlightDataExporter [#864](https://github.com/RocketPy-Team/RocketPy/issues/864) - BUG: Fix parallel Monte Carlo simulation showing incorrect iteration count [#806](https://github.com/RocketPy-Team/RocketPy/pull/806)