Skip to content
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

ENH: Add Eccentricity to Stochastic Simulations #792

Conversation

kevin-alcaniz
Copy link
Collaborator

@kevin-alcaniz kevin-alcaniz commented Mar 22, 2025

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)

Current behavior

Currently, it isn't possible to add CP and thrust eccentricities to the StochasticRocket class. As a result, these eccentricities can't be evaluated in the Monte Carlo simulations.

I also found out a BUG related to thrust eccenticities in the Rocket and Flight classes!!!

New behavior

  • Rocket class:
    I updated the documentation for the add_cm_eccentricity, add_cm_eccentricity and add_thrust_eccentricity functions to better clarify that these eccentricities are relative to center of DRY mass.
    BUG in add_thrust_eccentricity function: self.thrust_eccentricity_y was incorrectly assigned using the x coordinate and self.thrust_eccentricity_x using the y coordinate.

  • Flight class:
    BUG: The moments due to thrust eccentricity were miscalculated. They should be computed as follows:
    image

  • StochasticRocket class:
    Two new functions have been introduced: add_cp_eccentricity and add_thrust_eccentricity. These allow for defining a probabilistic distibution for their values. If not used, eccentricities remain undefined. If no inputs are provided, they default to the values used in the deterministic rocket. A new function _validate_eccentricity function was created to validate eccentricity inputs.
    A new _create_eccentricities fucntion was implemented to generate random eccentricity values. These values are then assigned to the sample rocket in the create_object function.

Breaking change

  • Yes
  • No

kevin-alcaniz and others added 13 commits March 14, 2025 18:46
the wind factor wasn't applied to the env.wind_velocity properties
It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in
Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com>
A bug has been corrected in Flight class and an enhancement has been performed in the Rocket class as well
eccentricity_y was defined by x coordinate and eccentricity_x was defined by y coordinate
@kevin-alcaniz kevin-alcaniz requested a review from a team as a code owner March 22, 2025 19:09
@kevin-alcaniz
Copy link
Collaborator Author

There are also changes related to another PR: BUG: fix the wind velocity factors usage and better visualization of uniform distributions in Stochastic Classes #783

@kevin-alcaniz
Copy link
Collaborator Author

I'm not passing the tests because you consider it valid that thrust_eccentricity_y = x and thrust_eccentricity_x = y. Why do you do that?? Wouldn't it be more intuitive to do it my way??

Anyway, even if you still want to mantain your nomenclature, there's still a BUG in u_dot_generalized in the Flight class. The moment M2 due to thrust eccentricity should be negative, but it's currently possitive (M2 -= - self.rocket.thrust_eccentricity_y * thrust is equivalent to M2 += self.rocket.thrust_eccentricity_y * thrust which is incorrect)

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

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

LGTM, just need to check if the stochastic_model file is correctly set here

@Gui-FernandesBR Gui-FernandesBR added Bug Something isn't working Enhancement New feature or request, including adjustments in current codes labels Mar 23, 2025
@Gui-FernandesBR Gui-FernandesBR merged commit 90553f5 into RocketPy-Team:develop Mar 23, 2025
7 checks passed
Copy link

codecov bot commented Mar 23, 2025

Codecov Report

Attention: Patch coverage is 28.57143% with 25 lines in your changes missing coverage. Please review.

Project coverage is 79.31%. Comparing base (7348053) to head (b028e00).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/stochastic/stochastic_rocket.py 19.35% 25 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #792      +/-   ##
===========================================
- Coverage    79.48%   79.31%   -0.18%     
===========================================
  Files           96       96              
  Lines        11504    11537      +33     
===========================================
+ Hits          9144     9150       +6     
- Misses        2360     2387      +27     

☔ 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.

@kevin-alcaniz kevin-alcaniz deleted the enh/add-stochastic-eccentricity branch March 23, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Enhancement New feature or request, including adjustments in current codes
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants