Skip to content

BUG: fix fin_flutter_analysis for flights without wind - #1250

Open
rundvd wants to merge 1 commit into
RocketPy-Team:developfrom
rundvd:bug/fin-flutter-no-wind
Open

rundvd wants to merge 1 commit into
RocketPy-Team:developfrom
rundvd:bug/fin-flutter-no-wind

Conversation

@rundvd

@rundvd rundvd commented Dec 1, 2026

Copy link
Copy Markdown

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added
  • ruff check, ruff format --check and pylint pass on the changed files
  • tests/unit and tests/integration/simulation pass locally

Current behavior

Closes #1249. fin_flutter_analysis raises ValueError for a flight without wind, because the Mach number is 0 until liftoff and the safety factor divides by it.

New behavior

The points where the Mach number is 0 are left out of the safety factor. The remaining values are unchanged, but the safety factor is now interpolated with pchip instead of spline. Just after liftoff the values are so large that a spline oscillates: with flight_calisto_robust it reaches about -10,600, and it also goes negative between samples in a wind of 0.01 m/s.

The new tests use flight_calisto_robust, which has no wind. They compare the safety factor with the ratio of the two Mach numbers, check that the interpolated curve never goes below its lowest sample, and cover the prints and graphs. They fail on develop.

Breaking change

  • No

With wind, the safety factor keeps its domain and its value at every sample, so the printed minimum doesn't change. Between samples it changes slightly: with flight_calisto_custom_wind (5.4 m/s of wind), by at most 1.2% up to apogee and by 0.03% where the safety factor is below 6. The largest difference is in the second or so around main parachute deployment, where the spline dipped to about 7 between two samples of 19.5 and pchip stays at 19.5.

Additional information

#1201 changes _flutter_mach_number in the same file. The branches merge without conflicts, and these tests don't depend on the flutter constant. _flutter_safety_factor now reads the samples of flight.mach_number, so I changed the stub flight in #1201's test to use sampled Functions instead of constant ones. With that, the tests in test_utilities.py pass with both changes applied.

Without wind the Mach number is exactly 0 until liftoff, so the safety
factor divided by zero and the spline fit raised a ValueError. Leave those
points out.

Just after liftoff the safety factor is very large and a spline through it
oscillates below zero, so interpolate it with pchip. The values at the
samples do not change.
@rundvd
rundvd requested a review from a team as a code owner December 1, 2026 07:12
@Gui-FernandesBR Gui-FernandesBR added Bug Something isn't working Aerodynamics Any problem to be worked on top of RocketPy's Aerodynamic Tests Regarding Tests labels Dec 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Aerodynamics Any problem to be worked on top of RocketPy's Aerodynamic Bug Something isn't working Tests Regarding Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants