Skip to content

Commit 9ff9581

Browse files
committed
DOC: finish docstrings
1 parent 719be74 commit 9ff9581

14 files changed

Lines changed: 114 additions & 108 deletions

rocketpy/rocket/aero_surface/aero_surface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def compute_forces_and_moments(
140140
R1, R2, R3, M1, M2, M3 = 0, 0, 0, 0, 0, 0
141141
cpz = cp[2]
142142
stream_vx, stream_vy, stream_vz = stream_velocity
143-
if stream_vx**2 + stream_vy**2 != 0: # TODO: maybe try/except
143+
if stream_vx**2 + stream_vy**2 != 0:
144144
# Normalize component stream velocity in body frame
145145
stream_vzn = stream_vz / stream_speed
146146
if -1 * stream_vzn < 1:

rocketpy/rocket/aero_surface/fins/_elliptical_mixin.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,13 @@
22

33

44
class _EllipticalMixin:
5-
"""Mixin class for elliptical fins.
6-
This class holds methods and properties specific to elliptical fin shapes.
7-
It is designed to be used in conjunction with other classes that define the
8-
overall behavior of the fins.
9-
"""
5+
"""Mixin class for elliptical fins. This class holds methods and properties
6+
specific to elliptical fin shapes. It is designed to be used in conjunction
7+
with other classes that define the overall behavior of the fins."""
108

119
def evaluate_geometrical_parameters(self): # pylint: disable=too-many-statements
1210
"""Calculates and saves fin set's geometrical parameters such as the
13-
fins' area, aspect ratio and parameters for roll movement.
14-
15-
Returns
16-
-------
17-
None
18-
"""
11+
fins' area, aspect ratio and parameters for roll movement."""
1912

2013
# Compute auxiliary geometrical parameters
2114
# pylint: disable=invalid-name

rocketpy/rocket/aero_surface/fins/_free_form_mixin.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55

66
class _FreeFormMixin:
7-
"""Mixin class for free form fins.
8-
This class holds methods and properties specific to free form fin shapes.
9-
It is designed to be used in conjunction with other classes that define the
10-
overall behavior of the fins.
11-
"""
7+
"""Mixin class for free form fins. This class holds methods and properties
8+
specific to free form fin shapes. It is designed to be used in conjunction
9+
with other classes that define the overall behavior of the fins."""
1210

1311
def _initialize(self, shape_points):
1412
self.shape_points = shape_points
@@ -34,16 +32,10 @@ def _initialize(self, shape_points):
3432
)
3533

3634
def evaluate_geometrical_parameters(self): # pylint: disable=too-many-statements
37-
"""
38-
Calculates and saves the fin set's geometrical parameters such as the
35+
"""Calculates and saves the fin set's geometrical parameters such as the
3936
fin area, aspect ratio, and parameters related to roll movement. This
4037
method uses the same calculations to those in OpenRocket for free-form
41-
fin shapes.
42-
43-
Returns
44-
-------
45-
None
46-
"""
38+
fin shapes."""
4739
# pylint: disable=invalid-name
4840
# pylint: disable=too-many-locals
4941
# Calculate the fin area (Af) using the Shoelace theorem (polygon area formula)

rocketpy/rocket/aero_surface/fins/_trapezoidal_mixin.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33

44
class _TrapezoidalMixin:
5-
"""Mixin class for trapezoidal fins.
6-
This class holds methods and properties specific to trapezoidal fin shapes.
7-
It is designed to be used in conjunction with other classes that define the
8-
overall behavior of the fins.
9-
"""
5+
"""Mixin class for trapezoidal fins. This class holds methods and properties
6+
specific to trapezoidal fin shapes. It is designed to be used in conjunction
7+
with other classes that define the overall behavior of the fins."""
108

119
@property
1210
def tip_chord(self):
@@ -67,12 +65,7 @@ def _initialize(self, sweep_length, sweep_angle, root_chord, tip_chord, span):
6765

6866
def evaluate_geometrical_parameters(self):
6967
"""Calculates and saves fin set's geometrical parameters such as the
70-
fins' area, aspect ratio and parameters for roll movement.
71-
72-
Returns
73-
-------
74-
None
75-
"""
68+
fins' area, aspect ratio and parameters for roll movement."""
7669
# pylint: disable=invalid-name
7770
Yr = self.root_chord + self.tip_chord
7871
Af = Yr * self.span / 2 # Fin area

rocketpy/rocket/aero_surface/fins/elliptical_fin.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import numpy as np
2-
31
from rocketpy.plots.aero_surface_plots import _EllipticalFinPlots
42
from rocketpy.prints.aero_surface_prints import _EllipticalFinPrints
53
from rocketpy.rocket.aero_surface.fins._elliptical_mixin import _EllipticalMixin
@@ -9,7 +7,7 @@
97
class EllipticalFin(_EllipticalMixin, Fin):
108
"""Class that defines and holds information for an elliptical fin set.
119
12-
This class inherits from the Fins class.
10+
This class inherits from the Fin class.
1311
1412
Note
1513
----
@@ -21,12 +19,10 @@ class EllipticalFin(_EllipticalMixin, Fin):
2119
2220
See Also
2321
--------
24-
Fins
22+
Fin
2523
2624
Attributes
2725
----------
28-
EllipticalFin.n : int
29-
Number of fins in fin set.
3026
EllipticalFin.rocket_radius : float
3127
The reference rocket radius used for lift coefficient normalization, in
3228
meters.
@@ -35,9 +31,6 @@ class EllipticalFin(_EllipticalMixin, Fin):
3531
Second is the unit of the curve (radians or degrees)
3632
EllipticalFin.cant_angle : float
3733
Fins cant angle with respect to the rocket centerline, in degrees.
38-
EllipticalFin.changing_attribute_dict : dict
39-
Dictionary that stores the name and the values of the attributes that
40-
may be changed during a simulation. Useful for control systems.
4134
EllipticalFin.cant_angle_rad : float
4235
Fins cant angle with respect to the rocket centerline, in radians.
4336
EllipticalFin.root_chord : float
@@ -93,7 +86,7 @@ class EllipticalFin(_EllipticalMixin, Fin):
9386

9487
def __init__(
9588
self,
96-
n,
89+
angular_position,
9790
root_chord,
9891
span,
9992
rocket_radius,
@@ -105,8 +98,10 @@ def __init__(
10598
10699
Parameters
107100
----------
108-
n : int
109-
Number of fins, must be larger than 2.
101+
angular_position : float
102+
Angular position of the fin in degrees measured as the rotation
103+
around the symmetry axis of the rocket relative to one of the other
104+
principal axis. See :ref:`Angular Position Inputs <angular_position>`
110105
root_chord : int, float
111106
Fin root chord in meters.
112107
span : int, float
@@ -153,7 +148,7 @@ def __init__(
153148
"""
154149

155150
super().__init__(
156-
n,
151+
angular_position,
157152
root_chord,
158153
span,
159154
rocket_radius,

rocketpy/rocket/aero_surface/fins/elliptical_fins.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ class EllipticalFins(_EllipticalMixin, Fins):
3636
Second is the unit of the curve (radians or degrees)
3737
EllipticalFins.cant_angle : float
3838
Fins cant angle with respect to the rocket centerline, in degrees.
39-
EllipticalFins.changing_attribute_dict : dict
40-
Dictionary that stores the name and the values of the attributes that
41-
may be changed during a simulation. Useful for control systems.
4239
EllipticalFins.cant_angle_rad : float
4340
Fins cant angle with respect to the rocket centerline, in radians.
4441
EllipticalFins.root_chord : float

rocketpy/rocket/aero_surface/fins/fin.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ def __init__(
107107
108108
Parameters
109109
----------
110-
angular_position : int, float
111-
Angular position of the fin in degrees.
110+
angular_position : float
111+
Angular position of the fin in degrees measured as the rotation
112+
around the symmetry axis of the rocket relative to one of the other
113+
principal axis. See :ref:`Angular Position Inputs <angular_position>`
112114
root_chord : int, float
113115
Fin root chord in meters.
114116
span : int, float
@@ -244,11 +246,12 @@ def evaluate_rotation_matrix(self):
244246
Note
245247
----
246248
Local coordinate system:
249+
247250
- Origin located at the leading edge of the root chord.
248-
- Z axis along the longitudinal axis of the fin, positive downwards
249-
(leading edge -> trailing edge).
251+
- Z axis along the longitudinal axis of the fin, positive
252+
downwards (leading edge -> trailing edge).
250253
- Y axis perpendicular to the Z axis, in the span direction,
251-
positive upwards (root chord -> tip chord).
254+
positive upwards (root chord -> tip chord).
252255
- X axis completes the right-handed coordinate system.
253256
254257
@@ -258,7 +261,7 @@ def evaluate_rotation_matrix(self):
258261
259262
References
260263
----------
261-
[1] TODO link to docs
264+
:ref:`Individual Fin Model <individual_fins>`
262265
"""
263266
phi = self.angular_position_rad
264267
delta = self.cant_angle_rad

rocketpy/rocket/aero_surface/fins/free_form_fin.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import warnings
2-
3-
import numpy as np
4-
51
from rocketpy.plots.aero_surface_plots import _FreeFormFinPlots
62
from rocketpy.prints.aero_surface_prints import _FreeFormFinPrints
73
from rocketpy.rocket.aero_surface.fins._free_form_mixin import _FreeFormMixin
8-
9-
from .fins import Fins
4+
from rocketpy.rocket.aero_surface.fins.fin import Fin
105

116

12-
class FreeFormFin(_FreeFormMixin, Fins):
7+
class FreeFormFin(_FreeFormMixin, Fin):
138
"""Class that defines and holds information for a free form fin set.
149
15-
This class inherits from the Fins class.
10+
This class inherits from the Fin class.
1611
1712
Note
1813
----
@@ -24,7 +19,7 @@ class FreeFormFin(_FreeFormMixin, Fins):
2419
2520
See Also
2621
--------
27-
Fins
22+
Fin
2823
2924
Attributes
3025
----------
@@ -90,7 +85,7 @@ class FreeFormFin(_FreeFormMixin, Fins):
9085

9186
def __init__(
9287
self,
93-
n,
88+
angular_position,
9489
shape_points,
9590
rocket_radius,
9691
cant_angle=0,
@@ -101,8 +96,10 @@ def __init__(
10196
10297
Parameters
10398
----------
104-
n : int
105-
Number of fins, must be larger than 2.
99+
angular_position : float
100+
Angular position of the fin in degrees measured as the rotation
101+
around the symmetry axis of the rocket relative to one of the other
102+
principal axis. See :ref:`Angular Position Inputs <angular_position>`
106103
shape_points : list
107104
List of tuples (x, y) containing the coordinates of the fin's
108105
geometry defining points. The point (0, 0) is the root leading edge.
@@ -139,7 +136,7 @@ def __init__(
139136
root_chord, span = self._initialize(shape_points)
140137

141138
super().__init__(
142-
n,
139+
angular_position,
143140
root_chord,
144141
span,
145142
rocket_radius,

rocketpy/rocket/aero_surface/fins/free_form_fins.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import warnings
2-
3-
import numpy as np
4-
51
from rocketpy.plots.aero_surface_plots import _FreeFormFinsPlots
62
from rocketpy.prints.aero_surface_prints import _FreeFormFinsPrints
73
from rocketpy.rocket.aero_surface.fins._free_form_mixin import _FreeFormMixin

rocketpy/rocket/aero_surface/fins/trapezoidal_fin.py

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import math
2-
3-
import numpy as np
4-
51
from rocketpy.plots.aero_surface_plots import _TrapezoidalFinPlots
62
from rocketpy.prints.aero_surface_prints import _TrapezoidalFinPrints
73
from rocketpy.rocket.aero_surface.fins._trapezoidal_mixin import _TrapezoidalMixin
@@ -10,7 +6,7 @@
106

117

128
class TrapezoidalFin(_TrapezoidalMixin, Fin):
13-
"""A class used to represent a single trapezoidal fin. TODO: review this
9+
"""A class used to represent a single trapezoidal fin.
1410
1511
This class inherits from the Fin class.
1612
@@ -29,8 +25,8 @@ class TrapezoidalFin(_TrapezoidalMixin, Fin):
2925
Attributes
3026
----------
3127
TrapezoidalFin.angular_position : float
32-
Angular position of the fin set with respect to the rocket centerline, in
33-
degrees.
28+
Angular position of the fin set with respect to the rocket centerline,
29+
in degrees.
3430
TrapezoidalFin.rocket_radius : float
3531
The reference rocket radius used for lift coefficient normalization, in
3632
meters.
@@ -39,9 +35,6 @@ class TrapezoidalFin(_TrapezoidalMixin, Fin):
3935
Second is the unit of the curve (radians or degrees).
4036
TrapezoidalFin.cant_angle : float
4137
Fins cant angle with respect to the rocket centerline, in degrees.
42-
TrapezoidalFin.changing_attribute_dict : dict
43-
Dictionary that stores the name and the values of the attributes that
44-
may be changed during a simulation. Useful for control systems.
4538
TrapezoidalFin.cant_angle_rad : float
4639
Fins cant angle with respect to the rocket centerline, in radians.
4740
TrapezoidalFin.root_chord : float
@@ -102,6 +95,56 @@ def __init__(
10295
airfoil=None,
10396
name="Fins",
10497
):
98+
"""Initializes the TrapezoidalFin class.
99+
100+
Parameters
101+
----------
102+
angular_position : float
103+
Angular position of the fin in degrees measured as the rotation
104+
around the symmetry axis of the rocket relative to one of the other
105+
principal axis. See :ref:`Angular Position Inputs <angular_position>`
106+
root_chord : int, float
107+
Fin root chord in meters.
108+
tip_chord : int, float
109+
Fin tip chord in meters.
110+
span : int, float
111+
Fin span in meters.
112+
rocket_radius : int, float
113+
Reference radius to calculate lift coefficient, in meters.
114+
cant_angle : int, float, optional
115+
Fins cant angle with respect to the rocket centerline. Must
116+
be given in degrees.
117+
sweep_length : int, float, optional
118+
Fins sweep length in meters. By sweep length, understand the axial
119+
distance between the fin root leading edge and the fin tip leading
120+
edge measured parallel to the rocket centerline. If not given, the
121+
sweep length is assumed to be equal the root chord minus the tip
122+
chord, in which case the fin is a right trapezoid with its base
123+
perpendicular to the rocket's axis. Cannot be used in conjunction
124+
with sweep_angle.
125+
sweep_angle : int, float, optional
126+
Fins sweep angle with respect to the rocket centerline. Must
127+
be given in degrees. If not given, the sweep angle is automatically
128+
calculated, in which case the fin is assumed to be a right trapezoid
129+
with its base perpendicular to the rocket's axis.
130+
Cannot be used in conjunction with sweep_length.
131+
airfoil : tuple, optional
132+
Default is null, in which case fins will be treated as flat plates.
133+
Otherwise, if tuple, fins will be considered as airfoils. The
134+
tuple's first item specifies the airfoil's lift coefficient
135+
by angle of attack and must be either a .csv, .txt, ndarray
136+
or callable. The .csv and .txt files can contain a single line
137+
header and the first column must specify the angle of attack, while
138+
the second column must specify the lift coefficient. The
139+
ndarray should be as [(x0, y0), (x1, y1), (x2, y2), ...]
140+
where x0 is the angle of attack and y0 is the lift coefficient.
141+
If callable, it should take an angle of attack as input and
142+
return the lift coefficient at that angle of attack.
143+
The tuple's second item is the unit of the angle of attack,
144+
accepting either "radians" or "degrees".
145+
name : str
146+
Name of fin set.
147+
"""
105148
super().__init__(
106149
angular_position,
107150
root_chord,

0 commit comments

Comments
 (0)