Skip to content

Commit 01819ac

Browse files
MAINT: updating docstrings of AeroSurfaces
1 parent 6b906d5 commit 01819ac

File tree

1 file changed

+142
-85
lines changed

1 file changed

+142
-85
lines changed

rocketpy/AeroSurfaces.py

Lines changed: 142 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
__author__ = "Guilherme Fernandes Alves"
1+
__author__ = "Guilherme Fernandes Alves, Mateus Stano Junqueira"
22
__copyright__ = "Copyright 20XX, RocketPy Team"
33
__license__ = "MIT"
44

5-
import numpy as np
65
import matplotlib.pyplot as plt
6+
import numpy as np
77
from matplotlib.patches import Ellipse
8+
89
from .Function import Function
910

1011

@@ -27,10 +28,21 @@ class NoseCone:
2728
Tuple with the x, y and z coordinates of the nose cone center of pressure
2829
relative to the rocket center of mass. Has units of length and must be
2930
given in meters.
31+
NoseCone.cpx : float
32+
Nose cone center of pressure x coordinate relative to the rocket center
33+
of mass. Has units of length and must be given in meters.
34+
NoseCone.cpy : float
35+
Nose cone center of pressure y coordinate relative to the rocket center
36+
of mass. Has units of length and must be given in meters.
37+
NoseCone.cpz : float
38+
Nose cone center of pressure z coordinate relative to the rocket center
39+
of mass. Has units of length and must be given in meters.
3040
NoseCone.cl : Function
3141
Function which defines the lift coefficient as a function of the angle of
3242
attack and the Mach number. It must take as input the angle of attack in
3343
radians and the Mach number. It should return the lift coefficient.
44+
NoseCone.clalpha : float
45+
Lift coefficient derivative. Has units of 1/rad.
3446
"""
3547

3648
def __init__(self, length, kind, distanceToCM, name="Nose Cone"):
@@ -43,7 +55,7 @@ def __init__(self, length, kind, distanceToCM, name="Nose Cone"):
4355
Nose cone length. Has units of length and must be given in meters.
4456
kind : string
4557
Nose cone kind. Can be "conical", "ogive" or "lvhaack".
46-
distanceToCM : _type_
58+
distanceToCM : float
4759
Distance between nose cone tip and rocket center of mass. Has units of
4860
length and must be given in meters.
4961
name : str, optional
@@ -91,65 +103,71 @@ class Fins:
91103
"""Super class that holds common methods for the fin classes.
92104
Should not be instantiated.
93105
94-
Attributes
106+
Parameters
95107
----------
108+
None
96109
97-
Geometrical attributes:
98-
Fins.n : int
99-
Number of fins in fin set
100-
Fins.radius : float
101-
Radius of the rocket at the position of the fin set
102-
Fins.airfoil : tuple
103-
Tuple of two items. First is the airfoil lift curve.
104-
Second is the unit of the curve (radians or degrees)
105-
Fins.distanceToCM : float
106-
Fin set position relative to rocket unloaded center of
107-
mass, considering positive direction from center of mass to
108-
nose cone.
109-
Fins.cantAngle : float
110-
Fins cant angle with respect to the rocket centerline, in degrees
111-
Fins.changingAttributeDict : dict
112-
Dictionary that stores the name and the values of the attributes that may
113-
be changed during a simulation. Useful for control systems.
114-
Fins.cantAngleRad : float
115-
Fins cant angle with respect to the rocket centerline, in radians
116-
Fins.rootChord : float
117-
Fin root chord in meters.
118-
Fins.tipChord : float
119-
Fin tip chord in meters.
120-
Fins.span : float
121-
Fin span in meters.
122-
Fins.name : string
123-
Name of fin set
124-
Fins.sweepLength : float
125-
Fins sweep length in meters. By sweep length, understand the axial distance
126-
between the fin root leading edge and the fin tip leading edge measured
127-
parallel to the rocket centerline.
128-
Fins.sweepAngle : float
129-
Fins sweep angle with respect to the rocket centerline. Must
130-
be given in degrees.
131-
Fins.d : float
132-
Diameter of the rocket at the position of the fin set
133-
Fins.Aref : float
134-
Reference area of the rocket
135-
Fins.Af : float
136-
Area of the longtudinal section of each fin in the set
137-
Fins.AR : float
138-
Aspect ratio of each fin in the set
139-
Fins.gamma_c : float
140-
Fin midchord sweep angle
141-
Fins.Yma : float
142-
Span wise position of the mean aerodynamic chord
143-
Fins.rollGeometricalConstant : float
144-
Geometrical constant used in roll calculations
145-
Fins.tau : float
146-
Geometrical relation used to simplify lift and roll calculations
147-
Fins.liftInterferenceFactor : float
148-
Factor of Fin-Body interference in the lift coefficient
110+
Attributes
111+
----------
112+
Fins.n : int
113+
Number of fins in fin set
114+
Fins.radius : float
115+
Radius of the rocket at the position of the fin set
116+
Fins.airfoil : tuple
117+
Tuple of two items. First is the airfoil lift curve.
118+
Second is the unit of the curve (radians or degrees)
119+
Fins.distanceToCM : float
120+
Fin set position relative to rocket unloaded center of
121+
mass, considering positive direction from center of mass to
122+
nose cone.
123+
Fins.cantAngle : float
124+
Fins cant angle with respect to the rocket centerline, in degrees
125+
Fins.cl : Function
126+
Function which defines the lift coefficient as a function of the angle of
127+
attack and the Mach number. It must take as input the angle of attack in
128+
radians and the Mach number. It should return the lift coefficient.
129+
Fins.changingAttributeDict : dict
130+
Dictionary that stores the name and the values of the attributes that may
131+
be changed during a simulation. Useful for control systems.
132+
Fins.cantAngleRad : float
133+
Fins cant angle with respect to the rocket centerline, in radians
134+
Fins.rootChord : float
135+
Fin root chord in meters.
136+
Fins.tipChord : float
137+
Fin tip chord in meters.
138+
Fins.span : float
139+
Fin span in meters.
140+
Fins.name : string
141+
Name of fin set
142+
Fins.sweepLength : float
143+
Fins sweep length in meters. By sweep length, understand the axial distance
144+
between the fin root leading edge and the fin tip leading edge measured
145+
parallel to the rocket centerline.
146+
Fins.sweepAngle : float
147+
Fins sweep angle with respect to the rocket centerline. Must
148+
be given in degrees.
149+
Fins.d : float
150+
Diameter of the rocket at the position of the fin set
151+
Fins.Aref : float
152+
Reference area of the rocket
153+
Fins.Af : float
154+
Area of the longitudinal section of each fin in the set
155+
Fins.AR : float
156+
Aspect ratio of each fin in the set
157+
Fins.gamma_c : float
158+
Fin mid-chord sweep angle
159+
Fins.Yma : float
160+
Span wise position of the mean aerodynamic chord
161+
Fins.rollGeometricalConstant : float
162+
Geometrical constant used in roll calculations
163+
Fins.tau : float
164+
Geometrical relation used to simplify lift and roll calculations
165+
Fins.liftInterferenceFactor : float
166+
Factor of Fin-Body interference in the lift coefficient
149167
"""
150168

151169
def evaluateLiftCoefficient(self):
152-
"""Calculates and returns the finset's lift coefficient.
170+
"""Calculates and returns the lift coefficient of the fin set.
153171
The lift coefficient is saved and returned. This function
154172
also calculates and saves the lift coefficient derivative
155173
for a single fin and the lift coefficient derivative for
@@ -163,9 +181,9 @@ def evaluateLiftCoefficient(self):
163181
-------
164182
self.cl : Function
165183
Function of the angle of attack (Alpha) and the mach number
166-
(Mach) expressing the finset's lift coefficient. The inputs
184+
(Mach) expressing the lift coefficient of the fin set. The inputs
167185
are the angle of attack (in radians) and the mach number.
168-
The output is the finset's lift coefficient.
186+
The output is the lift coefficient of the fin set.
169187
"""
170188
if not self.airfoil:
171189
# Defines clalpha2D as 2*pi for planar fins
@@ -219,7 +237,7 @@ def evaluateLiftCoefficient(self):
219237
return self.cl
220238

221239
def evaluateRollCoefficients(self):
222-
"""Calculates and returns the finset's roll coefficients.
240+
"""Calculates and returns the fin set's roll coefficients.
223241
The roll coefficients are saved in a list.
224242
225243
Parameters
@@ -261,7 +279,7 @@ def setAttribute(self, name, value):
261279
262280
Parameters
263281
----------
264-
name : strig
282+
name : string
265283
Name of the attribute that will be changed.
266284
value : any
267285
value to which the attribute will be changed to.
@@ -418,8 +436,8 @@ def rollInfo(self):
418436
)
419437
)
420438

421-
self.rollParameters[0]()
422-
self.rollParameters[1]()
439+
self.rollParameters[0]() # TODO: improve this plot
440+
self.rollParameters[1]() # TODO: improve this plot
423441

424442
return None
425443

@@ -495,11 +513,11 @@ class TrapezoidalFins(Fins):
495513
TrapezoidalFins.Aref : float
496514
Reference area of the rocket
497515
TrapezoidalFins.Af : float
498-
Area of the longtudinal section of each fin in the set
516+
Area of the longitudinal section of each fin in the set
499517
TrapezoidalFins.AR : float
500518
Aspect ratio of each fin in the set
501519
TrapezoidalFins.gamma_c : float
502-
Fin midchord sweep angle
520+
Fin mid-chord sweep angle
503521
TrapezoidalFins.Yma : float
504522
Span wise position of the mean aerodynamic chord
505523
TrapezoidalFins.rollGeometricalConstant : float
@@ -672,7 +690,7 @@ def __init__(
672690
self.evaluateRollCoefficients()
673691

674692
def evaluateCenterOfPressure(self):
675-
"""Calculates and returns the finset's center of pressure
693+
"""Calculates and returns the center of pressure of the fin set
676694
in relation to the rocket's center of dry mass. the center
677695
of pressure position is saved and stored in a tuple.
678696
@@ -850,11 +868,11 @@ class EllipticalFins(Fins):
850868
EllipticalFins.Aref : float
851869
Reference area of the rocket
852870
EllipticalFins.Af : float
853-
Area of the longtudinal section of each fin in the set
871+
Area of the longitudinal section of each fin in the set
854872
EllipticalFins.AR : float
855873
Aspect ratio of each fin in the set
856874
EllipticalFins.gamma_c : float
857-
Fin midchord sweep angle
875+
Fin mid-chord sweep angle
858876
EllipticalFins.Yma : float
859877
Span wise position of the mean aerodynamic chord
860878
EllipticalFins.rollGeometricalConstant : float
@@ -1022,7 +1040,7 @@ def __init__(
10221040
return None
10231041

10241042
def evaluateCenterOfPressure(self):
1025-
"""Calculates and returns the finset's center of pressure
1043+
"""Calculates and returns the center of pressure of the fin set.
10261044
in relation to the rocket's center of dry mass. the center
10271045
of pressure position is saved and stored in a tuple.
10281046
@@ -1067,7 +1085,7 @@ def draw(self):
10671085
)
10681086

10691087
# Mean Aerodynamic Chord
1070-
Yma_length = 8 * self.rootChord / (3 * np.pi) # From barrowman
1088+
Yma_length = 8 * self.rootChord / (3 * np.pi) # From Barrowman's theory
10711089
Yma_start = (self.rootChord - Yma_length) / 2
10721090
Yma_end = self.rootChord - (self.rootChord - Yma_length) / 2
10731091
Yma_line = plt.Line2D(
@@ -1114,37 +1132,76 @@ def draw(self):
11141132

11151133

11161134
class Tail:
1117-
"""Class that defines a tail for the rocket.
1135+
"""Class that defines a tail for the rocket. Currently only accepts
1136+
conical tails.
11181137
11191138
Parameters
11201139
----------
1121-
length : int, float
1122-
Length of the tail.
1123-
...
1140+
Tail.topRadius : int, float
1141+
Radius of the top of the tail. The top radius is defined as the radius
1142+
of the transversal section that is closest to the rocket's nose.
1143+
Tail.bottomRadius : int, float
1144+
Radius of the bottom of the tail.
1145+
Tail.length : int, float
1146+
Length of the tail. The length is defined as the distance between the
1147+
top and bottom of the tail. The length is measured along the rocket's
1148+
longitudinal axis. Has the unit of meters.
1149+
Tail.distanceToCM : int, float
1150+
Distance from the center of dry mass to the center of the tail.
1151+
Tail.radius: int, float
1152+
The radius of the rocket's body at the tail's position.
1153+
Tail.name : str
1154+
Name of the tail. Default is 'Tail'.
11241155
1156+
Attributes
1157+
----------
1158+
Tail.cpx : int, float
1159+
x coordinate of the center of pressure of the tail.
1160+
Tail.cpy : int, float
1161+
y coordinate of the center of pressure of the tail.
1162+
Tail.cpz : int, float
1163+
z coordinate of the center of pressure of the tail.
1164+
Tail.cp : tuple
1165+
Tuple containing the coordinates of the center of pressure of the tail.
1166+
Tail.cl : Function
1167+
Function that returns the lift coefficient of the tail. The function
1168+
is defined as a function of the angle of attack and the mach number.
1169+
Tail.clalpha : float
1170+
Lift coefficient slope. Has the unit of 1/rad.
1171+
Tail.slantLength : float
1172+
Slant length of the tail. The slant length is defined as the distance
1173+
between the top and bottom of the tail. The slant length is measured
1174+
along the tail's slant axis. Has the unit of meters.
1175+
Tail.surfaceArea : float
1176+
Surface area of the tail. Has the unit of meters squared.
11251177
11261178
"""
11271179

11281180
def __init__(
11291181
self, topRadius, bottomRadius, length, distanceToCM, radius, name="Tail"
11301182
):
1131-
"""_summary_
1183+
"""Initializes the tail object by computing and storing the most
1184+
important values.
11321185
11331186
Parameters
11341187
----------
1135-
topRadius : _type_
1136-
_description_
1137-
bottomRadius : _type_
1138-
_description_
1139-
length : _type_
1140-
_description_
1141-
distanceToCM : _type_
1142-
_description_
1188+
topRadius : int, float
1189+
Radius of the top of the tail. The top radius is defined as the radius
1190+
of the transversal section that is closest to the rocket's nose.
1191+
bottomRadius : int, float
1192+
Radius of the bottom of the tail.
1193+
length : int, float
1194+
Length of the tail.
1195+
distanceToCM : int, float
1196+
Distance from the center of dry mass to the center of the tail.
1197+
radius : int, float
1198+
The radius of the rocket's body at the tail's position.
1199+
name : str
1200+
Name of the tail. Default is 'Tail'.
11431201
11441202
Returns
11451203
-------
1146-
_type_
1147-
_description_
1204+
None
11481205
"""
11491206

11501207
# Store arguments as attributes

0 commit comments

Comments
 (0)