{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER07:COMPRESSIBLE FLOW SOME PRELIMINARY ASPECTS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E01 : Pg 222"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The internal energy in the room is: E = 2.916375\n",
      "The Enthalpy in the room is: H =  4.082925\n"
     ]
    }
   ],
   "source": [
    "# All the quantities are expressed in SI units\n",
    "import math \n",
    "l = 5.;                # dimensions of the room\n",
    "b = 7.;\n",
    "h = 3.3;\n",
    "V = l*b*h;            # volume of the room\n",
    "p = 101000.;           # ambient pressure\n",
    "T = 273. + 25.;         # ambient temperature\n",
    "R = 287.;              # gas constant\n",
    "gam = 1.4;            # ratio of specific heats\n",
    "cv = R/(gam-1.);\n",
    "cp = gam*R/(gam-1.);\n",
    "\n",
    "# the density can by calculaled by the ideal gas law\n",
    "rho = p/R/T;\n",
    "\n",
    "# thus the mass is given by\n",
    "M = rho*V;\n",
    "\n",
    "# from eq.(7.6a), the internal energy per unit mass is\n",
    "e = cv*T;\n",
    "\n",
    "# thus internal energy in the room is\n",
    "E = e*M;\n",
    "\n",
    "# from eq.(7.6b), the enthalpy per unit mass is given by\n",
    "h = cp*T;\n",
    "\n",
    "# Thus the enthalpy in the room is\n",
    "H = M*h;\n",
    "\n",
    "print\"The internal energy in the room is: E =\", E/10**7\n",
    "print\"The Enthalpy in the room is: H = \",H/10**7"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E02 : Pg 223"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The temperature at the given point is: T = 206.668775312 K\n"
     ]
    }
   ],
   "source": [
    "# All the quantities are expressed in SI units\n",
    "\n",
    "p_inf = 22790.9;            # ambient pressure at 36000 ft\n",
    "T_inf = 217.2;              # ambient temperature at 36000 ft\n",
    "p = 19152;                  # pressure at the given point\n",
    "gam = 1.4;\n",
    "\n",
    "# thus the temperature at the given point can be calculated by eq.(7.32) as\n",
    "T = T_inf*((p/p_inf)**((gam-1)/gam));\n",
    "\n",
    "print\"The temperature at the given point is: T =\",T,\"K\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example E03 : Pg 223"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The total temperature and pressure are given by: T0 = 817.760079642 K\n",
      "P0 = 26.678766535 atm\n"
     ]
    }
   ],
   "source": [
    "# All the quantities are expressed in SI units\n",
    "\n",
    "p =101000;                # static pressure\n",
    "T = 320;                  # static temperature\n",
    "v = 1000;                 # velocity\n",
    "gam = 1.4;                # ratio of specific heats\n",
    "R = 287;                  # universal gas constant\n",
    "cp = gam*R/(gam-1);       # specific heat at constant pressure\n",
    "\n",
    "# from eq.(7.54), the total temperature is given by\n",
    "T0 = T + (v**2)/2/cp;\n",
    "\n",
    "# from eq.(7.32),the total pressure is given by\n",
    "p0 = p*((T0/T)**(gam/(gam-1)));\n",
    "\n",
    "p0_atm = p0/101000;\n",
    "\n",
    "\n",
    "print\"The total temperature and pressure are given by: T0 =\",T0,\"K\"\n",
    "print\"P0 =\",p0_atm,\"atm\""
   ]
  }
 ],
 "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
}
