diff --git a/lib/models/aerosurfaces.py b/lib/models/aerosurfaces.py index 0d76565..069909e 100644 --- a/lib/models/aerosurfaces.py +++ b/lib/models/aerosurfaces.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import Optional +from typing import Optional, Tuple, List from pydantic import BaseModel @@ -24,6 +24,11 @@ class FinsKinds(str, Enum): ELLIPTICAL: str = "ELLIPTICAL" +class AngleUnit(str, Enum): + RADIANS: str = "RADIANS" + DEGREES: str = "DEGREES" + + class Fins(BaseModel): fins_kind: FinsKinds name: str @@ -34,7 +39,7 @@ class Fins(BaseModel): position: float cant_angle: float radius: float - airfoil: str + airfoil: Tuple[List[Tuple[float, float]], AngleUnit] # TODO: implement airbrakes diff --git a/lib/models/rocket.py b/lib/models/rocket.py index fb46c2b..1ebc3a0 100644 --- a/lib/models/rocket.py +++ b/lib/models/rocket.py @@ -60,18 +60,20 @@ class Rocket(BaseModel): base_radius=0.0635, rocket_radius=0.0635, ) - fins: Optional[Fins] = Fins( - fins_kind=FinsKinds.TRAPEZOIDAL, - name="Fins", - n=4, - root_chord=0.12, - tip_chord=0.04, - span=0.1, - position=-1.04956, - cant_angle=0, - radius=0.0635, - airfoil="", - ) + fins: Optional[List[Fins]] = [ + Fins( + fins_kind=FinsKinds.TRAPEZOIDAL, + name="Fins", + n=4, + root_chord=0.12, + tip_chord=0.04, + span=0.1, + position=-1.04956, + cant_angle=0, + radius=0.0635, + airfoil=([(0.0, 0.0), (0.1, 0.1), (0.2, 0.2)], "RADIANS"), + ) + ] tail: Optional[Tail] = Tail( name="Tail", top_radius=0.0635, diff --git a/lib/services/rocket.py b/lib/services/rocket.py index 32d7729..40a8ea1 100644 --- a/lib/services/rocket.py +++ b/lib/services/rocket.py @@ -1,4 +1,4 @@ -from typing import Self +from typing import Self, List import dill @@ -63,8 +63,11 @@ def from_rocket_model(cls, rocket: Rocket) -> Self: rocketpy_rocket.evaluate_static_margin() # FinSet - finset = cls.get_rocketpy_finset(rocket.fins, rocket.fins.fins_kind) - rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position) + rocketpy_finset_list = cls.get_rocketpy_finset_list_from_fins_list( + rocket.fins + ) + for finset in rocketpy_finset_list: + rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position) rocketpy_rocket.evaluate_static_margin() # Tail @@ -134,6 +137,14 @@ def get_rocketpy_nose(nose: NoseCone) -> RocketPyNoseCone: rocketpy_nose.position = nose.position return rocketpy_nose + @classmethod + def get_rocketpy_finset_list_from_fins_list( + cls, fins_list: List[Fins] + ) -> List[RocketPyFins]: + return [ + cls.get_rocketpy_finset(fins, fins.fins_kind) for fins in fins_list + ] + @staticmethod def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins: """