Skip to content

Commit f598b67

Browse files
Minor bug fix and feature extension
- Fixed airfoil signature to be the same as power_off_drag (str -> List[tuples]) - Implement multiple rocket fins attachment Fixes #32
1 parent 245aee1 commit f598b67

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

lib/models/aerosurfaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enum import Enum
2-
from typing import Optional
2+
from typing import Optional, List, Tuple
33
from pydantic import BaseModel
44

55

@@ -34,7 +34,7 @@ class Fins(BaseModel):
3434
position: float
3535
cant_angle: float
3636
radius: float
37-
airfoil: str
37+
airfoil: List[Tuple[float, float]]
3838

3939

4040
# TODO: implement airbrakes

lib/models/rocket.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,24 @@ class Rocket(BaseModel):
6060
base_radius=0.0635,
6161
rocket_radius=0.0635,
6262
)
63-
fins: Optional[Fins] = Fins(
64-
fins_kind=FinsKinds.TRAPEZOIDAL,
65-
name="Fins",
66-
n=4,
67-
root_chord=0.12,
68-
tip_chord=0.04,
69-
span=0.1,
70-
position=-1.04956,
71-
cant_angle=0,
72-
radius=0.0635,
73-
airfoil="",
74-
)
63+
fins: Optional[List[Fins]] = [
64+
Fins(
65+
fins_kind=FinsKinds.TRAPEZOIDAL,
66+
name="Fins",
67+
n=4,
68+
root_chord=0.12,
69+
tip_chord=0.04,
70+
span=0.1,
71+
position=-1.04956,
72+
cant_angle=0,
73+
radius=0.0635,
74+
airfoil=[
75+
(0.0, 0.0),
76+
(0.1, 0.1),
77+
(0.2, 0.2),
78+
],
79+
)
80+
]
7581
tail: Optional[Tail] = Tail(
7682
name="Tail",
7783
top_radius=0.0635,

lib/services/rocket.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Self
1+
from typing import Self, List
22

33
import dill
44

@@ -63,9 +63,12 @@ def from_rocket_model(cls, rocket: Rocket) -> Self:
6363
rocketpy_rocket.evaluate_static_margin()
6464

6565
# FinSet
66-
finset = cls.get_rocketpy_finset(rocket.fins, rocket.fins.fins_kind)
67-
rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position)
68-
rocketpy_rocket.evaluate_static_margin()
66+
rocketpy_finset_list = cls.get_rocketpy_finset_list_from_fins_list(
67+
rocket.fins
68+
)
69+
for finset in rocketpy_finset_list:
70+
rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position)
71+
rocketpy_rocket.evaluate_static_margin()
6972

7073
# Tail
7174
tail = cls.get_rocketpy_tail(rocket.tail)
@@ -134,6 +137,18 @@ def get_rocketpy_nose(nose: NoseCone) -> RocketPyNoseCone:
134137
rocketpy_nose.position = nose.position
135138
return rocketpy_nose
136139

140+
@classmethod
141+
def get_rocketpy_finset_list_from_fins_list(
142+
cls, fins_list: List[Fins]
143+
) -> List[RocketPyFins]:
144+
rocketpy_finset_list = []
145+
if not fins_list:
146+
return []
147+
for fins in fins_list:
148+
rocketpy_fins = cls.get_rocketpy_finset(fins, fins.kind)
149+
rocketpy_finset_list.append(rocketpy_fins)
150+
return rocketpy_finset_list
151+
137152
@staticmethod
138153
def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins:
139154
"""

0 commit comments

Comments
 (0)