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: implement power series nose cones (#475) #603

Merged
merged 10 commits into from
Jun 25, 2024

Conversation

Lucas-Prates
Copy link
Contributor

@Lucas-Prates Lucas-Prates commented May 19, 2024

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

This PR implements power series nose cones, as requested in #475 .

New behavior

The implementation required adding an extra argument, power, to the initialization of the NoseCone class and the add_nose method on the Rocket class.

I tried to maintain the implementation style using setters and property decorators.

I calculated the enigmatic self.k attribute, used to compute the Center of Pressure, in the same way other methods calculate it:

$k = 1 - V/(\pi R^2 L) $.

$V$ can be computed using basic calculus on the volume of solids of revolution

$V = \int_{0}^{L} \pi R^2 (\frac{x}{L}) ^ {2n} dx$.

Since this is a simple integral, the final result, if I computed things correctly, is:

$k = \frac{2n}{2n + 1}$

Breaking change

  • No

Additional information

I tested it on the example rocket in the Getting Started notebook. Here are some drawings with different values for the 'power' parameter:

$n = 0.2$
powerseries_draw_0-2

$n = 0.5$
powerseries_draw_0-5

$n = 0.8$
powerseries_draw_0-8

@Lucas-Prates Lucas-Prates requested a review from a team as a code owner May 19, 2024 16:01
@Lucas-Prates Lucas-Prates added Enhancement New feature or request, including adjustments in current codes Aerodynamics Any problem to be worked on top of RocketPy's Aerodynamic labels May 19, 2024
Copy link

codecov bot commented May 19, 2024

Codecov Report

Attention: Patch coverage is 23.33333% with 23 lines in your changes missing coverage. Please review.

Project coverage is 73.46%. Comparing base (2a74fa4) to head (6789c94).
Report is 1 commits behind head on develop.

Current head 6789c94 differs from pull request most recent head 5f57e5f

Please upload reports for the commit 5f57e5f to get more accurate results.

Files Patch % Lines
rocketpy/rocket/aero_surface.py 23.33% 23 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #603      +/-   ##
===========================================
- Coverage    73.69%   73.46%   -0.24%     
===========================================
  Files           70       70              
  Lines        10304    10340      +36     
===========================================
+ Hits          7594     7596       +2     
- Misses        2710     2744      +34     

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

@Gui-FernandesBR
Copy link
Member

Nice one!

@Lucas-Prates can you mark the PR 475 in the "Development" section at the top right corner of your PR?
This ensures the issue will be automatically closed when this PR gets to the default branch (i.e. the master).

image

@Lucas-Prates Lucas-Prates linked an issue May 19, 2024 that may be closed by this pull request
@Lucas-Prates Lucas-Prates changed the title ENH: implement powerseries NoseCones (#475) ENH: implement power series nose cones (#475) May 19, 2024
Copy link
Member

@MateusStano MateusStano left a comment

Choose a reason for hiding this comment

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

Hey! This is great! The center of pressure values seem to be correct, so just a few comments:

  • Can you add NoseCone.power to the class attributes docs?
  • The parameter bluffness should not be used with power I think. It would be good to have a check on this. The drawing breaks if you add bluffness to a powerseries nose cone.

rocketpy/rocket/aero_surface.py Outdated Show resolved Hide resolved
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.

Very good PR, simple and effective, congratulations!

This PR made me to realize that we do not have a docs page for each aerodynamic surface. maybe this is something to be added to the documentation tasks. @phmbressan

@Gui-FernandesBR
Copy link
Member

@Lucas-Prates your PR looks nice to me.

Just to attention points:

  • The CHANGELOG was not updated with your PR
  • There is no test too cover the new feature. Indeed, there are no such thing as a "test_aero_surfaces.py" file in the repo, which make everything harder.

The changelog needs to be updated before merging the PR, it is really simple so it is a must.
However, the tests are discussable... How good is your understand about unit/integration/e2e tests right now?
Would you prefer to merge this PR first and open up another PR with new tests OR to implement the tests here directly?

We can help you with theses tests, no rocket science, don't worry.

@Lucas-Prates
Copy link
Contributor Author

Thanks a lot for the review, @Gui-FernandesBR. With respect to the tests, I have extremely basic experience with it. However, I do not mind implementing the tests in this PR since it seems to be a good opportunity to learn.

Also, I do not know what a changelog is or how to adequately update it, so I will need guidance with that as well.

@Lucas-Prates
Copy link
Contributor Author

Lucas-Prates commented May 23, 2024

One minor issue: the documentation states that the power argument must be between $0$ and $1$. However, it could also be one of these extreme values. When power equals $1$, we have the same result as a 'conical' nose cone, and the code runs normally.

When power equals $0$, we currently raise a ValueError since the drawing breaks because the front end of the nose cone does not close ($0 ^ 0 = 1$ for Python). However, we could understand $0$ as the limit case where the nose cone becomes a cylinder.

Should we still raise a ValueError if the user passes $0$ as input for power or should we handle this input differently? For instance, we could set power to a value close to $0$, e.g. 1e-6, so its behavior is equivalent but without breaking the drawing.

Here are some drawings to understand.

power $= 0.01$
powerseries_1e-2

power $= 1e-6$
powerseries_1e-6

power $= 0$ (Would raise a ValueError)
powerseries_0

@MateusStano
Copy link
Member

Should we still raise a ValueError if the user passes 0 as input for power or should we handle this input differently? For instance, we could set power to a value close to 0 , e.g. 1e-6, so its behavior is equivalent but without breaking the drawing.

Passing 0 should raise an error since it does not make physical sense. Passing 1 should work normally

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.

Good job with this PR @Lucas-Prates!! I believe we are ready to merge it already, we will just need to fix a simple conflict within the CHANGELOG.md file

@Gui-FernandesBR Gui-FernandesBR merged commit a7be2fe into develop Jun 25, 2024
9 checks passed
@Gui-FernandesBR Gui-FernandesBR deleted the enh/power_series_nosecones branch June 25, 2024 02:02
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 Enhancement New feature or request, including adjustments in current codes
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

ENH: Support for power series nose cones
4 participants