Skip to content

Commit

Permalink
ENH: Enabling the creation of Rail Buttons separately (adding the roc…
Browse files Browse the repository at this point in the history
…ket_radius attribute to the RailButtons class). Improvement of the Railbuttons class.
  • Loading branch information
juliomachad0 committed Jul 19, 2024
1 parent d977fbe commit f3896dc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rocketpy/rocket/aero_surface/rail_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ class RailButtons(AeroSurface):
relative to one of the other principal axis.
"""

def __init__(self, buttons_distance, angular_position=45, name="Rail Buttons"):
def __init__(
self,
buttons_distance,
angular_position=45,
name="Rail Buttons",
rocket_radius=None,
):
"""Initializes RailButtons Class.
Parameters
Expand All @@ -40,7 +46,7 @@ def __init__(self, buttons_distance, angular_position=45, name="Rail Buttons"):
self.buttons_distance = buttons_distance
self.angular_position = angular_position
self.name = name

self.rocket_radius = rocket_radius
self.evaluate_lift_coefficient()
self.evaluate_center_of_pressure()

Expand Down
9 changes: 9 additions & 0 deletions rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,18 @@ def add_surfaces(self, surfaces, positions):
-------
None
"""
if isinstance(surfaces, list) is False:
if isinstance(surfaces, RailButtons):
surfaces = [surfaces]
positions = [positions]
try:
for surface, position in zip(surfaces, positions):
self.aerodynamic_surfaces.add(surface, position)
if isinstance(surface, RailButtons):
try:
self.rail_buttons.add(surface, position)
except TypeError:
self.rail_buttons.add(surface, positions)
except TypeError:
self.aerodynamic_surfaces.add(surfaces, positions)

Expand Down
4 changes: 4 additions & 0 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import simplekml
from scipy import integrate

from rocketpy.rocket.aero_surface import RailButtons

from ..mathutils.function import Function, funcify_method
from ..mathutils.vector_matrix import Matrix, Vector
from ..plots.flight_plots import _FlightPlots
Expand Down Expand Up @@ -1723,6 +1725,8 @@ def u_dot_generalized(
velocity_in_body_frame = Kt @ v
# Calculate lift and moment for each component of the rocket
for aero_surface, position in self.rocket.aerodynamic_surfaces:
if isinstance(aero_surface, RailButtons):
continue
comp_cpz = (
position - self.rocket.center_of_dry_mass_position
) * self.rocket._csys - aero_surface.cpz
Expand Down

0 comments on commit f3896dc

Please sign in to comment.