{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 13 - Process Calculations for Stationary Systems"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1a - Pg 203"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the final temperature and heat transferred from the steam\n",
      "#initialization of varaibles\n",
      "P1=100. #psia\n",
      "T1=500+460. #R\n",
      "v=10. #cu ft\n",
      "P2=50. #psia\n",
      "cv=0.172\n",
      "R=53.34\n",
      "m=2.81 #lb\n",
      "#calculations\n",
      "T2=T1*P2/P1\n",
      "Q1=P1*144*v*cv*(T2-T1)/(R*T1)\n",
      "u1=165.26 #Btu/lb\n",
      "u2=81.77 #Btu/lb\n",
      "du=u2-u1\n",
      "Q2=m*du\n",
      "#results\n",
      "print '%s' %(\"Case 1,\")\n",
      "print '%s %d %s' %(\"\\n Final temperature of the steam = \",T2,\"R\")\n",
      "print '%s %.1f %s' %(\"\\n Heat transferred =\",Q1,\"Btu\")\n",
      "print '%s %.1f %s' %(\"\\n Heat transferred in case 2 =\",Q2,\"Btu\")\n",
      "print '%s' %(\"\\n The answer may be a bit different due to rounding off error in the textbook\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case 1,\n",
        "\n",
        " Final temperature of the steam =  480 R\n",
        "\n",
        " Heat transferred = -232.2 Btu\n",
        "\n",
        " Heat transferred in case 2 = -234.6 Btu\n",
        "\n",
        " The answer may be a bit different due to rounding off error in the textbook\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1b - Pg 204"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the final temperature and heat transferred\n",
      "#initialization of varaibles\n",
      "P1=100. #psia\n",
      "T1=500.+460 #R\n",
      "V=10. #cu ft\n",
      "P2=50. #psia\n",
      "cv=0.172\n",
      "R=53.34\n",
      "v=5.589 #cu ft/lb\n",
      "#calculations\n",
      "m=V/v\n",
      "x2=(v-0.017)/8.498\n",
      "print '%s' %(\"From table 2,\")\n",
      "T2=281.01 #F\n",
      "h1=1279.1\n",
      "u1=h1-144*P1*v/778.\n",
      "uf=249.93\n",
      "ufg=845.4\n",
      "u2=uf+x2*ufg\n",
      "Q=m*(u2-u1)\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Final temperature =\",T2,\"F\")\n",
      "print '%s %d %s' %(\"\\n Heat transferred =\",Q,\"Btu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 2,\n",
        "Final temperature = 281.01 F\n",
        "\n",
        " Heat transferred = -664 Btu\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2a - Pg 205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the final temperature, Enthalpy and heat transferred in the process\n",
      "#initialization of varaibles\n",
      "T1=350+460 #R\n",
      "v1=6 #cu ft/lb\n",
      "m=1 #lb\n",
      "R=53.34\n",
      "v2=2*v1\n",
      "cp=0.24\n",
      "#calculations\n",
      "P=R*T1/(v1*144)\n",
      "W=P*144*(v2-v1)\n",
      "T2=T1*v2/v1\n",
      "Q=cp*(T2-T1)\n",
      "h1=194.25\n",
      "h2=401.09\n",
      "dh=h2-h1\n",
      "#results\n",
      "print '%s %d %s' %(\"Final temperature =\",T2-460,\"F\")\n",
      "print '%s %.2f %s' %(\"\\n Enthalpy =\",dh,\"B/lb\")\n",
      "print '%s %d %s' %(\"\\n Heat =\",Q,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final temperature = 1160 F\n",
        "\n",
        " Enthalpy = 206.84 B/lb\n",
        "\n",
        " Heat = 194 B/lb\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2b - Pg 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the final temperature, Enthalpy and heat transferred in the process\n",
      "#initialization of varaibles\n",
      "T1=350+460. #R\n",
      "v1=6 #cu ft/lb\n",
      "m=1 #lb\n",
      "R=53.34\n",
      "v2=2*v1\n",
      "cp=0.24\n",
      "#calculations\n",
      "print '%s' %(\"From steam tables,\")\n",
      "vg=3.342 #cu ft/lb\n",
      "P1=77.5 #psia\n",
      "P2=P1\n",
      "h1=1204.8  #B/lb\n",
      "v2=2*v1\n",
      "T2=1106 #F\n",
      "h2=1586.7 #B/lb\n",
      "Q=h2-h1\n",
      "W=P1*144*(v2-v1)\n",
      "#results\n",
      "print '%s %d %s' %(\"Final temperature =\",T2,\"F\")\n",
      "print '%s %d %s' %(\"\\n Work =\",W,\"ft lb/lb\")\n",
      "print '%s %.1f %s' %(\"\\n Heat =\",Q,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Final temperature = 1106 F\n",
        "\n",
        " Work = 66960 ft lb/lb\n",
        "\n",
        " Heat = 381.9 B/lb\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3a - Pg 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final pressure, work done and change in internal energy of the process\n",
      "#initialization of varaibles\n",
      "import math\n",
      "T1=400+460. #R\n",
      "P1=50. #psia\n",
      "ratio=1/10.\n",
      "R=53.34\n",
      "#calculations\n",
      "P2=P1/ratio\n",
      "W=R*T1*math.log(ratio)\n",
      "du=0\n",
      "#results\n",
      "print '%s %d %s' %(\"Final pressure =\",P2,\"psia\")\n",
      "print '%s %.1f %s' %(\"\\n Work done =\",W,\"B/lb\")\n",
      "print '%s %d %s' %(\"\\n Change in Internal energy \",du,\"Btu/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final pressure = 500 psia\n",
        "\n",
        " Work done = -105625.1 B/lb\n",
        "\n",
        " Change in Internal energy  0 Btu/lb\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3b - Pg 207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final pressure, work done and change in internal energy of the process\n",
      "#initialization of varaibles\n",
      "T1=400+460. #R\n",
      "P1=50. #psia\n",
      "ratio=1/10.\n",
      "R=53.34\n",
      "v1=10.065 #cu ft/lb\n",
      "vfg=1.8447 #cu ft/lb\n",
      "vg=1.8633 #cu ft/lb\n",
      "#calculations\n",
      "v2=v1*ratio\n",
      "dx=(v2-vg)/vfg\n",
      "P2=247.3 #psia\n",
      "print '%s' %(\"From steam tables,\")\n",
      "u2=773. #B/lb\n",
      "u1=1141.6 #B/lb\n",
      "du=u2-u1\n",
      "s1=1.7349 #B/lb R\n",
      "s2=1.082 #B/lb R\n",
      "W=T1*(s2-s1) - du\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Final pressure = \",P2,\"psia\")\n",
      "print '%s %d %s' %(\"\\n Work done =\",W,\"B/lb\")\n",
      "print '%s %d %s' %(\"\\n Change in Internal energy = \",du,\"B/lb \")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Final pressure =  247.3 psia\n",
        "\n",
        " Work done = -192 B/lb\n",
        "\n",
        " Change in Internal energy =  -368 B/lb \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4a - Pg 208"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate final specific volume and work per pound of fluid in the problem\n",
      "#initialization of varaibles\n",
      "import math\n",
      "P1=150. #psia\n",
      "T1=400.+460 #R\n",
      "P2=15. #psia\n",
      "g=1.4\n",
      "R=53.34\n",
      "#calculations\n",
      "Tratio=math.pow((P2/P1),((g-1)/g))\n",
      "W=53.34*T1*(Tratio-1)/(1-g)\n",
      "T2=T1*Tratio\n",
      "v2=R*T2/(P2*144)\n",
      "u1=147.50\n",
      "Pr1=7.149\n",
      "Pr2=Pr1*P2/P1\n",
      "print '%s' %(\"From tables,\")\n",
      "Pr=0.7149\n",
      "T2=447. #R\n",
      "u2=76.13 #B/lb\n",
      "W=-(u2-u1)\n",
      "v2=R*T2/(P2*144)\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Final specific volume =\",v2,\"cu ft/lb\")\n",
      "print '%s %.1f %s' %(\"\\n Work per pound of fluid =\",W,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From tables,\n",
        "Final specific volume = 11.0 cu ft/lb\n",
        "\n",
        " Work per pound of fluid = 71.4 B/lb\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4b - Pg 209"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate final specific volume and work per pound of fluid in the problem\n",
      "#initialization of varaibles\n",
      "print '%s' %(\"From Steam tables,\")\n",
      "h1=1219.4\n",
      "P1=150 #psia\n",
      "v1=0.59733 #cu ft/lb\n",
      "s1=1.5995 #B/lb R\n",
      "#calculations\n",
      "u1=h1-P1*v1\n",
      "sg=1.7549\n",
      "sfg=1.4415\n",
      "s2=s1\n",
      "dx=(sg-s2)/sfg\n",
      "u2=981.3\n",
      "W=u1-u2\n",
      "v2=23.48\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Final specific volume =\",v2,\"cu ft/lb\")\n",
      "print '%s %.1f %s' %(\"\\n Work per pound of fluid = \",W,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From Steam tables,\n",
        "Final specific volume = 23.48 cu ft/lb\n",
        "\n",
        " Work per pound of fluid =  148.5 B/lb\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5a - Pg 210"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final specific volume, temperature and the net heat transferred in the process\n",
      "#initialization of varaibles\n",
      "import math\n",
      "P1=150. #psia\n",
      "T1=400.+460 #R\n",
      "P2=15.  #psia\n",
      "n=1.15\n",
      "cv=0.172\n",
      "R=53.34\n",
      "#calculations\n",
      "v2=R*T1*math.pow((P1/P2),(1/n)) /(P1*144.)\n",
      "v1=R*T1/(P1*144.)\n",
      "T2=T1*P2*v2/(P1*v1)\n",
      "Q=(cv - 0.458)*(T2-T1)\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Final specific volume = \",v2,\"cu ft/lb\")\n",
      "print '%s %d %s' %(\"\\n Final temperature =\",T2,\"R\")\n",
      "print '%s %.1f %s' %(\"\\n Heat transferred =\",Q,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final specific volume =  15.7 cu ft/lb\n",
        "\n",
        " Final temperature = 636 R\n",
        "\n",
        " Heat transferred = 63.8 B/lb\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5b - Pg 211"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final specific volume, temperature and the net heat transferred in the process\n",
      "#initialization of varaibles\n",
      "import math\n",
      "print '%s' %(\"From table 3,\")\n",
      "v1=3.223 #cu ft/lb\n",
      "P1=150. #psia\n",
      "T1=400.+460 #R\n",
      "P2=15.  #psia\n",
      "n=1.15\n",
      "#calculations\n",
      "v2=v1*math.pow((P1/P2),(1/n))\n",
      "T2=213 #F\n",
      "W=144*(P2*v2-P1*v1)*0.00129/(1-n)\n",
      "u1=1129.8 #B/lb\n",
      "v2=23.9\n",
      "vg=26.29\n",
      "vfg=26.27\n",
      "dx=(vg-v2)/vfg\n",
      "u2=996.1\n",
      "Q=(u2-u1)+W\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Final specific volume =\",v2,\"cu ft/lb\")\n",
      "print '%s %d %s' %(\"\\n Final temperature =\",T2,\" F\")\n",
      "print '%s %.1f %s' %(\"\\n Heat transferred =\",Q,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 3,\n",
        "Final specific volume = 23.9 cu ft/lb\n",
        "\n",
        " Final temperature = 213  F\n",
        "\n",
        " Heat transferred = 21.6 B/lb\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6a - Pg 212"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final specific volume, temperature and the net work done in the process\n",
      "#initialization of varaibles\n",
      "v2=15.7 #cu ft/lb\n",
      "T2=640 #R\n",
      "cv=0.172\n",
      "T1=400+460. #R\n",
      "#calculations\n",
      "du=cv*(T2-T1)\n",
      "W=-du\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Final specific volume =\",v2,\"cu ft/lb\")\n",
      "print '%s %d %s' %(\"\\n Final temperature =\",T2,\"R \")\n",
      "print '%s %.1f %s' %(\"\\n Work done =\",W,\"B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final specific volume = 15.7 cu ft/lb\n",
        "\n",
        " Final temperature = 640 R \n",
        "\n",
        " Work done = 37.8 B/lb\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6b - Pg 213"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final specific volume, temperature and the net work done in the process\n",
      "#initialization of varaibles\n",
      "print '%s' %(\"From steam tables,\")\n",
      "T2=213 #F\n",
      "v2=23.9 #cu ft/lb\n",
      "W=133.7 #B/lb\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Final specific volume =\",v2,\"cu ft/lb\")\n",
      "print '%s %d %s' %(\"\\n Final temperature =\",T2,\"F\")\n",
      "print '%s %.1f %s' %(\"\\n Work done = \",W,\" B/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Final specific volume = 23.9 cu ft/lb\n",
        "\n",
        " Final temperature = 213 F\n",
        "\n",
        " Work done =  133.7  B/lb\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}