{
 "metadata": {
  "name": "",
  "signature": "sha256:21747075c112c6cd9e1a0a4f001fec6264fd627d603e23ce68da0341f7d86ac0"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 27 : Ideal Processes Efficiency and the Mechanical Energy Balance"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 27.1 page no. 838\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "V_w = 1. ;\t\t\t#  Volume of given water -[L]\n",
      "P_atm = 100. ;\t\t\t# Atmospheric pressure - [kPa]\n",
      "\n",
      "#W = -p*del_V\n",
      "V_H2O = 0.001043 ;\t\t\t# Specific volume of water from steam table according to book- [cubic metre] \n",
      "V_vap = 1.694 ;\t\t\t# Specific volume of vapour from steam table according to book- [cubic metre] \n",
      "V1 = 0 ;\t\t\t# Initial volume of H2O in bag-[cubic metre]\n",
      "\n",
      "# Calculations\n",
      "V2 = (V_w*V_vap)/(1000*V_H2O) ;\t\t\t# Final volume of water vapour -[cubic metre] \n",
      "W = -P_atm*(V2 -V1)* 1000 ;\t\t\t# Work done by saturated liquid water -[J]\n",
      " \n",
      "# Results \n",
      "print ' Work done by saturated liquid water is %.3e J.'%W\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Work done by saturated liquid water is -1.624e+05 J.\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 27.2  page no. 840\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "m_N2 = 1. ;\t\t\t# Moles of N2 taken -[kg mol]\n",
      "p = 1000.;\t\t\t# Pressure of cylinder-[kPa]\n",
      "T = 20. + 273. ;\t\t\t# Temperature of cylinder -[K]\n",
      "a_pis = 6. ;\t\t\t# Area of piston - [square centimetre]\n",
      "m_pis = 2. ;\t\t\t# Mass of pston - [kg]\n",
      "R = 8.31 ;\t\t\t# Ideal gas constant - [(kPa*cubic metre)/(K * kgmol)]\n",
      "\n",
      "# Calculations\n",
      "V = (R*T)/p ;\t\t\t# Specific volue of gas at initial stage -[cubic metre/kg mol]\n",
      "V1 = V * m_N2 ;\t\t\t# Initial volume of gas - [cubic metre]\n",
      "V2 = 2.*V1 ;\t\t\t# Final volume of gas according to given condition -[cubic metre]\n",
      "\n",
      "# Assumed surrounding pressure constant = 1 atm\n",
      "p_atm = 101.3 ;\t\t\t# Atmospheric pressure-[kPa]\n",
      "del_Vsys = V2 -V1 ;\t\t\t# Change in volume of system -[cubic metre]\n",
      "del_Vsurr = - del_Vsys ;\t\t\t# Change in volume of surrounding -[cubic metre]\n",
      "W_surr = -p_atm*del_Vsurr ;\t\t\t# Work done by surrounding - [kJ]\n",
      "W_sys = -W_surr ;\t\t\t# Work done by system - [kJ]\n",
      "\n",
      "# Results\n",
      "print ' Work done by gas(actually gas + piston system) is %.0f kJ.'%W_sys\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Work done by gas(actually gas + piston system) is -247 kJ.\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 27.3  page no. 845\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "p_plant = 20. ;\t\t\t# Power generated by plant-[MW]\n",
      "h = 25. ;\t\t\t# Height of water level - [m]\n",
      "V = 100. ;\t\t\t# Flow rate of water -[cubic metre/s]\n",
      "d_water = 1000. ;\t\t\t# Density of water - [ 1000 kg / cubic metre]\n",
      "g = 9.807 ;\t\t\t# Acceleration due to gravity-[m/square second]\n",
      "\n",
      "# Calculations\n",
      "M_flow = V*d_water ;\t\t\t# Mass flow rate of water -[kg/s]\n",
      "del_PE = M_flow*g*h ;\t\t\t# Potential energy change of water per second -[W]\n",
      "eff = (p_plant*10**6) /(del_PE) ;\t\t\t# Efficiency of plant \n",
      "\n",
      "# Results\n",
      "print ' Efficiency of plant is %.2f .'%eff\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Efficiency of plant is 0.82 .\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 27.4  page no. 845\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "LHV = 36654. ;\t\t\t# LHV value of fuel - [kJ/ cubic metre]\n",
      "Q1 = 16. ;\t\t\t#- [kJ/ cubic metre]\n",
      "Q2 = 0 ;\t\t\t#- [kJ/ cubic metre]\n",
      "Q3 = 2432. ;\t\t\t#- [kJ/ cubic metre]\n",
      "Q4 = 32114. ;\t\t\t#- [kJ/ cubic metre]\n",
      "Q41 = 6988. ;\t\t\t#- [kJ/ cubic metre]\n",
      "Q8 = 1948. ;\t\t\t#- [kJ/ cubic metre]\n",
      "Q9 = 2643. ;\t\t\t#- [kJ/ cubic metre]\n",
      "Q81 = 2352. - Q8 ;\t\t\t# - [kJ/ cubic metre]\n",
      "Q567 = 9092. ;\t\t\t# Sum of Q5, Q6 and Q7- [kJ/ cubic metre]\n",
      "\n",
      "# Calculations and Results\n",
      "#(a)\n",
      "G_ef = (LHV+ Q1 +Q2 + Q3 - Q9)/(LHV) ;\t\t\t# Gross efficiency\n",
      "print '(a) Gross efficiency is %.3f .'%G_ef\n",
      "\n",
      "#(b)\n",
      "T_ef = (Q567+Q8)/(LHV+ Q1 +Q2 + Q3) ;\t\t\t#Thermal efficiency \n",
      "print ' (b) Thermal efficiency is %.3f .'%T_ef\n",
      "\n",
      "#(c)\n",
      "C_ef = Q4/(Q4 + Q41) ;\t\t\t# Combustion efficiency\n",
      "print ' (c) Combustion efficiency is %.3f .'%C_ef\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Gross efficiency is 0.995 .\n",
        " (b) Thermal efficiency is 0.282 .\n",
        " (c) Combustion efficiency is 0.821 .\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 27.5 page no. 850"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "\n",
      "from scipy.integrate import quad\n",
      "\n",
      "# Variables\n",
      "V1 = 5. ;\t\t\t# Volume of gas initially - [cubic feet]\n",
      "P1 = 1. ;\t\t\t# Initial pressure - [atm]\n",
      "P2 = 10. ;\t\t\t# Final pressure - [atm]\n",
      "T1 = 100. + 460 ;\t\t\t# initial temperature - [degree Rankine]\n",
      "R = 0.7302 ;\t\t\t# Ideal gas constant -[(cubic feet*atm)/(lb mol)*(R)]\n",
      "\t\t\t#Equation of state pV**1.4 = constant\n",
      "\n",
      "\n",
      "# Calculations and Results\n",
      "V2 = V1*(P1/P2)**(1/1.4) ;\t\t\t# Final volume - [cubic feet]    \n",
      "\n",
      "def f(V):\n",
      "    return -(P1)*(V1/V)**(1.4)\n",
      "    \n",
      "W1_rev = quad(f,V1,V2)[0] ;\t\t\t# Reversible work done in compresion in a horizontal cylinder with piston -[cubic feet *atm]\n",
      "W1 = W1_rev *1.987/.7302 ;\t\t\t# Conversion to Btu -[Btu]\n",
      "print '(a)Reversible work done in compression in a horizontal cylinder with piston is %.1f Btu . '%W1\n",
      "\n",
      "#(b)\n",
      "n1 = (P1*V1)/(R*T1) ;\t\t\t# Number of moles of gas\n",
      "\n",
      "def f1(P):\n",
      "    return (V1)*(P1/P)**(1/1.4)\n",
      "W2_rev = quad(f1,P1,P2)[0]\t\t# Reversible work done in compresion in a rotary compressor -[cubic feet *atm]\n",
      "W2 = W2_rev *1.987/.7302 ;\t\t\t# Conversion to Btu -[Btu]\n",
      "\n",
      "print '(b)Reversible work done in a rotary compressor is %.1f Btu . '%W2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Reversible work done in compression in a horizontal cylinder with piston is 31.7 Btu . \n",
        "(b)Reversible work done in a rotary compressor is 44.3 Btu . \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 27.6 page no. 853"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.integrate import quad\n",
      "# Variables\n",
      "m_water = 1. ;\t\t\t# Mass flow rate of water -[lb/min]\n",
      "P1 = 100. ;\t\t\t# Initial pressure - [psia]\n",
      "P2 = 1000. ;\t\t\t# Final pressure - [psia]\n",
      "T1 = 80. + 460 ;\t\t\t# initial temperature - [degree Rankine]\n",
      "T2 = 100. + 460 ;\t\t\t# final temperature - [degree Rankine]\n",
      "h = 10. ;\t\t\t# Difference in water level between entry and exit of stream-[ft]\n",
      "g = 32.2 ;\t\t\t# Accleration due to gravity - [ft/ square second]\n",
      "gc = 32.2 ;\t\t\t#[(ft*lbm)/(lbf*square second)]\n",
      "\n",
      "v1 = .01607 ;\t\t\t# specific volume of liquid water at 80 degree F -[cubic feet/lbm]\n",
      "v2 = .01613 ;\t\t\t# specific volume of liquid water at 100 degree F -[cubic feet/lbm] \n",
      "v= 0.0161 ;\t\t\t# -[cubic feet/lbm]\n",
      "\n",
      "# Calculations\n",
      "del_PE = (h*g)/(gc*778) ;\t\t\t# Change in potential energy - [Btu/lbm]\n",
      "\n",
      "def f(P):\n",
      "    return (v)*(12**2/778.)\n",
      "    \n",
      "PV_work = quad(f,P1,P2)[0]\t\t\t# PV work done  -[Btu/lbm]\n",
      "#From eqn. (A)\n",
      "W = PV_work + del_PE ;\t\t\t# Work per minute required to pump 1 lb water per minute - [Btu/lbm]\n",
      "\n",
      "# Results\n",
      "print ' Work per minute required to pump 1 lb water per minute is %.2f Btu/lbm . '%W\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Work per minute required to pump 1 lb water per minute is 2.69 Btu/lbm . \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}