Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
eab9be8
Update Environment.py
FranzYuri Nov 5, 2021
5a0decf
commit on 'enh/utc_time'
Nov 9, 2021
73962a1
commit on 'enh/utc_time'
Nov 9, 2021
c322a49
Update requirements.txt
FranzYuri Nov 11, 2021
8ad3df6
commit on 'enh/utc_time'
Jan 3, 2022
4d37d86
FEAT: add pytz to setup.py install requirements
giovaniceotto Jan 3, 2022
ac46cf0
MAINT: minor code refactoring
giovaniceotto Jan 3, 2022
16c1107
FEAT: added time zone argument to Env.init
giovaniceotto Jan 3, 2022
658f478
MAINT: rename time_zone to timeZone, following current camelCase stan…
giovaniceotto Jan 3, 2022
6394b0f
Maint: rename local_date to LocalDate to follow camelCase
giovaniceotto Jan 3, 2022
756381d
BUG: fix conversion between local and UTC time zone using astimezone
giovaniceotto Jan 3, 2022
4ed5fc0
MAINT: minor code refactoring
giovaniceotto Jan 3, 2022
f14b26d
MAINT: fix date time format in Env.allInfo()
giovaniceotto Jan 3, 2022
f6120b1
TST: fix failing tests due to minor bugs
giovaniceotto Jan 3, 2022
c284e81
STY: apply black formatting
giovaniceotto Jan 3, 2022
746311d
Fixed airfoil lift calculation
MateusStano Jan 4, 2022
03e35d9
Merge branch 'develop' into bug/airfoil-lift-calculation
MateusStano Jan 4, 2022
af21461
Merge pull request #1 from MateusStano/bug/airfoil-lift-calculation
MateusStano Jan 4, 2022
a2724b1
Add files via upload
MateusStano Jan 4, 2022
f74a5b9
Fixed documentation link and text
MateusStano Jan 4, 2022
d81ae0c
Update Rocket.py
MateusStano Jan 4, 2022
8b79cb9
Update Rocket.py
MateusStano Jan 4, 2022
7f419d6
Removed 'extrapolation' from Function objects based on a callable
MateusStano Jan 7, 2022
54fd3ca
Merge branch 'develop' into develop
MateusStano Jan 8, 2022
6436b64
Merge branch 'develop' into enh/utc_time
FranzYuri Jan 8, 2022
7d8ddbd
Update Rocket.py
MateusStano Jan 8, 2022
0060dcb
Merge branch 'develop' into enh/utc_time
FranzYuri Jan 8, 2022
f458d30
Fix code style issues with Black
lint-action Jan 8, 2022
4caf4e0
Merge pull request #110 from Projeto-Jupiter/enh/utc_time
FranzYuri Jan 9, 2022
086922a
Applied Black formatting
MateusStano Jan 10, 2022
641b566
Fixed Cld dived by zero bug
MateusStano Jan 11, 2022
13fdc8e
Merge pull request #120 from MateusStano/bug/Cld-diveded-by-zero
MateusStano Jan 11, 2022
977f7e1
Changed the solution to division by zero to a more trustful one
MateusStano Jan 11, 2022
1e36730
BUG: remove airfoil implementation
Lucas-KB Feb 3, 2022
13fff34
Fix code style issues with Black
lint-action Feb 3, 2022
d941e6e
Fixed lift coefficient, roll coefficients and roll moment calculations
MateusStano Feb 6, 2022
db8531b
ran black and pytest
MateusStano Feb 6, 2022
d7c85ec
Removed unnecessary Function() on cldOmega
MateusStano Feb 6, 2022
4362cb1
FEAT: add interpolation and extrapolation argument to Flight.postProc…
giovaniceotto Feb 7, 2022
d8ce2fb
WIP: stability check notebook to try out different possibilites to te…
giovaniceotto Feb 7, 2022
b70303f
Fix code style issues with Black
lint-action Feb 7, 2022
0ffcf35
BUG: readd airfoil implementation with fix
Lucas-KB Feb 9, 2022
44631cf
Fix code style issues with Black
lint-action Feb 9, 2022
10b5a57
MAINT: change aerodynamic surfaces to dictionaries
Lucas-KB Feb 10, 2022
c416872
MAINT: change aerodynamic surfaces to dictionaries
Lucas-KB Feb 10, 2022
4903160
Functions require netCDF4
Feb 10, 2022
d148a31
ENH: Functions require netCDF4
Feb 10, 2022
5da3d87
TST: add test to check stability
Lucas-KB Feb 10, 2022
44cd211
Merge branch 'bug/issue-115-static-margin-stability' of https://githu…
Lucas-KB Feb 10, 2022
5694c61
STY: black lint
Feb 10, 2022
f7c1f68
Merge branch 'master' of https://github.com/skrobchik/RocketPy
Feb 10, 2022
0820a1f
merge fix
Feb 10, 2022
920f653
Added/Fixed suggested changes
MateusStano Feb 10, 2022
1248c3e
Merge branch 'Projeto-Jupiter:develop' into develop
MateusStano Feb 10, 2022
f3bbe34
Added pytest for rolling flight
MateusStano Feb 10, 2022
b115cc5
Merge pull request #127 from skrobchik/master
MrGribel Feb 10, 2022
38a1cbf
MAINT: add a rocket tail to static margin stability test
giovaniceotto Feb 11, 2022
dbe2191
MAINT: move helper function so that it can be used with other tests i…
giovaniceotto Feb 11, 2022
cc165de
MAINT: simplify stability test ifs and asserts
giovaniceotto Feb 11, 2022
d49b633
MAINT: implement pytest parametrize to simplify static margin stabili…
giovaniceotto Feb 11, 2022
15d0b4d
BUG: fix duplicate angle of attack in component lift calculation
giovaniceotto Feb 11, 2022
4e7338e
Delete stability_check.ipynb
Gui-FernandesBR Feb 12, 2022
56e421c
Reformated M3d equation.
MateusStano Feb 12, 2022
56bd8fa
Merge branch 'develop' into bug/Cld-diveded-by-zero
MateusStano Feb 12, 2022
0acce21
Removed cantAngleRad != 0 check on rollParameters
MateusStano Feb 12, 2022
10a9b8e
Merge branch 'bug/Cld-diveded-by-zero' of https://github.com/MateusSt…
MateusStano Feb 12, 2022
324abec
Merge pull request #122 from MateusStano/bug/Cld-diveded-by-zero
MateusStano Feb 12, 2022
3dd62c8
Merge branch 'develop' into bug/issue-115-static-margin-stability
Gui-FernandesBR Feb 13, 2022
cf47bfa
Fix code style issues with Black
lint-action Feb 13, 2022
98f2191
Merge pull request #125 from Projeto-Jupiter/bug/issue-115-static-mar…
Gui-FernandesBR Feb 13, 2022
a68475f
Delete TODO.md
Gui-FernandesBR Feb 13, 2022
09573c7
BUG: remove absolute value from lift calculation
Lucas-KB Feb 13, 2022
fbef6d3
BUG: set infinite speed of sound in stability static margin test
giovaniceotto Feb 13, 2022
861001d
MAINT: black formatting
giovaniceotto Feb 13, 2022
5d8d8a1
Merge branch 'develop' into develop
MateusStano Feb 15, 2022
6bbc3fe
Revert "WIP: Airfoil fins normal force coefficient derivative calcula…
MateusStano Feb 15, 2022
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
Fixed lift coefficient, roll coefficients and roll moment calculations
  • Loading branch information
MateusStano committed Feb 6, 2022
commit d941e6eeae58d14c55f94a1dae632b046c7d945d
Binary file modified docs/technical/aerodynamics/Roll_Equations.pdf
Binary file not shown.
28 changes: 21 additions & 7 deletions rocketpy/Flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,8 @@ def uDot(self, t, u, postProcessing=False):
c = -self.rocket.distanceRocketNozzle
a = b * Mt / M
rN = self.rocket.motor.nozzleRadius
Aref = self.rocket.area
d = self.rocket.radius * 2
# Prepare transformation matrix
a11 = 1 - 2 * (e2 ** 2 + e3 ** 2)
a12 = 2 * (e1 * e2 - e0 * e3)
Expand Down Expand Up @@ -1324,7 +1326,7 @@ def uDot(self, t, u, postProcessing=False):
compStreamVzBn = compStreamVzB / compStreamSpeed
if -1 * compStreamVzBn < 1:
compAttackAngle = np.arccos(-compStreamVzBn)
cLift = abs(aerodynamicSurface[1](compAttackAngle))
cLift = abs(aerodynamicSurface[1](compAttackAngle, freestreamMach))
# Component lift force magnitude
compLift = (
0.5 * rho * (compStreamSpeed ** 2) * self.rocket.area * cLift
Expand All @@ -1342,13 +1344,25 @@ def uDot(self, t, u, postProcessing=False):
# Calculates Roll Moment
if aerodynamicSurface[-1] == "Fins":
Clfdelta, Cldomega, cantAngleRad = aerodynamicSurface[2]
Clf = Clfdelta * cantAngleRad
Cld = (
Cldomega * omega3 * min(1, 1 / freestreamSpeed)
if freestreamSpeed != 0
else Cldomega * omega3
M3f = (
(1 / 2 * rho * freestreamSpeed ** 2)
* Aref
* d
* Clfdelta(freestreamMach)
* cantAngleRad
)
M3d = (
(
(1 / 2 * rho * freestreamSpeed)
* Aref
* d
* Cldomega(freestreamMach)
* omega3
* d
/ 2
)
M3 += Clf - Cld
)
M3 += M3f - M3d
# Calculate derivatives
# Angular acceleration
alpha1 = (
Expand Down
177 changes: 112 additions & 65 deletions rocketpy/Rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,13 @@ def evaluateStaticMargin(self):
# Calculate total lift coefficient derivative and center of pressure
if len(self.aerodynamicSurfaces) > 0:
for aerodynamicSurface in self.aerodynamicSurfaces:
self.totalLiftCoeffDer += aerodynamicSurface[1].differentiate(
x=1e-2, dx=1e-3
)
self.totalLiftCoeffDer += Function(
lambda alpha: aerodynamicSurface[1](alpha, 0)
).differentiate(x=1e-2, dx=1e-3)
self.cpPosition += (
aerodynamicSurface[1].differentiate(x=1e-2, dx=1e-3)
Function(
lambda alpha: aerodynamicSurface[1](alpha, 0)
).differentiate(x=1e-2, dx=1e-3)
* aerodynamicSurface[0][2]
)
self.cpPosition /= self.totalLiftCoeffDer
Expand Down Expand Up @@ -416,7 +418,7 @@ def addTail(self, topRadius, bottomRadius, length, distanceToCM):

Returns
-------
cldata : Function
cl : Function
Object of the Function class. Contains tail's lift data.
self : Rocket
Object of the Rocket class.
Expand All @@ -435,16 +437,14 @@ def addTail(self, topRadius, bottomRadius, length, distanceToCM):

# Calculate clalpha
clalpha = -2 * (1 - r ** (-2)) * (topRadius / rref) ** 2
cldata = Function(
lambda x: clalpha * x,
"Alpha (rad)",
cl = Function(
lambda alpha, mach: clalpha * alpha,
["Alpha (rad)", "Mach"],
"Cl",
interpolation="linear",
extrapolation="natural",
)

# Store values as new aerodynamic surface
tail = [(0, 0, cpz), cldata, "Tail"]
tail = [(0, 0, cpz), cl, "Tail"]
self.aerodynamicSurfaces.append(tail)

# Refresh static margin calculation
Expand Down Expand Up @@ -476,7 +476,7 @@ def addNose(self, length, kind, distanceToCM):

Returns
-------
cldata : Function
cl : Function
Object of the Function class. Contains nose's lift data.
self : Rocket
Object of the Rocket class.
Expand All @@ -499,16 +499,14 @@ def addNose(self, length, kind, distanceToCM):

# Calculate clalpha
clalpha = 2
cldata = Function(
lambda x: clalpha * x,
"Alpha (rad)",
cl = Function(
lambda alpha, mach: clalpha * alpha,
["Alpha (rad)", "Mach"],
"Cl",
interpolation="linear",
extrapolation="natural",
)

# Store values
nose = [(0, 0, cpz), cldata, "Nose Cone"]
nose = [(0, 0, cpz), cl, "Nose Cone"]
self.aerodynamicSurfaces.append(nose)

# Refresh static margin calculation
Expand Down Expand Up @@ -564,7 +562,7 @@ def addFins(

Returns
-------
cldata : Function
cl : Function
Object of the Function class. Contains fin's lift data.
self : Rocket
Object of the Rocket class.
Expand All @@ -579,20 +577,67 @@ def addFins(
Ymac = (
(s / 3) * (Cr + 2 * Ct) / Yr
) # span wise position of fin's mean aerodynamic chord
gamac = np.arctan((Cr - Ct) / (2 * span))
Lf = np.sqrt((rootChord / 2 - tipChord / 2) ** 2 + span ** 2)
radius = self.radius if radius == 0 else radius
d = 2 * radius
Aref = np.pi * radius ** 2
AR = 2 * s ** 2 / Af
cantAngleRad = np.radians(cantAngle)
trapezoidalConstant = ((Yr) / 2) * (radius ** 2) * s
trapezoidalConstant += ((Cr + 2 * Ct) / 3) * radius * (s ** 2)
trapezoidalConstant += ((Cr + 3 * Ct) / 12) * (s ** 3)
trapezoidalConstant = (
(Cr + 3 * Ct) * s ** 3
+ 4 * (Cr + 2 * Ct) * radius * s ** 2
+ 6 * (Cr + Ct) * s * radius ** 2
) / 12

# Fin–body interference correction parameters
tau = (s + radius) / radius
λ = Ct / Cr
liftInterferenceFactor = 1 + 1 / tau
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))
)
rollDampingInterferenceFactor = 1 + (
((tau - λ) / (tau)) - ((1 - λ) / (tau - 1)) * np.log(tau)
) / (
((tau + 1) * (tau - λ)) / (2) - ((1 - λ) * (tau ** 3 - 1)) / (3 * (tau - 1))
)

# Save geometric parameters for later Fin Flutter Analysis and Roll Moment Calculation
self.rootChord = Cr
self.tipChord = Ct
self.span = s
self.distanceRocketFins = distanceToCM

# Auxiliary functions

# Defines beta parameter
def beta(mach):
if mach < 0.8:
return np.sqrt(1 - mach ** 2)
elif mach < 1.1:
return np.sqrt(1 - 0.8 ** 2)
else:
return np.sqrt(mach ** 2 - 1)

# Defines number of fins correction
def finNumCorrection(n):
correctorFactor = [2.37, 2.74, 2.99, 3.24]
if n >= 5 and n <= 8:
return correctorFactor[n - 5]
else:
return n / 2

# Calculate cp position relative to cm
if distanceToCM < 0:
cpz = distanceToCM - (
Expand All @@ -607,44 +652,35 @@ def addFins(

# Calculate lift parameters for planar fins
if not airfoil:
# Calculate clalpha
clalpha = (4 * n * (s / d) ** 2) / (1 + np.sqrt(1 + (2 * Lf / Yr) ** 2))
clalpha *= 1 + radius / (s + radius)

# # Create a function of lift values by attack angle
cldata = Function(
lambda x: clalpha * x, "Alpha (rad)", "Cl", interpolation="linear"
)
# Parameters for Roll Moment. Documented at: https://github.com/Projeto-Jupiter/RocketPy/blob/develop/docs/technical/aerodynamics/Roll_Equations.pdf
clfDelta = n * (Ymac + radius) * clalpha / d
cldOmega = (
n * clalpha * np.cos(cantAngleRad) * trapezoidalConstant / (Af * d)
clalphaSingleFin = Function(
lambda mach: 2
* np.pi
* AR
* (Af / Aref)
/ (2 + np.sqrt(4 + ((beta(mach) * AR) / (np.cos(gamac))) ** 2)),
)
rollParameters = (
[clfDelta, cldOmega, cantAngleRad] if cantAngleRad != 0 else [0, 0, 0]
)

# Store values
fin = [(0, 0, cpz), cldata, rollParameters, "Fins"]
self.aerodynamicSurfaces.append(fin)

# Refresh static margin calculation
self.evaluateStaticMargin()
clalphaMultipleFins = (
liftInterferenceFactor * finNumCorrection(n) * clalphaSingleFin
) # Function of mach number

# Return self
return self.aerodynamicSurfaces[-1]
# Calculates clalpha * alpha
cl = Function(
lambda alpha, mach: alpha * clalphaMultipleFins(mach),
["Alpha (rad)", "Mach"],
"Cl",
)

else:

def cnalfa1(cn):
"""Calculates the normal force coefficient derivative of a 3D
airfoil for a given Cnalfa0

Parameters
----------
cn : int
Normal force coefficient derivative of a 2D airfoil.

Returns
-------
Cnalfa1 : int
Expand Down Expand Up @@ -672,7 +708,7 @@ def cnalfa1(cn):

# Applies number of fins to lift coefficient data
data = [[cl[0], (n / 2) * cnalfa1(cl[1])] for cl in read]
cldata = Function(
cl = Function(
data,
"Alpha (rad)",
"Cl",
Expand All @@ -681,26 +717,35 @@ def cnalfa1(cn):
)

# Takes an approximation to an angular coefficient
clalpha = cldata.differentiate(x=0, dx=1e-2)

# Parameters for Roll Moment. Documented at: https://github.com/Projeto-Jupiter/RocketPy/blob/develop/docs/technical/aerodynamics/Roll_Equations.pdf
clfDelta = n * (Ymac + radius) * clalpha / d
cldOmega = (
n * clalpha * np.cos(cantAngleRad) * trapezoidalConstant / (Af * d)
)
rollParameters = (
[clfDelta, cldOmega, cantAngleRad] if cantAngleRad != 0 else [0, 0, 0]
)
clalpha = cl.differentiate(x=0, dx=1e-2)

# Parameters for Roll Moment.
# Documented at: https://github.com/Projeto-Jupiter/RocketPy/blob/develop/docs/technical/aerodynamics/Roll_Equations.pdf
clfDelta = (
rollForcingInterferenceFactor * n * (Ymac + radius) * clalphaSingleFin / d
) # Function of mach number
cldOmega = Function(
2
* rollDampingInterferenceFactor
* n
* clalphaSingleFin
* np.cos(cantAngleRad)
* trapezoidalConstant
/ (Aref * d ** 2)
) # Function of mach number
rollParameters = (
[clfDelta, cldOmega, cantAngleRad] if cantAngleRad != 0 else [0, 0, 0]
)

# Store values
fin = [(0, 0, cpz), cldata, rollParameters, "Fins"]
self.aerodynamicSurfaces.append(fin)
# Store values
fin = [(0, 0, cpz), cl, rollParameters, "Fins"]
self.aerodynamicSurfaces.append(fin)

# Refresh static margin calculation
self.evaluateStaticMargin()
# Refresh static margin calculation
self.evaluateStaticMargin()

# Return self
return self.aerodynamicSurfaces[-1]
# Return self
return self.aerodynamicSurfaces[-1]

def addParachute(
self, name, CdS, trigger, samplingRate=100, lag=0, noise=(0, 0, 0)
Expand Down Expand Up @@ -987,7 +1032,9 @@ def allInfo(self):
print("\nAerodynamics Lift Coefficient Derivatives")
for aerodynamicSurface in self.aerodynamicSurfaces:
name = aerodynamicSurface[-1]
clalpha = aerodynamicSurface[1].differentiate(x=1e-2, dx=1e-3)
clalpha = Function(
lambda alpha: aerodynamicSurface[1](alpha, 0),
).differentiate(x=1e-2, dx=1e-3)
print(
name + " Lift Coefficient Derivative: {:.3f}".format(clalpha) + "/rad"
)
Expand Down