{
 "metadata": {
  "name": "",
  "signature": "sha256:719cabf4d155b5060d8459b45f43cc016b1e1aad0e88a0a317b0beeb5ac9abba"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter2-Basic Thermodynamics, Fluid Mechanics: Definitions of Efficiency"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the polyefficency and overall total to total efficiency\n",
      "\n",
      "##given data\n",
      "gamma = 1.4;\n",
      "pi = 8.;##pressure ratio\n",
      "T01 = 300.;##inlet temperature in K\n",
      "T02 = 586.4;##outlet temperature in K\n",
      "\n",
      "##Calculations\n",
      "##Calculation of Overall Total to Total efficiency\n",
      "Tot_eff = ((pi**((gamma-1.)/gamma))-1.)/((T02/T01)-1.);\n",
      "\n",
      "##Calculation of polytropic efficiency\n",
      "Poly_eff = ((gamma-1.)/gamma)*((math.log(pi))/math.log(T02/T01));\n",
      "\n",
      "##Results\n",
      "print'%s %.2f %s'%('The Overall total-to-total efficiency is ',Tot_eff,'');\n",
      "print'%s %.2f %s'%('The polytropic efficiency is ',Poly_eff,'');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Overall total-to-total efficiency is  0.85 \n",
        "The polytropic efficiency is  0.89 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the\n",
      "\n",
      "##given data\n",
      "T01 = 1200.;##Stagnation temperature at which gas enters in K\n",
      "p01 = 4.;##Stagnation pressure at which gas enters in bar\n",
      "c2 = 572.;##exit velocity in m/s\n",
      "p2 = 2.36;##exit pressure in bar\n",
      "Cp = 1.160*1000.;##in J/kgK\n",
      "gamma = 1.33\n",
      "\n",
      "##calculations\n",
      "T2 = T01 - 0.5*(c2**2)/Cp;##Calculation of exit temperature in K\n",
      "Noz_eff = ((1.-(T2/T01))/(1.-(p2/p01)**((gamma-1.)/gamma)));##Nozzle efficiency\n",
      "\n",
      "##Results\n",
      "print'%s %.2f %s'%('Nozzle efficiency is ',Noz_eff,'');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Nozzle efficiency is  0.96 \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the\n",
      "\n",
      "##given data\n",
      "cp = 0.6;##coefficient of pressure\n",
      "AR = 2.13;##Area ratio\n",
      "N_R1 = 4.66;\n",
      "\n",
      "##calculations\n",
      "cpi = 1. - (1./(AR**2));\n",
      "Diff_eff = cp/cpi;##diffuser efficiency\n",
      "theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle\n",
      "\n",
      "##Results\n",
      "print'%s %.2f %s'%('cpi = \\n',cpi,'');\n",
      "print'%s %.2f %s'%('The included cone angle can be found = ',theta,' deg.');\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "cpi = \n",
        " 0.78 \n",
        "The included cone angle can be found =  11.26  deg.\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the\n",
      "\n",
      "##given data\n",
      "AR = 1.8;##Area ratio\n",
      "cp = 0.6;##coefficient of pressure\n",
      "N_R1 = 7.85;\n",
      "\n",
      "##calculations\n",
      "Theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle\n",
      "cpi = 1.-(1./(AR**2));\n",
      "Diff_eff = cp/cpi;##diffuser efficeincy\n",
      "\n",
      "##Results\n",
      "print'%s %.2f %s'%('The included cone angle can be found = ',Theta,' deg.\\n');\n",
      "print'%s %.2f %s'%('cpi = \\n',cpi,'');\n",
      "print'%s %.2f %s'%('Diffuser efficiency = ',Diff_eff,'');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The included cone angle can be found =  4.98  deg.\n",
        "\n",
        "cpi = \n",
        " 0.69 \n",
        "Diffuser efficiency =  0.87 \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate the\n",
      "\n",
      "##given data\n",
      "AR = 2.0;##Area ratio\n",
      "alpha1 = 1.059;\n",
      "B1 = 0.109;\n",
      "alpha2 = 1.543;\n",
      "B2 = 0.364;\n",
      "cp = 0.577;##coefficient of pressure\n",
      "\n",
      "##calculations\n",
      "cp = (alpha1 - (alpha2/(AR**2))) - 0.09;\n",
      "Diff_eff = cp/(1.-(1./(AR**2)));##Diffuser efficiency\n",
      "\n",
      "##Results\n",
      "print'%s %.2f %s'%('The diffuser efficiency = ',Diff_eff,'');\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The diffuser efficiency =  0.78 \n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}