forked from jgressier/aerokit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split of CompressibleFlow package into Isentropic, MassFlow, Propulsi…
…on ; keep legacy interface
- Loading branch information
Showing
8 changed files
with
2,411 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,74 @@ | ||
# Python module : CompressibleFlow | ||
"""@package CompressibleFlow | ||
legacy package importing legacy functions | ||
""" | ||
|
||
import math | ||
import numpy as np | ||
import IterativeSolve | ||
import Isentropic as ist | ||
import Supersonic as sup | ||
import MassFlow as mfl | ||
|
||
# -- isentropic functions -- | ||
|
||
def TiTs_Mach(Mach, gamma=1.4): | ||
return 1.+.5*(gamma-1)*Mach**2 | ||
""" legacy interface to same function in Isentropic | ||
""" | ||
return ist.TiTs_Mach(Mach, gamma) | ||
|
||
def PiPs_Mach(Mach, gamma=1.4): | ||
return (1.+.5*(gamma-1.)*Mach**2)**(gamma/(gamma-1.)) | ||
""" legacy interface to same function in Isentropic | ||
""" | ||
return ist.PiPs_Mach(Mach, gamma) | ||
|
||
def Mach_TiTs(TiTs, gamma=1.4): | ||
return np.sqrt((TiTs-1.)*2./(gamma-1.)) | ||
""" legacy interface to same function in Isentropic | ||
""" | ||
return ist.Mach_TiTs(TiTs, gamma) | ||
|
||
def Mach_PiPs(PiPs, gamma=1.4): | ||
return np.sqrt((PiPs**((gamma-1.)/gamma)-1.)*2./(gamma-1.)) | ||
""" legacy interface to same function in Isentropic | ||
""" | ||
return ist.Mach_PiPs(PiPs, gamma) | ||
|
||
def Velocity_MachTi(Mach, Ti, r=287.1, gamma=1.4): | ||
return Mach*np.sqrt(gamma*r*Ti/TiTs_Mach(Mach, gamma)) | ||
|
||
# -- Compressible flow functions -- | ||
|
||
def WeightMassFlow(Mach, r=287.1, gamma=1.4): | ||
return np.sqrt(gamma/r)*Mach*(1.+.5*(gamma-1)*Mach**2)**(-.5*(gamma+1.)/(gamma-1.)) | ||
|
||
def Sigma_Mach(Mach, gamma=1.4): | ||
return (2./(gamma+1.)*(1.+.5*(gamma-1)*Mach**2))**(.5*(gamma+1.)/(gamma-1.))/Mach | ||
|
||
def Mach_Sigma(sigma, Mach=2., gamma=1.4): | ||
def sigma_of_mach(m): | ||
return Sigma_Mach(m, gamma) | ||
return IterativeSolve.secant_solve(sigma_of_mach, sigma, Mach) | ||
""" legacy interface to same function in Isentropic | ||
""" | ||
return ist.Velocity_MachTi(Mach, Ti, r, gamma) | ||
|
||
# -- 2D supersonic invariants -- | ||
|
||
def PrandtlMeyer_Mach(Mach, gamma=1.4): | ||
g = gamma | ||
gm1 = gamma - 1. | ||
beta = np.sqrt(Mach**2-1.) | ||
return (np.sqrt((g+1.)/gm1)*np.arctan(np.sqrt(gm1/(g+1.))*beta) - np.arctan(beta))*180./math.pi | ||
""" legacy interface to same function in Supersonic | ||
""" | ||
return sup.PrandtlMeyer_Mach(Mach, gamma) | ||
|
||
def Mach_PrandtlMeyer(omega, gamma=1.4): | ||
def omega_of_mach(m): | ||
return PrandtlMeyer_Mach(m, gamma) | ||
return IterativeSolve.secant_solve(omega_of_mach, omega, 2.) | ||
# return IterativeSolve.secant_solve(omega_of_mach, omega, 2.) | ||
""" legacy interface to same function in Supersonic | ||
""" | ||
return sup.Mach_PrandtlMeyer(omega, gamma) | ||
|
||
def deflection_Mach_IsentropicPsratio(Mach, Pratio, gamma=1.4): | ||
m2 = Mach_PiPs(PiPs_Mach(Mach, gamma)/Pratio, gamma) | ||
return -PrandtlMeyer_Mach(Mach, gamma)+PrandtlMeyer_Mach(m2, gamma) | ||
""" legacy interface to same function in Supersonic | ||
""" | ||
return sup.deflection_Mach_IsentropicPsratio(Mach, Pratio, gamma) | ||
|
||
def IsentropicPsratio_Mach_deflection(Mach, dev, gamma=1.4): | ||
m2 = Mach_PrandtlMeyer(PrandtlMeyer_Mach(Mach, gamma)-dev, gamma) | ||
return PiPs_Mach(Mach, gamma)/PiPs_Mach(m2, gamma) | ||
""" legacy interface to same function in Supersonic | ||
""" | ||
return sup.IsentropicPsratio_Mach_deflection(Mach, dev, gamma) | ||
|
||
# -- Compressible flow functions -- | ||
|
||
# -- Thrust functions -- | ||
def WeightMassFlow(Mach, r=287.1, gamma=1.4): | ||
""" legacy interface to same function in MassFlow | ||
""" | ||
return mfl.WeightMassFlow(Mach, r, gamma) | ||
|
||
def ThrustFunction(Mach, gamma=1.4): | ||
return Sigma_Mach(Mach, gamma)/PiPs_Mach(Mach, gamma)*(1.+gamma*Mach**2) | ||
def Sigma_Mach(Mach, gamma=1.4): | ||
""" legacy interface to same function in MassFlow | ||
""" | ||
return mfl.Sigma_Mach(Mach, gamma) | ||
|
||
def Mach_Sigma(sigma, Mach=2., gamma=1.4): | ||
""" legacy interface to same function in MassFlow | ||
""" | ||
return mfl.Mach_Sigma(sigma, Mach, gamma) | ||
|
||
def Mach_ThrustFunction(thrust, Mach=2., gamma=1.4): | ||
def thrust_of_mach(m): | ||
return ThrustFunction(m, gamma) | ||
return IterativeSolve.secant_solve(thrust_of_mach, thrust, Mach) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""@package Isentropic | ||
isentropic functions | ||
""" | ||
|
||
import math | ||
import numpy as np | ||
import IterativeSolve | ||
|
||
# -- isentropic functions -- | ||
|
||
def TiTs_Mach(Mach, gamma=1.4): | ||
return 1.+.5*(gamma-1)*Mach**2 | ||
|
||
def PiPs_Mach(Mach, gamma=1.4): | ||
return (1.+.5*(gamma-1.)*Mach**2)**(gamma/(gamma-1.)) | ||
|
||
def Mach_TiTs(TiTs, gamma=1.4): | ||
return np.sqrt((TiTs-1.)*2./(gamma-1.)) | ||
|
||
def Mach_PiPs(PiPs, gamma=1.4): | ||
return np.sqrt((PiPs**((gamma-1.)/gamma)-1.)*2./(gamma-1.)) | ||
|
||
def Velocity_MachTi(Mach, Ti, r=287.1, gamma=1.4): | ||
return Mach*np.sqrt(gamma*r*Ti/TiTs_Mach(Mach, gamma)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""@package MassFlow | ||
Compressible flow functions | ||
""" | ||
|
||
import math | ||
import numpy as np | ||
import IterativeSolve | ||
|
||
# -- Compressible flow functions -- | ||
|
||
def WeightMassFlow(Mach, r=287.1, gamma=1.4): | ||
return np.sqrt(gamma/r)*Mach*(1.+.5*(gamma-1)*Mach**2)**(-.5*(gamma+1.)/(gamma-1.)) | ||
|
||
def Sigma_Mach(Mach, gamma=1.4): | ||
return (2./(gamma+1.)*(1.+.5*(gamma-1)*Mach**2))**(.5*(gamma+1.)/(gamma-1.))/Mach | ||
|
||
def Mach_Sigma(sigma, Mach=2., gamma=1.4): | ||
def sigma_of_mach(m): | ||
return Sigma_Mach(m, gamma) | ||
return IterativeSolve.secant_solve(sigma_of_mach, sigma, Mach) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""@package Supersonic | ||
supersonic flow functions | ||
""" | ||
|
||
import math | ||
import numpy as np | ||
import IterativeSolve | ||
import Isentropic as Is | ||
|
||
# -- 2D supersonic invariants -- | ||
|
||
def PrandtlMeyer_Mach(Mach, gamma=1.4): | ||
g = gamma | ||
gm1 = gamma - 1. | ||
beta = np.sqrt(Mach**2-1.) | ||
return (np.sqrt((g+1.)/gm1)*np.arctan(np.sqrt(gm1/(g+1.))*beta) - np.arctan(beta))*180./math.pi | ||
|
||
def Mach_PrandtlMeyer(omega, gamma=1.4): | ||
def omega_of_mach(m): | ||
return PrandtlMeyer_Mach(m, gamma) | ||
return IterativeSolve.secant_solve(omega_of_mach, omega, 2.) | ||
|
||
def deflection_Mach_IsentropicPsratio(Mach, Pratio, gamma=1.4): | ||
m2 = Is.Mach_PiPs(Is.PiPs_Mach(Mach, gamma)/Pratio, gamma) | ||
return -PrandtlMeyer_Mach(Mach, gamma)+PrandtlMeyer_Mach(m2, gamma) | ||
|
||
def IsentropicPsratio_Mach_deflection(Mach, dev, gamma=1.4): | ||
m2 = Mach_PrandtlMeyer(PrandtlMeyer_Mach(Mach, gamma)-dev, gamma) | ||
return Is.PiPs_Mach(Mach, gamma)/Is.PiPs_Mach(m2, gamma) | ||
|
Oops, something went wrong.