{
 "metadata": {
  "name": "",
  "signature": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4, Fuel Air and Actual Cycles"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EXAMPLE 4.10, page 340"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Initialisation of Variables\n",
      "r=7  #Compression Ratio\n",
      "t2=715  #Temperature at the end of isentropic compression in Kelvin\n",
      "t4=1610  #Temperature at the end of expansion in Kelvin\n",
      "#Calculations\n",
      "vr2=65.8  #From steam table\n",
      "u2=524.2  #From steam table\n",
      "vr4=5.69  #From steam table\n",
      "u4=1307.63  #From steam table\n",
      "vr1=r*vr2 \n",
      "t1=338  #From steam table\n",
      "u1=241.38  #From steam table\n",
      "vr3=vr4/r \n",
      "t3=2800  #From steam table\n",
      "u3=2462.5  #From steam table\n",
      "W=(u3-u2)-(u4-u1)  #Work done\n",
      "Qa=(u3-u2)  #Heat added\n",
      "eta=W/Qa  #Cycle efficiency\n",
      "print \"The cycle work = %0.2f kJ/kg \" %W \n",
      "print \"The cycle efficiency = %0.2f %%\" %(eta*100) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The cycle work = 872.05 kJ/kg \n",
        "The cycle efficiency = 44.99 %\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EXAMPLE 4.2, page 342"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "# Initialisation of Variables\n",
      "r=8  #Compression Ratio\n",
      "ga=1.4 #Degree of freedom for the gas\n",
      "Cvinc=1.1 #Increase of specific heat at constant volume in percentage\n",
      "#Calculations\n",
      "eta=1-1/(r**(ga-1))  #efficiency of otto cycle\n",
      "deta=(1-eta)*(ga-1)*log(r)*(Cvinc/100) #Change in efficiency\n",
      "etach=-deta/eta #Percentage change in efficiency of change in efficiency\n",
      "print \"The percentage change in the efficiency of otto cycle = %0.2f %%\"%(etach*100)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The percentage change in the efficiency of otto cycle = -0.71 %\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EXAMPLE 4.3, page 345"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Initialisation of Variables\n",
      "r=7.0  #Compression Ratio\n",
      "ga=1.4  #Degree of freedom for the gas\n",
      "Cvinc=3.0  #Increase of specific heat at constant volume in percentage\n",
      "#Calculations\n",
      "eta=1-1/(r**(ga-1)) #efficiency of otto cycle\n",
      "deta=(1-eta)*(ga-1)*log(r)*(Cvinc/100) #Change in efficiency\n",
      "etach=-deta/eta #Percentage change in efficiency of change in efficiency\n",
      "print \"The percentage change in the efficiency of otto cycle = %0.2f %%\"%(etach*100)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The percentage change in the efficiency of otto cycle = -1.98 %\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EXAMPLE 4.4, page 349"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Initialisation of Variables\n",
      "r=18.0 #Compression Ratio\n",
      "co=5.0  #Cut off percent of stroke\n",
      "cv=0.71 #Mean specific heat for cycle in kJ/kg K\n",
      "R=0.285  #Charecteristic gas constant in kJ/kh K\n",
      "cvinc=2.0  #Percentage increase in mean specific heat of the cycle\n",
      "#Calculation\n",
      "rho=(co/100)*(r-1)+1 \n",
      "ga=1+(R/cv) \n",
      "eta=1-(1/(ga*(r**(ga-1))))*((rho**ga)-1)/(rho-1) #Efficiency of diesel cycle \n",
      "etach=-((1-eta)/eta)*(ga-1)*(log(r)-(((rho**ga)*log(rho))/((rho**ga)-1))+(1/ga))*(cvinc/100) #Variation in the air standard efficiency\n",
      "print \"The percentage change in the efficiency = %0.2f %%\"%(etach*100)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The percentage change in the efficiency = -1.15 %\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EXAMPLE 4.5, page 351"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import sqrt\n",
      "# Initialisation of Variables\n",
      "r=7 #Compression ratio\n",
      "C=44000 #Calorific value of fuel used in kJ/kg\n",
      "afr=15  #Air fuel ratio\n",
      "t1=338  #Temperature of the charge at the end of the stroke in Kelvin\n",
      "p1=1  #Pressure of the charge at the end of the stroke in bar\n",
      "n=1.33  #Index of compression\n",
      "cv=0.71  #Specific heat constant at constant volume in kJ/kgK\n",
      "k=20*10**(-5) \n",
      "#Calculations\n",
      "p2=p1*(r)**n \n",
      "t2=(t1*p2)/(p1*r) \n",
      "ha=C/(afr+1) #Heat added per kg of charge in kJ\n",
      "t3=((-2*cv)+sqrt((4*cv*cv)+(4*k*((2*cv*t2)+(k*t2*t2)+(2*ha)))))/(2*k) \n",
      "p3=(p2*t3)/t2  #Max pressure for constant volume process in bar\n",
      "P3=p2*((ha/cv)+t2)/t2  #Max pressure for constant specific heat in bar\n",
      "print \"Max pressure in the cylinder = %0.2f bar \" %(p3)\n",
      "print \"Max pressure for constant specific heat = %0.2f bar\" %P3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Max pressure in the cylinder = 65.52 bar \n",
        "Max pressure for constant specific heat = 93.52 bar\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EXAMPLE 4.6, page 356"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Initialisation of Variables\n",
      "r=10  #Compression ratio\n",
      "C=48000 #Calorific value of fuel used in kJ/kg\n",
      "afr=15  #Air fuel ratio\n",
      "t1=330  #Temperature of the charge at the end of the stroke in Kelvin\n",
      "p1=1  #Pressure of the charge at the end of the stroke in bar\n",
      "n=1.36  #Index of compression\n",
      "cv=0.7117 #Specific heat constant at constant volume in kJ/kgK\n",
      "k=2.1*10**(-4) \n",
      "#Calculations\n",
      "p2=p1*(r)**n \n",
      "t2=t1*((p2/p1)**((n-1)/n)) \n",
      "ha=C/(afr+1) #Heat added per kg of charge in kJ\n",
      "t3=((-2*cv)+sqrt((4*cv*cv)+(4*k*((2*cv*t2)+(k*t2*t2)+(2*ha)))))/(2*k) \n",
      "p3=(p2*t3)/t2  #Max pressure for constant volume process in bar\n",
      "P3=p2*((ha/cv)+t2)/t2 #Max pressure for constant specific heat in bar\n",
      "print \"Max pressure in the cylinder = %0.2f bar \" %(p3)\n",
      "print \"Max pressure for constant specific heat = %0.2f bar\" %P3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Max pressure in the cylinder = 102.27 bar \n",
        "Max pressure for constant specific heat = 150.64 bar\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EXAMPLE 4.7, page 360"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Initialisation of Variables\n",
      "r=15 #Compression ratio\n",
      "C=43000 #Calorific value of fuel used in kJ/kg\n",
      "afr=27 #Air fuel ratio\n",
      "t2=870 #Temperature of the charge at the end of the stroke in Kelvin\n",
      "cv=0.71  #Specific heat constant at constant volume in kJ/kgK\n",
      "R=0.287  #Gas constant in kJ/kgK\n",
      "k=20*10**(-5) \n",
      "#Calculations\n",
      "cp=cv+R  #Specific heat at constant pressure\n",
      "ha=C/(afr+1) #Heat added per kg of charge in kJ\n",
      "t3=((-2*cp)+sqrt((4*cp*cp)+(4*k*((2*cp*t2)+(k*t2*t2)+(2*ha)))))/(2*k) \n",
      "co=((t3/t2)-1)/(r-1) #combustion occupies this amt of stroke \n",
      "print \"Percentage of the stroke when the combustion is completed is\",round((co*100),2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage of the stroke when the combustion is completed is 9.77\n"
       ]
      }
     ],
     "prompt_number": 28
    }
   ],
   "metadata": {}
  }
 ]
}