{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 4. Oblique Shock and Expansion Waves"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shock wave angle 37.50 degrees\n",
      "p2 = 3.72 atm\n",
      "T2 = 446.69 K\n",
      "M2 = 2.03 \n",
      "po2 = 29.42 atm\n",
      "To2 = 806.40 K\n"
     ]
    }
   ],
   "source": [
    "# Example 4.1.py\n",
    "# A uniform supersonic stream with M1 = 3.0, p1 = 1 atm, T1 = 288 K encounters\n",
    "# a compression corner which deflects the stream by an angle theta = 20 deg. \n",
    "# Calculate the shock wave angle, and p2, T2, M2, po2 and To2 behind the shock\n",
    "# wave.\n",
    "\n",
    "\n",
    "# Variable declaration\n",
    "M1 = 3.0          # upstream mach number\n",
    "p1 = 1.0          # upstream pressure (in atm)\n",
    "T1 = 288          # upstream temperature (in K)\n",
    "theta = 20        # deflection (in degrees)\n",
    "\n",
    "# Calculations \n",
    "# subscript 2 means behind the shock\n",
    "\n",
    "# from figure 4.5 from M1 = 3.0, theta = 20.0 deg.\n",
    "beta = 37.5                 # shock angle (in degress)\n",
    "\n",
    "# degree to radian conversion is done by multiplying by pi/180\n",
    "from numpy import sin, pi\n",
    "Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.826\n",
    "p2_by_p1 = 3.723            # p2/p1\n",
    "T2_by_T1 = 1.551            # T2/T1\n",
    "Mn2 = 0.6108                \n",
    "po2_by_po1 = 0.8011         # po2/po1\n",
    "\n",
    "p2 = p2_by_p1 * p1          # p2 (in atm) = p2/p1 * p1\n",
    "T2 = T2_by_T1 * T1          # T2 (in K) = T2/T1 * T1\n",
    "\n",
    "M2 = Mn2/(sin((beta-theta)*pi/180)) # mach number behind the shock\n",
    "\n",
    "# from A1 for M1 = 3.0\n",
    "po1_by_p1 = 36.73\n",
    "To1_by_T1 = 2.8\n",
    "\n",
    "po2 = po2_by_po1 * po1_by_p1 * p1   # po2 (in atm) = po2/po1 * po1/p1 * p1\n",
    "To2 = To1 =  To1_by_T1 * T1   # To2 (in atm) = To2/To1 * To1/T1 * T1\n",
    "\n",
    "\n",
    "# Result \n",
    "print \"Shock wave angle %.2f degrees\"%(beta)\n",
    "print \"p2 = %.2f atm\" %(p2)\n",
    "print \"T2 = %.2f K\" %(T2)\n",
    "print \"M2 = %.2f \" %(M2)\n",
    "print \"po2 = %.2f atm\" %(po2)\n",
    "print \"To2 = %.2f K\" %(To2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shock wave angle 52.00 degrees\n",
      "p2 = 6.276 atm\n",
      "M2 = 1.41 \n",
      "\n",
      "Comparing the above results with those from Example 4.1. When theta is increased, the shock wave becomes stronger, as evidenced by the increased pressure behind\n",
      "the shock(6.276 atm as compared to 3.723). The Mach number behind the shock is\n",
      "reduced(1.41 compared to 2.03). Also, as theta is increased, beta also increases\n",
      "(52 degrees compared to 37.5 degrees.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Example 4.2.py\n",
    "# In Example 4.1, the deflection angle is increased to theta = 30 degrees. \n",
    "# Calculate the pressure and Mach number behind the wave, and compare these\n",
    "# results with those of Example 4.1.\n",
    "\n",
    "\n",
    "# Variable declaration\n",
    "M1 = 3.0          # upstream mach number\n",
    "p1 = 1.0          # upstream pressure (in atm)\n",
    "T1 = 288          # upstream temperature (in K)\n",
    "theta = 30        # deflection (in degrees)\n",
    "\n",
    "# Calculations \n",
    "# subscript 2 means behind the shock\n",
    "\n",
    "# from figure 4.5 from M1 = 3.0, theta = 30.0 deg.\n",
    "beta = 52.0                 # shock angle (in degress)\n",
    "\n",
    "# degree to radian conversion is done by multiplying by pi/180\n",
    "from numpy import sin, pi\n",
    "Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock\n",
    "\n",
    "# from Table A2 for Mn1 = 2.364\n",
    "p2_by_p1 = 6.276            # p2/p1\n",
    "Mn2 = 0.5286\n",
    "\n",
    "p2 = p2_by_p1 * p1          # p2 (in atm) = p2/p1 * p1\n",
    "M2 = Mn2/(sin((beta-theta)*pi/180)) # mach number behind the shock\n",
    "\n",
    "\n",
    "print \"Shock wave angle %.2f degrees\"%(beta)\n",
    "print \"p2 = %.3f atm\" %(p2)\n",
    "print \"M2 = %.2f \" %(M2)\n",
    "comparison = \"\"\"\n",
    "Comparing the above results with those from Example 4.1. When theta is increased, the shock wave becomes stronger, as evidenced by the increased pressure behind\n",
    "the shock(6.276 atm as compared to 3.723). The Mach number behind the shock is\n",
    "reduced(1.41 compared to 2.03). Also, as theta is increased, beta also increases\n",
    "(52 degrees compared to 37.5 degrees.\n",
    "\"\"\"\n",
    "print comparison\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shock wave angle 30.00 degrees\n",
      "p2 = 7.125 atm\n",
      "M2 = 2.95 \n"
     ]
    }
   ],
   "source": [
    "# Example 4.3.py\n",
    "# In Example 4.1, the free stream mach number is increased to 5.0. \n",
    "# Calculate the pressure and Mach number behind the wave, and compare these\n",
    "# results with those of Example 4.1.\n",
    "\n",
    "\n",
    "# Variable declaration \n",
    "M1 = 5.0          # upstream mach number\n",
    "p1 = 1.0          # upstream pressure (in atm)\n",
    "T1 = 288          # upstream temperature (in K)\n",
    "theta = 20.0        # deflection (in degrees)\n",
    "\n",
    "# Calculations \n",
    "# subscript 2 means behind the shock\n",
    "\n",
    "# from figure 4.5 from M1 = 5.0, theta = 20.0 deg.\n",
    "beta = 30.0                 # shock angle (in degress)\n",
    "\n",
    "# degree to radian conversion is done by multiplying by pi/180\n",
    "from numpy import sin, pi\n",
    "Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock\n",
    "\n",
    "# from Table A2 for Mn1 = 2.5\n",
    "p2_by_p1 = 7.125            # p2/p1\n",
    "Mn2 = 0.513\n",
    "\n",
    "p2 = p2_by_p1 * p1          # p2 (in atm) = p2/p1 * p1\n",
    "M2 = Mn2/(sin((beta-theta)*pi/180)) # mach number behind the shock\n",
    "\n",
    "\n",
    "print \"Shock wave angle %.2f degrees\"%(beta)\n",
    "print \"p2 = %.3f atm\" %(p2)\n",
    "print \"M2 = %.2f \" %(M2)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Coefficient of pressure is 0.289\n"
     ]
    }
   ],
   "source": [
    "# Example 4.5.py\n",
    "# Consider a 15 deg half angle wedge at zero angle of attack. Calculate the\n",
    "# pressure coefficient on the wedge surface in a Mach 3 flow of air.\n",
    "\n",
    "\n",
    "# Variable declaration \n",
    "M1 = 3.0            # upstream mach number\n",
    "theta = 15.0        # deflection (in degrees)\n",
    "gamma = 1.4         # ratio of specific heats\n",
    "\n",
    " \n",
    "# Calculations \n",
    "# subscript 2 means behind the shock\n",
    "\n",
    "# from figure 4.5 from M1 = 3.0, theta = 15.0 deg.\n",
    "beta = 32.2                 # shock angle (in degress)\n",
    "\n",
    "# degree to radian conversion is done by multiplying by pi/180\n",
    "from numpy import sin, pi\n",
    "Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.6\n",
    "p2_by_p1 = 2.82            # p2/p1\n",
    "\n",
    "Cp = 2/(gamma*M1*M1) * (p2_by_p1 - 1) \n",
    "\n",
    "\n",
    "# Results\n",
    "print \"Coefficient of pressure is %.3f\"%(Cp)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Coefficient of drag is 0.155\n"
     ]
    }
   ],
   "source": [
    "# Example 4.6.py\n",
    "# Consider a 15 deg half angle wedge at zero angle of attack in a Mach 3 flow of\n",
    "# air. Calculate the drag coefficient. Assume that the pressure exerted over the \n",
    "# base of the wedge, the base pressure, is equal to the free stream pressure.\n",
    "\n",
    "\n",
    "\n",
    "# Variable declaration \n",
    "M1 = 3.0            # upstream mach number\n",
    "theta = 15.0        # deflection (in degrees)\n",
    "gamma = 1.4         # ratio of specific heats\n",
    "\n",
    " \n",
    "# Calculations \n",
    "# subscript 2 means behind the shock\n",
    "\n",
    "# from figure 4.5 from M1 = 3.0, theta = 15.0 deg.\n",
    "beta = 32.2                 # shock angle (in degress)\n",
    "\n",
    "# degree to radian conversion is done by multiplying by pi/180\n",
    "from numpy import sin, pi, tan\n",
    "Mn1 = M1 * sin(beta*pi/180) # upstream mach number normal to the shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.6\n",
    "p2_by_p1 = 2.82            # p2/p1\n",
    "\n",
    "Cd = 4/(gamma*M1*M1)*(p2_by_p1 - 1)*tan(theta*pi/180)\n",
    "\n",
    "\n",
    "# Results\n",
    "print \"Coefficient of drag is %.3f\"%(Cd)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "phi 29.50 degrees\n",
      "Pressure behind reflected shock, p3 = 6.54 atm\n",
      "Temperature behind reflected shock, T3 = 932.16 R\n",
      "Mach behind reflected shock, M3 = 1.45 \n"
     ]
    }
   ],
   "source": [
    "# Example 4.7.py\n",
    "# Consider a horizontal supersonic flow at Mach 2.8 with a static pressure and\n",
    "# temperature of 1 atm and 519 R, respectively. This flow passes over a compr-\n",
    "# ession corner with deflection angle of 16 degrees. The oblique shock generated\n",
    "# at the corner propagates into the flow, and is incident on a horizontal wall, \n",
    "# as shown in Fig. 4.15. Calculate the angle phi made by the reflected shock wave\n",
    "# with respect to the wall, and the Mach number, pressure and temperature behind\n",
    "# the reflected shock.\n",
    "\n",
    "\n",
    "# Variable declaration\n",
    "M1 = 2.8          # upstream mach number\n",
    "p1 = 1.0          # upstream pressure (in atm)\n",
    "T1 = 519.0        # upstream temperature (in R)\n",
    "theta = 16.0      # deflection (in degrees)\n",
    "\n",
    "# Calculations \n",
    "# subscript 2 means behind the shock\n",
    "\n",
    "# from figure 4.5 from M1 = 2.8, theta = 16.0 deg.\n",
    "beta_1 = 35.0                         # shock angle (in degress)\n",
    "\n",
    "# degree to radian conversion is done by multiplying by pi/180\n",
    "from numpy import sin, pi\n",
    "Mn1 = M1 * sin(beta_1*pi/180)         # upstream mach number normal to the shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.606\n",
    "p2_by_p1 = 2.82                       # p2/p1\n",
    "T2_by_T1 = 1.388                      # T2/T1\n",
    "Mn2 = 0.6684                \n",
    "\n",
    "\n",
    "p2 = p2_by_p1 * p1                    # p2 (in atm) = p2/p1 * p1\n",
    "T2 = T2_by_T1 * T1                    # T2 (in R) = T2/T1 * T1\n",
    "\n",
    "M2 = Mn2/(sin((beta_1-theta)*pi/180)) # mach number behind the shock\n",
    "\n",
    "# from figure 4.5 from M2 = 2.053, theta = 16.0 deg.\n",
    "beta_2 = 45.5                         # shock angle of reflected(in degress)\n",
    "\n",
    "# degree to radian conversion is done by multiplying by pi/180\n",
    "Mn2 = M2 * sin(beta_2*pi/180)         # upstream mach number normal to the shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.46\n",
    "p3_by_p2 = 2.32                       # p3/p2\n",
    "T3_by_T2 = 1.294                      # T3/T2\n",
    "Mn3 = 0.7157\n",
    "\n",
    "\n",
    "p3 = p3_by_p2 * p2                    # p3 (in atm) = p3/p2 * p2\n",
    "T3 = T3_by_T2 * T2                    # T3 (in R) = T3/T2 * T2\n",
    "\n",
    "phi = beta_2 - theta                  # (in degrees)\n",
    "M3 = Mn3/(sin((beta_2-theta)*pi/180)) # mach number behind the reflected shock\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# Result \n",
    "print \"phi %.2f degrees\" %(phi)\n",
    "print \"Pressure behind reflected shock, p3 = %.2f atm\" %(p3)\n",
    "print \"Temperature behind reflected shock, T3 = %.2f R\" %(T3)\n",
    "print \"Mach behind reflected shock, M3 = %.2f \" %(M3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "M2 = 2.207\n",
      "p2 = 577.31 lb/ft^2\n",
      "T2 = 337.89 deg R\n",
      "po2 = 6240.70 lb/ft^2\n",
      "To2 = 667.00 deg R\n",
      "Angle forward = 41.81 degrees\n",
      "Angle rearward = 6.95 degrees\n"
     ]
    }
   ],
   "source": [
    "# Example 4.8.py\n",
    "# A uniform supersonic stream with M1 = 1.5, p1 = 1700 lb/ft^2, and T1 = 460.0 R\n",
    "# encounters an expansion corner which deflects the stream by and angle theta_2\n",
    "# = 20 degrees. Calculate M2, p2, T2, po2, To2, and the angles the forward and\n",
    "# rearward Mach lines make with respect to the upstream flow direction.\n",
    "\n",
    "\n",
    "# Variable declaration\n",
    "M1 = 1.5          # upstream mach number\n",
    "p1 = 1700.0       # upstream pressure (in lb/ft^2)\n",
    "T1 = 460.0        # upstream temperature (in R)\n",
    "theta_2 = 20.0    # deflection (in degrees)\n",
    "\n",
    "\n",
    "# Calculations \n",
    "# subscript 2 means after the expansion fan\n",
    "\n",
    "# from Table A5 for M1 = 1.5\n",
    "v1 = 11.91        # (in degrees)\n",
    "mu1 = 41.81       # (in degrees)\n",
    "\n",
    "v2 = v1 + theta_2\n",
    "\n",
    "# from Table A5, for v2 = 31.91\n",
    "M2 = 2.207        # Mach behind the expansion fan\n",
    "mu2 = 26.95       # (in degrees)\n",
    "\n",
    "# from Table A1 for M1 = 1.5\n",
    "po1_by_p1 = 3.671 # po1/p1\n",
    "To1_by_T1 = 1.45  # To1/T1\n",
    "\n",
    "# from Table A1 for M2 = 2.207\n",
    "po2_by_p2 = 10.81 # po2/p2\n",
    "To2_by_T2 = 1.974 # To2/T2\n",
    "\n",
    "p2 = 1/po2_by_p2 * po1_by_p1 * p1 # p2 (in lb/ft^2) = p2/po2 * po2/po1 * po1/p1 * p1 and po2 = po1\n",
    "T2 = 1/To2_by_T2 * To1_by_T1 * T1 # T2 (in R) = T2/To2 * To2/To1 * To1/T1 * T1 and To2 = To1\n",
    "\n",
    "po2 = po1 = po1_by_p1 * p1        # po2 (in lb/ft^2) = po1/p1 * p1\n",
    "To2 = To1 = To1_by_T1 * T1        # To2 (in R) = To1/T1 * T1\n",
    "\n",
    "angle_forward  = mu1              # angle of forward ray (in degrees)\n",
    "angle_rearward = mu2 - theta_2    # angle of backward ray (in degrees)\n",
    "\n",
    "\n",
    "# Result \n",
    "print \"M2 = %.3f\" %(M2)\n",
    "print \"p2 = %.2f lb/ft^2\" %(p2)\n",
    "print \"T2 = %.2f deg R\" %(T2)\n",
    "print \"po2 = %.2f lb/ft^2\" %(po2)\n",
    "print \"To2 = %.2f deg R\" %(To2)\n",
    "print \"Angle forward = %.2f degrees\" %(angle_forward)\n",
    "print \"Angle rearward = %.2f degrees\" %(angle_rearward)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Freestream mach number is 3.5\n"
     ]
    }
   ],
   "source": [
    "# Example 4.9.py\n",
    "# Consider the arrangement shows in fig. 4.29. A 15 degree half angle diamond \n",
    "# wedge airfoil is in supersonic flow at zero angle of attack. A pitot tube is\n",
    "# inserted into the flow at the location shown in fig 4.29. The pressure measured\n",
    "# by the Pitot tube is 2.596 atm. At point a on the backface, the pressure is 0.1\n",
    "# atm. Calculate the freestream Mach number M1.\n",
    "\n",
    "from numpy import sin, pi\n",
    "\n",
    "# Variable declaration\n",
    "theta = 15.0    # wedge angle/deflection (in degrees)\n",
    "po4 = 2.596     # measured pressure (in atm)\n",
    "p3 = 0.1        # pressure at point a (in atm)\n",
    "\n",
    "# Calculations \n",
    "\n",
    "po4_by_p3 = po4/p3\n",
    "\n",
    "# from Table A 2 for po4/p3  = 25.96\n",
    "M3 = 4.45\n",
    "v3 = 71.27\n",
    "v2 = v3 - 2*theta\n",
    "\n",
    "# from Table A 5, for v2 = 41.27 degrees\n",
    "M2 = 2.6\n",
    "# Mn2 = M2*sin((beta-theta)*pi/180)  @equation 1\n",
    "\n",
    "# Guessing\n",
    "\n",
    "# Guess 1\n",
    "M1 = 4.0                          # Guess for freestream number\n",
    "beta = 27.0                       # from fig 4.5 (in degrees)\n",
    "Mn1 = M1*sin(beta*pi/180)         # mach number normal to shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.816\n",
    "Mn2 = 0.612                     \n",
    "# but Mn2 from equation 1 is 0.54\n",
    "\n",
    "# Guess 2\n",
    "M1 = 4.5                          # Guess for freestream number\n",
    "beta = 25.5                       # from fig 4.5 (in degrees)\n",
    "Mn1 = M1*sin(beta*pi/180)         # mach number normal to shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.937\n",
    "Mn2 = 0.588                     \n",
    "# but Mn2 from equation 1 is 0.47\n",
    "\n",
    "# Guess 3\n",
    "M1 = 3.5                          # Guess for freestream number\n",
    "beta = 29.2                       # from fig 4.5 (in degrees)\n",
    "Mn1 = M1*sin(beta*pi/180)         # mach number normal to shock\n",
    "\n",
    "# from Table A2 for Mn1 = 1.71\n",
    "Mn2 = 0.638                     \n",
    "# but Mn2 from equation 1 is 0.638\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# Result \n",
    "print \"Freestream mach number is %.1f\" %(M1)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lift coefficient : 0.152\n",
      "Drag coefficient : 0.0133\n"
     ]
    }
   ],
   "source": [
    "# Example 4.10.py\n",
    "# Consider an infinitely this flat plate at 5 degrees angle of attack in a Mach\n",
    "# 2.6 free stream. Calculate the lift and drag coefficients. \n",
    "\n",
    "from numpy import sin, cos, pi\n",
    "\n",
    "# Variable declaration\n",
    "alpha = 5.0    # angle of attack in degrees (in degrees)\n",
    "M1 = 2.6       # freestream mach number \n",
    "gamma = 1.4    # ratio of specific heats\n",
    "\n",
    "# Calculations \n",
    "\n",
    "# from table A5 for M1 = 2.6\n",
    "v1 = 41.41      # (in degrees)\n",
    "v2 = v1 + alpha # (in degrees)\n",
    "# from table A5 for v2 = 46.41 deg\n",
    "M2 = 2.85\n",
    "# from A1 for M1 = 2.6\n",
    "po1_by_p1 = 19.95\n",
    "# from A1 for M2 = 2.85\n",
    "po2_by_p2 = 29.29\n",
    "\n",
    "p2_by_p1 = 1/po2_by_p2 * po1_by_p1 # p2/p1 = p2/po2 * po2/po1 * po1/p1 and po2 = po1\n",
    "\n",
    "# from theta-beta-M diagram for M1 = 2.6\n",
    "theta = 5.0               # deflection (in degrees)\n",
    "beta = 26.5               # shock angle (in degrees)\n",
    "Mn1 = M1*sin(beta*pi/180) # mach number normal to the shock\n",
    "\n",
    "# from table A2 for Mn1 = 1.16\n",
    "p3_by_p1 = 1.403          # p3/p1\n",
    "\n",
    "cl = 2.0/(gamma*M1*M1)*(p3_by_p1 - p2_by_p1)*cos(alpha*pi/180) # coefficient of lift\n",
    "cd = 2.0/(gamma*M1*M1)*(p3_by_p1 - p2_by_p1)*sin(alpha*pi/180) # coefficient of drag\n",
    "\n",
    "\n",
    "# Results\n",
    "print \"Lift coefficient : %.3f\"%(cl)\n",
    "print \"Drag coefficient : %.4f\"%(cd)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
