{
 "metadata": {
  "name": "",
  "signature": "sha256:ff76720b6d591e09d5857c774c4d9dbfbab10ecbdd3710baee1b7c89ef730620"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 8: Vapor Power Cycle"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1, page no. 275"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "\n",
      "#Variable Declaration: \n",
      "p1 = 7 #Lower pressure limit(in kPa):\n",
      "p2 = 7 #Higher pressure limit(in MPa):\n",
      "h2 = 2772.1 #Enthalpy at state 2(in kJ/kg): \n",
      "s2 = 5.8133 #Entropy at state 2(in kJ/kg.K):\n",
      "h3 = 1267 #Enthalpy at state 3(in kJ/kg):\n",
      "s3 = 3.1211 #Entropy at state 3(in kJ/kg.K):\n",
      "sf1 = 0.5564 #Value of sf at 7 kPa(in kJ/kg.K):\n",
      "sfg1 = 7.7237 #Value of sfg at 7 kPa(in kJ/kg.K):\n",
      "hf1 = 162.60 #Value of hf at 7 kPa(in kJ/kg):\n",
      "hfg1 = 2409.54 #Value of hfg at 7 kPa(in kJ/kg):\n",
      "s1 = s2 #Entropy at state 1(in kJ/kg.K):\n",
      "\n",
      "#Calculations:\n",
      "x1 = (s1-sf1)/sfg1 #Dryness fraction at state 1:\n",
      "h1 = hf1+x1*hfg1 #Enthalpy at state 1(in kJ/kg):\n",
      "s4 = s3 #Entropy at state 4(in kJ/kg.K):\n",
      "x4 = (s4-sf1)/sfg1 #Dryness fraction for state 4:\n",
      "h4 = hf1+x4*hfg1 #Enthalpy at state 4(in kJ/kg):\n",
      "W1 = h2-h1 #Expansion work per kg(in kJ/kg):\n",
      "W2 = h3-h4 #Compression work per kg(in kJ/kg):\n",
      "H = h2-h3 #Heat added per kg(in kJ/kg):\n",
      "W = W1-W2 #Net work done(in kJ/kg):\n",
      "n = W/H #Thermal efficiency:\n",
      "\n",
      "#Results:\n",
      "print  \"Thermal Efficiency: \",round(n*100,2),\"%\"\n",
      "print  \"Turbine work: \",round(W1,2),\"KJ/Kg\"\n",
      "print  \"Compression work: \",round(W2,2),\"KJ/Kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal Efficiency:  44.2 %\n",
        "Turbine work:  969.52 KJ/Kg\n",
        "Compression work:  304.3 KJ/Kg\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2, page no. 276"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "p1 = 5        #Lower pressure limit(in kPa):\n",
      "p2 = 5000 #Higher pressure limit(in kPa):\n",
      "#From gas tables:\n",
      "hf5M = 1154.23 #Value of hf at 5 MPa(in kJ/kg): \n",
      "sf5M = 2.92 #Value of sf at 5 MPa(in kJ/kg.K):\n",
      "hg5M = 2794.3 #Value of hg at 5 MPa(in kJ/kg):\n",
      "sg5M = 5.97 #Value of sg at 5 MPa(in kJ/kg.K):\n",
      "hf5k = 137.82 #Value of hf at 5 kPa(in kJ/kg):\n",
      "sf5k = 0.4764 #Value of sf at 5 kPa(in kJ/kg.K):\n",
      "hg5k = 2561.5 #Value of hg at 5 kPa(in kJ/kg):\n",
      "sg5k = 8.3961 #Value of sg at 5 kPa(in kJ/kg.K):\n",
      "vf5k = 0.001005 #/Value of vf at 5 kPa(in m**3/kg):\n",
      "\n",
      "#Calculation:\n",
      "sfg5k = sg5k-sf5k #Value of sfg at 5 kPa(in kJ/kg.K):\n",
      "hfg5k = hg5k-hf5k #Value of hfg at 5 kPa(in kJ/kg.K):\n",
      "s2 = sg5M #Entropy at point 2(in kJ/kg.K): \n",
      "s3 = s2         #As process 2-3 is isentropic:\n",
      "x3 = (s3-sf5k)/sfg5k #Dryness fraction at point 3:\n",
      "h3 = hf5k+x3*hfg5k #Enthalpy at point 3(in kJ/kg):\n",
      "h2 = hg5M #Enthalpy at point 2(in kJ/kg):\n",
      "s1 = sf5M #Entropy at point 1(in kJ/kg.K):\n",
      "s4 = s1  #Process 1-4 is isentropic:\n",
      "x4 = (s4-sf5k)/sfg5k #Dryness fraction at point 4:\n",
      "h4 = hf5k+x4*hfg5k #Enthalpy at point 4(in kJ/kg):\n",
      "h1 = hf5M #Enthalpy at point 1(in kJ/kg):\n",
      "n = ((h2-h3)-(h1-h4))/(h2-h1) #Carnot efficiency:\n",
      "Pw = vf5k*(p2-p1) #Pump work: \n",
      "h5 = hf5k #Enthalpy at point 5(in kJ/kg):\n",
      "h6 = h5+Pw #Enthalpy at point 6(in kJ/kg):\n",
      "Nw = (h2-h3)-(h6-h5) #Net work in the cycle:\n",
      "Ha = h2-h6 #Heat added:\n",
      "nr = Nw/Ha #Rankine efficiency:\n",
      "\n",
      "#Results:\n",
      "print \"Carnot cycle efficiency: \",round(n*100,2)\n",
      "print \"Rankine cycle efficiency: \",round(nr*100,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Carnot cycle efficiency:  43.09\n",
        "Rankine cycle efficiency:  36.59\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3, page no. 278"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      " \n",
      "#Variable Declaration: \n",
      "p1 = 40 #Pressure of steam entering(in bar):\n",
      "T1 = 350+273    #Temperature(in K):\n",
      "p4 = 0.05  #Pressure of steam leaving(in bar):\n",
      "#From steam tables:\n",
      "h2 = 3092.5                 #kJ/kg\n",
      "s2 = 6.5821                 #kJ/kg.K\n",
      "h4 = 137.82                 #kJ/kg\n",
      "s4 = 0.4764                 #kJ/kg.K\n",
      "v4 = 0.001005               #m**3/kg\n",
      "sf = 0.4764                 #kJ/kg.K\n",
      "sfg = 7.9187                #kJ/kg.K\n",
      "hf = 137.82                 #kJ/kg\n",
      "hfg = 2423.7                #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s3 = s2  #Entropy at state 3:\n",
      "x3 = (s3-sf)/sfg            #Dryness fraction at state 3:\n",
      "h3 = hf+x3*hfg  #Enthalpy at state 3(in kJ/kg):\n",
      "h1 = h4+v4*(p1-p4)*10**2    #Enthalpy at state 1(in kJ/kg):\n",
      "Wp = h1-h4 #Pump work(in kJ/kg):\n",
      "Wnet = h2-h3-Wp  #Net work(in kJ/kg):\n",
      "Q = h2-h1 #Heat added(in kJ/kg):\n",
      "n = Wnet/Q*100   #Cycle efficiency(in kJ/kg):\n",
      "\n",
      "#Results:\n",
      "print \"Net work per kg of steam: \",round(Wnet,2),\"kJ/kg\"\n",
      "print \"Cycle efficiency: \",round(n,2),\"%\"\n",
      "print \"Pump work per kg of steam: \",round(Wp,2),\"kJ/kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Net work per kg of steam:  1081.88 kJ/kg\n",
        "Cycle efficiency:  36.67 %\n",
        "Pump work per kg of steam:  4.01 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4, page no. 279"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      " \n",
      "#Variable Declaration: \n",
      "p1 = 20  #Pressure of the steam entering(in MPa):\n",
      "T1 = 500+273   #Temperature(in K):\n",
      "x = 0.90  #Dryness fraction of the steam leaving:\n",
      "p6 = 0.005 #Condensor pressure(in MPa):\n",
      "#From steam tables:\n",
      "h2 = 3238.2                 #kJ/kg\n",
      "s2 = 6.1401                 #kJ/kg.K\n",
      "s3 = s2\n",
      "hf = 137.82                 #kJ/kg\n",
      "hfg = 2423.7                #kJ/kg.K\n",
      "sf = 0.4764                 #kJ/kg.K\n",
      "sfg = 7.9187                #kJ/kg.K\n",
      "h6 = 137.82                 #kJ/kg\n",
      "h4 = 3474.1                 #kJ/kg\n",
      "sf1 = 2.2842                #kJ/kg.K\n",
      "sfg1 = 4.1850               #kJ/kg.K\n",
      "hf1 = 830.3                 #kJ/kg\n",
      "hfg1 = 1959.7               #kJ/kg\n",
      "v6 = 0.001005               #m**3/kg\n",
      "\n",
      "#Calculations:\n",
      "h5 = hf+x*hfg #Enthalpy at state 5(in kJ/kg):\n",
      "s5 = sf+x*sfg\n",
      "p4 = 1.4 #By interpolation, pressure at state 4(in bar):\n",
      "x3 = (s3-sf1)/sfg1  #Dryness fraction at state 3:\n",
      "h3 = hf1+x3*hfg1 #Enthalpy at state 3(in kJ/kg):\n",
      "h1 = h6+v6*(p1-p6)*10**3    #Enthalpy at state 1(in kJ/kg):\n",
      "Wnet = (h2-h3)+(h4-h5)-(h1-h6) #Net work per kg of steam(in kJ/kg):\n",
      "Q = h2-h1 #Heat added per kg of steam(in kJ/kg):\n",
      "n = Wnet/Q*100  #Thermal efficiency:\n",
      "\n",
      "#Results:\n",
      "print \"Pressure of steam leaving HP turbine: \",round(p4,2),\"MPa\"\n",
      "print \"Thermal efficiency: \",round(n,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure of steam leaving HP turbine:  1.4 MPa\n",
        "Thermal efficiency:  56.4 %\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5, page no. 280"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      " \n",
      "#Variable Declaration:\n",
      "p1 = 10 #Pressure of steam leaving the boiler(in MPa):\n",
      "T1 = 700+273 #Temperature(in K):\n",
      "p4 = 0.005 #Pressure of steam leaving the turbine(in MPa):\n",
      "W = 50 #Output of the plant(in MW):\n",
      "Twin = 15+273 #Temperature of the cooling water entering and leaving the condensor(in K):\n",
      "Twout = 30+273\n",
      "#From steam tables:\n",
      "h2 = 3870.5             #kJ/kg \n",
      "s2 = 7.1687             #kJ/kg.K\n",
      "sf = 0.4764             #kJ/kg.K\n",
      "sfg = 7.9187            #kJ/kg.K\n",
      "hf = 137.82             #kJ/kg\n",
      "hfg = 2423.7            #kJ/kg\n",
      "v4 = 0.001005           #m**3/kg\n",
      "Cp = 4.18 #Specific heat of water(in kJ/kg.K):\n",
      "\n",
      "#Calculations:\n",
      "s3 = s2\n",
      "h4 = hf\n",
      "x3 = (s3-sf)/sfg #Dryness fraction at state 3:\n",
      "h3 = hf+x3*hfg #Enthalpy at state 3(in kJ/kg):\n",
      "h1 = h4+v4*(p1-p4) #Enthalpy at state 1(in kJ/kg):\n",
      "Wnet = (h2-h3)-(h1-h4) #Net output per kg of steam(in kJ/kg):\n",
      "ms = W*10**3/Wnet #Mass flow rate of steam(in kg/s):\n",
      "mw = (h3-h4)*ms/(Cp*(Twout-Twin))#Mass flow rate of water(in kg/s):\n",
      "Q = h2-h1 #Heat added per kg of steam(in kJ/kg):\n",
      "n = Wnet/Q #Thermal efficiency:\n",
      "r = (h2-h1)/(h3-h4)\t#Ratio of heat supplied:\n",
      "\n",
      "print \"Mass flow rate of steam: \",round(ms,2),\"kg/s\"\n",
      "print \"Mass flow rate of condensor cooling water: \",round(mw,2),\"kg/s\"\n",
      "print \"Thermal efficiency: \",round(n*100,2),\"%\"\n",
      "print \"Ratio of heat supplied and rejected: \",round(r,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass flow rate of steam:  29.69 kg/s\n",
        "Mass flow rate of condensor cooling water:  969.78 kg/s\n",
        "Thermal efficiency:  45.12 %\n",
        "Ratio of heat supplied and rejected:  1.822\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6, page no. 282"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "   \n",
      "#Variable Declaration: \n",
      "p1 = 200  #Pressure of steam leaving the boiler(in MPa):\n",
      "T1 = 650+273 #Temperature(in K):\n",
      "p4 = 0.05  #Pressure of steam leaving the turbine(in MPa):\n",
      "#From steam tables:\n",
      "h2 = 3675.3                 #kJ/kg\n",
      "s2 = 6.6582                 #kJ/kg.K\n",
      "h4 = 137.82                 #kJ/kg\n",
      "v4 = 0.001005               #m**3/kg\n",
      "sf = 0.4764                 #kJ/kg.K\n",
      "sfg = 7.9187                #kJ/kg.K\n",
      "hf = 137.82                 #kJ/kg\n",
      "hfg = 2423.7                #kJ/kg\n",
      "hf8 = 721.11                #kJ/kg\n",
      "hfg8 = 2048                 #kJ/kg\n",
      "vf8 = 0.001115              #m**3/kg\n",
      "sf8 = 2.0462                #kJ/kg.K\n",
      "sfg8 = 4.6166               #kJ/kg.K\n",
      "T10 = 370.36+273            #K(by interpolation)\n",
      "h10 = 3141.81               #kJ/kg\n",
      "sf4 = 1.7766                #kJ/kg.K\n",
      "sfg4 = 5.1193               #kJ/kg.K\n",
      "hf4 = 604.74                #kJ/kg\n",
      "hfg4 = 2133.8               #kJ/kg\n",
      "s3 = s2\n",
      "s6 = s2  #For case b:\n",
      "s10 = s2    #For case c:\n",
      "s9 = s2\n",
      "h11 = hf4\n",
      "h13 = 1087.31               #kJ/kg\n",
      "v11 = 0.001084              #m**3/kg\n",
      "v13 = 0.001252              #m**3/kg\n",
      "p10 = 40                    #bar\n",
      "p9 = 4                      #bar\n",
      "\n",
      "#Calculations:\n",
      "#Case a:\n",
      "x3 = (s3-sf)/sfg  #Dryness farction at state 3:\n",
      "h3 = hf+x3*hfg #Enthalpy at state 3(in kJ/kg):\n",
      "h1 = h4+v4*(p1-p4)   #Enthalpy at state 1(in kJ/kg):\n",
      "Wnet = (h2-h3)-(h1-h4)    #Net output per kg of steam(in kJ/kg):\n",
      "Q = h2-h1   #Heat added(in kJ/kg):\n",
      "na = Wnet/Q*100    #Thermal efficiency:\n",
      "#Case b:\n",
      "x6 = (s6-sf8)/sfg8   #Dryness fraction at state 6(in kJ/kg.K): \n",
      "h6 = hf8+x6*hfg8   #Enthalpy at state 6(in kJ/kg):\n",
      "h7 = hf8   #Enthalpy at state 7(in kJ/kg):\n",
      "h5 = h4+v4*(p1-p4)*10**2    #Enthalpy at state 5(in kJ/kg):\n",
      "m = (h7-h5)/(h6-h5)\t    #Mass of steam(in kg):\n",
      "h1 = h7+vf8*(p1-p4)*10**2   #Enthalpy at state 1(in kJ/kg):\n",
      "nb = ((h2-h6)+(1-m)*(h6-h3)-((1-m)*(h5-h4)+(h1-h7)))/(h2-h1)*100 #Thermal efficiency:\n",
      "#Case c:\n",
      "x9 = (s9-sf4)/sfg4    #Dryness fraction at state 9:\n",
      "h9 = hf4+x9*hfg4  #Enthalpy at state 9(in kJ/kg):\n",
      "h8 = h4+v4*(p9-p4)*10**2    #Enthalpy at state 8(in kJ/kg):\n",
      "h12 = h11+v11*(p10-p9)*10**2#Enthalpy at state 12(in kJ/kg):\n",
      "h1a = h13+v13*(p1-p10)*10**2#Enthalpy at state 1'(in kJ/kg):\n",
      "m1 = (h13-h12)/(h10-h12)    #Mass of steam flowing through first heater:\n",
      "m2 = ((1-m1)*h11-(1-m1)*h8)/(h9-h8)#Mass of steam flowing through second heater:\n",
      "Wcep = (1-m1-m2)*(h8-h4)    #Work done by Condensate extraction pump(in kJ/kg):\n",
      "WFP1 = h1a-h13 #Work done by feed pump 1(in kJ/kg):\n",
      "WFP2 = (1-m1)*(h12-h11)   #Work done by feed pump 2(in kJ/kg):\n",
      "nc = ((h2-h10)+(1-m1)*(h10-h9)+(1-m1-m2)*(h9-h3)-(Wcep+WFP1+WFP2))/(h2-h1a)*100\t#Thermal efficiency:\n",
      "\n",
      "#Results:\n",
      "print \"Thermal efficiency in case a: \",round(na,2),\"%\"\n",
      "print \"Thermal efficiency in case b: \",round(nb,2),\"%\"\n",
      "print \"Thermal efficiency in case c: \",round(nc,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency in case a:  46.51 %\n",
        "Thermal efficiency in case b:  49.4 %\n",
        "Thermal efficiency in case c:  51.39 %\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7, page no. 287"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "p1 = 50 #Pressure at which steam is generated(in bar):\n",
      "T1 = 500+273 #Temperature of the steam(in K):\n",
      "p3 = 5 #Pressure upto which steam is expanded(in bar):\n",
      "T3 = 400+273 #Temperature(in K):\n",
      "p5 = 0.05 #Final pressure(in bar):\n",
      "#From steam tables:\n",
      "h2 = 3433.8     #kJ/kg \n",
      "s2 = 6.9759     #kJ/kg.K\n",
      "s3 = s2\n",
      "T3 = 183.14+273 #K(by interpolation)\n",
      "h3 = 2818.03    #kJ/kg\n",
      "h4 = 3271.9     #kJ/kg\n",
      "s4 = 7.7938     #kJ/kg.K\n",
      "s5 = s4\n",
      "sf = 0.4764     #kJ/kg.K\n",
      "sfg = 7.9187    #kJ/kg.K\n",
      "hf = 137.82     #kJ/kg\n",
      "hfg = 2423.7    #kJ/kg\n",
      "h6 = hf\n",
      "v6 = 0.001005   #m**3/kg\n",
      "\n",
      "#Calculations:\n",
      "x5 = (s5-sf)/sfg #Dryness fraction at state 5:\n",
      "h5 = hf+x5*hfg #Enthalpy at state 5(in kJ/kg):\n",
      "h1 = h6+v6*(p1-p5)*10**2#Enthalpy at state 1(in kJ/kg):\n",
      "Wt = (h2-h3)+(h4-h5) #Turbine work(in kJ/kg):\n",
      "Wp = h1-h6 #Pump work(in kJ/kg):\n",
      "Wnet = Wt-Wp #Net output per kg of steam(in kJ/kg):\n",
      "Q = h2-h1 #Heat added per kg of steam(in kJ/kg):\n",
      "n = Wnet/Q #Cycle efficiency:\n",
      "ssc = 0.7457*3600/Wnet #Specific steam consumption(in kg/hp.hr):\n",
      "r = Wnet/Wt #Work ratio:\n",
      "\n",
      "#Results:\n",
      "print \"Cycle efficiency: \",round(n*100,2),\"%\"\n",
      "print \"Specific steam consumption: \",round(ssc,2),\"kg/hp.hr\"\n",
      "print \"Work ratio: \",round(r,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cycle efficiency:  45.74 %\n",
        "Specific steam consumption:  1.78 kg/hp.hr\n",
        "Work ratio:  0.9967\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8, page no. 288"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "m = 0.144  #Mass of steam entering the feed pump(in kg):\n",
      "p1 = 60 #Pressure of steam fed in HP turbine(in bar):\n",
      "T1 = 450+273 #Temperature of the steam(in K):\n",
      "p3 = 3 #Pressure of steam entering LP turbine(in bar):\n",
      "p4 = 0.05 #Pressure of steam leaving the LP turbine(in bar):\n",
      "T3 = 115 #Condensate temperature(in C):\n",
      "W = 30 #Alternator output(in MW):\n",
      "nb = 0.90 #Boiler efficiency:\n",
      "na = 0.98 #Alternator efficiency:\n",
      "#From steam tables:\n",
      "h2 = 3301.8     #kJ/kg \n",
      "s2 = 6.7198     #kJ/kg.K\n",
      "hf = 137.82     #kJ/kg\n",
      "hfg = 2423.7    #kJ/kg\n",
      "vf = 0.001005   #m**3/kg\n",
      "h8 = 561.47     #kJ/kg\n",
      "sf3 = 1.6718    #kJ/kg.K\n",
      "sfg3 = 5.3201   #kJ/kg.K\n",
      "hf3 = 561.47    #kJ/kg\n",
      "hfg3 = 2163.8   #kJ/kg\n",
      "sf = 0.4764     #kJ/kg.K\n",
      "sfg = 7.9187    #kJ/kg.K\n",
      "\n",
      "#Calculations:\n",
      "h5 = hf\n",
      "v5 = vf\n",
      "s3 = s2\n",
      "s4 = s2\n",
      "h9 = h8\n",
      "v6 = v5\n",
      "x3 = (s3-sf3)/sfg3                  #Dryness fraction at state 3:\n",
      "x4 = (s4-sf)/sfg                    #Dryness fraction at state 4:\n",
      "h3 = hf3+x3*hfg3                    #Enthalpy at state 3(in kJ/kg): \n",
      "h4 = hf+x4*hfg                    #Enthalpy at state 4(in kJ/kg): \n",
      "h1 = 4.18*T3                  #Enthalpy at state 1(in kJ/kg):\n",
      "Wp = v5*(p1-p4)*10**2               #Pumping work(in kJ/kg) also equal to h7-h6:\n",
      "Wnet = (h2-h3)+(1-m)*(h3-h4)-(1-m)*Wp#Net output(in kJ/kg):\n",
      "ms = W*10**3/(na*Wnet)              #Mass of steam required to be generated(in kg/hr):\n",
      "Q = (h2-h1)/nb                    #Heat added(in kJ/kg):\n",
      "no = Wnet/Q*100                     #Overall thermal efficiency:\n",
      "\n",
      "#Results:\n",
      "print \"Steam bled for feed heating: \",round(m,3),\"kg\"\n",
      "print \"Capacity of boiler: \",round(ms,2)*3600,\"kg/hr\"\n",
      "print \"Overall thermal efficiency: \",round(no,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Steam bled for feed heating:  0.144 kg\n",
        "Capacity of boiler:  94464.0 kg/hr\n",
        "Overall thermal efficiency:  37.21 %\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9, page no. 290"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "p1 = 30 #Pressure of steam entering(in bar):\n",
      "T1 = 300 #Temperature(in C):\n",
      "p3 = 6 #Pressure of steam leaving the first stage(in bar):\n",
      "p4 = 1 #Steam leaving second stage at pressure(in bar):\n",
      "p5 = 0.075 #Pressure of steam leaving the third stage(in bar):\n",
      "T = 38 #Condenstate temperature(in C):\n",
      "T8 = 150 #Temperature of water after leaving first and second heater(in C):\n",
      "T13 = 95\n",
      "n = 0.8 #Efficiency of turbine:\n",
      "W = 15 #Turbine output(in MW):\n",
      "#From steam tables:\n",
      "h2 = 3230.9                     #kJ/kg\n",
      "s2 = 6.9212                     #kJ/kg.K\n",
      "T3 = 190.97                     #K(by interpolation)\n",
      "h3 = 2829.63                    #kJ/kg\n",
      "s3a = 7.1075                    #kJ/kg.K\n",
      "sf1 = 1.3026                    #kJ/kg.K\n",
      "sfg1 = 6.0568                   #kJ/kg.K\n",
      "hf1 = 417.46                    #kJ/kg\n",
      "hfg1 = 2258                     #kJ/kg\n",
      "h5 = 234.64                     #kJ/kg\n",
      "hf6 = 670.56                    #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s3 = s2\n",
      "s4 = s3a\n",
      "h11 = hf6\n",
      "h3a = round(h2-n*(h2-h3),2) #Actual enthalpy at state 3(in kJ/kg):\n",
      "x4 = round((s4-sf1)/sfg1,3) #Dryness fraaction at state 4:\n",
      "h4 = hf1+x4*hfg1  #Enthalpy at state 4(in kJ/kg):\n",
      "h4a = round(h3a-n*(h3a-h4),2) #Actual enthaly at state 4(in kJ/kg):\n",
      "x4a = (h4a-hf1)/hfg1 #Actual dryness fraction at state 4:\n",
      "s4a = sf1+x4a*sfg1 #Actual entropy at state 4(in kJ/kg.K):\n",
      "s5 = s4a #Entropy at state 5(in kJ/kg.K):\n",
      "x5 = 0.8735 #Dryness fraction:\n",
      "h5 = 2270.43 #Enthalpy at state 5(in kJ/kg):\n",
      "h5a = h4a-n*(h4a-h5) #Actual enthalpy at state 5(in kJ/kg):\n",
      "m1 = 0.1293 \n",
      "m2 = 0.1059 \n",
      "Wt = (h2-h3a)+(1-m1)*(h3a-h4a)+(1-m1-m2)*(h4a-h5a)  #Turbine output(in kJ/kg):\n",
      "r = W*10**3/Wt*3600 #Rate of steam generation required(in kg/hr):\n",
      "c = (m1+m2)*r #Capacity of drain pump(in kg/hr):\n",
      "\n",
      "#Results:\n",
      "print \"Capacity of drain pump: \",round(c,2),\"kg/hr\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacity of drain pump:  16273.8 kg/hr\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10, page no. 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "p1 = 70 #Pressure of the steam entering(in bar):\n",
      "T1 = 450 #Temperature of the steam entering the HP turbine(in C):\n",
      "p3 = 30 #Pressure at which steam is extracted(in bar):\n",
      "T4 = 400 #Temperature at which it is reheated(in C):\n",
      "p6 = 0.075 #Pressure of steam after expanding(in bar):\n",
      "T = 140 #Temperature at which steam is bled(in C):\n",
      "nh = 0.80 #Efficiency of HP turbine:\n",
      "nl = 0.85 #Efficiency of LP turbine:\n",
      "#From steam tables:\n",
      "h2 = 3287.1                     #kJ/kg \n",
      "s2 = 6.6327                     #kJ/kg.K\n",
      "h3 = 3049.48                    #kJ/kg\n",
      "h4 = 3230.9                     #kJ/kg\n",
      "s4 = 6.9212                     #kJ/kg.K\n",
      "h6 = 2158.55                    #kJ/kg\n",
      "p5 = 3.61                       #bar\n",
      "h5 = 2712.38                    #kJ/kg\n",
      "h9 = 1008.42                    #kJ/kg\n",
      "v7 = 0.001008                   #m**3/kg\n",
      "h7 = 168.79                     #kJ/kg\n",
      "h8 = 169.15                     #kJ/kg\n",
      "v9 = 0.00108                    #m**3/kg\n",
      "\n",
      "#Calculations:\n",
      "s6 = s4\n",
      "s5 = s4\n",
      "h3a = h2-nh*(h2-h3) #Actual enthalpy at state 3(in kJ/kg):\n",
      "h6a = h4-nl*(h4-h6) #Actual enthaly at state 6(in kJ/kg):\n",
      "h5a = h4-nl*(h4-h5) #Actual enthaly at state 5(in kJ/kg):\n",
      "h8 = h7+v7*(p5-p6)*10**2 #Enthalpy at state 8(in kJ/kg):\n",
      "m = (h9-h8)/(h5a-h8) #Mass of bled steam per kg of steam generated(in kg/kg steam generated):\n",
      "h1 = h9+v9*(p1-p5)*10**2 #Enthalpy at state 1(in kJ/kg):\n",
      "Wnet = (h2-h3a)+(h4-h5a)+(1-m)*(h5a-h6a)-((1-m)*(h8-h7)+(h1-h9))#Net work per kg of steam generated(in kJ/kg):\n",
      "Q = (h2-h1)+(h4-h3a) #Heat added per kg of steam generated(in kJ/kg):\n",
      "n = Wnet/Q*100 #Thermal efficiency:\n",
      "\n",
      "#Result:\n",
      "print \"Thermal efficiency: \",round(n,2),\"%\"\n",
      "print \"___There is a calculation mistake in calculating h2-h1 in book hence difference in answer_____\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency:  39.22 %\n",
        "___There is a calculation mistake in calculating h2-h1 in book hence difference in answer_____\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11, page no. 294"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "p1 = 150 #Pressure of the steam entering the boiler(in bar):\n",
      "T1 = 450 #Temperature of the steam entering the turbine(in C):\n",
      "p6 = 0.05 #Condensor pressure(in bar):\n",
      "p3 = 10 #Pressure of steam bled out between 1st & 2nd stage and 2nd & 3rd(in bar):\n",
      "p4 = 1.5\n",
      "T11 = 150 #Temperature of feed water leaving closed water heater(in C):\n",
      "m = 300 #Mass flow rate(in kg/s):\n",
      "#From steam tables:\n",
      "h2 = 3308.6                     #kJ/kg \n",
      "s2 = 6.3443                     #kJ/kg.K\n",
      "h3 = 2667.26                    #kJ/kg\n",
      "h4 = 2355.18                    #kJ/kg\n",
      "h5 = 1928.93                    #kJ/kg\n",
      "h6 = 137.82                     #kJ/kg\n",
      "v6 = 0.001005                   #m**3/kg\n",
      "h8 = 467.11                     #kJ/kg\n",
      "v8 = 0.001053                   #m**3/kg\n",
      "h10 = 1610.5                    #kJ/kg\n",
      "v10 = 0.001658                  #m**3/kg\n",
      "\n",
      "#Calculations:\n",
      "s3 = s2\n",
      "s4 = s2\n",
      "s5 = s2\n",
      "h7 = h6+v6*(p4-p6)*10**2                #Enthalpy at state 7(in kJ/kg):\n",
      "h9 = round(h8+v8*(p1-p4)*10**2,2)       #Enthalpy at state 9(in kJ/kg):\n",
      "h12 = round(h10+v10*(p1-p3)*10**2,2)    #Enthalpy at state 12(in kJ/kg):\n",
      "m1 = round((4.18*T11-h9)/(h3-h9+4.18*T11-h10),2)#Mass of steam bled out in closed feed water heater(in kg/kg of steam generated):\n",
      "m2 = round(((1-m1)*(h8-h7))/(h4-h7),2)\n",
      "h1 = (4.18*T11)*(1-m1)+m1*h12   #Enthalpy at state 1(in kJ/kg):\n",
      "Wnet = (h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-((1-m1-m2)*(h7-h6)+(1-m1)*(h9-h8)+m1*(h12-h10))\t#Net work output per kg of steam generated(in kJ/kg):\n",
      "Q = h2-h1  #Heat added(in kJ/kg):\n",
      "n = Wnet/Q*100    #Cycle thermal efficiency:\n",
      "P = Wnet*m                              #Net power developed(KW)\n",
      "\n",
      "#Results:\n",
      "print \"Cycle thermal efficiency: \",round(n,1),\"%\"\n",
      "print \"Net power developed: \",round(P),\"kW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cycle thermal efficiency:  47.6 %\n",
        "Net power developed:  365700.0 kW\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12, page no. 297"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "\n",
      "#Variable Declaration: \n",
      "p1 = 100 #Pressure of the steam entering the boiler(in bar):\n",
      "T1 = 500 #Temperature of the steam entering the turbine(in \u00baC):\n",
      "p6 = 0.075 #Condensor pressure(in bar):\n",
      "p3 = 20 #Pressure at which steam is extracted at exit of HPT(in bar):\n",
      "p4 = 4 #Pressure at which steam is extracted at exit of IPT(in bar):\n",
      "T = 200 #Temperature at which feed water leaves closed feed warere heater(in C):\n",
      "W = 100 #Net power output(in MW):\n",
      "#From steam tables:\n",
      "h2 = 3373.7                     #kJ/kg\n",
      "s2 = 6.5966                     #kJ/kg.K\n",
      "T3 = 261.6                      #C(by interpolation)\n",
      "h3 = 2930.57                    #kJ/kg\n",
      "h4 = 2612.65                    #kJ/kg\n",
      "h5 = 2055.09                    #kJ/kg\n",
      "h10 = 908.79                    #kJ/kg\n",
      "h8 = 604.74                     #kJ/kg\n",
      "v6 = 0.001008                   #m**3/kg\n",
      "h6 = 168.79                     #kJ/kg\n",
      "h8 = 604.74                     #kJ/kg\n",
      "v8 = 0.001084                   #m**3/kg\n",
      "#For modified part:\n",
      "h3a = 3247.6                    #kJ/kg \n",
      "s3a = 7.1271                    #kJ/kg.K\n",
      "T4 = 190.96                     #C(by interpolation)\n",
      "h4a = 2841.2                    #kJ/kg\n",
      "h5a = 2221.11                   #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s3 = s2\n",
      "s4 = s2\n",
      "s5 = s2\n",
      "h1 = 4.18*T\n",
      "h11 = h10\n",
      "s4a = s3a\n",
      "s5a = s3a\n",
      "h7 = h6+v6*(p4-p6)*10**2 #Enthalpy at state 7(in kJ/kg):\n",
      "h9 = h8+v8*(p3-p4)*10**2 #Enthalpy at state 9(in kJ/kg):\n",
      "m1 = (h1-h9)/(h3-h10) #Mass of steam bled out in closed feed water heater(in kg/kg of steam generated):\n",
      "m2 = ((h8-h7)-m1*(h11-h7))/(h4-h7)\n",
      "Wnet = (h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-((1-m1-m2)*(h7-h6)+(h9-h8)) #Net work per steam generated(in kJ/kg):\n",
      "Q = h2-h1 #Heat added(in kJ/kg):\n",
      "n = Wnet/Q*100 #Thermal efficiency:\n",
      "sgc = W*10**3/Wnet #Steam genration rate(in kg/s):\n",
      "m2a = ((h8-h7)-m1*(h11-h7))/(h4a-h7)#Mass of steam bled out in closed feed water heater(in kg/kg of steam generated):\t\t\t\t#For modified part:\n",
      "Wneta = (h2-h3)+(1-m1)*(h3a-h4a)+(1-m1-m2a)*(h4a-h5a)-((1-m1-m2a)*(h7-h6)+(h9-h8)) #Net work per steam generated(in kJ/kg):\n",
      "Qa = h2-h1+(1-m1)*(h3a-h3) #Heat added(in kJ/kg):\n",
      "na = Wneta/Qa*100 #Thermal efficiency:\n",
      "I = (na-n)/n*100 #% Increase in thermal efficiency due to reheating:\n",
      "\n",
      "#Results:\n",
      "print \"Thermal efficiency: \",round(n,2),\"%\"\n",
      "print \"Steam generation rate: \",round(sgc,2),\"kg/s\"\n",
      "print \"Thermal efficiency: \",round(na,2),\"%\"\n",
      "print \"Percentage increase in efficiency due to reheating: \",round(I,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency:  44.8 %\n",
        "Steam generation rate:  87.95 kg/s\n",
        "Thermal efficiency:  45.04 %\n",
        "Percentage increase in efficiency due to reheating:  0.52 %\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13, page no. 301"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "hd = 349    #Enthalpy of dry saturated vapour at 8.45 bar(KJ/Kg)\n",
      "hi = 234.5   #Enthalpy after isentropic expansion to 0.07 bar(KJ/Kg)\n",
      "hs =  35  #Enthalpy of saturated liquid at 0.07 bar (KJ/Kg)\n",
      "n1 = 0.85 #Capability:\n",
      "Cpw = 4.18 #Specific heat of water:\n",
      "#From steam tables:\n",
      "h1 = 2767.13                            #kJ/kg \n",
      "h2 = 3330.3                             #kJ/kg\n",
      "s2 = 6.9363                             #kJ/kg.K\n",
      "h3 = 2899.23                            #kJ/kg\n",
      "x4 = 0.93\n",
      "h4 = 2517.4                             #kJ/kg\n",
      "x5 = 0.828\n",
      "h5 = 2160.958                           #kJ/kg\n",
      "h6 = 168.79                             #kJ/kg\n",
      "v6 = 0.001008                           #m**3/kg\n",
      "h7 = 168.88                             #kJ/kg\n",
      "h9 = 417.46                             #kJ/kg\n",
      "h13 = 721.11                            #kJ/kg\n",
      "v13 = 0.001252                          #m**3/kg\n",
      "T1 = 150                                #\u00baC\n",
      "h10 = 418.19                            #kJ/kg\n",
      "m1 = 0.102\n",
      "m2 = 0.073\n",
      "\n",
      "#Calculations:\n",
      "s3 = s2\n",
      "s4 = s2\n",
      "s5 = s2\n",
      "qd = hd-hi #For mercury cycle,Isentropic heat drop: \n",
      "qda = n1*qd#Actual heat drop:\n",
      "qre = hd-qda-hs #Heat rejected in condenser(in kJ/kg):\n",
      "qa = hd-hs #Heat added in the boiler(in kJ/kg):\n",
      "qam = h1-Cpw*T1 #Heat added in the condenser of mercury cycle(in kJ/kg):\n",
      "m = qam/qre #Mercury per steam required per kg of steam:\n",
      "Wp = v13*(40-8)*10**2 #Pump work(in kJ/kg):\n",
      "qt = m*qa+h2-h1 #Total heat supplied(in kJ/kg steam):\n",
      "Wm = m*qda #Work done in mercury cycle(in kJ/kg):\n",
      "Ws = (h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-(1-m1-m2)*(h7-h6)-m2*(h10-h9)-m1*Wp#Work done in steam cycle(in kJ/hr):\n",
      "Wt = Wm+Ws #Total work done(in kJ/kg):\n",
      "n = Wt/qt*100 #Thermal efficiency:\n",
      "\n",
      "#Results:\n",
      "print \"Thermal efficiency: \",round(n,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency:  55.36 %\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14, page no. 303"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from sympy import symbols,solve\n",
      "\n",
      "#Variable Declaration: \n",
      "h1 = 3023.5             #KJ/Kg\n",
      "s1 = 6.7664             #KJ/Kg.K\n",
      "n = 0.8                 #Efficiency ratio of HP and LP\n",
      "W = 0.1                 #Steam consumption at no load\n",
      "P = 2500                #Pressure turbine output\n",
      "mHP,cHP,mLP,cLP = symbols('mHp cHP mLP cLP')     #Symbolic expressions for  mHP,cHP,mLP,cLP respectively   \n",
      "LPavail = 1.5           #LP steam available(Kg/s) for getting 1000hp    \n",
      "DhLP = 387.49           #Actual enthalpy drop in LP(KJ/Kg)\n",
      "\n",
      "#From Table 3\n",
      "sf = 0.5764\n",
      "sfg = 7.6752\n",
      "hf = 168.79\n",
      "hfg = 2406.0\n",
      "\n",
      "#Calculations:\n",
      "s2 = s1\n",
      "x3 = round((s2 - sf)/sfg,3)\n",
      "h3HP = hf + x3*hfg\n",
      "DhHP = n*(h1-h3HP)      #Actual enthalpy drop in HP(KJ/Kg)\n",
      "x3a = (7.1271-sf)/sfg\n",
      "h3LP = hf+ x3a*hfg      #Enthalpy at exit(KJ/Kg)\n",
      "HPfull = P*0.7457/DhHP  #HP steam consumption at full load(Kg/s)\n",
      "HPNL = W*HPfull         #HP steam consumption at no load(Kg/s)\n",
      "LPfull = P*0.7457/DhLP  #LP steam consumption at full load(Kg/s)\n",
      "LPNL = W*LPfull         ##LP steam consumption at no load(Kg/s)\n",
      "HP = solve([mHP*P+cHP-HPfull,mHP*0+cHP-HPNL],[mHP,cHP])\n",
      "LP = solve([mLP*P+cLP-LPfull,mLP*0+cLP-LPNL],[mLP,cLP])\n",
      "xLP = (LPavail-LP[cLP])/LP[mLP]\n",
      "xHP = 1000-xLP\n",
      "yHP = HP[mHP]*xHP + HP[cHP]\n",
      "\n",
      "#Results:\n",
      "print 'HP steam required:',round(yHP,2),'Kg/s'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "HP steam required: 0.63 Kg/s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15, page no. 304"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "Cpw = 4.18 #Specific heat of water:\n",
      "#From steam tables:\n",
      "h2 = 2960.7                     #kJ/kg \n",
      "s2 = 6.3615                     #kJ/kg\n",
      "x3 = 0.863\n",
      "h3 = 2404.94                    #kJ/kg\n",
      "h7 = 358.59                     #kJ/kg\n",
      "x10 = 0.754\n",
      "h10 = 1982.91                   #kJ/kg\n",
      "\n",
      "#Calculation:\n",
      "s3 = s2\n",
      "s10 = s3\n",
      "m1 = (1-x3)*0.5 #Mass pf moisture in separator(in kg):\n",
      "m2 = 0.5-m1 #Mass of steam entering LPT(in kg):\n",
      "m3 = 0.5+m1 #Mass of water entering the hot well(in kg):\n",
      "T = (m3*90+m2*40) #Temperature of water leaving hotwell(in C):\n",
      "Q = 0.5*(h3-h7) #Heat transferred per kg steam generated:\n",
      "Wnet = (h2-h3)*1+m2*(h3-h10) #Net work output(in kJ/kg):\n",
      "Qa = h2-Cpw*T #Heat added(in kJ/kg):\n",
      "n = Wnet/Qa*100 #Thermal efficiency:\n",
      "\n",
      "#Results:\n",
      "print \"Temperature of water leaving hotwell: \",round(T,3),\"\u00b0C\"\n",
      "print \"Heat transferred per kg steam generated: \",round(Q,3),\"kJ/kg steam\"\n",
      "print \"Thermal efficiency: \",round(n,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature of water leaving hotwell:  68.425 \u00b0C\n",
        "Heat transferred per kg steam generated:  1023.175 kJ/kg steam\n",
        "Thermal efficiency:  27.59 %\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16, page no. 306"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "m = 35 #Steam flow rate(in kg/s):\n",
      "#From steam tables:\n",
      "h1 = 3530.9                     #kJ/kg \n",
      "s1 = 6.9486                     #kJ/kg.K\n",
      "x2 = 0.864\n",
      "h2 = 2288.97                    #kJ/kg\n",
      "v3 = 0.001017                   #m**3/kg\n",
      "h3 = 251.40                     #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s2 = s1\n",
      "Wp = v3*(70-0.20)*10**2 #Pump work(in kJ/kg):\n",
      "Wt = h1-h2 #Turbine work(in kJ/kg):\n",
      "Wnet = Wt-Wp #Net work(in kJ/kg):\n",
      "P = m*Wnet/10**3 #Power produced(in MW):\n",
      "h4 = h3+Wp #Enthalpy at state 4(in kJ/kg):\n",
      "Q = m*(h1-h4) #Total heat supplied to the boiler(in kJ/s):\n",
      "n = Wnet*m/Q*100 #Thermal efficiency:\n",
      "\n",
      "#results:\n",
      "print \"Net power: \",round(P,2),\"MW\"\n",
      "print \"Thermal efficiency: \",round(n,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Net power:  43.22 MW\n",
        "Thermal efficiency:  37.73 %\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17, page no. 307"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "P = 10 #Output(in MW):\n",
      "#From steam tables:\n",
      "h1 = 3625.3             #kJ/kg \n",
      "s1 = 6.9029             #kJ/kg.K\n",
      "h2 = 3105.08            #kJ/kg\n",
      "x3 = 0.834\n",
      "h3 = 2187.43            #kJ/kg\n",
      "h6 = 908.79             #kJ/kg\n",
      "h5 = 191.83             #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s2 = s1\n",
      "s3 = s2\n",
      "h4 = h5\n",
      "h7 = h6\n",
      "mb = (h6-h5)/(h2-h5) #Steam bled per kg of steam passing through HP stage:\n",
      "m = round(P*10**3/((h1-h2)+(1-mb)*(h2-h3)),2) #Mass of steam leaving boiler(in kg/s):\n",
      "Q = m*(h1-h7) #Heat supplied to the boiler(in kJ/s):\n",
      "\n",
      "#Results:\n",
      "print \"Steam bled per kg of steam passing through HP stage: \",round(mb,3),\"kg\"\n",
      "print \"Heat added: \",round(Q,2),\"kJ/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Steam bled per kg of steam passing through HP stage:  0.246 kg\n",
        "Heat added:  22411.21 kJ/s\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18, page no. 309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "P = 50  #Net output(in MW):\n",
      "#From steam tables:\n",
      "h1 = 3373.7                     #kJ/kg\n",
      "s1 = 6.5966                     #kJ/kg.K\n",
      "s3 = 7.7622                     #kJ/kg.K\n",
      "h6 = 2930.572                   #kJ/kg\n",
      "h3 = 3478.5                     #kJ/kg\n",
      "T2 = 181.8                      #C\n",
      "h2 = 2782.8                     #kJ/kg\n",
      "T8 = 358.98                     #C\n",
      "h8 = 3188.7                     #kJ/kg\n",
      "x4 = 0.95\n",
      "h4 = 2462.99                    #kJ/kg\n",
      "h11 = 856.8                     #kJ/kg\n",
      "h9 = 604.74                     #kJ/kg\n",
      "h7 = 908.79                     #kJ/kg\n",
      "h4a = 191.83                    #kJ/kg\n",
      "v4a = 0.001010                  #m**3/kg\n",
      "v9 = 0.001084                   #m**3/kg\n",
      "\n",
      "#Calculations:\n",
      "s6 = s1\n",
      "s2 = s1\n",
      "s8 = s3\n",
      "s4 = s3\n",
      "h7a = h7\n",
      "h5 = h4a+v4a*(4-0.1)*10**2 #Enthalpy at state 5(in kJ/kg):\n",
      "h10 = h9+v9*(100-4)*10**2 #Enthalpy at state 10(in kJ/kg):\n",
      "m6 = (h11-h10)/(h6-h7) #Mass per kg of steam from boiler(in kg):\n",
      "m8 = (h9-(1-m6)*h5-m6*h7a)/(h8-h5)\n",
      "m6 = 0.135\n",
      "m8 = 0.105\n",
      "Whpt = (h1-h6)+(1-m6)*(h6-h2) #Work in turbines(in kJ/kg):\n",
      "Wlpt = (1-m6)*(h3-h8)+(1-m6-m8)*(h8-h4)\n",
      "Wcep = (1-m6-m8)*(h5-h4a) #Pump works(in kJ/kg)\n",
      "Wfp = h10-h9\n",
      "m = P*10**3/(Whpt+Wlpt-Wcep-Wfp)#Mass of steam entering first stage of turbine(in kg/s):\n",
      "Q = m*(h1-h11) #Heat supplied in the boiler(in kJ/s):\n",
      "n = P*10**3/Q*100 #Thermal efficiency:\n",
      "\n",
      "#Results:\n",
      "print \"Mass of steam bled at 20 bar: \",round(m6,3),\" kg per kg of steam entering first stage\"\n",
      "print \"Mass of steam bled at 4 bar: \",round(m8,3),\" kg per kg of steam entering first stage\"\n",
      "print \"Mass of steam entering first stage: \",round(m,2),\" kg/s\"\n",
      "print \"Thermal efficiency: \",round(n,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass of steam bled at 20 bar:  0.135  kg per kg of steam entering first stage\n",
        "Mass of steam bled at 4 bar:  0.105  kg per kg of steam entering first stage\n",
        "Mass of steam entering first stage:  36.7  kg/s\n",
        "Thermal efficiency:  54.13 %\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 19, page no. 312"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "nt = 0.85   #Turbine efficiency:\n",
      "ng = 0.90  #Generator efficiency:\n",
      "nm = 0.95  #Mechanical efficiency:\n",
      "Cpw = 4.18 #Specific heat of water:\n",
      "#From steam tables:\n",
      "h1 = 3450.02                        #kJ/kg\n",
      "s1 = 6.6923                         #kJ/kg.K\n",
      "h3 = 3576.99                        #kJ/kg\n",
      "s3 = 7.52411                        #kJ/kg.K\n",
      "h2 = 3010                           #kJ/kg\n",
      "h9 = 3175                           #kJ/kg\n",
      "h4 = 2300                           #kJ/kg\n",
      "h5 = 137.82                         #kJ/kg\n",
      "v5 = 0.001005                       #m**3/kg\n",
      "h8 = 962.11                         #kJ/kg\n",
      "h12 = 1407.56                       #kJ/kg\n",
      "h10 = 670.56                        #kJ/kg\n",
      "v10 = 0.001101                      #m**3/kg\n",
      "PO = 120                            #Plant output(MW)\n",
      "\n",
      "#Calculations:\n",
      "h2a = h1-(h1-h2)*nt #Enthalpy at state 2'(in kJ/kg):\n",
      "h9a = h3-(h3-h9)*nt  #Enthalpy at state 9'(in kJ/kg):\n",
      "h4a = h3-(h3-h4)*nt  #Enthalpy at state 4'(in kJ/kg):\n",
      "h6 = h5+v5*(6-0.05)*10**2 #Enthalpy at state 6(in kJ/kg):\n",
      "h6a = h5+(h6-h5)/ng #Enthalpy at state 6'(in kJ/kg):\n",
      "h11 = h10+v10*(100-6)*10**2 #Enthalpy at state 11(in kJ/kg):\n",
      "h11a = h10+(h11-h10)/ng  #Enthalpy at state 11'(in kJ/kg):\n",
      "m1 = round((h11a-h12)/(h8-h2a),3)   #Mass flow rate(in kg/kg steam):\n",
      "m2 = round((h10-m1*h8-(1-m1)*h6a)/(h9-h6a),3)\n",
      "Whp = h1-h2a    #Work from HP turbine(in kJ/kg):\n",
      "Wlp = (1-m1)*(h3-h9a)+(1-m1-m2)*(h9a-h4a)#Work from LP turbine(in kJ/kg):\n",
      "Wp = (1-m1-m2)*(h6a-h5)+(h11a-h10)  #Pump work:\n",
      "Wnet = Whp+Wlp-Wp #Net work(in kJ/kg):\n",
      "ssc = 3600/(Wnet*ng*nm)  #Specific steam consumption(in kg/kw.h):\n",
      "ssc = 3.93\n",
      "no = Wnet*nm*ng/((h1-h12)+(1-m1)*(h3-h2a))*100  #Overall thermal efficiency:\n",
      "m = ssc*PO*10**3 #Mass of steam required(in kg/hr):\n",
      "\n",
      "#Results:\n",
      "print \"Specific steam consumption: \",round(ssc,2),\"kg/kw.h\"\n",
      "print \"Overall efficiency: \",round(no,2),\"%\"\n",
      "print \"Mass of steam held from HP turbine: \",round(m1*m,1),\"kg/hr\"\n",
      "print \"Mass of steam held from LP turbine: \",round(m2*m,1),\"kg/hr\"\n",
      "\n",
      "print m1, m2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific steam consumption:  3.93 kg/kw.h\n",
        "Overall efficiency:  36.57 %\n",
        "Mass of steam held from HP turbine:  161758.8 kg/hr\n",
        "Mass of steam held from LP turbine:  38671.2 kg/hr\n",
        "0.343 0.082\n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 20, page no. 316"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "P = 14000 #Power required(in kW):\n",
      "r = 0.75 #Efficiency ratio of turbine:\n",
      "#From steam tables:\n",
      "h1 = 3137                               #kJ/kg \n",
      "s1 = 6.9563                             #kJ/kg.K\n",
      "x2 = 0.765\n",
      "h2 = 2170.38                            #kJ/kg\n",
      "hf = 467.11                             #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s2 = s1\n",
      "h2a = h1-(h1-h2)*r #Enthalpy at state 2'(in kJ/kg):\n",
      "m = P/(h2a-hf) #Mass of steam required(in kg/s):\n",
      "P1 = m*(h1-h2a) #Power available to the generator(in kW):\n",
      "\n",
      "#Results:\n",
      "print \"Power available to the generator: \",round(P1,2),\"kW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power available to the generator:  5218.46 kW\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21, page no. 317"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "\n",
      "#Variable Declaration: \n",
      "nt = 0.80 #Turbine efficiency:\n",
      "nb = 0.80 #Boiler efficiency:\n",
      "P = 9000 #Power required(in kW):\n",
      "h1 = 3137 #kJ/kg #From steam tables:\n",
      "s1 = 6.9563 #kJ/kg.K\n",
      "s2 = s1\n",
      "x2 = 0.960\n",
      "h2 = 2638.34 #kJ/kg\n",
      "hf = 503.71 #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "h2a = h1-(h1-h2)*nt #Enthalpy at state 2'(in kJ/kg):\n",
      "ms = P/(h2a-hf) #Mass flow rate(in kg/s):\n",
      "P1 = ms*(h1-h2a) #Power developed(in kW):\n",
      "pt = (h1-hf)*ms #Total heat consumption in the bolier(in kW):\n",
      "pa = pt/nb #Actual heat consumption(in kJ/s):\n",
      "\n",
      "#Results:\n",
      "print \"Power developed: \",round(P1,2),\"kW\"\n",
      "print \"Actual heat consumption: \",round(pa,2),\"kJ/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power developed:  1606.88 kW\n",
        "Actual heat consumption:  13258.6 kJ/s\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 22, page no. 318"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Variable Declaration: \n",
      "P = 4500 #Total power required(in kW):\n",
      "Q = 15000 #Heat load(in kW):\n",
      "n = 0.80 #Efficiency of turbines:\n",
      "m = 10  #Steam consumption rate(in kg/s):\n",
      "#From steam tables:\n",
      "h1 = 3137                               #kJ/kg\n",
      "s1 = 6.9563                             #kJ/kg.K\n",
      "T2 = 179.18                             #C\n",
      "h2 = 2813.41                            #kJ/kg\n",
      "hf = 640.23                             #kJ/kg\n",
      "#For case 1:\n",
      "T2a = 213.34                            #C \n",
      "s2a = 7.125                             #kJ/kg.K\n",
      "x3 = 0.853\n",
      "h3 = 2221.11                            #kJ/kg\n",
      "#For case 2:\n",
      "h2a = 2878.13                           #kJ/kg\n",
      "T3aa = 210.04                           #C\n",
      "s3aa = 7.138                            #kJ/kg.K\n",
      "x4 = 0.855\n",
      "h4 = 2225.92                            #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s3 = s2a\n",
      "h3aa = h2a\n",
      "s4 = s3aa\n",
      "h2a = h1-(h1-h2)*n #Enthalpy at state 2'(in kJ/kg):\n",
      "q = h2a-hf #Heat available for process heating(in kJ/kg):\n",
      "msh = Q/q #Mass flow rate(in kg/s):\n",
      "h3a = h2-(h2a-h3)*n #Enthalpy at state 3'(in kJ/kg):\n",
      "mshp = (P+msh*(h2a-h3a))/((h1-h2a)+(h2a-h3a)) #Mass of steam produced:\n",
      "#For case 2:\n",
      "mshpn = 10 \n",
      "mshn = 6.7\n",
      "Pn = mshpn*(h1-h2a) #Power produced by HP turbine(in kW):\n",
      "M3aa = mshpn-mshn\n",
      "h4a = h3aa-(h3aa-h4)*n #Enthalpy at state 4'(in kJ/kg):\n",
      "Pn1 = M3aa*(h3aa-h4a) #Power produced by LP turbine(in kW):\n",
      "Pt = Pn+Pn1 #Total power produced(in kW):\n",
      "\n",
      "#Results:\n",
      "print \"Total power produced: \",round(Pt,2),\"kW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total power produced:  4310.55 kW\n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23, page no. 322"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "\n",
      "#Variable Declaration: \n",
      "na = 0.975 #Alternator efficiency:\n",
      "nt = 0.80 #Turbine efficiency:\n",
      "L = 50 #Turbine's losses(in kW):\n",
      "p = 8 #Electric power developed(in mW):\n",
      "m = 8 #Condenser discharge(in kg/s):\n",
      "#From steam tables:\n",
      "h1 = 3137                               #kJ/kg\n",
      "s1 = 6.9563                             #kJ/kg.K\n",
      "s1a = 7                                 #kJ/kg.K\n",
      "h2 = 2830                               #kJ/kg\n",
      "h4 = 2210                               #kJ/kg\n",
      "hf = 376.92                             #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "h1a = h1\n",
      "s2 = s1a\n",
      "h2a = h1a-(h1a-h2)*nt #Enthalpy at state 2'(in kJ/kg):\n",
      "h3 = h2a\n",
      "h4a = h3-(h3-h4)*nt #Enthalpy at state 4'(in kJ/kg):\n",
      "P = m/na #Power available to the alternator(in MW):\n",
      "Pt = P*10**3+L #Total power produced(in kW):\n",
      "plp = m*(h3-h4) #Power produced by LP turbine(in kW):\n",
      "php = Pt-plp #Power produced by LP turbine(in kW):\n",
      "m1 = round(php/(h1a-h2a),2) #Mass flow rate through HP turbine(in kg/s):\n",
      "ph = (m1-m)*(h2-hf) #Heat available for process heating(in kW):\n",
      "\n",
      "#Results:\n",
      "print \"Heat available for process heating: \",round(ph,2),\"kW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat available for process heating:  8389.53 kW\n"
       ]
      }
     ],
     "prompt_number": 54
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 24, page no. 323"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      " \n",
      "#Variable Declaration: \n",
      "nt = 0.80 #Turbine efficiency:\n",
      "nm = 0.90 #Mechanical efficiency:\n",
      "p = 720 #Power delivered by turbine(in kW):\n",
      "#From steam tables:\n",
      "h1 = 3045.8                             #kJ/kg\n",
      "s1 = 7.0317                             #kJ/kg.K\n",
      "x4 = 0.841\n",
      "h4 = 2192.24                            #kJ/kg.K\n",
      "h2 = 2706.7                             #kJ/kg\n",
      "s2 = 7.1271                             #kJ/kg.K\n",
      "x3 = 0.854\n",
      "h3 = 2223.51                            #kJ/kg\n",
      "\n",
      "#Calculation:\n",
      "s4 = s1\n",
      "s3 = s2\n",
      "h4a = h1-(h1-h4)*nt #Enthalpy at state 4'(in kJ/kg):\n",
      "h3a = h2-(h2-h3)*nt #Enthalpy at state 3'(in kJ/kg):\n",
      "P = p/nm #Power developed in the turbine(in kW):\n",
      "m1 = 3600/(h1-h4a) #HP steam consumption(in kg/kW.h):\n",
      "m2 = 3600/(h2-h3a) #LP steam consumption(in kg/kW.h):\n",
      "\n",
      "#Results:\n",
      "print \"HP steam consumption: \",round(m1,2),\"kg/kW.h\"\n",
      "print \"LP steam consumption: \",round(m2,2),\"kg/kW.h\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "HP steam consumption:  5.27 kg/kW.h\n",
        "LP steam consumption:  9.31 kg/kW.h\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 25, page no. 325"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable Declaration: \n",
      "mhp = 2 #Mass flow rate(in kg/s):\n",
      "mlp = 1.5\n",
      "n = 0.90 #Expansion efficiency:\n",
      "P = 3000 #Power developed by the turbine(in kW):\n",
      "#From steam tables:\n",
      "h1 = 3034.8                     #kJ/kg\n",
      "s1 = 6.8844                     #kJ/kg.K\n",
      "x3 = 0.9566\n",
      "h3 = 2611.04                    #kJ/kg\n",
      "h2 = 2706.7                     #kJ/kg\n",
      "xout = 0.8535\n",
      "hout = 2222.31                  #kJ/kg\n",
      "h4 = 2676.25                    #kJ/kg\n",
      "h5 = 2290                       #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "s3 = s1\n",
      "hin = h2\n",
      "h3a = h1-(h1-h3)*n #Enthalpy at state 3'(in kJ/kg):\n",
      "houta = hin-(hin-hout)*n #Enthalpy of steam going out(in kJ/kg):\n",
      "ms = P/(hin-hout) #Mass flow rate of steam(in kg/s):\n",
      "h5a = h4-(h4-h5)*n #Enthalpy at state 5'(in kJ/kg):\n",
      "p = mhp*(h1-h3a)+(mhp+mlp)*(h4-h5a)#Power output from mixed pressure turbine(in kW):\n",
      "\n",
      "#Results:\n",
      "print \"Power: \",round(p,2),\"KW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power:  1979.46 KW\n"
       ]
      }
     ],
     "prompt_number": 60
    }
   ],
   "metadata": {}
  }
 ]
}