ENH: Add the Coriolis Force to the Flight class
Pull request type
- [x] Code changes (bugfix, features)
Checklist
- [ ] Tests for the changes have been added (if needed)
- [ ] Docs have been reviewed and added / updated
- [ ] Lint (
black rocketpy/ tests/) has passed locally - [ ] All tests (
pytest tests -m slow --runslow) have passed locally - [ ]
CHANGELOG.mdhas been updated (if relevant)
Current behavior
Currently, RocketPy doesn't account for the Coriolis force, even though the Flight Coordinate System is not truly an inertial reference frame.
New behavior
-
Environmentclass: A new attribute has been added: the Earth's angular velocity vector. Additionally, a new function has been implemented to compute it. -
Flightclass: The Coriolis acceleration has been added to thevdotvector in theu_dot_generalizedfunction. A theoretical explanation justifying this implementation is attached below.
Breaking change
- [ ] Yes
- [ ] No
Theory
@Gui-FernandesBR All good on my side!!
Thank you, @Gui-FernandesBR , I appreciate it!
Sure. I'm looking forward to the third check. If you have any doubts or suggestions, please, let me know.
Before we start working on updating the tests, does any of you have anything to say regarding this PR, @phmbressan @MateusStano ? another review would be appreciated here.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 80.11%. Comparing base (
4df0b38) to head (5ca314d). Report is 22 commits behind head on develop.
Additional details and impacted files
@@ Coverage Diff @@
## develop #799 +/- ##
===========================================
+ Coverage 79.11% 80.11% +0.99%
===========================================
Files 96 98 +2
Lines 11575 12057 +482
===========================================
+ Hits 9158 9659 +501
+ Misses 2417 2398 -19
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Really awesome @kevin-alcaniz!
I took the liberty to add everything that was missing here since it had been so long.
From you implementation though, there was only one mistake: you were applying an extra unnecessary rotation to the earth_rotation_vector. Taking that out made the simulation behavior make more sense.
I also added the coriolis effect to the parachute udot.
For documentation purposes here is a few plots exemplifying the correct expected behavior with the Coriolis acceleration. The simulation here has no wind, no parachutes, and no aerodynamic forces (0 drag and no aero surfaces)
- Environment at Latitude 0, Inclination = 90, Heading = 0. There is no North-South drift, only westward drift:
- Same conditions, this time showing the effect of increasing latitude. As expected, drift decreases as it gets closer to the poles
Now some cases showing the effect of north vs south hemisphere. The expected behavior can be seen from analyzing the added acceleration from the Coriolis effect (written in the Flight Coord System):
$$ a_c = -2 \omega_E \times v = 2 \begin{bmatrix} - v_z \omega \cos{\phi} + v_y \omega \sin{\phi} \\ - v_x \omega \sin{\phi} \\ v_x \omega \cos{\phi} \end{bmatrix} $$
Wherever the $\sin$ terms appear, a difference due to hemisphere is expected. With $v_x$ positive, we expect the northern hemisphere launch to drift southwards, while the southern hemisphere drifts northwards. Opposite should happen for $v_x$ negative
For $v_y$ positive, the northern hemisphere launch should drift further eastwards than the southern hemisphere launch. Opposite for the negative case
- Free falling rocket beginning at 80000 m. Zero initial velocity.
- Free falling rocket beginning at 80000 m. Positive X (eastwards) velocity.
- Free falling rocket beginning at 80000 m. Negative X (westwards) velocity.
- Free falling rocket beginning at 80000 m. Positive Y (northwards) velocity.
- Free falling rocket beginning at 80000 m. Negative Y (southwards) velocity.
Now we just a need a final approve and we can merge this! @Gui-FernandesBR @phmbressan