{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER14:ELEMENTS OF HYPERSONIC FLOW"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E01 : Pg 440"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The exact results from the shock-expansion theory are:\n",
      "Cp2 = -0.0218681754368\n",
      "Cp3 =  0.188459821429\n",
      " cl = 0.203161244164\n",
      "cd = 0.054436891307\n",
      "L/D = 3.73205080757\n",
      "\n",
      "(b) The results from Newtonian theory are:\n",
      "Cp2 = 0\n",
      "Cp3 = 0.133974596216\n",
      "cl  = 0.129409522551\n",
      "cd  = 0.0346751770605\n",
      "L/D = 3.73205080757\n"
     ]
    }
   ],
   "source": [
    "# All the quantities are expressed in SI units\n",
    "from math import sqrt,pi,sin,cos\n",
    "M1 = 8.;                    # mach number\n",
    "alpha = 15.*pi/180.;        # anlge of attack\n",
    "theta= alpha;\n",
    "gam = 1.4;\n",
    "# (a)\n",
    "# for M = 8\n",
    "v1 = 95.62*pi/180.;\n",
    "v2 = v1 + theta;\n",
    "# from Appendix C\n",
    "M2 = 14.32;\n",
    "# from Appendix A, for M1 = 8 and M2 = 14.32\n",
    "p_ratio = 0.9763e4/0.4808e6;\n",
    "# from eq.(11.22)\n",
    "Cp2 = 2/gam/M1**2*(p_ratio - 1);\n",
    "# for M1 = 8 and theta = 15\n",
    "b = 21*pi/180;\n",
    "Mn_1 = M1*sin(b);\n",
    "# for this value of Mn,1, from appendix B\n",
    "p_ratio2 = 9.443;\n",
    "# thus\n",
    "Cp3 = 2./gam/M1**2.*(p_ratio2 - 1.);\n",
    "c_n = Cp3 - Cp2;\n",
    "c_l = c_n*cos(alpha);\n",
    "c_d = c_n*sin(alpha);\n",
    "L_by_D = c_l/c_d;\n",
    "print\"The exact results from the shock-expansion theory are:\"\n",
    "print\"Cp2 =\",Cp2\n",
    "print\"Cp3 = \",Cp3\n",
    "print\" cl =\",c_l\n",
    "print\"cd =\",c_d\n",
    "print\"L/D =\",L_by_D\n",
    "# (b)\n",
    "# from Newtonian theory, by eq.(14.9)\n",
    "Cp3 = 2.*sin(alpha)**2;\n",
    "Cp2 = 0;\n",
    "c_l = (Cp3 - Cp2)*cos(alpha);\n",
    "c_d = (Cp3 - Cp2)*sin(alpha);\n",
    "L_by_D = c_l/c_d;\n",
    "print\"\\n(b) The results from Newtonian theory are:\"\n",
    "print\"Cp2 =\",Cp2\n",
    "print\"Cp3 =\",Cp3\n",
    "print\"cl  =\",c_l\n",
    "print\"cd  =\",c_d\n",
    "print\"L/D =\",L_by_D"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "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.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
