{
 "metadata": {
  "name": "",
  "signature": "sha256:85497d817768e6e1d81546cc4adcb855eed2a97589497e4f8a3f22d0bc4a6c3d"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "\n",
      "Chapter 23 : Calculation of Enthalpy Changes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 23.1   Page no. 686\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "%matplotlib inline\n",
      "from matplotlib.pyplot import *\n",
      "\n",
      "# Variables\n",
      "# Given\n",
      "x_Tl = [90,92,97,100] ;\t\t\t# Temperature of saturated liquid- [degree C]\n",
      "x_Tg = [100,102,107,110] ;\t\t\t# Temperature of saturated vapour- [degree C]\n",
      "y_Hl = [376.9,385.3,406.3,418.6] ;\t\t\t# Enthalpy change of saturated liquid -[kJ/kg]\n",
      "y_Hg = [2256.44,2251.2,2237.9,2229.86] ;\t\t\t# Enthalpy change of saturated vapour -[kJ/kg]\n",
      "\n",
      "# Results\n",
      "plot(x_Tl,y_Hl,x_Tg,y_Hg);\n",
      "show()\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Populating the interactive namespace from numpy and matplotlib\n"
       ]
      },
      {
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAD9CAYAAABazssqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFTxJREFUeJzt3V9MW+fBx/HfCbjKXiVRclFMZkdyF0yJgwN0lZOLZXOV\nQBOkMapMqGRrSEOmCTQtVaOp20U7mLRCL7aJpkPqBZ1QJhUytUA0rRYXk9O10mCjRJrqrHE0omJj\n2DKGRFZekZDzXkTxG8J/7GDI8/1IEeb4nOPHJyfnax+Og2Xbti0AgJ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ZFtqW9fX1Ghoa0uXLl7Vz506dPXs2\n00PdsJbaF9lPV+b+7fnlL39Zw8PDGhwc1C9/+UsdP35ck5OTGR7ho2OpfTOj/4voqVOn9Ne//lWX\nLl3Sjh07lJ+fL6fTqdHRUUlSIpFQTk5OJoe4Ydy/Lbdv364nn3xSjz/+ePIf2+nTpzllsUIL7YsP\nfuYlFovJ5XJlZIwbyULb87HHHkue7njqqae0e/duRaPRjI1zI1vNvpnRCPzzn/+UJH3++ed6//33\ndfz4cVVUVKi9vV2S1N7ersrKykwOccO4f1t2dXXp+PHjSiQSyfu7urpmXV2ApS20L1ZUVKijo0PT\n09MaGhpSNBpVIBDI5FA3hIW2540bNzQzMyNJ+sc//qFoNKqvfOUrGRvnRnP/z/1WtW8+pB9oL8vB\ngwdtn89nFxUV2X/84x9t27btf//73/ahQ4dsr9drl5aW2v/5z38yOcQNY75t+cILL9h+v9/et2+f\n/a1vfcseHR3N8CjXr+eff97euXOn7XA4bLfbbb/zzjuL7os///nP7d27d9tPPvmkHQqFMjjy9Wkl\n2/O9996z9+7daxcXF9tPPfWU/fvf/z7Do19fHtyWbW1tdldXl+12u+3NmzfbTqfTPnLkSHL+le6b\nlm1z+QgAmIrfLAYABiMCAGAwIgAABiMCAGAwIgAABiMCAGCw/wMDiUOF/Sr3yAAAAABJRU5ErkJg\ngg==\n",
       "text": [
        "<matplotlib.figure.Figure at 0x33aa350>"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 23.2  page no. 687\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "# Basis : 1 g mol\n",
      "R = 8.314 * 10**-3 ;\t\t\t# Ideal gas constant -[kJ/(g mol * K)]\n",
      "Hv = 30.20 ;\t\t\t# Experimental value of heat of vaporization of acetone -[kJ/g]  \n",
      "\n",
      "# additional needed data for acetone from Appendix D\n",
      "T = 329.2 ;\t\t\t# Normal boiling point of acetone - [K]\n",
      "Tc = 508.0 ;\t\t\t# Critical temperature  of acetone - [K]\n",
      "Pc = 47.0 ;\t\t\t# Critical presure of acetone -[atm]\n",
      "\n",
      "# Calculations and Results\n",
      "Tbc = T/Tc ;\t\t\t# variable required in etimation equations\n",
      "lnPc = math.log(Pc)  ;\t\t\t#  variable required in etimation equations\n",
      "\n",
      "B = 2940.46 ;\n",
      "C = -35.93 ;\n",
      "\n",
      "del_Hv1 = (R*B*T**2)/((C+T)**2) ;\t\t\t#Heat of vapourization -[kJ/g]\n",
      "d1 = (abs(Hv - del_Hv1)*100)/Hv ;\t\t\t# differece of experimental and calculated value -[%]\n",
      "print '(a) Heat of vapourization of acetone is %.2f kJ/g mol. And differece of experimental and calculated value is %.1f %% . '%(del_Hv1,d1);\n",
      "\n",
      "del_Hv2 = R*T*((3.978*Tbc - 3.938 +1.555*lnPc)/(1.07 - Tbc)) ;\t\t\t#Heat of vapourization -[kJ/g]\n",
      "d2 = (abs(Hv - del_Hv2)*100)/Hv ;\t\t\t# differece of experimental and calculated value -[%]\n",
      "print ' (b) Heat of vapourization of acetone is %.2f kJ/g mol. And differece of experimental and calculated value is %.1f %% . '%(del_Hv2,d2);\n",
      "\n",
      "\n",
      "del_Hv3 = 1.093*R*Tc*((Tbc*(lnPc-1))/(0.93-Tbc)) ;\t\t\t#Heat of vapourization -[kJ/g]\n",
      "d3 = (abs(Hv - del_Hv3)*100)/Hv ;\t\t\t# differece of experimental and calculated value -[%]\n",
      "print ' (c) Heat of vapourization of acetone is %.2f kJ/g mol. And differece of experimental and calculated value is %.1f %% . '%(del_Hv3,d3);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Heat of vapourization of acetone is 30.80 kJ/g mol. And differece of experimental and calculated value is 2.0 % . \n",
        " (b) Heat of vapourization of acetone is 30.01 kJ/g mol. And differece of experimental and calculated value is 0.6 % . \n",
        " (c) Heat of vapourization of acetone is 30.24 kJ/g mol. And differece of experimental and calculated value is 0.1 % . \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "\n",
      "Example 23.3   Page no. 693\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "c = 2.675*10**4    #*.4536)/(1055*1.8) ;\n",
      "d = 42.27#*.4536)/(1055*1.8) ;\n",
      "e = 1.425*10**-2#*.4536)/(1055*1.8) ;\n",
      "# Calculations\n",
      "#Now convert Tk (Temperature in K) to TF (temperature in F) to get answer of form x + yT - zT**2,where\n",
      "x = c + d*460/1.8 - e*((460/1.8)**2) ;\n",
      "y = d/1.8;\n",
      "z = e/(1.8*1.8) ;\n",
      "\n",
      "# Results\n",
      "print 'The required answer is %.2e + (%.2e)T - (%.3e) T**2 Btu/(lb mol*F) , where T is in degree F .  '%(x,y,z)\n",
      "\n",
      "print \"Note answer in textbook seems wrong by order of 10^-3\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The required answer is 3.66e+04 + (2.35e+01)T - (4.398e-03) T**2 Btu/(lb mol*F) , where T is in degree F .  \n",
        "Note answer in textbook seems wrong by order of 10^-3\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 23.4  page no. 694\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "# Take all 18 experimenta data in an array Cp\n",
      "Cpi = [39.87,39.85,39.90,45.16,45.23,45.17,50.72,51.03,50.90,56.85,56.80,57.02,63.01,63.09,63.14,69.52,69.68,69.63] ;\t\t\t# Array of Cpi(Heat capacity) values\n",
      "# Take corresponding temperatures in array T\n",
      "Ti = [300,300,300,400,400,400,500,500,500,600,600,600,700,700,700,800,800,800] ;\t\t\t# array of Ti\n",
      "Ti_sqr = [300**2,300**2,300**2,400**2,400**2,400**2,500**2,500**2,500**2,600**2,600**2,600**2,700**2,700**2,700**2,800**2,800**2,800**2] ;\t\t\t# array of Ti**2\n",
      "Ti_cub = [300**3,300**3,300**3,400**3,400**3,400**3,500**3,500**3,500**3,600**3,600**3,600**3,700**3,700**3,700**3,800**3,800**3,800**3];\t\t\t# array of Ti**3\n",
      "Ti_qd = [300**4,300**4,300**4,400**4,400**4,400**4,500**4,500**4,500**4,600**4,600**4,600**4,700**4,700**4,700**4,800**4,800**4,800**4];\t\t\t# array of Ti**4\n",
      "Cpi_Ti = [39.87*300,39.85*300,39.90*300,45.16*400,45.23*400,45.17*400,50.72*500,51.03*500,50.90*500,56.85*600,56.80*600,57.02*600,63.01*700,63.09*700,63.14*700,69.52*800,69.68*800,69.63*800] ;\t\t\t# Array of Cpi(Heat capacity)*Ti  values\n",
      "Cpi_Ti_sqr = [39.87*300**2,39.85*300**2,39.90*300**2,45.16*400**2,45.23*400**2,45.17*400**2,50.72*500**2,51.03*500**2,50.90*500**2,56.85*600**2,56.80*600**2,57.02*600**2,63.01*700**2,63.09*700**2,63.14*700**2,69.52*800**2,69.68*800**2,69.63*800**2] ;\t\t\t# Array of Cpi(Heat capacity)*Ti**2  values\n",
      "\n",
      "n = 18. ;\t\t\t# Number of data\n",
      "# Calculations\n",
      "\n",
      "from numpy import matrix\n",
      "# Solve equations (a),(b) & (c) simultaneously using matrix\n",
      "a = matrix([[n,sum(Ti),sum(Ti_sqr)],[sum(Ti),sum(Ti_sqr),sum(Ti_cub)],[sum(Ti_sqr),sum(Ti_cub),sum(Ti_qd)]]) ;\t\t\t# Matrix of coefficients of unknown\n",
      "b = matrix([[sum(Cpi)],[sum(Cpi_Ti)],[sum(Cpi_Ti_sqr)]]) ;\t\t\t# Matrix of constants\n",
      "x = (a)**-1 * b ;\t\t\t# Matrix of solutions a = x(1), b = x(2) , c = x(3) \n",
      "\n",
      "# Results\n",
      "print 'The solution is Cp = %.2f + %.3e T + %.2e T**2 .Therefore coefficients are as follows :'%(x[0],x[1],x[2])\n",
      "print ' a = %.2f. b = %.3e . c = %.2e .'%(x[0],x[1],x[2])\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The solution is Cp = 25.44 + 4.371e-02 T + 1.44e-05 T**2 .Therefore coefficients are as follows :\n",
        " a = 25.44. b = 4.371e-02 . c = 1.44e-05 .\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 23.5 page no : 695"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "from scipy.integrate import quad\n",
      "# Variables\n",
      "# Basis : 1 g mol of gas\n",
      "#Given\n",
      "T1 = 550. ;\t\t\t# Initial temperature - [degree F]\n",
      "T2 = 200. ;\t\t\t# Final temperature - [degree F]\n",
      "CO2 = 9.2/100 ;\t\t\t# Mole fraction \n",
      "CO = 1.5/100 ;\t\t\t# Mole fraction \n",
      "O2 = 7.3/100 ;\t\t\t# Mole fraction \n",
      "N2 = 82.0/100 ;\t\t\t#Mole fraction \n",
      "\n",
      "# Calculations\n",
      "# Additional data needed  :\n",
      "a_N2 = 6.895;\t\t\t# constant\n",
      "b_N2 = 0.7624*10**-3;\t\t\t# coefficient of T\n",
      "c_N2 = -0.7009*10**-7;\t\t\t# coefficient of square T\n",
      "a_O2 = 7.104 ;\t\t\t# constant\n",
      "b_O2 = (0.7851*10**-3);\t\t\t# coefficient of T\n",
      "c_O2 = (-0.5528*10**-7); \t\t\t# coefficient of square T\n",
      "a_CO2 = 8.448;\t\t\t# constant\n",
      "b_CO2 = 5.757*10**-3;\t\t\t# coefficient of T\n",
      "c_CO2 = -21.59*10**-7;\t\t\t# coefficient of square T\n",
      "d_CO2 = 3.059*10**-10;\t\t\t# coefficient of cubic T\n",
      "a_CO = 6.865 ;\t\t\t# constant\n",
      "b_CO = 0.8024*10**-3;\t\t\t# coefficient of T\n",
      "c_CO = -0.7367*10**-7; \t\t\t# coefficient of square T\n",
      "\n",
      "# New coefficients after multiplying mole fraction of each component\n",
      "a1_N2 = 6.895*N2 ;\t\t\t# constant\n",
      "b1_N2 = N2*0.7624*10**-3; \t\t\t# coefficient of T\n",
      "c1_N2 = (-0.7009*10**-7)*N2; \t\t\t# coefficient of square T \n",
      "a1_O2 = 7.104*O2 ;\t\t\t# constant\n",
      "b1_O2 = (0.7851*10**-3)*O2;\t\t\t# coefficient of T\n",
      "c1_O2 = (-0.5528*10**-7)*O2; \t\t\t# coefficient of square T\n",
      "a1_CO2 = 8.448*CO2;\t\t\t# constant\n",
      "b1_CO2 = (5.757*10**-3)*CO2;\t\t\t# coefficient of T\n",
      "c1_CO2 = (-21.59*10**-7)*CO2; \t\t\t# coefficient of square T\n",
      "d1_CO2 = (3.059*10**-10)*CO2; \t\t\t# coefficient of cubic T\n",
      "a1_CO = 6.865*CO;\t\t\t# constant\n",
      "b1_CO = (0.8024*10**-3)*CO;\t\t\t# coefficient of T\n",
      "c1_CO = (-0.7367*10**-7)*CO; \t\t\t# coefficient of square T\n",
      "\n",
      "# Get net coefficients of T , square T and cubic T by adding them\n",
      "a_net = a1_N2+a1_CO2+a1_CO+a1_O2; \t\t\t#Net constant\n",
      "b_net = b1_N2+b1_CO2+b1_CO+b1_O2; \t\t\t#Net coefficient of T\n",
      "c_net = c1_N2+c1_CO2+c1_CO+c1_O2 ;\t\t\t#Net coefficient of square T\n",
      "d_net = d1_CO2;\t\t\t#Net coefficient of cubic T\n",
      "\n",
      "def f(T):\n",
      "    return (a_net )+( b_net*T) + (c_net*(T**2)) + (d_net*(T**3))\n",
      "    \n",
      "del_H = quad(f,T1,T2)[0] \t\t\t# Change in enthalpy of gas over given range-[Btu/lb mol gas]\n",
      "\n",
      "# Results\n",
      "print ' Change in enthalpy of gas over given range is %.0f Btu/lb mol gas . '%del_H\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Change in enthalpy of gas over given range is -2616 Btu/lb mol gas . \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 23.6  page no. 700 \n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "\n",
      "# Solution \n",
      "#Given\n",
      "N2 = 1. ;\t\t\t# Moles of N2 - [kg mol]\n",
      "P = 100. ;\t\t\t# Pressure of gas - [kPa] \n",
      "T1 = 18. ;\t\t\t# Initial temperature - [degree C]\n",
      "T2 = 1100.  ;\t\t\t# Final temperature - [degree C]\n",
      "\n",
      "# Calculations\n",
      "# In the book it is mentioned to use tables in Appendix D6 to calculate enthalpy change, we get \n",
      "H_T1 = 0.524;\t\t\t# Initial enthalpy -[kJ/kg mol]\n",
      "H_T2 = 34.715   ;\t\t\t# Final enthalpy - [kJ/kg mol]\n",
      "del_H =  H_T2 - H_T1 ;\t\t\t# Change in enthalpy - [kJ/kg]\n",
      "\n",
      "# Results\n",
      "print ' Change in enthalpy of N2 over given range is %.3f kJ/kg mol N2 . '%del_H\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Change in enthalpy of N2 over given range is 34.191 kJ/kg mol N2 . \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 23.7  page no. 701\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "#Given\n",
      "T1 = 640. ;\t\t\t# Initial temperature -[degree F]\n",
      "T2 = 480. ;\t\t\t# Final temperature -[degree F]\n",
      "P1 = 92. ;\t\t\t# Initial pressure -[psia]\n",
      "P2 = 52. ;\t\t\t# Final pressure - [psia]\n",
      "\n",
      "\n",
      "#From steam table\n",
      "#At 90 psia\n",
      "H1_600 = 1328.7 ;\t\t\t#H at 90 psia and 600 F-[Btu/lb]\n",
      "H1_700 = 1378.1 ;\t\t\t#H at 90 psia and 700 F-[Btu/lb]\n",
      "H2_600 = 1328.4 ;\t\t\t#H at 95 psia and 600 F-[Btu/lb]\n",
      "H2_700 = 1377.8 ;\t\t\t#H at 95 psia and 700 F-[Btu/lb]\n",
      "\n",
      "# Calculations\n",
      "H3_600 = H1_600+ ((H2_600-H1_600)/(95.-90))*(92-90);\t\t\t#H  at 92 psia and 600 F-[Btu/lb]\n",
      "H3_700 = H1_700+ ((H2_700-H1_700)/(95.-90))*(92-90);\t\t\t#H at 92 psia and 700 F-[Btu/lb]\n",
      "H3_640 = H3_600+((H3_700-H3_600)/(700.-600))*(640-600);\t\t\t#H at 92 psia and 640 F-[Btu/lb]\n",
      "\n",
      "H1_450 = 1258.7 ;\t\t\t#H at 50 psia and 450 F-[Btu/lb]\n",
      "H1_500 = 1282.6 ;\t\t\t#H at 50 psia and 500 F-[Btu/lb]\n",
      "H2_450 = 1258.2 ;\t\t\t#H at 55 psia and 450 F-[Btu/lb]\n",
      "H2_500 = 1282.2 ;\t\t\t#H at 55 psia and 500 F-[Btu/lb]\n",
      "H3_450 = H1_450+ ((H2_450-H1_450)/(55.-50))*(52-50) ;\t\t\t#H at 52 psia and 450 F-[Btu/lb]\n",
      "H3_500 = H1_500+ ((H2_500-H1_500)/(55.-50))*(52-50);\t\t\t#H at 52 psia and 500 F-[Btu/lb]\n",
      "H3_480 = H3_450+((H3_500-H3_450)/(500.-450))*(480-450);\t\t\t# H at 52 psia and 480 F-[Btu/lb]\n",
      "del_H =   H3_480 - H3_640;\t\t\t# Change in enthalpy - [Btu/lb]\n",
      "\n",
      "# Results\n",
      "print 'Change in enthalpy is %.1f Btu/lb .'%del_H\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in enthalpy is -75.5 Btu/lb .\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 23.8  page no. 702\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "\n",
      "# Solution \n",
      "\n",
      "# Variables\n",
      "W = 4. ;\t\t\t# Mass of water -[kg]\n",
      "Ti= 27.+273 ;\t\t\t# Initial temperature -[K]\n",
      "Pi = 200. ;\t\t\t# Initial pressure -[kPa]\n",
      "Pf = Pi ;\t\t\t# Final pressure -[kPa]\n",
      "V1 = 0.001004 ;\t\t\t# Specific volume at Ti -[cubic metre/kg]\n",
      "V2 = 1000. * V1 ;\t\t\t#Specific volume at final temperature(Tf) from given condition in problem - [cubic metre/kg]\n",
      "va = 0.9024  ;\t\t\t# Specific volume -[cubic metre/kg]\n",
      "Ta = 400. ;\t\t\t# [K]\n",
      "vb = 1.025 ;\t\t\t# Specific volume -[cubic metre/kg]\n",
      "Tb = 450. ;\t\t\t#[K]\n",
      "vf = V2 ;\t\t\t# Final specific volume -[cubic metre/kg]\n",
      " \n",
      "# Calculations\n",
      "m=(Tb - Ta)/(vb - va);\t\t\t# slope \n",
      "Tf=Ta + m*(vf - va) ;\t\t\t# Final temperature - [K]\n",
      "\n",
      "# Results\n",
      "print ' Final temperature is %.0f K.'%Tf\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Final temperature is 441 K.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 23.9  page no. 704\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Solution \n",
      "\n",
      "# Variables\n",
      "mv = 1. ;\t\t\t# Mass of saturated vapour - [lb]\n",
      "P1 = 2. ;\t\t\t# Initial pressure -[atm]\n",
      "P2 = 20. ;\t\t\t# Final pressure -[atm]\n",
      "H_2 = 179. ;\t\t\t# Specific enthalpy at 2 atm - [Btu/lb]\n",
      "H_20 = 233. ;\t\t\t#  Specific enthalpy at 20 atm - [Btu/lb]\n",
      "V_2 = 3.00 ;\t\t\t# Specific volume at 2 atm - [cubic feet/lb]\n",
      "V_20 = 0.30 ;\t\t\t#  Specific volume at 20 atm - [cubic feet/lb]\n",
      "T_2 = 72. ;\t\t\t# Temperature at 2 atm -[degree F]\n",
      "T_20 = 239. ;\t\t\t# Temperature at 20 atm -[degree F]\n",
      "\n",
      "# Calculations\n",
      "del_H = H_20 - H_2 ;\t\t\t# Change in specific enthalpy -[Btu/lb] \n",
      "del_V = V_20 - V_2 ;\t\t\t# Change in specific volume -[cubic feet/lb] \n",
      "del_T = T_20 - T_2 ;\t\t\t# Change in temperature -[degree F]\n",
      "\n",
      "# Results\n",
      "print '(a) Change in specific enthalpy is %.0f Btu/lb.'%del_H\n",
      "print ' (b) Change in specific volume is %.2f cubic feet/lb.'%del_V\n",
      "print ' (c) Change in temperature is %.1f degree F.'%del_T\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Change in specific enthalpy is 54 Btu/lb.\n",
        " (b) Change in specific volume is -2.70 cubic feet/lb.\n",
        " (c) Change in temperature is 167.0 degree F.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 9
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}