Skip to content

Commit

Permalink
enhance numpy handling, examples and gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
jgressier committed May 1, 2014
1 parent 1d0813d commit 78f72f8
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# python compiled files
*.pyc
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
aero
----

Python packages for compressible flow computations

### Features
* Mach dependent functions for isentropic total pressure, temperature and mass flow
* local Rankine-Hugoniot shock wave equations
* conical shock waves
* misc: degree based trigo functions, Newton iterative solve, ODE integration

### Installation & usage
* `aero` folder must be placed in a PYTHONPATH structure
* or append `$PWD`to your `PYTHONPATH`
PYTHONPATH=$PWD:$PYTHONPATH python examples/test.py

### Requirements
* examples are plotted using [matplotlib](http://matplotlib.org)


12 changes: 6 additions & 6 deletions aero/ShockWave.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import degree
import CompressibleFlow
import IterativeSolve
import numpy
import numpy as np

# --- NORMAL SHOCK WAVE ---

Expand All @@ -27,9 +27,9 @@ def Pi_ratio(Mn, gamma=1.4):
# --- LOCAL 2D SHOCK WAVE ---

def deflection_Mach_sigma(Mach, sigma, gamma=1.4):
sigrad = math.radians(sigma)
Mn = Mach*math.sin(sigrad)
return sigma-math.degrees(math.atan(math.tan(sigrad)/Rho_ratio(Mn, gamma)))
sigrad = np.radians(sigma)
Mn = Mach*np.sin(sigrad)
return sigma-np.degrees(np.arctan2(np.tan(sigrad), Rho_ratio(Mn, gamma)))

def deflection_Mach_ShockPsratio(Mach, Pratio, gamma=1.4):
return deflection_Mach_sigma(Mach, degree.asin(Mn_Ps_ratio(Pratio, gamma)/Mach), gamma)
Expand All @@ -41,7 +41,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 "pas de solution choc faible"
print "no weak shok wave solution"
return degree.asin(1./Mach)
else:
phi = math.acos(-.5*ke/math.sqrt(kd**3))
Expand All @@ -55,7 +55,7 @@ def strongsigma_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 "pas de solution choc fort"
print "no strong shock wave solution"
return 90.
else:
phi = math.acos(-.5*ke/math.sqrt(kd**3)) + 4*math.pi
Expand Down
Binary file added examples/polar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions examples/shockwave-polar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
"""
Plot of local Rankine-Hugoniot equations (2D shock waves)
@author: j.gressier
"""

import aero.degree as deg
import aero.CompressibleFlow as aerof
import aero.ShockWave as aerosw
import numpy as np
import matplotlib.pyplot as plt

npoints = 100
gam = 1.4

fig=plt.figure(1, figsize=(10,8))
fig.suptitle('Polar of Shock-Waves, $\gamma = %.1f$'%gam, fontsize=12, y=0.93)

macharray = [ 1.05, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2., 2.2, 2.5, 3., 3.5, 4., 5., 10., 100. ]

for m in macharray:
sig = np.linspace(deg.asin(1./m), 90., npoints+1)
dev = aerosw.deflection_Mach_sigma(m, sig, gam)
plt.plot(dev, sig, 'k-')
plt.text(dev[npoints/2], sig[npoints/2], '%.3g'%m, horizontalalignment='center', verticalalignment='top',
fontsize=8, bbox=dict(facecolor='white', alpha=0.8),
rotation='60')

#labels.append(legends[i]+", t=%.1f"%results[i][t].time)
#legend(labels, loc='upper left',prop={'size':10})
plt.axis([0., 50., 0., 90.])
plt.xlabel('deviation $\Delta\\theta$', fontsize=10)
plt.ylabel('shock angle $\sigma$', fontsize=10)
plt.minorticks_on()
plt.grid(which='major', linestyle='-', alpha=0.8)
plt.grid(which='minor', linestyle=':', alpha=0.5)
fig.savefig('polar.png', bbox_inches='tight')
#show()
Binary file added gallery/polar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions make_gallery.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ -z "$PYTHONPATH" ] ; then
export PYTHONPATH=$PWD
else
export PYTHONPATH=$PWD:$PYTHONPATH
fi

mkdir -p gallery
cd gallery
for fic in ../examples/*.py ; do
echo run $fic
${PYTHON:-python} $fic
done

0 comments on commit 78f72f8

Please sign in to comment.