{
 "metadata": {
  "name": "",
  "signature": "sha256:c78d396c993e1067d10db02248ea7bb1149674e24ff2199a434e078a4771b88f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9 : Gas Power Cycles"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.1  Page No : 462"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "Rc = 7.; \t\t\t#Compression Ratio Rc = v2/v3\n",
      "k = 1.4;  \t\t\t#It is apparent incerease in compression ratio yields an increased cycle efficiency\n",
      "notto = (1-(1/Rc)**(k-1))*100; \t\t\t#Efficiency of an otto engine\n",
      "print \"The efficiency of the otto cycle is %.2f percentage\"%(notto);\n",
      "#For the carnot cycle,\n",
      "#Nc = 1-(T2/T4) \t\t\t#efficiency for the carnot cycle \t\t\t#T2 = lowest temperature \t\t\t#T4 = Highest temperature\n",
      "\n",
      "T2 = 70.+460; \t\t\t#for converting to R \t\t\t#Conversion of unit\n",
      "#At 700 F\n",
      "T4 = 700.+460; \t\t\t#temperatures converted to absolute temperatures;\n",
      "nc = (1-(T2/T4))*100; \t\t\t#efficiency of the carnot cycle\n",
      "print \"When peak temperature is 700 fahrenheit, efficiency of the carnot cycle is %.2f percentage\"%(nc);        \n",
      "\n",
      "#At 1000 F\n",
      "T4 = 1000.+460; \t\t\t#temperatures converted to absolute temperatures;\n",
      "nc = (1-(T2/T4))*100; \t\t\t#efficiency of the carnot cycle\n",
      "print \"When peak temperature is 1000 fahrenheit, efficiency of the carnot cycle is %.2f percentage\"%(nc);\n",
      "\n",
      "#At 3000 F\n",
      "T4 = 3000.+460; \t\t\t#temperatures converted to absolute temperatures;\n",
      "nc = (1-(T2/T4))*100; \t\t\t#efficiency of the carnot cycle\n",
      "print \"When peak temperature is 3000 fahrenheit, efficiency of the carnot cycle is %.2f percentage\"%(nc);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The efficiency of the otto cycle is 54.08 percentage\n",
        "When peak temperature is 700 fahrenheit, efficiency of the carnot cycle is 54.31 percentage\n",
        "When peak temperature is 1000 fahrenheit, efficiency of the carnot cycle is 63.70 percentage\n",
        "When peak temperature is 3000 fahrenheit, efficiency of the carnot cycle is 84.68 percentage\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.2  Page No : 463"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy.linalg import inv\n",
      "\n",
      "cv = 0.172; \t\t\t#Unit:Btu/(lbm*R) \t\t\t#Specific heat constant\n",
      "Rc = 7; \t\t\t#Compression Ratio Rc = v2/v3\n",
      "k = 1.4; \t\t\t#It is apparent incerease in compression ratio yields an increased cycle efficiency\n",
      "T2 = 70+460; \t\t\t#for converting to R \t\t\t#Conversion of unit\n",
      "#For 1000 F\n",
      "T4 = 1000+460; \t\t\t#temperatures converted to absolute temperatures;\n",
      "T3byT2 = Rc**(k-1); \t\t\t#Unit less\n",
      "T3 = T3byT2*T2;\n",
      "qin = cv*(T4-T3); \t\t\t#Unit:Btu/lbm \t\t\t#Heat added\n",
      "#Qr = cv*(T5-T2)*(T5/T4) = (v2/v3)**(k-1)\n",
      "Qr = (inv([[Rc]]))**(k-1); \t\t\t#Unit:Btu/lbm \t\t\t#Heat rejected\n",
      "T5 = T4*Qr;\n",
      "Qr = cv*(T5-T2); \t\t\t#Unit:Btu/lbm \t\t\t#Heat rejected\n",
      "print \"The net work out is %.2f Btu/lbm\"%(qin-Qr);\n",
      "notto = ((qin-Qr)/qin)*100; \t\t\t#The efficiency of otto cycle \n",
      "print \"The efficiency of otto cycle is %.2f percentage\"%(notto);\n",
      "#The value agrees with the results of problem 9.1\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The net work out is 28.44 Btu/lbm\n",
        "The efficiency of otto cycle is 54.08 percentage\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.3  Page No : 464"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "cv = 0.7186; \t\t\t#Unit:kJ/(kg*K) \t\t\t#Specific heat constant for constant volume process\n",
      "Rc = 8.; \t\t\t#Compression Ratio Rc = v2/v3\n",
      "k = 1.4;  \t\t\t#It is apparent incerease in compression ratio yields an increased cycle efficiency\n",
      "T2 = 20.+273; \t\t\t#20 C converted to its kelvin value\n",
      "qin = 50.; \t\t\t#Heat added \t\t\t#Unit:kJ\n",
      "T3byT2 = Rc**(k-1);\n",
      "T3 = T3byT2*T2; \t\t\t#Unit:K\n",
      "#qin = cv*(T4-T3) \t\t\t#heat added \t\t\t#Unit:kJ\n",
      "T4 = (qin/cv)+T3; \t\t\t#The peak temperature of the cycle \t\t\t#Unit:K\n",
      "print \"The peak temperature of the cycle is %.2f Kelvin i.e. %.2f Celcius\"%(T4,T4-273);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The peak temperature of the cycle is 742.72 Kelvin i.e. 469.72 Celcius\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.4  Page No : 465"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#For an Otto cycle,\n",
      "rc = 7.; \t\t\t#Compression Ratio Rc = v2/v3\n",
      "q = 50.; \t\t\t#Unit:Btu/lbm \t\t\t#Heat added\n",
      "p2 = 14.7; \t\t\t#Unit:psia \t\t\t#pressure at point 2\n",
      "T2 = 60.+460; \t\t\t#temperatures converted to absolute temperatures; \t\t\t#Unit:R\n",
      "cp = 0.24; \t\t\t#Unit:Btu/(lbm*R) \t\t\t#Specific heat constant for constant pressure process\n",
      "cv = 0.171; \t\t\t#Unit:Btu/(lbm*R) \t\t\t#Specific heat constant for constant volume process\n",
      "R = 53.3; \t\t\t#Unit:ft*lbf/lbm*R \t\t\t#constant of proportionality\n",
      "k = 1.4;  \t\t\t#It is apparent incerease in compression ratio yields an increased cycle efficiency\n",
      "#Refering to figure 9.9,\n",
      "#At (2),we need v2.\n",
      "#p2*v2 = R*T2\n",
      "v2 = (R*T2)/(p2*144); \t\t\t#Unit:ft**3/lbm \t\t\t#1ft**2 = 144 in**2 \t\t\t#specific volume at point 2\n",
      "print \"At point 2, specific volume v2 = %.2f ft**3/lbm\"%(v2);\n",
      "#For The isentropic path (2)&(3),p3*v3**k = p2*v2**k,so\n",
      "#So,p3 = p2*(v2/v3)**k;\n",
      "p3 = p2*rc**k; \t\t\t#Unit:psia \t\t\t#pressure at point 3\n",
      "print \"At path2&3\";\n",
      "print \"pressure p3 = %.2f psia\"%(p3);\n",
      "v3 = v2/rc; \t\t\t#Unit:ft**3/lbm \t\t\t#specific volume at point 3\n",
      "print \"specific volume v3 = %.2f ft**3/lbm\"%(v3);\n",
      "T3 = (p3*v3*144)/R; \t\t\t#Unit:R \t\t\t#1ft**2 = 144 in**2 \t\t\t#temperature at point 3\n",
      "print \"temperature T3 = %.2f R\"%(T3);\n",
      "print \"At point4\"\n",
      "#To obtain the values at (4),we note\n",
      "v4 = v3; \t\t\t#Unit:ft**3/lbm \t\t\t#specific volume at point 4\n",
      "print \"specific volume v4 = %.2f ft**3/lbm\"%(v4);\n",
      "#qin = cv*(T4-T3)\n",
      "T4 = T3+(q/cv); \t\t\t#Unit:R \t\t\t#temperature at point 4 \n",
      "print \"temperature T4 = %.2f R\"%(T4);\n",
      "#For p4,\n",
      "p4 = (R*T4)/(144*v4); \t\t\t#Unit:psia \t\t\t#1ft**2 = 144 in**2 \t\t\t#pressure at point 4\n",
      "print \"pressure p4 = %.2f psia\"%(p4);\n",
      "#The last point has the same specific volume as (2),giving\n",
      "print \"At last point\"\n",
      "v5 = v2; \t\t\t#Unit:ft**3/lbm \t\t\t#specific volume at point 5\n",
      "print \"specific volume v5 = %.2f ft**3/lbm\"%(v5);\n",
      "#The isentropic path equation,p5*v5**k = p4*v4**k,so\n",
      "p5 = p4*(v4/v5)**k; \t\t\t#Unit:psia \t\t\t#pressure at point 5\n",
      "print \"pressure p5 = %.2f psia\"%(p5);\n",
      "T5 = (p5*v5*144)/(R); \t\t\t#Unit:R \t\t\t#1ft**2 = 144 in**2 temperature at point 5\n",
      "print \"temperature T5 = %.2f R\"%(T5);\n",
      "n = (((T4-T3)-(T5-T2))/(T4-T3))*100; \t\t\t#The efficiency of the cycle\n",
      "print \"The efficiency of the cycle is %.2f percentage\"%(n);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At point 2, specific volume v2 = 13.09 ft**3/lbm\n",
        "At path2&3\n",
        "pressure p3 = 224.11 psia\n",
        "specific volume v3 = 1.87 ft**3/lbm\n",
        "temperature T3 = 1132.51 R\n",
        "At point4\n",
        "specific volume v4 = 1.87 ft**3/lbm\n",
        "temperature T4 = 1424.91 R\n",
        "pressure p4 = 281.97 psia\n",
        "At last point\n",
        "specific volume v5 = 13.09 ft**3/lbm\n",
        "pressure p5 = 18.50 psia\n",
        "temperature T5 = 654.26 R\n",
        "The efficiency of the cycle is 54.08 percentage\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.7  Page No : 468"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#For four cycle engine,\n",
      "#Using the results of problem 9.6,\n",
      "pm = 1000.; \t\t\t#Unit:kPa \t\t\t#mean effective pressure \t\t\t#Unit:psia\n",
      "N = 4000./2; \t\t\t#Power strokes per minute \t\t\t#2L engine \t\t\t#Unit:rpm\n",
      "LA = 2.     \t\t\t#Mean \t\t\t#Unit:liters\n",
      "hp = (pm*LA*N)/44760; \t\t\t#The horsepower \t\t\t#Unit:hp\n",
      "print \"The horsepower is %.2f hp\"%(hp);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The horsepower is 89.37 hp\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.9  Page No : 469"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables.\n",
      "c=0.2;      #clearance equal to 20% of its displacement\n",
      "#An otto engine\n",
      "#Using results of problem 9.8, \n",
      "rc = (1+c)/c; \t\t\t#The compression ratio\n",
      "print \"The compression ratio is %.2f\"%(rc);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The compression ratio is 6.00\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.10  Page No : 470"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#For four cycle,six cylinder engine,\n",
      "#Using the results of problem 9.5,\n",
      "hp = 100; \t\t\t#Horsepower \t\t\t#Unit:hp\n",
      "L = 4./12; \t\t\t#Unit:ft \t\t\t#stroke is 4 in.\n",
      "A = (math.pi/4)*(3)**2*6; \t\t\t#Cylinder bore is 3 in.\n",
      "N = 4000/2; \t\t\t#Power strokes per minute \t\t\t#2L engine \t\t\t#Unit:rpm\n",
      "#hp = (pm*LA*N)/33000;\n",
      "pm = (hp*33000)/(L*A*N); \t\t\t#The mean effective pressure \t\t\t#psia\n",
      "\n",
      "# Results\n",
      "print \"The mean effective pressure is %.2f psia\"%(pm);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean effective pressure is 116.71 psia\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.11  Page No : 470"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#six cylinder engine,with print lacement 3.3L\n",
      "#Using the results of problem 9.5,\n",
      "hp = 230; \t\t\t#Horsepower \t\t\t#Unit:hp\n",
      "#3.3L*1000 cm**3/L*(in/2.54 cm)**3\n",
      "LA = 3.3*1000*(1/2.54)**3; \t\t\t#mean \t\t\t#in**3\n",
      "N = 5500/2; \t\t\t#Power strokes per minute \t\t\t#2L engine \t\t\t#Unit:rpm\n",
      "#hp = (pm*LA*N)/33000;\n",
      "pm = (hp*33000*12)/(LA*N); \t\t\t#1ft = 12inch \t\t\t#The mean effective pressure \t\t\t#psia\n",
      "print \"The mean effective pressure is %.2f psia\"%(pm);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean effective pressure is 164.47 psia\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.12  Page No : 478"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy.linalg import inv\n",
      "\n",
      "#An air-smath.radians(numpy.arcmath.tan(ard Diesel engine\n",
      "rc = 16; \t\t\t#Compression Ratio Rc = v2/v3\n",
      "v4byv3 = 2; \t\t\t#Cutoff ratio = v4/v3\n",
      "k = 1.4; \t\t\t#with the cycle starting at 14 psia and 100 F  \t\t\t#It is apparent incerease in compression ratio yields an increased cycle efficiency\n",
      "T2 = 100+460; \t\t\t#temperatures converted to absolute temperatures;\n",
      "ndiesel = 1-((inv([[rc]]))**(k-1)*(((v4byv3)**k-1)/(k*(v4byv3-1)))); \t\t\t#The efficiency of the diesel engine\n",
      "print \"The efficiency of the diesel engine is %.2f percentage\"%(ndiesel*100);\n",
      "# T3/T2 = rc**k-1 and T5/T4 = (1/re**k-1) \t\t\t#re = expansion ratio = v5/v4\n",
      "#But T4/T3 = v4/v3 = rc/re\n",
      "#So,\n",
      "T5 = T2*(v4byv3)**k; \t\t\t#The temperature of the exhaust of the cycle \t\t\t#Unit:R\n",
      "print \"The temperature of the exhaust of the cycle is %.2f R i.e. %.2f F\"%(T5,T5-460);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The efficiency of the diesel engine is 61.38 percentage\n",
        "The temperature of the exhaust of the cycle is 1477.85 R i.e. 1017.85 F\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.13  Page No : 479"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Now,in problem 9.12,\n",
      "#An air-smath.radians(numpy.arcmath.tan(ard Diesel engine\n",
      "rc = 16; \t\t\t#Compression Ratio Rc = v2/v3\n",
      "v4byv3 = 2; \t\t\t#Cutoff ratio = v4/v3\n",
      "k = 1.4; \t\t\t#with the cycle starting at 14 psia and 100 F  \t\t\t#It is apparent incerease in compression ratio yields an increased cycle efficiency\n",
      "T2 = 100; \t\t\t#Unit:F \t\t\t#temperature \n",
      "T5 = 1018; \t\t\t#Unit:F \t\t\t#Found in 9.12 \t\t\t#The temperature of the exhaust of the cycle \t\t\t#Unit:R\n",
      "ndiesel = 0.614 \t\t\t#Efficiency of the diesel engine \t\t\t#Found in 9.12\n",
      "#Now,in problem 9.13,\n",
      "cp = 0.24; \t\t\t#Unit:Btu/(lbm*R) \t\t\t#Specific heat constant for constant pressure process\n",
      "cv = 0.172; \t\t\t#Unit:Btu/(lbm*R) \t\t\t#Specific heat constant for constant volume process\n",
      "\n",
      "Qr = cv*(T5-T2); \t\t\t#Heat rejected \t\t\t#Unit:Btu/lbm\n",
      "#ndeisel = 1-(Qr/qin); \t\t\t#Efficiency = ndeisel \t\t\t#qin = heat added\n",
      "qin = Qr/(1-ndiesel); \t\t\t#Unit:Btu/lbm\n",
      "J = 778; \t\t\t#J = Conversion factor\n",
      "networkout = J*(qin-Qr); \t\t\t#(ft*lbf)/lbm \t\t\t#Net work out per pound of gas\n",
      "print \"Net work out per pound of gas is %.2f ft*lbf)/lbm\"%(networkout);\n",
      "#The mean effective pressure is net work divided by (v2-v3):\n",
      "mep = networkout/((16-1)*144); \t\t\t#1ft**2 = 144 in**2 \t\t\t#Unit:psia  \t\t\t#The mean effective pressure\n",
      "print \"The mean effective pressure is %.2f psia\"%(mep); \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Net work out per pound of gas is 195403.25 ft*lbf)/lbm\n",
        "The mean effective pressure is 90.46 psia\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.14  Page No : 489"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy.linalg import inv\n",
      "\n",
      "#A Brayton cycle\n",
      "rc = 7; \t\t\t#Compression Ratio Rc = v2/v3\n",
      "k = 1.4;  \t\t\t#It is apparent incerease in compression ratio yields an increased cycle efficiency\n",
      "cp = 0.24; \t\t\t#Unit:Btu/(lbm*R) \t\t\t#Specific heat constant for constant pressure process\n",
      "T3 = 1500; \t\t\t#(unit:fahrenheit) \t\t\t#peak tempeature\n",
      "p1 = 14.7; \t\t\t#Unit:psia \t\t\t#Initial condition\n",
      "T1 = 70+460; \t\t\t#temperatures converted to absolute temperatures; \t\t\t#Initial condition\n",
      "R = 53.3; \t\t\t#Unit:ft*lbf/lbm*R \t\t\t#constant of proportionality\n",
      "nBrayton = 1-(0.1428571**(k-1)); \t\t\t#A Brayton cycle efficiency \n",
      "print \"A Brayton cycle efficiency is %.2f percentage\"%(nBrayton*100);\n",
      "#If we base our calculation on 1 lbm of gas and use subscripts that corresponds to points (1),(2),(3) and (4) of fig.9.22,we have\n",
      "v1 = (R*T1)/p1; \t\t\t#Unit:ft**3/lbm \t\t\t#specific volume at point 1\n",
      "#Because rc = 7 then,\n",
      "v2 = v1/rc; \t\t\t#Unit:ft**3/lbm \t\t\t#specific volume at point 2\n",
      "#After the isentropic compression, T2*v2**k-1  =  T1*v1**k-1\n",
      "T2 = T1*(v1/v2)**(k-1); \t\t\t#Unit:R \t\t\t#temperature at point 2\n",
      "T2 = T2-460; \t\t\t#Unit:fahrenheit \t\t\t#temperature at point 2\n",
      "qin = cp*(T3-T2); \t\t\t#Heat in \t\t\t#Unit:Btu/lbm\n",
      "print \"The heat in is %.2f Btu/lbm\"%(qin);\n",
      "#Because efficiency can be stated to be work out divided by heat in,\n",
      "wbyJ = nBrayton*qin; \t\t\t#The work out \t\t\t#Unit:Btu/lbm\n",
      "print \"The work out is %.2f Btu/lbm\"%(wbyJ); \t\t\t#Answer is wrong in the book.cause they have taken efficiency value wrong\n",
      "print \"The heat rejected is %.2f Btu/lbm\"%(qin-wbyJ); \t\t\t#Anser is affected because of value of wbyJ\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A Brayton cycle efficiency is 54.08 percentage\n",
        "The heat in is 193.37 Btu/lbm\n",
        "The work out is 104.58 Btu/lbm\n",
        "The heat rejected is 88.79 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}