{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 : Phase Equilibia 2 Fugacity"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1  Page No : 397"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "# Variables\n",
      "h_cap_H2O = 2676.0 ; \t\t\t#[kJ/kg],From steam table\n",
      "S_cap_H2O = 7.3548 ; \t\t\t#[kJ/kgK],From steam table\n",
      "h_cap_0_H2O = 2687.5 ; \t\t\t#[kJ/kg],From Appendix B\n",
      "S_cap_0_H2O = 8.4479 ; \t\t\t#[kJ/kgK],From Appendix B\n",
      "P_0_H2O = 10. ;\t\t\t#[kPa]\n",
      "T = 373.15 ;\t\t\t#[K]\n",
      "R = 8.314 / 18 ;\n",
      "P_sys = 101.35 ;\t\t\t#[kPa]\n",
      "\n",
      "# Calculations\n",
      "g_cap_H2O = h_cap_H2O - T * S_cap_H2O ;\n",
      "g_cap_0_H2O = h_cap_0_H2O - T * S_cap_0_H2O ;  \n",
      "\n",
      "f_H2O = P_0_H2O * math.exp((g_cap_H2O - g_cap_0_H2O ) / (R * T)) ;\n",
      "\n",
      "Sai_H2O = f_H2O / P_sys ;\n",
      "\n",
      "\n",
      "# Results\n",
      "print \"The fugacity = %.2f kPa  The fugacity coefficient = %.3f\"%(f_H2O,Sai_H2O);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The fugacity = 99.73 kPa  The fugacity coefficient = 0.984\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3  Page No : 402"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "P = 50.      \t\t\t#[bar]\n",
      "T = 25. + 273.2\t\t\t#[K]\n",
      "P_c = 48.7 ; \t\t\t#[bar] , From Appendix A.1 Table C.7 & C.8\n",
      "T_c = 303.5 ; \t\t\t#[K] , From Appendix A.1 Table C.7 & C.8\n",
      "w = 0.099 ; \t\t\t# From Appendix A.1 Table C.7 & C.8\n",
      "log_w_0 = -0.216 ;\t\t\t# By interpolation\n",
      "log_w_1 = -0.060 ;\t\t\t# By interpolation\n",
      "\n",
      "# Calculations\n",
      "X = log_w_0 + w * log_w_1 ;\n",
      "sai_eth = 10**(X) ;\n",
      "f_eth = sai_eth * P ;\n",
      "\n",
      "# Results\n",
      "print \"Fugacity = %.f bar\"%(f_eth);\n",
      " \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity = 30 bar\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10  Page No : 435"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "import math\n",
      "gama_a_inf = 0.88 ;\n",
      "gama_b_inf = 0.86 ;\n",
      "R =  8.314 ;\n",
      "T = 39.33 + 273 ;\n",
      "\n",
      "# Calculations\n",
      "A_1 = R * T * math.log(gama_a_inf) ;\n",
      "A_2 = R * T * math.log(gama_b_inf) ;\n",
      "A = (A_1 + A_2) / 2 ;\n",
      "\n",
      "# Results\n",
      "print \"The average value of two-suffix Margules parameter A = %.f J/mol\"%(A);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The average value of two-suffix Margules parameter A = -362 J/mol\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.13  Page No : 448"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "A_T1 = 1401. ; \t\t\t#[J/mol]\n",
      "T1 = 10 + 273. ;\t\t\t#[K]\n",
      "T2 = 60 + 273. ; \t\t\t#[K]\n",
      "C = 3250. ;\n",
      "A_T2_prev = 1143. ;\t\t\t#[J/mol]\n",
      "\n",
      "# Calculations and Results\n",
      "A_T2 = T2 * (C *(1./T2 - 1./T1) + A_T1 / T1);\n",
      "print \"Value of A at 60*C = %.f J/mol\"%(A_T2) ;\n",
      "\n",
      "x = (A_T2_prev - A_T2) / A_T2_prev* 100 ;\n",
      "print \"The values differ by = %.f %%\"%(x)\n",
      "\n",
      "# Note: Answer may vary because of rounding off error. "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of A at 60*C = 1074 J/mol\n",
        "The values differ by = 6 %\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}