1
- __author__ = "Guilherme Fernandes Alves"
1
+ __author__ = "Guilherme Fernandes Alves, Mateus Stano Junqueira "
2
2
__copyright__ = "Copyright 20XX, RocketPy Team"
3
3
__license__ = "MIT"
4
4
5
- import numpy as np
6
5
import matplotlib .pyplot as plt
6
+ import numpy as np
7
7
from matplotlib .patches import Ellipse
8
+
8
9
from .Function import Function
9
10
10
11
@@ -27,10 +28,21 @@ class NoseCone:
27
28
Tuple with the x, y and z coordinates of the nose cone center of pressure
28
29
relative to the rocket center of mass. Has units of length and must be
29
30
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.
30
40
NoseCone.cl : Function
31
41
Function which defines the lift coefficient as a function of the angle of
32
42
attack and the Mach number. It must take as input the angle of attack in
33
43
radians and the Mach number. It should return the lift coefficient.
44
+ NoseCone.clalpha : float
45
+ Lift coefficient derivative. Has units of 1/rad.
34
46
"""
35
47
36
48
def __init__ (self , length , kind , distanceToCM , name = "Nose Cone" ):
@@ -43,7 +55,7 @@ def __init__(self, length, kind, distanceToCM, name="Nose Cone"):
43
55
Nose cone length. Has units of length and must be given in meters.
44
56
kind : string
45
57
Nose cone kind. Can be "conical", "ogive" or "lvhaack".
46
- distanceToCM : _type_
58
+ distanceToCM : float
47
59
Distance between nose cone tip and rocket center of mass. Has units of
48
60
length and must be given in meters.
49
61
name : str, optional
@@ -91,65 +103,71 @@ class Fins:
91
103
"""Super class that holds common methods for the fin classes.
92
104
Should not be instantiated.
93
105
94
- Attributes
106
+ Parameters
95
107
----------
108
+ None
96
109
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
149
167
"""
150
168
151
169
def evaluateLiftCoefficient (self ):
152
- """Calculates and returns the finset's lift coefficient.
170
+ """Calculates and returns the lift coefficient of the fin set .
153
171
The lift coefficient is saved and returned. This function
154
172
also calculates and saves the lift coefficient derivative
155
173
for a single fin and the lift coefficient derivative for
@@ -163,9 +181,9 @@ def evaluateLiftCoefficient(self):
163
181
-------
164
182
self.cl : Function
165
183
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
167
185
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 .
169
187
"""
170
188
if not self .airfoil :
171
189
# Defines clalpha2D as 2*pi for planar fins
@@ -219,7 +237,7 @@ def evaluateLiftCoefficient(self):
219
237
return self .cl
220
238
221
239
def evaluateRollCoefficients (self ):
222
- """Calculates and returns the finset 's roll coefficients.
240
+ """Calculates and returns the fin set 's roll coefficients.
223
241
The roll coefficients are saved in a list.
224
242
225
243
Parameters
@@ -261,7 +279,7 @@ def setAttribute(self, name, value):
261
279
262
280
Parameters
263
281
----------
264
- name : strig
282
+ name : string
265
283
Name of the attribute that will be changed.
266
284
value : any
267
285
value to which the attribute will be changed to.
@@ -418,8 +436,8 @@ def rollInfo(self):
418
436
)
419
437
)
420
438
421
- self .rollParameters [0 ]()
422
- self .rollParameters [1 ]()
439
+ self .rollParameters [0 ]() # TODO: improve this plot
440
+ self .rollParameters [1 ]() # TODO: improve this plot
423
441
424
442
return None
425
443
@@ -495,11 +513,11 @@ class TrapezoidalFins(Fins):
495
513
TrapezoidalFins.Aref : float
496
514
Reference area of the rocket
497
515
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
499
517
TrapezoidalFins.AR : float
500
518
Aspect ratio of each fin in the set
501
519
TrapezoidalFins.gamma_c : float
502
- Fin midchord sweep angle
520
+ Fin mid-chord sweep angle
503
521
TrapezoidalFins.Yma : float
504
522
Span wise position of the mean aerodynamic chord
505
523
TrapezoidalFins.rollGeometricalConstant : float
@@ -672,7 +690,7 @@ def __init__(
672
690
self .evaluateRollCoefficients ()
673
691
674
692
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
676
694
in relation to the rocket's center of dry mass. the center
677
695
of pressure position is saved and stored in a tuple.
678
696
@@ -850,11 +868,11 @@ class EllipticalFins(Fins):
850
868
EllipticalFins.Aref : float
851
869
Reference area of the rocket
852
870
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
854
872
EllipticalFins.AR : float
855
873
Aspect ratio of each fin in the set
856
874
EllipticalFins.gamma_c : float
857
- Fin midchord sweep angle
875
+ Fin mid-chord sweep angle
858
876
EllipticalFins.Yma : float
859
877
Span wise position of the mean aerodynamic chord
860
878
EllipticalFins.rollGeometricalConstant : float
@@ -1022,7 +1040,7 @@ def __init__(
1022
1040
return None
1023
1041
1024
1042
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.
1026
1044
in relation to the rocket's center of dry mass. the center
1027
1045
of pressure position is saved and stored in a tuple.
1028
1046
@@ -1067,7 +1085,7 @@ def draw(self):
1067
1085
)
1068
1086
1069
1087
# 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
1071
1089
Yma_start = (self .rootChord - Yma_length ) / 2
1072
1090
Yma_end = self .rootChord - (self .rootChord - Yma_length ) / 2
1073
1091
Yma_line = plt .Line2D (
@@ -1114,37 +1132,76 @@ def draw(self):
1114
1132
1115
1133
1116
1134
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.
1118
1137
1119
1138
Parameters
1120
1139
----------
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'.
1124
1155
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.
1125
1177
1126
1178
"""
1127
1179
1128
1180
def __init__ (
1129
1181
self , topRadius , bottomRadius , length , distanceToCM , radius , name = "Tail"
1130
1182
):
1131
- """_summary_
1183
+ """Initializes the tail object by computing and storing the most
1184
+ important values.
1132
1185
1133
1186
Parameters
1134
1187
----------
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'.
1143
1201
1144
1202
Returns
1145
1203
-------
1146
- _type_
1147
- _description_
1204
+ None
1148
1205
"""
1149
1206
1150
1207
# Store arguments as attributes
0 commit comments