Repository navigation
MNT: store ref_factor on rocket aero surface components (#561) - #1129
Gui-FernandesBR merged 3 commits into
Conversation
ab19b9a to
f881d7e
Compare
f881d7e to
ebe5b8b
Compare
|
This one needs a different approach rather than a rebase. Two compatibility problems, and the first is what is failing CI: 1. It breaks
2. It breaks the public API. A backward-compatible shape would be to keep the 2-tuple iteration contract intact and expose 3. Lint is one self._components.append(self.component_tuple(component, position, ref_factor)) |
Rocket.from_dict unpacked three fields from every serialized entry, so a .rpy file written before ref_factor was stored failed to load with "not enough values to unpack (expected 3, got 2)" -- which is what the committed fixture tests/fixtures/utilities/flight_calisto_robust.rpy is, and what every file a user already has saved is too. Regenerating the fixture would have turned the suite green while leaving those files unreadable, so the three loops take a trailing star instead and read either length. Nothing is lost by ignoring the stored factor: add_surfaces derives it again from the surface's own radius. Two tests that reached develop after this branch opened, in RocketPy-Team#1169 and RocketPy-Team#1170, iterate Components expecting pairs, and now get triples. Both take the star as well, so a later field does not break them again. Also fixes what CI would have failed on regardless of the above: pylint C0415 for the two rocketpy imports inside test functions, now at the top of the module, and one ruff formatting difference in components.py. Simulation results are unchanged -- the 18 acceptance tests pass, and the factor is the same number as before, computed once when the surface is added rather than at every lift evaluation. Co-Authored-By: Claude Opus 5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1129 +/- ##
===========================================
+ Coverage 91.21% 91.24% +0.02%
===========================================
Files 131 131
Lines 17618 17619 +1
===========================================
+ Hits 16070 16076 +6
+ Misses 1548 1543 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ltistage #1129 landed on develop while this branch was open and made Components yield (component, position, ref_factor). This branch reads that collection in five places, so 29 of its tests failed with "too many values to unpack (expected 2)": axial_extent, two surface comprehensions and one draw loop in multistage, plus a dict(composed.aerodynamic_surfaces) in the tests, which failed differently again ("dictionary update sequence element #0 has length 3"). All five take a trailing star now, so a further field does not break them a third time. Addressing the review, in the same order the comments were left: - multistage.py was 810 lines holding four classes and a helper, and is now a package of one class per file, following the aero_surface layout that is already in rocketpy/rocket/. __init__ re-exports all five names, so every existing import path keeps working unchanged -- including the notebook's and the docstring cross-reference to axial_extent. - multistage_mission_test_report.ipynb is removed. It was the author's own working file, as they confirmed, and nothing referenced it. That leaves the two CI failures: ruff format over the notebook, multistage and its tests, and the build-docs warning that multistage_mission.ipynb sat in no toctree, which is now listed under Special Case Simulations next to the sensors notebook. Removing the report notebook takes care of the second warning of the two, since it was unreferenced as well. Co-Authored-By: Claude Opus 5 <[email protected]>
…ltistage #1129 landed on develop while this branch was open and made Components yield (component, position, ref_factor). This branch reads that collection in five places, so 29 of its tests failed with "too many values to unpack (expected 2)": axial_extent, two surface comprehensions and one draw loop in multistage, plus a dict(composed.aerodynamic_surfaces) in the tests, which failed differently again ("dictionary update sequence element #0 has length 3"). All five take a trailing star now, so a further field does not break them a third time. Addressing the review, in the same order the comments were left: - multistage.py was 810 lines holding four classes and a helper, and is now a package of one class per file, following the aero_surface layout that is already in rocketpy/rocket/. __init__ re-exports all five names, so every existing import path keeps working unchanged -- including the notebook's and the docstring cross-reference to axial_extent. - multistage_mission_test_report.ipynb is removed. It was the author's own working file, as they confirmed, and nothing referenced it. That leaves the two CI failures: ruff format over the notebook, multistage and its tests, and the build-docs warning that multistage_mission.ipynb sat in no toctree, which is now listed under Special Case Simulations next to the sensors notebook. Removing the report notebook takes care of the second warning of the two, since it was unreferenced as well. Co-Authored-By: Claude Opus 5 <[email protected]>
The stand-in rocket listed its aerodynamic surfaces as three values, the layout RocketPy-Team#1129 introduced. RocketPy-Team#1129 was reverted in RocketPy-Team#1210, so the flight code unpacks two again and the seven tests that use the stand-in failed with "too many values to unpack". Co-Authored-By: Claude Fable 5.2 <[email protected]>
* BUG: correct the position-vector convention in u_dot_generalized The v1 derivation takes the center of dry mass as its origin, so it wants CDM to CM and CDM to nozzle. Both Rocket attributes run the other way. evaluate_com_to_cdm_function documents the identity com_to_cdm_function plus center_of_mass equals center_of_dry_mass_position, which makes it CM to CDM, and it labels its own output "Z Coordinate COM to CDM". nozzle_to_cdm is -(nozzle_position - center_of_dry_mass_position) * _csys, which is nozzle to CDM. u_dot_generalized reads both without negating; lateral_surface_wind, in the same file, does negate com_to_cdm_function before using it as a vector from the CDM. Both are negated here and the v_dot term that follows the sign changes with them. Filed as #1186. The equations of motion v1 page states the convention it works in and says the two attributes are the opposite vectors. Several typos in the derivation go with it: r_CM where the term is r_CM' or r_CM'', a missing plus before the aerodynamic force, the sign on the gravity term of T21, a square dropped from the H matrix and a brace misplaced around another. tests/unit/simulation/test_generalized_eom.py is new and was untracked until now: seven tests for what the block system claims, among them that the lever arm comes from the center of mass, that an axial force through the axis makes no rotation, and that the result does not depend on the reference origin. The nozzle gyration tensor half of this reached develop as #1188, so it is not here: rebasing dropped both of its hunks. Signed-off-by: thc1006 <[email protected]> * TST: re-measure what the convention change moves, on current develop Rebasing onto a50d07d dropped the nozzle gyration half, which reached develop as #1188, and left the sign convention and its documentation. What follows is measured on that base rather than carried over from the old one. The stand-in rocket in test_generalized_eom.py yielded (component, position) for aerodynamic_surfaces, and #1129 made that a triple. Its factor is 1.0 here, which is what Components.add defaults to, and u_dot_generalized binds it as unused, so it cannot move the result. The Defiance acceptance flight, against the measured 9308.32 m AGL: develop a50d07d 9243.8350 m 0.6928 % with the convention 9247.9733 m 0.6483 % Its impact point moves further than the 3 m the test allows, so the two references follow the flight: x from 1609.40 to 1550.23 and y from 87.03 to 104.80. Max speed and max acceleration stay inside the 1 percent the test gives them, at 443.99 against 444.24 and 10356.62 against 10400.76. Four expectations in test_flight.py move at apogee, all of them values the file says were copied from a run rather than derived. Measured again here: moments (-0.652606, -0.734029, -2.115675e-14), forces (2.266124, -2.014696, -0.818709), velocity (-11.634095, 16.695945, -0.000173) and acceleration (0.073233, -0.062635, -9.614299). The first three are what this branch recorded four weeks ago, so #1188 landing did not disturb them. Whole suite on this branch: 2655 passed, 10 failed, against 2644 passed and the same 10 on develop at a50d07d. Those ten want optional dependencies this machine does not have. ruff and ruff format are clean and pylint is 10.00 with exit 0. Signed-off-by: thc1006 <[email protected]> * DOC: give this branch its changelog line Under Changed rather than Fixed: nothing about the API moves, but every number out of the generalized equations of motion does, so a study built on the old ones will not reproduce. The entry says that first and carries the one measured comparison the suite has. Signed-off-by: thc1006 <[email protected]> * TST: build the stand-in surfaces as (component, position) pairs The stand-in rocket listed its aerodynamic surfaces as three values, the layout #1129 introduced. #1129 was reverted in #1210, so the flight code unpacks two again and the seven tests that use the stand-in failed with "too many values to unpack". Co-Authored-By: Claude Fable 5.2 <[email protected]> --------- Signed-off-by: thc1006 <[email protected]> Co-authored-by: Mateus Stano Junqueira <[email protected]> Co-authored-by: MateusStano <[email protected]> Co-authored-by: Claude Fable 5.2 <[email protected]>
Summary
Components.component_tuplewithref_factor(default1.0) and pass it throughComponents.add, serialization, and call sites that unpacked(component, position).ref_factor = (surface.rocket_radius / rocket.radius)**2when adding aero surfaces; use the stored value inevaluate_center_of_pressureand rocket prints.Fixes #561
Test plan
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest tests/unit/rocket/test_components.py tests/unit/rocket/test_rocket.py -qPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest tests/unit/rocket/ tests/unit/test_rail_buttons_bending_moments.py tests/integration/test_sensor.py tests/unit/simulation/test_flight.py -q