RocketPy-Team / RocketPy

Next generation High-Power Rocketry 6-DOF Trajectory Simulation
https://docs.rocketpy.org/
MIT License
570 stars 137 forks source link

BUG: Swap `rocket.total_mass.differentiate` for `motor.total_mass_flow rate` #585

Closed MateusStano closed 2 months ago

MateusStano commented 2 months ago

Pull request type

Checklist

Description

If a simulation is using the new EOMs and has a time node at the motor burn-out time, an outlier acceleration value might be calculated:

image

This is due to the second-order differentiation of rocket.total_mass blowing up due to numerical errors. Swapping this to motor.total_mass_flow_rate gives the following:

image

This makes u_dot_generalized more similar to the old udot

Breaking change

Gui-FernandesBR commented 2 months ago

Nice one.

Let me make a question, why not creating a Rocket.total_mass_flow_rate in the Rocket class and then accessing it in the u_dot_generalized? .

This would allow for a better readability in the flight class, plus it would allow us to access the mass flow rate directly from the rocket object.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 72.88%. Comparing base (61bf4d7) to head (6b26f61). Report is 1 commits behind head on develop.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #585 +/- ## ======================================== Coverage 72.87% 72.88% ======================================== Files 59 59 Lines 9590 9591 +1 ======================================== + Hits 6989 6990 +1 Misses 2601 2601 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Gui-FernandesBR commented 2 months ago

More questions:

MateusStano commented 2 months ago

Let me make a question, why not creating a Rocket.total_mass_flow_rate in the Rocket class and then accessing it in the u_dot_generalized? .

Sounds like something nice to have. Added it in https://github.com/RocketPy-Team/RocketPy/pull/585/commits/8ee2c95f6961e94f93ef569303588c643647778f