Skip to content

Comments

ENH: Improve multi-variable drag compatibility, regular-grid handling, and related tests/docs#927

Open
MateusStano wants to merge 15 commits intodevelopfrom
enh/multi-variable-drag-fix
Open

ENH: Improve multi-variable drag compatibility, regular-grid handling, and related tests/docs#927
MateusStano wants to merge 15 commits intodevelopfrom
enh/multi-variable-drag-fix

Conversation

@MateusStano
Copy link
Member

@MateusStano MateusStano commented Feb 23, 2026

Pull request type

  • 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.md has been updated (if relevant)

Description

This PR follows up on #875, and improves how multi-variable drag data is handled, and preserves backward compatibility. It also aligns interpolation documentation and updates tests to reflect the current drag/function behavior. Changes:

  • Now drag also works with 1D and 7D functions (just as generic_srafaces)
  • Refined Function grid-interpolation to work the same as other interpolation methods
  • Added/updated support paths and validation around regular_grid usage for multi-dimensional datasets
  • Updated docs to correctly describe interpolation options and current behavior
  • Updated tests

Breaking change

  • No

@MateusStano MateusStano requested a review from a team as a code owner February 23, 2026 16:17
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 85.08065% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.09%. Comparing base (9cf3dd4) to head (cdd7f35).
⚠️ Report is 28 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/tools.py 77.66% 23 Missing ⚠️
rocketpy/rocket/rocket.py 86.27% 7 Missing ⚠️
rocketpy/mathutils/function.py 92.85% 3 Missing ⚠️
rocketpy/plots/rocket_plots.py 50.00% 2 Missing ⚠️
rocketpy/simulation/flight.py 95.34% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #927      +/-   ##
===========================================
+ Coverage    80.27%   81.09%   +0.82%     
===========================================
  Files          104      107       +3     
  Lines        12769    13857    +1088     
===========================================
+ Hits         10250    11238     +988     
- Misses        2519     2619     +100     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reasons to delete these two test files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new tests are covering what these were covering I believe

"Function, or callable."
)

def __load_csv(self, file_path, coeff_name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a load_csv function inside the Rocket class? is it extremelly necessary? It seems like a tools function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved in 20f60ab

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances multi-variable drag coefficient support and regular-grid interpolation handling in RocketPy. Following PR #875, it standardizes drag interfaces to support both 1D (Mach-only) and 7D (alpha, beta, mach, reynolds, pitch_rate, yaw_rate, roll_rate) drag functions, refines grid-based interpolation, and updates related tests and documentation.

Changes:

  • Introduced a unified 7D drag coefficient interface (power_*_drag_7d) that wraps all drag inputs (scalars, 1D Mach functions, or full 7D functions)
  • Refactored Function class to handle regular-grid interpolation consistently with other interpolation methods (removing deprecated from_grid class method)
  • Updated flight dynamics to compute and pass all 7 aerodynamic parameters (alpha, beta, Mach, Reynolds, pitch/yaw/roll rates) to drag functions
  • Added comprehensive test coverage for various drag input types and regular-grid interpolation

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rocketpy/rocket/rocket.py Added __process_drag_input and __load_csv methods to normalize all drag inputs to 7D interface; created power_*_drag_by_mach convenience wrappers
rocketpy/simulation/flight.py Replaced __get_drag_coefficient with __compute_drag_7d_inputs; updated all flight dynamics methods to use 7D drag interface
rocketpy/mathutils/function.py Integrated regular-grid processing into standard __validate_source flow; removed from_grid class method and __get_value_opt_grid
rocketpy/rocket/aero_surface/generic_surface.py Updated CSV loading to support column-order independence and prefer regular-grid interpolation when applicable
rocketpy/plots/rocket_plots.py Updated drag curve plotting to use power_*_drag_by_mach attributes
tests/unit/rocket/test_rocket.py Added comprehensive tests for drag input type handling and CSV column ordering
tests/unit/mathutils/test_function.py Added tests for regular-grid constructor, interpolation, and extrapolation
tests/integration/simulation/test_flight_3dof.py Added test verifying 7D drag interface usage in 3-DOF simulations
docs/user/rocket/generic_surface.rst Updated documentation to reflect column-order independence for CSV files
docs/user/function.rst Updated interpolation method documentation to include regular_grid

Comment on lines +1991 to +1992
power_off_drag = self.power_off_drag_7d
power_on_drag = self.power_on_drag_7d
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phmbressan Should this be discretized? Can we discretize N-D Functions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it has merely 10 point in each dimension, it will have 10^7 total points. So no, don't discretize unless your domain has very few relevant points. I am working on a PR to handle ND Discretization, but don't wait for me.

Copy link
Collaborator

@phmbressan phmbressan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, I had to publish a review for my answer to another comment from this PR not to be pending.

nozzle_position=parameters.get("distance_rocket_nozzle")[0],
)
# rocket information
BellaLui = Rocket(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PascalCase variable name? Probably should be snake_case.

Comment on lines +1991 to +1992
power_off_drag = self.power_off_drag_7d
power_on_drag = self.power_on_drag_7d
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it has merely 10 point in each dimension, it will have 10^7 total points. So no, don't discretize unless your domain has very few relevant points. I am working on a PR to handle ND Discretization, but don't wait for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants