{
 "metadata": {
  "name": "",
  "signature": "sha256:c896c859a24a6b70446a5e83cded412ac42718005bc7d2e546816e8274c18e21"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 19 : The Phase Rule and Vapor Liquid Equilibria"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 19.1  Page No. 563\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "N1 = 1.;\n",
      "P1 = 1. ;\t\t\t# Number of phases present\n",
      "C1 = 1. ;\t\t\t#Number of components present\n",
      "F1 = 2.-P1+C1 ;\t\t\t#Number of degree of freedom\n",
      "print ' (a) Number of degree of freedom of pure benzene is %i.\\n Therefore %i additional \\\n",
      "intensive variables must be specified to fix to fix the system.'%(F1,F1)\n",
      "\n",
      "\t\t\t# (b)\n",
      "N2 = 1.;\n",
      "P2 = 2. ;\t\t\t# Number of phases present\n",
      "C2 = 1. ;\t\t\t#Number of components present\n",
      "F2 = 2.-P2+C2 ;\t\t\t#Number of degree of freedom\n",
      "print '(b) Number of degree of freedom of a mixture of ice and water only is %i.\\\n",
      " \\nTherefore %i additional intensive variables must be specified to fix the system. '%(F2,F2)\n",
      "\n",
      "\t\t\t# (c)\n",
      "N3 = 2.;\n",
      "P3 = 2. ;\t\t\t# Number of phases present\n",
      "C3 = 2. ;\t\t\t#Number of components present\n",
      "F3 = 2.-P3+C3 ;\t\t\t#Number of degree of freedom\n",
      "print '(c) Number of degree of freedom of a mixture of liquid benzene,benzene vapour and\\\n",
      " helium gas is %i. \\nTherefore %i additional intensive variables must be specified to fix the system. '%(F3,F3)\n",
      "\n",
      "\t\t\t# (d)\n",
      "N4 = 2.;\n",
      "P4 = 2. ;\t\t\t# Number of phases present\n",
      "C4 = 2. ;\t\t\t#Number of components present\n",
      "F4 = 2.-P4+C4 ;\t\t\t#Number of degree of freedom\n",
      "print '(d) Number of degree of freedom of a mixture of salt and water designed to achieve\\\n",
      " a specific vapour pressure is %i. \\nTherefore %i additional intensive variables must be\\\n",
      "  specified to fix the system. '%(F4,F4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " (a) Number of degree of freedom of pure benzene is 2.\n",
        " Therefore 2 additional intensive variables must be specified to fix to fix the system.\n",
        "(b) Number of degree of freedom of a mixture of ice and water only is 1. \n",
        "Therefore 1 additional intensive variables must be specified to fix the system. \n",
        "(c) Number of degree of freedom of a mixture of liquid benzene,benzene vapour and helium gas is 2. \n",
        "Therefore 2 additional intensive variables must be specified to fix the system. \n",
        "(d) Number of degree of freedom of a mixture of salt and water designed to achieve a specific vapour pressure is 2. \n",
        "Therefore 2 additional intensive variables must be  specified to fix the system. \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 19.2  Page No.564\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "N1 = 5.;\n",
      "P1 = 1.; \t\t\t# Number of phases present,here 1 gas \n",
      "C1 = 3. ;\t\t\t#Number of  independent components present,here 3 because 3 elements(C,O and H)\n",
      "F1 = 2-P1+C1 ;\t\t\t#Number of degree of freedom\n",
      "print ' (a) Number of degree of gas composed of CO,CO2,H2,H2O and CH4 is %i. \\n \\\n",
      "Therefore %i additional intensive variables must be specified to fix the system. '%(F1,F1)\n",
      "\n",
      "# (b)\n",
      "N2 = 4.;\n",
      "P2 = 4. ;\t\t\t# Number of phases present,here 3 different solid phases and 1 gas phase\n",
      "C2 = 3. ;\t\t\t#Number of components present, here 3 because 3 elements(Zn,O and C) ,you can also use method explained \n",
      "                    #in Appendix L1\n",
      "F2 = 2.-P2+C2 ;\t\t#Number of degree of freedom\n",
      "print '(b) Number of degree of freedom of a mixture of ZnO(s), C(s) ,CO(g) and Zn(s)  is %i. \\n \\\n",
      "Therefore %i additional intensive variables must be specified to fix the system. '%(F2,F2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " (a) Number of degree of gas composed of CO,CO2,H2,H2O and CH4 is 4. \n",
        " Therefore 4 additional intensive variables must be specified to fix the system. \n",
        "(b) Number of degree of freedom of a mixture of ZnO(s), C(s) ,CO(g) and Zn(s)  is 1. \n",
        " Therefore 1 additional intensive variables must be specified to fix the system. \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 19.3 Page No :576"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.optimize import fsolve\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "P_atm =  1. ;\t\t\t#[atm]\n",
      "P =  760. ;\t\t\t#[mm of Hg]\n",
      "x_1 = 4./100 ;\t\t\t# Mole fraction of hexane in liquid phase\n",
      "# Constant A,B and C for Antoine eqn. of n_hexane \n",
      "A1 = 15.8366;\n",
      "B1 = 2697.55 ;\n",
      "C1 = -48.784;\n",
      "# Constant A,B and C for Antoine eqn. of n_octane\n",
      "A2 = 15.9798;\n",
      "B2 = 3127.60 ;\n",
      "C2 = -63.633;\n",
      "\n",
      "# Calculations\n",
      "# Solve for bubble point temperature by eqn. obtained by using Antoine equation\n",
      "def f(T):\n",
      "    return math.exp(A1-(B1/(C1+T)))*x_1 + math.exp(A2-(B2/(C2+T)))*(1-x_1)  - P\n",
      "T = fsolve(f,390)[0] ;\t\t\t# Bubble point temperature \n",
      "\n",
      "print 'Bubble point temperature is %.1f K'%T\n",
      "\n",
      "# Composition of first vapour\n",
      "# Get vapour pressure of hexane and octane from Perry, it is\n",
      "vp_1 =  3114. ;\t\t\t#  vapour pressure of hexane-[mm of Hg]\n",
      "vp_2 = 661. ;\t\t\t#  vapour pressure of octane-[mm of Hg]\n",
      "y_1 = vp_1*x_1/P ;\t\t\t# Mole fraction of hexane in vapour phase\n",
      "y_2 =  1- y_1 ;\t\t\t#Mole fraction of octane in vapour phase\n",
      "\n",
      "# Results\n",
      "print ' Composition of first vapour. '\n",
      "print 'Component            Mole fraction. '\n",
      "print 'n_hexane             %.3f'%y_1\n",
      "print ' n_octane             %.3f'%y_2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Bubble point temperature is 393.6 K\n",
        " Composition of first vapour. \n",
        "Component            Mole fraction. \n",
        "n_hexane             0.164\n",
        " n_octane             0.836\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 19.4  Page no. 577"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "# Basis : 100 g solution\n",
      "F = 100. ;\t\t\t# Amount of solution-[g]\n",
      "P_atm = 1. ;\t\t\t#[atm]\n",
      "P = 760. ;\t\t\t# Total pressure -[mm of Hg]\n",
      "wf_hex = 68.6/100 ;\t\t\t#Weight fraction of hexane in  mixture\n",
      "wf_tol = 31.4/100 ;\t\t\t#Weight fraction of toluene in  mixture\n",
      "mw_hex = 86.17 ;\t\t\t# Mol.wt. of hexane-[g]\n",
      "mw_tol = 92.13 ;\t\t\t# Mol.wt. of toluene-[g]\n",
      "\n",
      "# Calculations\n",
      "mol_hex = wf_hex *F/mw_hex ;\t\t\t# moles of hexane-[g mol]\n",
      "mol_tol = wf_tol*F/mw_tol ;\t\t\t    # moles of toluene-[g mol]\n",
      "mol_total = mol_hex + mol_tol ;\t\t\t# Total moles in mixture-[g mol]\n",
      "molf_hex = mol_hex/mol_total ;\t\t\t# Mole fraction of hexane \n",
      "molf_tol = mol_tol/mol_total ;\t\t\t# Mole fraction of toluene \n",
      "# Get vapour pressure of hexane and toluene at 80 deg. C from Perry, it is\n",
      "vp_hex = 1020. ;\t\t\t#  vapour pressure of hexane-[mm of Hg]\n",
      "vp_tol = 290.  ;\t\t\t#  vapour pressure of toluene-[mm of Hg]\n",
      "K_hex = vp_hex/P ;\t\t\t# K-value of hexane\n",
      "K_tol = vp_tol/P  ;\t\t\t# K-value of toluene\n",
      "rec_K_hex = 1/K_hex ;\t\t\t# Reciprocal of K-value of hexane\n",
      "rec_K_tol = 1/K_tol ;\t\t\t# Reciprocal of K-value of toluene\n",
      "\n",
      "# Let L/F = x, then use eqn. 19.11 to find x(L/F) \n",
      "def g(x):\n",
      "    return (molf_hex)/(1-x*(1-rec_K_hex)) + (molf_tol)/(1-x*(1-rec_K_tol))-1\n",
      "\n",
      "x = fsolve(g,1)[0] ;\t\t\t# L/F value\n",
      "\n",
      "# Results\n",
      "print ' Fraction of liquid(L/F) that will remain at equilibrium after vaporization is %.3f. '%x\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Fraction of liquid(L/F) that will remain at equilibrium after vaporization is 0.744. \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 19.5  Page no. 578\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Vo = 3.0 ;\t\t\t# Initial volume of the solution containing the culture and virus-[L]\n",
      "Vp = 0.1 ;\t\t\t# Volume of the polymer solution added to the vessel -[L]\n",
      "Kpc = 100. ;\t\t\t# Partition coefficient for virus(cp/cc) between two phases\n",
      "\n",
      "# Calculations\n",
      "Vc = Vo ;\t\t\t# At equilibrium -[L]\n",
      "cp_by_co = Vo/(Vp+(Vo/Kpc)) ;\t\t\t\n",
      "Fr_rec = cp_by_co*(Vp/Vo) ;\t\t\n",
      "\n",
      "# Results\n",
      "print ' Fraction of the initial virus in the culture phase that is recovered in the polymer phase  is %.2f . '%Fr_rec\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Fraction of the initial virus in the culture phase that is recovered in the polymer phase  is 0.77 . \n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}