Repository navigation
BUG: use the angular rates in the solid propulsion equations of motion #1195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MateusStano
wants to merge
1
commit into
develop
Choose a base branch
from
bug/solid-propulsion-angular-rates
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -831,3 +831,58 @@ def test_max_acceleration_power_off_time_with_controllers( | |
| assert test.max_acceleration_power_off > 0, ( | ||
| "max_acceleration_power_off should be greater than zero" | ||
| ) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # The equations of motion themselves, evaluated on a fixed state | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def _coasting_state(flight, seconds_after_burnout=3.0): | ||
| """Return ``(t, state)`` a few seconds into the coast of a flown flight.""" | ||
| t = flight.rocket.motor.burn_out_time + seconds_after_burnout | ||
| return t, list(flight.get_solution_at_time(t)[1:]) | ||
|
|
||
|
|
||
| def _with_rates(state, w1=0.0, w2=0.0, w3=0.0): | ||
| return [*state[:10], w1, w2, w3] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("derivative", [Flight.u_dot, Flight.u_dot_generalized]) | ||
| def test_an_angular_rate_is_aerodynamically_damped(flight_calisto_robust, derivative): | ||
| """A rate about any body axis must produce an angular acceleration against it. | ||
|
|
||
| The solid propulsion equations once zeroed the rates before the | ||
| aerodynamics, so no rate was ever damped: a canted fin spun the rocket up | ||
| without bound. This checks each axis on a coasting state, for both sets of | ||
| equations. | ||
| """ | ||
| flight = flight_calisto_robust | ||
| t, state = _coasting_state(flight) | ||
| at_rest = derivative(flight, t, state) | ||
| for axis, rate in ((0, 2.0), (1, 2.0), (2, 20.0)): | ||
| slot = 10 + axis | ||
| positive = derivative(flight, t, _with_rates(state, **{f"w{axis + 1}": rate})) | ||
| negative = derivative(flight, t, _with_rates(state, **{f"w{axis + 1}": -rate})) | ||
| assert positive[slot] < at_rest[slot] < negative[slot], f"axis {axis + 1}" | ||
| # damping is close to linear in the rate at these magnitudes | ||
| assert positive[slot] - at_rest[slot] == pytest.approx( | ||
| -(negative[slot] - at_rest[slot]), rel=0.2 | ||
| ) | ||
|
|
||
|
|
||
| def test_solid_propulsion_and_generalized_equations_agree_when_rotating( | ||
| flight_calisto_robust, | ||
| ): | ||
| """With a pitch rate applied, both models give the same damping moment. | ||
|
|
||
| They differ in how variable mass is handled, not in the aerodynamics, so | ||
| the angular acceleration a rate produces must agree closely. | ||
| """ | ||
| flight = flight_calisto_robust | ||
| t, state = _coasting_state(flight) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the coast m_p = 0, so every |
||
| pitching = _with_rates(state, w1=2.0) | ||
| solid = Flight.u_dot(flight, t, pitching) | ||
| generalized = Flight.u_dot_generalized(flight, t, pitching) | ||
| assert solid[10] == pytest.approx(generalized[10], rel=0.1) | ||
| assert solid[3:6] == pytest.approx(generalized[3:6], rel=0.05) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flight runs with the default
equations_of_motion="standard", so it also passes on develop and doesn't guard this fix. It's still useful coverage ofu_dot_generalized.