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: Free-Form Fins #694

Merged
merged 22 commits into from
Sep 21, 2024
Merged

ENH: Free-Form Fins #694

merged 22 commits into from
Sep 21, 2024

Conversation

MateusStano
Copy link
Member

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

Free Form Fins have been added!

Every calculation that is related to the free-form fins shape points (essentially almost everything that is calculated inside evaluate_geometrical_parameters) comes directly from Open Rocket.

This means that the free-form fins in RocketPy are modeled exactly like Open Rocket, and only deviate when it comes to some effects related to Mach number variations (especially at supersonic speeds).

Breaking change

  • Yes
  • No

@MateusStano MateusStano requested a review from a team as a code owner September 17, 2024 23:31
@MateusStano MateusStano added Enhancement New feature or request, including adjustments in current codes Aerodynamics Any problem to be worked on top of RocketPy's Aerodynamic labels Sep 17, 2024
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.

Really nice feature, this is quite important for us.

1 - a good test would be to create a FreeFormFins set with the same size as a trapezoidal fins so we can validate that the center of pressure is the same when using both Trapezoidal and FreeForm fins
2 - can you provide a minimum example of using the class? It is still a bit abstract to me; i.e. I can`t visualize how to use this new feature.

Well done!

rocketpy/rocket/rocket.py Outdated Show resolved Hide resolved
Comment on lines +387 to +394
def draw(self):
"""Draw the fin shape along with some important information, including
the center line, the quarter line and the center of pressure position.

Returns
-------
None
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

The draw method is not closing the fin draw when the last point is different than the initial point, as shown in the figure below

image

Copy link
Member

Choose a reason for hiding this comment

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

how are we going to close it? linearly? we should provide an example (in a future PR maybe) showing case when the fin is set at a non-planar surface. for example when the fins are placed on the tail/transition

Copy link
Contributor

@Lucas-Prates Lucas-Prates Sep 20, 2024

Choose a reason for hiding this comment

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

Well, I assumed that the Fin is defined by a closed polygon. Indeed, the documentation states that "the last point should be the first one." So, if the user forgot to make sure the last point is the first one, we either should raise an error or just close it ourselves.

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 model assumes that it is closed linearly. I will add the last line in the plot as well

rocketpy/rocket/aero_surface/fins/free_form_fins.py Outdated Show resolved Hide resolved
Comment on lines +151 to +161
down = False
for i in range(1, len(shape_points)):
if shape_points[i][1] > shape_points[i - 1][1] and down:
warnings.warn(
"Jagged fin shape detected. This may cause small inaccuracies "
"center of pressure and pitch moment calculations."
)
break
if shape_points[i][1] < shape_points[i - 1][1]:
down = True
i += 1
Copy link
Contributor

@Lucas-Prates Lucas-Prates Sep 20, 2024

Choose a reason for hiding this comment

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

What is a jagged fin? I looked at OpenRocket documentation, page 27, but I am not sure what they define as a jagged fin. For instance, the images below show three different fins. For Fin 1, we get the jagged fin warning. For Fins 2 and 3, no warning is issued.

Fin 1 - Jagged Fin warning

image

Fin 2 - No Jagged fin warning

image

Fin 3 - No Jagged fin warning

image

According to the raised error, and OR documentation, jagged fins have unstable/unreliable calculations. Are not Fin 2 and Fin 3 also problematic? Should they not be "jagged?"

If that is the case, then is "jagged" a synonym for non-convex?

In any case, I think we should separate this logic into a function in mathutils module depending on what is jagged:

  • If jagged is not a synonym of non-convex, then we could create a check_jagged_region which just implements this, without the warning, and returns a boolean;
  • If jagged means non-convex, I can implement a check_convex_region that returns True if the region is convex or False otherwise.

The class would then just call any of these functions and raise the warning if the condition is False.

Copy link
Member Author

Choose a reason for hiding this comment

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

So Open Rocket only checks the "jaggedness" of the first case because I believe that is the only case that makes sense for fins. It would totally be valid to add better checks just like you mentioned

I am not sure though if the assumptions that Barrowman makes for the cp position and clalpha would still hold for case 2 and 3. I personally think they would be too inaccurate.

I don't think this is needed for this PR, but those extra checks you suggested would be great to have in the future. Opening an issue describing those cases would be useful

Comment on lines 259 to 260
prev_idx = int(y1 * 1.0001 / self.span * (points_per_line - 1))
curr_idx = int(y2 * 1.0001 / self.span * (points_per_line - 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 1.0001?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this is something related to numerical issues in Java. This comes directly from Open Rocket.

I removed it because I guess it is not needed for us

Copy link

codecov bot commented Sep 21, 2024

Codecov Report

Attention: Patch coverage is 93.03797% with 11 lines in your changes missing coverage. Please review.

Project coverage is 76.06%. Comparing base (208d528) to head (49abe78).
Report is 23 commits behind head on enh/generic-surfaces.

Files with missing lines Patch % Lines
...ocketpy/rocket/aero_surface/fins/free_form_fins.py 94.61% 7 Missing ⚠️
rocketpy/rocket/rocket.py 33.33% 4 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           enh/generic-surfaces     #694      +/-   ##
========================================================
+ Coverage                 75.81%   76.06%   +0.24%     
========================================================
  Files                        98       99       +1     
  Lines                     11092    11249     +157     
========================================================
+ Hits                       8409     8556     +147     
- Misses                     2683     2693      +10     

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

@MateusStano MateusStano merged commit d2d9aac into enh/generic-surfaces Sep 21, 2024
4 of 5 checks passed
@MateusStano MateusStano deleted the enh/free-form-fins branch September 21, 2024 10:35
@Gui-FernandesBR Gui-FernandesBR linked an issue Oct 11, 2024 that may be closed by this pull request
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: Free Form Fins
3 participants