Skip to content

Commit 024ea0f

Browse files
committed
bug: fixed setAttribute and fin area calculation
1 parent fdc5085 commit 024ea0f

File tree

2 files changed

+75
-73
lines changed

2 files changed

+75
-73
lines changed

rocketpy/AeroSurfaces.py

Lines changed: 73 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ def evaluateRollCoefficients(self):
233233
roll moment damping coefficient and the cant angle in
234234
radians
235235
"""
236+
237+
self.cantAngleRad = np.radians(self.cantAngle)
238+
236239
clfDelta = (
237240
self.rollForcingInterferenceFactor
238241
* self.n
@@ -271,7 +274,7 @@ def setAttribute(self, name, value):
271274
self.__dict__[name] = value
272275

273276
# Add changed attribute to dict
274-
if self.changingAttributeDict.has_key(name):
277+
if self.changingAttributeDict.get(name) != None:
275278
self.changingAttributeDict[name].append(value)
276279
else:
277280
self.changingAttributeDict[name] = [value]
@@ -442,8 +445,7 @@ def allInfo(self):
442445

443446
self.geometricalInfo()
444447
self.liftInfo()
445-
if self.cantAngle:
446-
self.rollInfo()
448+
self.rollInfo()
447449

448450
return None
449451

@@ -615,6 +617,27 @@ def __init__(
615617
# Fin–body interference correction parameters
616618
tau = (span + radius) / radius
617619
liftInterferenceFactor = 1 + 1 / tau
620+
# Parameters for Roll Moment.
621+
# Documented at: https://github.com/RocketPy-Team/RocketPy/blob/master/docs/technical/aerodynamics/Roll_Equations.pdf
622+
λ = tipChord / rootChord
623+
rollDampingInterferenceFactor = 1 + (
624+
((tau - λ) / (tau)) - ((1 - λ) / (tau - 1)) * np.log(tau)
625+
) / (
626+
((tau + 1) * (tau - λ)) / (2) - ((1 - λ) * (tau**3 - 1)) / (3 * (tau - 1))
627+
)
628+
rollForcingInterferenceFactor = (1 / np.pi**2) * (
629+
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
630+
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
631+
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
632+
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
633+
+ ((tau**2 + 1) ** 2)
634+
/ (tau**2 * (tau - 1) ** 2)
635+
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
636+
- (4 * (tau + 1))
637+
/ (tau * (tau - 1))
638+
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
639+
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
640+
)
618641

619642
# Store values
620643
self.n = n
@@ -623,7 +646,6 @@ def __init__(
623646
self.distanceToCM = distanceToCM
624647
self.cantAngle = cantAngle
625648
self.changingAttributeDict = {}
626-
self.cantAngleRad = np.radians(cantAngle)
627649
self.rootChord = rootChord
628650
self.tipChord = tipChord
629651
self.span = span
@@ -633,41 +655,21 @@ def __init__(
633655
self.d = d
634656
self.Aref = Aref # Reference area
635657
self.Yr = Yr
636-
self.Af = Af * span / 2 # Fin area
658+
self.Af = Af # Fin area
637659
self.AR = AR # Fin aspect ratio
638660
self.gamma_c = gamma_c # Mid chord angle
639661
self.Yma = Yma # Span wise coord of mean aero chord
640662
self.rollGeometricalConstant = rollGeometricalConstant
641663
self.tau = tau
642664
self.liftInterferenceFactor = liftInterferenceFactor
665+
self.λ = λ
666+
self.rollDampingInterferenceFactor = rollDampingInterferenceFactor
667+
self.rollForcingInterferenceFactor = rollForcingInterferenceFactor
643668

644669
self.evaluateCenterOfPressure()
645670
self.evaluateLiftCoefficient()
646671

647-
if cantAngle:
648-
# Parameters for Roll Moment.
649-
# Documented at: https://github.com/RocketPy-Team/RocketPy/blob/master/docs/technical/aerodynamics/Roll_Equations.pdf
650-
self.λ = tipChord / rootChord
651-
self.rollDampingInterferenceFactor = 1 + (
652-
((tau - self.λ) / (tau)) - ((1 - self.λ) / (tau - 1)) * np.log(tau)
653-
) / (
654-
((tau + 1) * (tau - self.λ)) / (2)
655-
- ((1 - self.λ) * (tau**3 - 1)) / (3 * (tau - 1))
656-
)
657-
self.rollForcingInterferenceFactor = (1 / np.pi**2) * (
658-
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
659-
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
660-
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
661-
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
662-
+ ((tau**2 + 1) ** 2)
663-
/ (tau**2 * (tau - 1) ** 2)
664-
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
665-
- (4 * (tau + 1))
666-
/ (tau * (tau - 1))
667-
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
668-
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
669-
)
670-
self.evaluateRollCoefficients()
672+
self.evaluateRollCoefficients()
671673

672674
def evaluateCenterOfPressure(self):
673675
"""Calculates and returns the finset's center of pressure
@@ -951,6 +953,44 @@ def __init__(
951953
# Fin–body interference correction parameters
952954
tau = (span + radius) / radius
953955
liftInterferenceFactor = 1 + 1 / tau
956+
rollDampingInterferenceFactor = 1 + (
957+
(radius**2)
958+
* (
959+
2
960+
* (radius**2)
961+
* np.sqrt(span**2 - radius**2)
962+
* np.log(
963+
(2 * span * np.sqrt(span**2 - radius**2) + 2 * span**2)
964+
/ radius
965+
)
966+
- 2
967+
* (radius**2)
968+
* np.sqrt(span**2 - radius**2)
969+
* np.log(2 * span)
970+
+ 2 * span**3
971+
- np.pi * radius * span**2
972+
- 2 * (radius**2) * span
973+
+ np.pi * radius**3
974+
)
975+
) / (
976+
2
977+
* (span**2)
978+
* (span / 3 + np.pi * radius / 4)
979+
* (span**2 - radius**2)
980+
)
981+
rollForcingInterferenceFactor = (1 / np.pi**2) * (
982+
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
983+
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
984+
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
985+
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
986+
+ ((tau**2 + 1) ** 2)
987+
/ (tau**2 * (tau - 1) ** 2)
988+
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
989+
- (4 * (tau + 1))
990+
/ (tau * (tau - 1))
991+
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
992+
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
993+
)
954994

955995
# Store values
956996
self.n = n
@@ -965,57 +1005,19 @@ def __init__(
9651005
self.name = name
9661006
self.d = d
9671007
self.Aref = Aref # Reference area
968-
self.Af = Af * span / 2 # Fin area
1008+
self.Af = Af # Fin area
9691009
self.AR = AR # Fin aspect ratio
9701010
self.gamma_c = gamma_c # Mid chord angle
9711011
self.Yma = Yma # Span wise coord of mean aero chord
9721012
self.rollGeometricalConstant = rollGeometricalConstant
9731013
self.tau = tau
9741014
self.liftInterferenceFactor = liftInterferenceFactor
1015+
self.rollDampingInterferenceFactor = rollDampingInterferenceFactor
1016+
self.rollForcingInterferenceFactor = rollForcingInterferenceFactor
9751017

9761018
self.evaluateCenterOfPressure()
9771019
self.evaluateLiftCoefficient()
978-
979-
if cantAngle:
980-
self.rollDampingInterferenceFactor = 1 + (
981-
(radius**2)
982-
* (
983-
2
984-
* (radius**2)
985-
* np.sqrt(span**2 - radius**2)
986-
* np.log(
987-
(2 * span * np.sqrt(span**2 - radius**2) + 2 * span**2)
988-
/ radius
989-
)
990-
- 2
991-
* (radius**2)
992-
* np.sqrt(span**2 - radius**2)
993-
* np.log(2 * span)
994-
+ 2 * span**3
995-
- np.pi * radius * span**2
996-
- 2 * (radius**2) * span
997-
+ np.pi * radius**3
998-
)
999-
) / (
1000-
2
1001-
* (span**2)
1002-
* (span / 3 + np.pi * radius / 4)
1003-
* (span**2 - radius**2)
1004-
)
1005-
self.rollForcingInterferenceFactor = (1 / np.pi**2) * (
1006-
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
1007-
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
1008-
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
1009-
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
1010-
+ ((tau**2 + 1) ** 2)
1011-
/ (tau**2 * (tau - 1) ** 2)
1012-
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
1013-
- (4 * (tau + 1))
1014-
/ (tau * (tau - 1))
1015-
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
1016-
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
1017-
)
1018-
self.evaluateRollCoefficients()
1020+
self.evaluateRollCoefficients()
10191021

10201022
return None
10211023

rocketpy/Rocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,10 @@ def addTrapezoidalFins(
535535
tipChord,
536536
span,
537537
distanceToCM,
538+
radius,
538539
cantAngle,
539540
sweepLength,
540541
sweepAngle,
541-
radius,
542542
airfoil,
543543
name,
544544
)
@@ -621,7 +621,7 @@ def addEllipticalFins(
621621

622622
# Create a fin set as an object of EllipticalFins class
623623
finSet = EllipticalFins(
624-
n, rootChord, span, distanceToCM, cantAngle, radius, airfoil, name
624+
n, rootChord, span, distanceToCM, radius, cantAngle, airfoil, name
625625
)
626626

627627
# Add fin set to the list of aerodynamic surfaces

0 commit comments

Comments
 (0)