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

Minor bug fix and feature extension #33

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/models/aerosurfaces.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Optional
from typing import Optional, Tuple, List
from pydantic import BaseModel


Expand All @@ -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
Expand All @@ -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
Expand Down
26 changes: 14 additions & 12 deletions lib/models/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
]
GabrielBarberini marked this conversation as resolved.
Show resolved Hide resolved
tail: Optional[Tail] = Tail(
name="Tail",
top_radius=0.0635,
Expand Down
17 changes: 14 additions & 3 deletions lib/services/rocket.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Self
from typing import Self, List

import dill

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down
Loading