{
 "metadata": {
  "name": "",
  "signature": "sha256:af5e98897fdd6a212dc067e1708c75ce618fcbb9ad24c85104d033a4702b884e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 : Thermodynamic Properties of Pure Fluids"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.1 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#Given:\n",
      "betta = 1.25*10**-3; \t\t\t#coeffecient of math.expansion (K**-1)\n",
      "V = 0.1; \t\t\t#molar volume of organic liquid (m**3/kmol)\n",
      "P2 = 20.; \t\t\t#final pressure (bar)\n",
      "P1 = 1.; \t\t\t#initial pressure (bar)\n",
      "\n",
      "# Calculations\n",
      "#To determine the change in entropy of system\n",
      "#betta = (1/V)*(del V/del T)p\n",
      "#Let k = (del V/del T)p\n",
      "k = betta*V;\n",
      "\n",
      "#Considering Maxwell's relation Eq. 6.24 (Page no. 193)\n",
      "#dS = -k*(dP)\n",
      "S = -k*(P2-P1)*10**5; \t\t\t#entropy change (J/kmol K)\n",
      "\n",
      "# Results\n",
      "print 'Change in entropy is %f J/kmol K'%S\n",
      "print ' It is assumed that (del V/del T)p is constant in the pressure range 1 to 20 bar'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy is -237.500000 J/kmol K\n",
        " It is assumed that (del V/del T)p is constant in the pressure range 1 to 20 bar\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.2"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "T1 = 363.; \t\t\t#temperature (K)\n",
      "T2 = 373.; \t\t\t#temperature (K)\n",
      "P2 = 101.3; \t\t\t#vapour pressure at 373 K (kPa)\n",
      "H = 2275.*18; \t\t\t#mean heat of vaporisation (kJ/kmol)\n",
      "R =8.314; \t\t\t#ideal gas constant (kJ/kmol K)\n",
      "\n",
      "# Calculations\n",
      "#To calculate vapour pressure of water at 363 K\n",
      "#Using eq. 6.28 (Page no. 196)\n",
      "P1 = P2/(math.e**((H/R)*((1./T1)-(1./T2))))\n",
      "\n",
      "# Results\n",
      "print ' Vapour pressure of water at 363 K is %f kPa'%P1\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Vapour pressure of water at 363 K is 70.408579 kPa\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "d_l = 13.69*10**3; \t\t\t#density of mercury in liquid state (kg/m**3)\n",
      "d_s = 14.193*10**3; \t\t\t#density of mercury in solid state (kg/m**3)\n",
      "T1 = 234.33; \t\t\t#temperature in K\n",
      "P1 = 1.; \t\t\t#initial pressure in bar\n",
      "P2 = 10.; \t\t\t#final pressure in bar\n",
      "Hf = 9.7876; \t\t\t#heat of fusion of mercury (kJ/kg)\n",
      "\n",
      "# Calculations\n",
      "#Assuming del_V/del_H remains constant% math.log(T2/T1) = (del_V/del_H)*(P2-P1)\n",
      "del_V = (1./d_l)-(1./d_s)\n",
      "T2 = T1*(math.e**((del_V/Hf)*(P2-P1)))\n",
      "\n",
      "# Results\n",
      "print 'The melting point of mercury at 10 bar is %f K'%T2\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The melting point of mercury at 10 bar is 234.330558 K\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.4, page no:198"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T1 = 300.; \t\t\t#initial temperature (K)\n",
      "T2 = 800.; \t\t\t#final temperature (K)\n",
      "\n",
      "# Calculations\n",
      "#Heat capacity (J/mol K)\n",
      "#Cp = 26.04+(5.586*10**-3*T)+(28.476*10**4*T**-2)\n",
      "import math\n",
      "S = 26.04*math.log(T2/T1)+5.586*10**-3*(T2-T1)+28.476*10**4/(-2)*(T2**-2-T1**-2)\n",
      "\n",
      "# Results\n",
      "print 'The increase in entropy of solid magnesium is %f J/mol K'%S\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The increase in entropy of solid magnesium is 29.693325 J/mol K\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 773.; \t\t\t#temperature (K)\n",
      "P = 100.; \t\t\t#pressure (bar)\n",
      "Ho = 0; \t\t\t#enthalpy of nitrogen at 273 K and 1 bar\n",
      "So = 192.4; \t\t\t#entropy of nitrogen at 298 K and 1 bar\n",
      "To = 273.; \t\t\t#(K)\n",
      "Po = 1.; \t\t\t#(bar)\n",
      "R = 8.314; \t\t\t#ideal gas constant (kJ/kmol K)\n",
      "\n",
      "# Calculations\n",
      "#Cp = 27.3+(4.2*10**-3*T) molal heat capacity at 1 bar\n",
      "#To calculate internal energy enthalpy entropy and free energyfor one mole of nitrogen\n",
      "#Step 1:\n",
      "#Assuming that nitrogen is initially at 273 K and 1 bar\n",
      "#del_H1 = intg(CpdT)\n",
      "del_H1 = 27.3*(T-To)+4.2*10**-3*(T**2-To**2)/2;\n",
      "#Assuming that nitrogen is initially at 298 K and 1 bar\n",
      "#del_S1 = intg(Cp*(dT/T))\n",
      "del_S1 = 27.3*math.log(T/To)+4.2*10**-3*(T-To)\n",
      "H1 = Ho + del_H1;\n",
      "S1 = So + del_S1;\n",
      "\n",
      "#Step 2:\n",
      "#del_H2 = [V - T*(del_V/del_T)p]dP\n",
      "#Since nitrogen behaves as ideal gas\n",
      "#(del_V/del_T)p = R/P% V-(R*T)/P = 0\n",
      "del_H2 = 0.;\n",
      "del_S2 = -R*math.log(P/Po)\n",
      "H = H1 + del_H2;\n",
      "S = S1 + del_S2;\n",
      "\n",
      "#Internal energy: U = H-PV = H-RT (J/mol)\n",
      "U = H - (R*T)\n",
      "\n",
      "#Gibbs free energy (J/mol)\n",
      "G = H-(T*S)\n",
      "\n",
      "# Results\n",
      "print 'Enthalpy is %5.3e J/mol'%H\n",
      "print ' Entropy is %f J/mol K'%S\n",
      "print ' Internal energy is %4.3e J/mol'%U\n",
      "print ' Gibbs free energy is %4.3e J/mol'%G\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Enthalpy is 1.475e+04 J/mol\n",
        " Entropy is 184.626653 J/mol K\n",
        " Internal energy is 8.322e+03 J/mol\n",
        " Gibbs free energy is -1.280e+05 J/mol\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "#Equation of state: P(V-B) = RT + (A*P**2)/T\n",
      "Cp = 33.6; \t\t\t#mean specific heat at atmosheric pressure (J/mol K)\n",
      "A = 1*10**-3; \t\t\t#m**3 K/(bar)mol\n",
      "B = 8.0*10**-5; \t\t\t#m**3/mol\n",
      "R = 8.314*10**-5; \t\t\t#ideal gas constant (m**3 (bar)/mol K)\n",
      "\n",
      "import math\n",
      "#For step 1:\n",
      "Po = 4.; \t\t\t#pressure at A (bar)\n",
      "P1 = 1.; \t\t\t#pressure at C (bar)\n",
      "T = 300.; \t\t\t#temperature (K)\n",
      "\n",
      "# Calculations and Results\n",
      "#del_S1 = intg[(del_V/del_T)pdP]\n",
      "del_S1 = (R*math.log(Po/P1) - (A/T**2)*(Po**2-P1**2)/2)*10**5; \t\t\t#(J/mol K)\n",
      "\n",
      "#For step 2:\n",
      "T1 = 300.; \t\t\t#temperature at C (K)\n",
      "T2 = 400.; \t\t\t#temperature at D (K)\n",
      "del_S2 = Cp*math.log(T2/T1) \t\t\t#(J/mol K)\n",
      "\n",
      "#For step 3:\n",
      "P2 = 1.; \t\t\t#pressure at D (bar)\n",
      "P3 = 12.; \t\t\t#pressure at B (bar)\n",
      "T = 400.; \t\t\t#temperature (K)\n",
      "del_S3 = (R*math.log(P2/P3) - (A/T**2)*(P2**2-P3**2)/2)*10**5; \t\t\t#(J/mol K)\n",
      "S = del_S1+del_S2+del_S3; \t\t\t#total entropy change\n",
      "print '(a). Total entropy change is %f J/mol K'%S\n",
      "\n",
      "#(b). The mean heat capacity at 12 bar\n",
      "P1 = 4.; \t\t\t#pressure at A (bar)\n",
      "P2 = 12.; \t\t\t#pressure at Co (bar)\n",
      "T = 300.; \t\t\t#temperature (K)\n",
      "del_S1 = R*math.log(P1/P2) - (A/T**2)*(P1**2-P2**2)/2;\n",
      "\n",
      "#For CoB\n",
      "T2 = 400.; \t\t\t#temperature at B (K)\n",
      "T1 = 300.; \t\t\t#temperature at Co (K)\n",
      "del_S2 = S-del_S1;\n",
      "Cpm = del_S2/(math.log(T2/T1))\n",
      "print ' (b). The mean heat capacity at 12 bar is %f J/mol K'%Cpm\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). Total entropy change is 0.568609 J/mol K\n",
        " (b). The mean heat capacity at 12 bar is 1.976835 J/mol K\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "betta = 1.8*10**-4; \t\t\t#coeffecient of volume math.expansion (K**-1)\n",
      "k = 3.9*10**-6; \t\t\t#coeffecient of compressibility (bar**-1)\n",
      "T = 273.; \t\t\t#temperature in K\n",
      "d = 13.596*10**3; \t\t\t#density (kg/m**3)\n",
      "Cp = 0.14*10**3; \t\t\t#(J/kg K)\n",
      "\n",
      "# Calculations\n",
      "#To calculate Cv for mercury\n",
      "#Using equation 6.55 (Page no. 208)\n",
      "Cv = Cp - (betta**2*T*10**5)/(k*d)\n",
      "\n",
      "# Results\n",
      "print 'Cv for mercury is %f J/kg K'%Cv\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cv for mercury is 123.318623 J/kg K\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "#Eqution of state: P(V-b) = RT\n",
      "P = 10.; \t\t\t#pressure (bar)\n",
      "T = 298.; \t\t\t#temperature (K)\n",
      "b = 3.707*10**-5; \t\t\t#Vander Waal's constant (m**3/mol)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "# Calculations\n",
      "#To estimate the fugacity of ammonia\n",
      "#Since PV = RT + Pb% Z = 1 + (Pb/RT)\n",
      "#Using equation 6.127 (Page no. 228)\n",
      "f = P*(math.e**((b*P*10**5)/(R*T)))\n",
      "\n",
      "# Results\n",
      "print 'Fugacity f = %f bar'%f\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity f = 10.150747 bar\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "#intg(alphadP) = -556.61 J/mol\n",
      "P = 50.; \t\t\t#pressure in bar\n",
      "T = 300.; \t\t\t#temperature in K\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "# Calculations\n",
      "#To determine the fugacity of gas\n",
      "#Using equation 6.130 (Page no. 230)\n",
      "f = P*math.e**(-556.61/(R*T))\n",
      "\n",
      "# Results\n",
      "print 'Fugacity of gas at 50 bar and 300 K is %i bar'%f\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity of gas at 50 bar and 300 K is 39 bar\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "#Equation of state: PV = RT(1-0.00513P)\n",
      "P = [1, 5, 10]; \t\t\t#pressures in bar\n",
      "phi = [0,0,0]\n",
      "\n",
      "# Calculations and Results\n",
      "for i in range(3):\n",
      "    phi[i] = math.e**(-0.00513*P[i])\n",
      "    print ' Fugacity coeffecient at %i bar is %f'%(P[i],phi[i])\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Fugacity coeffecient at 1 bar is 0.994883\n",
        " Fugacity coeffecient at 5 bar is 0.974676\n",
        " Fugacity coeffecient at 10 bar is 0.949994\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "P = 100.; \t\t\t#pressure in bar\n",
      "T = 373.; \t\t\t#temperature in K\n",
      "a = 0.453; \t\t\t#Vander Waal's constant (J m**3/mol**2)\n",
      "b = 0.571*10**-4; \t\t\t#Vander Waal's constant (m**3/mol)\n",
      "V = 2.072*10**-4; \t\t\t#molar volume (m**3/mol)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "# Calculations\n",
      "#To determine the fugacity of pure ethylene\n",
      "#Using eq. 6.139 (Page no. 233)\n",
      "ln_f = (b/(V-b)) - ((2*a)/(R*T*V)) + math.log((R*T*10**-5)/(V-b) )\n",
      "f = math.e**ln_f;\n",
      "\n",
      "# Results\n",
      "print 'Fugacity is %f bar'%f\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity is 73.789328 bar\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 623.; \t\t\t#temperature in K\n",
      "\n",
      "#Data from steam tables:\n",
      "H = 3159.; \t\t\t#enthalpy at 1000 kPa and 623 K (kJ/kg)\n",
      "S = 7.3; \t\t\t#entropy at 1000 kPa and 623 K (kJ/kg K)\n",
      "Ho = 3176.; \t\t\t#enthalpy at 101.3 kPa and 623 K (kJ/kg)\n",
      "So = 8.38; \t\t\t#entropy at 101.3 kPa and 623 K (kJ/kg K)\n",
      "fo = 101.3; \t\t\t#fugacity at 101.3 kPa (kPa)\n",
      "R = 8.314/18; \t\t\t#ideal gas consatnt (kJ/kg K)\n",
      "\n",
      "# Calculations\n",
      "#To determine fugacity and fugacity coeffecient of steam\n",
      "ln_phi = (1/(R*T))*((H-Ho)-T*(S-So))\n",
      "f = fo*math.e**ln_phi;\n",
      "phi = f/fo;\n",
      "\n",
      "# Results\n",
      "print 'Fugacity of steam is %f bar'%(f/100)\n",
      "print ' Fugacity coeffecient is %f'%phi\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity of steam is 9.895333 bar\n",
        " Fugacity coeffecient is 9.768345\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 473.; \t\t\t#temperature in K\n",
      "P = 50.*10**5; \t\t\t#pressure in Pa\n",
      "d = 24.3; \t\t\t#density of ammonia (kg/m**3)\n",
      "m = 17.; \t\t\t#molecular wt of ammonia\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "# Calculations\n",
      "#To estimate the fugacity of ammonia\n",
      "V = m/(d*1000) \t\t\t#molar volume of ammonia (m**3/kmol)\n",
      "#Using eq. 6.142 (Page no. 234)\n",
      "f = (V*(P**2))/(R*T)\n",
      "\n",
      "# Results\n",
      "print 'The fugacity of ammonia is %f bar'%(f/10**5)\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The fugacity of ammonia is 44.474543 bar\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 303.; \t\t\t#temperature in K\n",
      "P = 10.; \t\t\t#pressure in bar\n",
      "Ps = 4.241/100; \t\t\t#saturation pressure (bar)\n",
      "sp_vol = 1.004 *10**-3; \t\t\t#specific volume at 303 K (m**3/kg)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "# Calculations\n",
      "#To calculate the fugacity of liquid water\n",
      "V = sp_vol*10**-3*18; \t\t\t#molar volume (m**3/mol)\n",
      "#Assuming vapour behaves as an ideal gas\n",
      "f_sat = Ps;\n",
      "#Using Eq. 6.144 (Page no. 235)\n",
      "ln_phi = (V/(R*T))*(P-Ps)*10**5;\n",
      "f = f_sat*math.e**ln_phi;\n",
      "\n",
      "# Results\n",
      "print 'Fugacity of liquid water at given conditions is %f bar'%f\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity of liquid water at given conditions is 0.042714 bar\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 350.; \t\t\t#temperature in K\n",
      "P = 60.; \t\t\t#pressure in bar\n",
      "Ps = 9.35; \t\t\t#vapour pressure at 350 K (bar)\n",
      "V = 0.1072*10**-3; \t\t\t#molar volume (m**3/mol\n",
      "phi = 0.834; \t\t\t#fugacity coeffecient\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "import math\n",
      "\n",
      "# Calculations\n",
      "#To determine fugaity of n butane in liquid state at given conditions\n",
      "f_sat = phi*Ps;\n",
      "#Using eq. 6.144 (Page no. 235)\n",
      "ln_phi = (V/(R*T))*(P-Ps)*10**5;\n",
      "f = f_sat*math.e**ln_phi;\n",
      "\n",
      "# Results\n",
      "print 'Fugacity of n-butane in liquid state at given conditions is %f bar'%f\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fugacity of n-butane in liquid state at given conditions is 9.397539 bar\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "M = 24.32; \t\t\t#molecular wt of solid magnesium\n",
      "T = 300.; \t\t\t#temperature in K\n",
      "P = 10.; \t\t\t#pressure in bar\n",
      "Po = 1.; \t\t\t#reference state pressure (bar)\n",
      "R = 8.314\n",
      "d = 1.745*10**3; \t\t\t#density of Mg at 300 K in kg/m**3\n",
      "\n",
      "# Calculations\n",
      "#To determine the ativity of solid magnesiun\n",
      "#Using eq. 6.149 (Page no. 237)\n",
      "ln_a = (M/(d*10**3*R*T))*(P-Po)*10**5;\n",
      "a = (math.e)**ln_a;\n",
      "\n",
      "# Results\n",
      "print 'Acivity of solid magnesium at 300 K and 10 bar is %f'%a\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acivity of solid magnesium at 300 K and 10 bar is 1.005042\n"
       ]
      }
     ],
     "prompt_number": 34
    }
   ],
   "metadata": {}
  }
 ]
}