Skip to content

Commit

Permalink
BUG: Refactor fin_flutter_analysis function to handle multiple fin sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Dec 14, 2023
1 parent a964662 commit 77e456d
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions rocketpy/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def fin_flutter_analysis(
The fin thickness, in meters
shear_modulus : float
Shear Modulus of fins' material, must be given in Pascal
flight : rocketpy.Flight
flight : Flight
Flight object containing the rocket's flight data
see_prints : boolean, optional
True if you want to see the prints, False otherwise.
Expand All @@ -229,21 +229,23 @@ def fin_flutter_analysis(
------
None
"""
found_fin = False

Check warning on line 232 in rocketpy/utilities.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/utilities.py#L232

Added line #L232 was not covered by tests

# First, we need identify if there is at least a fin set in the rocket
for aero_surface in flight.rocket.aerodynamic_surfaces:
for aero_surface in flight.rocket.fins:

Check warning on line 235 in rocketpy/utilities.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/utilities.py#L235

Added line #L235 was not covered by tests
if isinstance(aero_surface, TrapezoidalFins):
# s: surface area; ar: aspect ratio; la: lambda
root_chord = aero_surface.root_chord
s = (aero_surface.tip_chord + root_chord) * aero_surface.span / 2
ar = aero_surface.span * aero_surface.span / s
la = aero_surface.tip_chord / root_chord
if not found_fin:
found_fin = True

Check warning on line 243 in rocketpy/utilities.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/utilities.py#L242-L243

Added lines #L242 - L243 were not covered by tests
else:
warnings.warn("More than one fin set found. The last one will be used.")

Check warning on line 245 in rocketpy/utilities.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/utilities.py#L245

Added line #L245 was not covered by tests

# This ensures that a fin set was found in the rocket, if not, break
try:
s = s
except NameError:
print("There is no fin set in the rocket, can't run a Flutter Analysis.")
if not found_fin:
print("There is no TrapezoidalFins in the rocket, can't run Flutter Analysis.")

Check warning on line 248 in rocketpy/utilities.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/utilities.py#L247-L248

Added lines #L247 - L248 were not covered by tests
return None

# Calculate the Fin Flutter Mach Number
Expand All @@ -257,14 +259,7 @@ def fin_flutter_analysis(
# Prints everything
if see_prints:
_flutter_prints(
fin_thickness,
shear_modulus,
s,
ar,
la,
flutter_mach,
safety_factor,
flight,
fin_thickness, shear_modulus, s, ar, la, flutter_mach, safety_factor, flight
)

# Plots everything
Expand Down

0 comments on commit 77e456d

Please sign in to comment.