Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bug: fixed setAttribute and fin area calculation
  • Loading branch information
MateusStano committed Nov 1, 2022
commit 024ea0f8c57b1ef7258260a2e7671442f4d80b8f
144 changes: 73 additions & 71 deletions rocketpy/AeroSurfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ def evaluateRollCoefficients(self):
roll moment damping coefficient and the cant angle in
radians
"""

self.cantAngleRad = np.radians(self.cantAngle)

clfDelta = (
self.rollForcingInterferenceFactor
* self.n
Expand Down Expand Up @@ -271,7 +274,7 @@ def setAttribute(self, name, value):
self.__dict__[name] = value

# Add changed attribute to dict
if self.changingAttributeDict.has_key(name):
if self.changingAttributeDict.get(name) != None:
self.changingAttributeDict[name].append(value)
else:
self.changingAttributeDict[name] = [value]
Expand Down Expand Up @@ -442,8 +445,7 @@ def allInfo(self):

self.geometricalInfo()
self.liftInfo()
if self.cantAngle:
self.rollInfo()
self.rollInfo()

return None

Expand Down Expand Up @@ -615,6 +617,27 @@ def __init__(
# Fin–body interference correction parameters
tau = (span + radius) / radius
liftInterferenceFactor = 1 + 1 / tau
# Parameters for Roll Moment.
# Documented at: https://github.com/RocketPy-Team/RocketPy/blob/master/docs/technical/aerodynamics/Roll_Equations.pdf
λ = tipChord / rootChord
rollDampingInterferenceFactor = 1 + (
((tau - λ) / (tau)) - ((1 - λ) / (tau - 1)) * np.log(tau)
) / (
((tau + 1) * (tau - λ)) / (2) - ((1 - λ) * (tau**3 - 1)) / (3 * (tau - 1))
)
rollForcingInterferenceFactor = (1 / np.pi**2) * (
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
+ ((tau**2 + 1) ** 2)
/ (tau**2 * (tau - 1) ** 2)
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
- (4 * (tau + 1))
/ (tau * (tau - 1))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
)

# Store values
self.n = n
Expand All @@ -623,7 +646,6 @@ def __init__(
self.distanceToCM = distanceToCM
self.cantAngle = cantAngle
self.changingAttributeDict = {}
self.cantAngleRad = np.radians(cantAngle)
self.rootChord = rootChord
self.tipChord = tipChord
self.span = span
Expand All @@ -633,41 +655,21 @@ def __init__(
self.d = d
self.Aref = Aref # Reference area
self.Yr = Yr
self.Af = Af * span / 2 # Fin area
self.Af = Af # Fin area
self.AR = AR # Fin aspect ratio
self.gamma_c = gamma_c # Mid chord angle
self.Yma = Yma # Span wise coord of mean aero chord
self.rollGeometricalConstant = rollGeometricalConstant
self.tau = tau
self.liftInterferenceFactor = liftInterferenceFactor
self.λ = λ
self.rollDampingInterferenceFactor = rollDampingInterferenceFactor
self.rollForcingInterferenceFactor = rollForcingInterferenceFactor

self.evaluateCenterOfPressure()
self.evaluateLiftCoefficient()

if cantAngle:
# Parameters for Roll Moment.
# Documented at: https://github.com/RocketPy-Team/RocketPy/blob/master/docs/technical/aerodynamics/Roll_Equations.pdf
self.λ = tipChord / rootChord
self.rollDampingInterferenceFactor = 1 + (
((tau - self.λ) / (tau)) - ((1 - self.λ) / (tau - 1)) * np.log(tau)
) / (
((tau + 1) * (tau - self.λ)) / (2)
- ((1 - self.λ) * (tau**3 - 1)) / (3 * (tau - 1))
)
self.rollForcingInterferenceFactor = (1 / np.pi**2) * (
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
+ ((tau**2 + 1) ** 2)
/ (tau**2 * (tau - 1) ** 2)
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
- (4 * (tau + 1))
/ (tau * (tau - 1))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
)
self.evaluateRollCoefficients()
self.evaluateRollCoefficients()

def evaluateCenterOfPressure(self):
"""Calculates and returns the finset's center of pressure
Expand Down Expand Up @@ -951,6 +953,44 @@ def __init__(
# Fin–body interference correction parameters
tau = (span + radius) / radius
liftInterferenceFactor = 1 + 1 / tau
rollDampingInterferenceFactor = 1 + (
(radius**2)
* (
2
* (radius**2)
* np.sqrt(span**2 - radius**2)
* np.log(
(2 * span * np.sqrt(span**2 - radius**2) + 2 * span**2)
/ radius
)
- 2
* (radius**2)
* np.sqrt(span**2 - radius**2)
* np.log(2 * span)
+ 2 * span**3
- np.pi * radius * span**2
- 2 * (radius**2) * span
+ np.pi * radius**3
)
) / (
2
* (span**2)
* (span / 3 + np.pi * radius / 4)
* (span**2 - radius**2)
)
rollForcingInterferenceFactor = (1 / np.pi**2) * (
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
+ ((tau**2 + 1) ** 2)
/ (tau**2 * (tau - 1) ** 2)
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
- (4 * (tau + 1))
/ (tau * (tau - 1))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
)

# Store values
self.n = n
Expand All @@ -965,57 +1005,19 @@ def __init__(
self.name = name
self.d = d
self.Aref = Aref # Reference area
self.Af = Af * span / 2 # Fin area
self.Af = Af # Fin area
self.AR = AR # Fin aspect ratio
self.gamma_c = gamma_c # Mid chord angle
self.Yma = Yma # Span wise coord of mean aero chord
self.rollGeometricalConstant = rollGeometricalConstant
self.tau = tau
self.liftInterferenceFactor = liftInterferenceFactor
self.rollDampingInterferenceFactor = rollDampingInterferenceFactor
self.rollForcingInterferenceFactor = rollForcingInterferenceFactor

self.evaluateCenterOfPressure()
self.evaluateLiftCoefficient()

if cantAngle:
self.rollDampingInterferenceFactor = 1 + (
(radius**2)
* (
2
* (radius**2)
* np.sqrt(span**2 - radius**2)
* np.log(
(2 * span * np.sqrt(span**2 - radius**2) + 2 * span**2)
/ radius
)
- 2
* (radius**2)
* np.sqrt(span**2 - radius**2)
* np.log(2 * span)
+ 2 * span**3
- np.pi * radius * span**2
- 2 * (radius**2) * span
+ np.pi * radius**3
)
) / (
2
* (span**2)
* (span / 3 + np.pi * radius / 4)
* (span**2 - radius**2)
)
self.rollForcingInterferenceFactor = (1 / np.pi**2) * (
(np.pi**2 / 4) * ((tau + 1) ** 2 / tau**2)
+ ((np.pi * (tau**2 + 1) ** 2) / (tau**2 * (tau - 1) ** 2))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
- (2 * np.pi * (tau + 1)) / (tau * (tau - 1))
+ ((tau**2 + 1) ** 2)
/ (tau**2 * (tau - 1) ** 2)
* (np.arcsin((tau**2 - 1) / (tau**2 + 1))) ** 2
- (4 * (tau + 1))
/ (tau * (tau - 1))
* np.arcsin((tau**2 - 1) / (tau**2 + 1))
+ (8 / (tau - 1) ** 2) * np.log((tau**2 + 1) / (2 * tau))
)
self.evaluateRollCoefficients()
self.evaluateRollCoefficients()

return None

Expand Down
4 changes: 2 additions & 2 deletions rocketpy/Rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,10 @@ def addTrapezoidalFins(
tipChord,
span,
distanceToCM,
radius,
cantAngle,
sweepLength,
sweepAngle,
radius,
airfoil,
name,
)
Expand Down Expand Up @@ -621,7 +621,7 @@ def addEllipticalFins(

# Create a fin set as an object of EllipticalFins class
finSet = EllipticalFins(
n, rootChord, span, distanceToCM, cantAngle, radius, airfoil, name
n, rootChord, span, distanceToCM, radius, cantAngle, airfoil, name
)

# Add fin set to the list of aerodynamic surfaces
Expand Down