Skip to content

Commit

Permalink
split of CompressibleFlow package into Isentropic, MassFlow, Propulsi…
Browse files Browse the repository at this point in the history
…on ; keep legacy interface
  • Loading branch information
jgressier committed May 3, 2014
1 parent 2410e47 commit f17bee4
Show file tree
Hide file tree
Showing 8 changed files with 2,411 additions and 45 deletions.
89 changes: 48 additions & 41 deletions aero/CompressibleFlow.py
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 added aero/Fanno.py
Empty file.
24 changes: 24 additions & 0 deletions aero/Isentropic.py
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))
21 changes: 21 additions & 0 deletions aero/MassFlow.py
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 added aero/Rayleigh.py
Empty file.
12 changes: 8 additions & 4 deletions aero/ShockWave.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"""@package ShockWave
locla Rankine Hugoniot equations for shock waves
"""

import math
import degree
import CompressibleFlow
import IterativeSolve
import numpy as np
import numpy as np
import Isentropic as Is

# --- NORMAL SHOCK WAVE ---

Expand All @@ -22,7 +26,7 @@ def downstream_Mn(Mn, gamma=1.4):
return math.sqrt((1.+.5*(gamma-1.)*Mn**2)/(gamma*Mn**2-.5*(gamma-1.)))

def Pi_ratio(Mn, gamma=1.4):
return Ps_ratio(Mn, gamma)*CompressibleFlow.PiPs_Mach(downstream_Mn(Mn, gamma))/CompressibleFlow.PiPs_Mach(Mn, gamma)
return Ps_ratio(Mn, gamma)*Is.PiPs_Mach(downstream_Mn(Mn, gamma))/Is.PiPs_Mach(Mn, gamma)

# --- LOCAL 2D SHOCK WAVE ---

Expand All @@ -41,7 +45,7 @@ def weaksigma_Mach_deflection(Mach, deflection, gamma=1.4):
kd = (ka**2/3. - kb)/3.
ke = 2.*ka**3/27. - ka*kb/3. + kc
if ke**2 - 4.*kd**3 > 0:
print "no weak shok wave solution"
print "no weak shock wave solution"
return degree.asin(1./Mach)
else:
phi = math.acos(-.5*ke/math.sqrt(kd**3))
Expand Down
30 changes: 30 additions & 0 deletions aero/Supersonic.py
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)

Loading

0 comments on commit f17bee4

Please sign in to comment.