{
 "metadata": {
  "name": "",
  "signature": "sha256:369d727c64e74475d8c5bb63540cbc246cbdecc5bfe067dfd2c4f31c8ec059a2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12: Mixtures"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.1, page no 235"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "w1 = 2 #lbm\n",
      "w2 = 1 #lbm\n",
      "P = 30 #lbm/in^2\n",
      "T = 60+460 #R\n",
      "\n",
      "#calculation\n",
      "R1 = 35.1\n",
      "R2 = 55.1\n",
      "Rm = (w1*R1+w2*R2)/(w1+w2)\n",
      "vm = (w1+w2)*Rm*T/(144*P)\n",
      "p1 = w1*R1*T/(144*vm)\n",
      "p2 = w2*R2*T/(144*vm)\n",
      "\n",
      "#result\n",
      "print \"Gas constant of the mixture  = \", round(Rm, 1), \"lb/in^2\"\n",
      "print \"Volume of the mixture  =  \", round(vm, 1), \"ft^3\"\n",
      "print \"Partial pressure of CO2  =  \", round(p1, 1), \"lb/in^2\"\n",
      "print \"Partial pressure of N2  =  \", round(p2, 1), \"lb/in^2\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gas constant of the mixture  =  41.8 lb/in^2\n",
        "Volume of the mixture  =   15.1 ft^3\n",
        "Partial pressure of CO2  =   16.8 lb/in^2\n",
        "Partial pressure of N2  =   13.2 lb/in^2\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.3, page no. 238"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import scipy.integrate\n",
      "\n",
      "#initialization\n",
      "cpm = 0.2523\n",
      "Rm = 54.7\n",
      "T1 = 60+460.0                           #R\n",
      "T2 = 400+460.0                          #R\n",
      "\n",
      "#calculation\n",
      "cvm = cpm-Rm/778.0\n",
      "Q = cpm*(T2-T1)\n",
      "W = Rm*(T2-T1)\n",
      "#Rm is divided and multiplied by 778.!\n",
      "def s(T):\n",
      "    cp = cpm/T\n",
      "    return cp\n",
      "ds = scipy.integrate.quadrature(s, T1, T2)[0]\n",
      "\n",
      "#result\n",
      "print \"Entropy change  = \", round(ds, 3), \"B/lbm\"\n",
      "print \"specific work  = \", W, \"ft-lb/lbm\"\n",
      "print \"Heat added per pound of mixture  = \", round(Q, 1), \"B/lbm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Entropy change  =  0.127 B/lbm\n",
        "specific work  =  18598.0 ft-lb/lbm\n",
        "Heat added per pound of mixture  =  85.8 B/lbm\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.4, page no. 239"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "P = 14.7                        #lb/in^2\n",
      "T = 80+460.0                    #R\n",
      "\n",
      "#calculation\n",
      "#From steam tables\n",
      "Ps = 0.5069                     #lb/in^2\n",
      "v = 633.1                       #ft^3/lbm\n",
      "Pair = P-Ps\n",
      "vair = 53.3*T/(144*Pair)\n",
      "wair = 1/(1+vair/v)\n",
      "wwater = vair/v/(1+vair/v)\n",
      "\n",
      "#result\n",
      "print \"Partial pressure of air  =  \", round(Pair, 1), \"ft^3/lbm\"\n",
      "print \"Partial pressure of water vapor  =  \", Ps, \"ft^3/lbm\"\n",
      "print \"Gravimetric analysis of air  =  \", round(wair, 4)\n",
      "print \"Gravimetric analysis of water  = \", round(wwater, 4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Partial pressure of air  =   14.2 ft^3/lbm\n",
        "Partial pressure of water vapor  =   0.5069 ft^3/lbm\n",
        "Gravimetric analysis of air  =   0.9782\n",
        "Gravimetric analysis of water  =  0.0218\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.5, page no. 240"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "P = 14.7                            #lb/in^2\n",
      "T = 80+460.0                        #R\n",
      "M = 18\n",
      "Ps = 0.5069                         #lb/in^2\n",
      "\n",
      "#calculation\n",
      "Pair = P-Ps\n",
      "R = 1544/M\n",
      "v = R*T/(144*Ps)\n",
      "vair = 53.3*T/(144*Pair)\n",
      "wair = 1/(1+vair/v)\n",
      "wwater = vair/v/(1+vair/v)\n",
      "\n",
      "#result\n",
      "print \"Partial pressure of air  =  \", round(Pair, 2), \"ft^3/lbm\"\n",
      "print \"Specific volume = \", round(v), \"ft^3/lbm\"\n",
      "print \"Gravimetric analysis of air  = \", round(wair, 4)\n",
      "print \"Gravimetric analysis of water  =  \", round(wwater, 4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Partial pressure of air  =   14.19 ft^3/lbm\n",
        "Specific volume =  629.0 ft^3/lbm\n",
        "Gravimetric analysis of air  =  0.9781\n",
        "Gravimetric analysis of water  =   0.0219\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.6, page no. 242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "RH = 0.62\n",
      "T = 80+460.0                        #R\n",
      "\n",
      "#calculation\n",
      "#From stram tables\n",
      "P = RH*0.5069\n",
      "\n",
      "#result\n",
      "print \"Partial pressure of water vapor  = \", round(P, 4), \"lb/in^2\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Partial pressure of water vapor  =  0.3143 lb/in^2\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exmaple 12.7, page no. 243"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "P = 14.5                        #lb/in^2\n",
      "T = 70+460.0                    #R\n",
      "rh = 0.34\n",
      "\n",
      "#calculation\n",
      "#From steam tables\n",
      "Pg = 0.3631                     #lb/in^2\n",
      "Pair = P-Pg\n",
      "wratio = rh*0.622*Pg/Pair\n",
      "\n",
      "#result\n",
      "print \"Specific humidity  =  %.5f lbm/lbm\" %wratio"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific humidity  =  0.00543 lbm/lbm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exmaple 12.8, page no. 244"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "T = 100+460.0                       #R\n",
      "rh = 0.6\n",
      "\n",
      "#calculation\n",
      "#From steam tables\n",
      "Pg = 0.9492                         #lb/in^2\n",
      "Pwv = rh*Pg\n",
      "T = 83                              #F\n",
      "\n",
      "#result\n",
      "print \"Dew point is obtained from saturation pressure table and is equal to %d F\" %T"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dew point is obtained from saturation pressure table and is equal to 83 F\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.9, page no. 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "T1 = 80+460.0                       #R\n",
      "T2 = 90+460.0                       #R\n",
      "P = 14.5                            #lb/in^2\n",
      "cp = 0.24\n",
      "\n",
      "#calculation\n",
      "#From steam tables\n",
      "hg2 = 1096.6\n",
      "hf3 = 48.02\n",
      "Pg2 = 0.5069\n",
      "hf2 = hf3\n",
      "Pair = P-Pg2\n",
      "wg2 = 0.622*Pg2/Pair\n",
      "hgv1 = 1100.9\n",
      "wwv1 = (cp*(T1-T2)+wg2*(hg2-hf3))/(hgv1-hf3)\n",
      "Pg = 0.6982\n",
      "xi = wwv1*(P-Pg)/(Pg*0.622)\n",
      "\n",
      "#result\n",
      "print \"Specific humidity  =  \", round(wwv1, 4), \"lbm/lbm\"\n",
      "print \"relative humidity  =  \", round(xi, 3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific humidity  =   0.0202 lbm/lbm\n",
        "relative humidity  =   0.641\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.10, page no. 247"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialization\n",
      "T1 = 69.0                           #F\n",
      "T2 = 84.0                           #F\n",
      "P = 14.7                            #lb/in^2\n",
      "\n",
      "#calculation\n",
      "# from wet bulb n dry bulb temperature charts\n",
      "sh = 82.0/7000.0\n",
      "rh = 47.0\n",
      "Pwv = 0.27\n",
      "T = 62.0                            #F\n",
      "h = 33.3\n",
      "\n",
      "#result\n",
      "print \"Specific humidity  =  \", round(sh, 4), \"lbm/lbm\"\n",
      "print \"Relative  humidity  = \" , rh, \"%\"\n",
      "print \"Partial pressure  =  \", round(Pwv, 2), \"lb/in^2\"\n",
      "print \"Dew point  = \", T, \"F\"\n",
      "print \"Enthalpy per pound of air  = \", round(h, 1), \"V/lbm dry air\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific humidity  =   0.0117 lbm/lbm\n",
        "Relative  humidity  =  47.0 %\n",
        "Partial pressure  =   0.27 lb/in^2\n",
        "Dew point  =  62.0 F\n",
        "Enthalpy per pound of air  =  33.3 V/lbm dry air\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.11, page no. 250"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#initialization\n",
      "g1 = [0.489, 100, 700, 35.1, 0.154]\n",
      "g2 = [0.483, 15, 600, 55.2, 0.177]\n",
      "g3 = [0.028, 30, 500, 386, 0.754]\n",
      "\n",
      "#calculation\n",
      "v1 = g1[0] *g1[3] *g1[2] /(144*g1[1])\n",
      "v2 = g2[0] *g2[3] *g2[2] /(144*g2[1])\n",
      "v3 = g3[0] *g3[3] *g3[2] /(144*g3[1])\n",
      "vm = v1+v2+v3\n",
      "Tm = (g1[0] *g1[4] *g1[2] +g2[0] *g2[4] *g2[2] +g3[0] *g3[4] *g3[2])/(g1[0] *g1[4] +g2[0] *g2[4] +g3[0] *g3[4])\n",
      "Pm = (g1[0] *g1[3] +g2[0] *g2[3] +g3[0] *g3[3]) *Tm/(vm*144)\n",
      "ds1 = g1[0] *(g1[4] *math.log(Tm/g1[2]) +g1[3] /778.0 *math.log(vm/v1))\n",
      "ds2 = g2[0] *(g2[4] *math.log(Tm/g2[2]) +g2[3] /778.0 *math.log(vm/v2))\n",
      "ds3 = g3[0] *(g3[4] *math.log(Tm/g3[2]) +g3[3] /778.0 *math.log(vm/v3))\n",
      "ds = ds1+ds2+ds3\n",
      "\n",
      "#result\n",
      "print \"Pressure  =  \", round(Pm, 1), \"lb/in^2\"\n",
      "print \"Temperature  =  \", round(Tm), \"R\"\n",
      "print \"Entropy change  =  \", round(ds, 4), \"B/R\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure  =   25.2 lb/in^2\n",
        "Temperature  =   630.0 R\n",
        "Entropy change  =   0.0914 B/R\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.13, page no. 254"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "vdot1 = 8500.0         #cfm of air\n",
      "v1 = 12.775            #from chart\n",
      "wdot = vdot1/v1\n",
      "\n",
      "h2 = 20.3              #from chart\n",
      "h1 = 13.85             #from chart\n",
      "h4 = 29.0              #from chart\n",
      "h3 = 20.3              #from chart\n",
      "\n",
      "#Part a\n",
      "Q12 = h2 - h1\n",
      "Q12 = wdot*Q12\n",
      "print \"Capacity of preheater: \", round(Q12, 2), \"B/min\"\n",
      "\n",
      "#Part b\n",
      "Q34 = h4 - h3\n",
      "Q34 = wdot*Q34\n",
      "print \"Capacity of reheater: \", round(Q34, 2), \"B/min\"\n",
      "\n",
      "#Part c\n",
      "\n",
      "w2 = 20.0/7000.0     #from chart\n",
      "w3 = 54.0/7000.0     #from chart\n",
      "W = w3 - w2\n",
      "W = wdot*W\n",
      "print \"Rate of water addition: \", round(W, 2), \"lbm/min\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacity of preheater:  4291.59 B/min\n",
        "Capacity of reheater:  5788.65 B/min\n",
        "Rate of water addition:  3.23 lbm/min\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}