Skip to content

Commit

Permalink
Merge pull request #694 from RocketPy-Team/enh/free-form-fins
Browse files Browse the repository at this point in the history
ENH: Free-Form Fins
  • Loading branch information
MateusStano authored Sep 21, 2024
2 parents 208d528 + 49abe78 commit d2d9aac
Show file tree
Hide file tree
Showing 10 changed files with 586 additions and 3 deletions.
1 change: 1 addition & 0 deletions rocketpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Components,
EllipticalFins,
Fins,
FreeFormFins,
GenericSurface,
LinearGenericSurface,
NoseCone,
Expand Down
67 changes: 67 additions & 0 deletions rocketpy/plots/aero_surface_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,73 @@ def draw(self):
plt.show()


class _FreeFormFinsPlots(_FinsPlots):
"""Class that contains all free form fin plots."""

# pylint: disable=too-many-statements
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
"""
# Color cycle [#348ABD, #A60628, #7A68A6, #467821, #D55E00, #CC79A7,
# #56B4E9, #009E73, #F0E442, #0072B2]

# Center of pressure
cp_point = [self.aero_surface.cpz, self.aero_surface.Yma]

# Mean Aerodynamic Chord
yma_line = plt.Line2D(
(
self.aero_surface.mac_lead,
self.aero_surface.mac_lead + self.aero_surface.mac_length,
),
(self.aero_surface.Yma, self.aero_surface.Yma),
color="#467821",
linestyle="--",
label="Mean Aerodynamic Chord",
)

# Plotting
fig = plt.figure(figsize=(7, 4))
with plt.style.context("bmh"):
ax = fig.add_subplot(111)

# Fin
ax.scatter(
self.aero_surface.shape_vec[0],
self.aero_surface.shape_vec[1],
color="#A60628",
)
ax.plot(
self.aero_surface.shape_vec[0],
self.aero_surface.shape_vec[1],
color="#A60628",
)
# line from the last point to the first point
ax.plot(
[self.aero_surface.shape_vec[0][-1], self.aero_surface.shape_vec[0][0]],
[self.aero_surface.shape_vec[1][-1], self.aero_surface.shape_vec[1][0]],
color="#A60628",
)

ax.add_line(yma_line)
ax.scatter(*cp_point, label="Center of Pressure", color="red", s=100, zorder=10)
ax.scatter(*cp_point, facecolors="none", edgecolors="red", s=500, zorder=10)

# Plot settings
ax.set_xlabel("Root chord (m)")
ax.set_ylabel("Span (m)")
ax.set_title("Free Form Fin Cross Section")
ax.legend(bbox_to_anchor=(1.05, 1.0), loc="upper left")

plt.tight_layout()
plt.show()


class _TailPlots(_AeroSurfacePlots):
"""Class that contains all tail plots."""

Expand Down
4 changes: 4 additions & 0 deletions rocketpy/prints/aero_surface_prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ class _EllipticalFinsPrints(_FinsPrints):
"""Class that contains all elliptical fins prints."""


class _FreeFormFinsPrints(_FinsPrints):
"""Class that contains all free form fins prints."""


class _TailPrints(_AeroSurfacePrints):
"""Class that contains all tail prints."""

Expand Down
1 change: 1 addition & 0 deletions rocketpy/rocket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
AirBrakes,
EllipticalFins,
Fins,
FreeFormFins,
GenericSurface,
LinearGenericSurface,
NoseCone,
Expand Down
7 changes: 6 additions & 1 deletion rocketpy/rocket/aero_surface/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from rocketpy.rocket.aero_surface.aero_surface import AeroSurface
from rocketpy.rocket.aero_surface.air_brakes import AirBrakes
from rocketpy.rocket.aero_surface.fins import EllipticalFins, Fins, TrapezoidalFins
from rocketpy.rocket.aero_surface.fins import (
EllipticalFins,
Fins,
FreeFormFins,
TrapezoidalFins,
)
from rocketpy.rocket.aero_surface.generic_surface import GenericSurface
from rocketpy.rocket.aero_surface.linear_generic_surface import LinearGenericSurface
from rocketpy.rocket.aero_surface.nose_cone import NoseCone
Expand Down
1 change: 1 addition & 0 deletions rocketpy/rocket/aero_surface/fins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from rocketpy.rocket.aero_surface.fins.elliptical_fins import EllipticalFins
from rocketpy.rocket.aero_surface.fins.fins import Fins
from rocketpy.rocket.aero_surface.fins.free_form_fins import FreeFormFins
from rocketpy.rocket.aero_surface.fins.trapezoidal_fins import TrapezoidalFins
Loading

0 comments on commit d2d9aac

Please sign in to comment.