{ "metadata": { "name": "", "signature": "sha256:8d10c3a8d696216084bffc2404a32e0b3c15831ac555c05fcb7016ab7d75d0e7" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 3 : PvT relations of fluids" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.1 Page No : 48" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "X = 0.8; \t\t\t #Quality of wet steam (no unit)\n", "T = 150.;\t \t\t #Temperature of the wet steam in degree celsius\n", "vf = 0.0010908;\t\t\t #molar volume of saturated liquid in m**3/kg\n", "vg = 0.3924;\t\t\t #molar volume of saturated vapour in m**3/kg\n", "uf = 631.63;\t\t\t #molar internal energy of the saturated liquid in kJ/kg\n", "ug = 2558.6;\t\t\t #molar internal energy of the saturated vapour in kJ/kg\n", "\n", "# Calculations\n", "V = (X*vg)+((1-X)*vf);\t\t\t # Calculations of specific volume in m**3/kg using Eq.(3.3)\n", "U = (X*ug)+((1-X)*uf);\t\t\t # Calculations of specific internal energy in kJ/kg using Eq.(3.6)\n", "\n", "# Results\n", "print 'The specific volume of wet steam = %0.4f m**3/kg '%(V);\n", "print 'The specific internal energy of wet steam = %0.1f kJ/kg '%(U);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The specific volume of wet steam = 0.3141 m**3/kg \n", "The specific internal energy of wet steam = 2173.2 kJ/kg \n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.2 Page No : 49" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "V = 1.42;\t\t\t #specific volume of wet steam in m**3/kg\n", "T = 100.;\t\t\t #temperature of wet steam in degree celsius\n", "vf = 0.0010437;\t\t #molar volume of saturated liquid in m**3/kg\n", "vg = 1.673;\t\t\t #molar volume of saturated vapour in m**3/kg\n", "\n", "# Calculations\n", "X = (V-vf)/(vg-vf);\t\t\t # Calculations of the quality of wet steam using Eq.(3.3) (no unit)\n", "\n", "# Results\n", "print ' The quality of wet steam = %0.4f '%(X);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The quality of wet steam = 0.8487 \n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.3 Page No : 49" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "T = 100.;\t\t\t #temperature inside the vessel in degree celsius\n", "V = 0.00317;\t\t\t #specific volume of water at the critical point in m**3/kg\n", "vf = 0.0010437;\t\t\t #molar volume of saturated liquid in m**3/kg\n", "vg = 1.673;\t\t\t #molar volume of saturated vapour in m**3/kg\n", "\n", "# Calculations\n", "X = (V-vf)/(vg-vf);\t\t\t # Calculations of the quality of wet steam using Eq.(3.3) (no unit)\n", "ratio = (X*vg)/((1-X)*vf);\t\t\t # Calculations of volume ratio of saturated vapour to the saturated liquid (no unit)\n", "\n", "# Results\n", "print ' The volume ratio of saturated vapour to the saturated liquid = %0.2f '%(ratio);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume ratio of saturated vapour to the saturated liquid = 2.04 \n" ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.4 Page No : 49" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "U = 2000.\t\t\t #specific internal energy of liquid-vapour mixture in kJ/kg\n", "uf = 850.6\t\t\t #specific internal energy of saturated liquid in kJ/kg\n", "ug = 2593.2\t\t\t #specific internal energy of saturated vapour in kJ/kg\n", "\n", "# Calculations\n", "mass_ratio = (U-uf)/(ug-U);\t\t\t # Calculations of the mass ratio of vapour to liquid using the lever rule (no unit)\n", "\n", "# Results\n", "print ' The mass ratio of vapour to liquid = %0.4f '%(mass_ratio);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The mass ratio of vapour to liquid = 1.9376 \n" ] } ], "prompt_number": 5 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.5 Page No : 52" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "n = 1.\t\t\t #number of moles of n-octane vapour in mol\n", "T = 427.85;\t\t\t #tempearture of n-octane vapour in K\n", "P = 0.215;\t\t\t #pressure n-octane vapour in MPa\n", "R = 8.314;\t\t\t #universal gas constant in (kPa m**3)/(kmol K)\n", "\n", "# Calculations\n", "V = ((n*10**-3)*R*T)/(P*10**3);\t\t\t # Calculations of volume using ideal gas law-Eq.(3.9) in m**3\n", "\n", "# Results\n", "print ' The volume occupied by n-octane vapour = %f m**3 '%(V);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane vapour = 0.016545 m**3 \n" ] } ], "prompt_number": 6 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.6 Page No : 54" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "n = 1.; \t\t\t #number of moles occupied by n-octane vapour in mol\n", "T = 427.85;\t\t\t #temperature in K\n", "P = 0.215;\t\t\t #saturation pressure in MPa\n", "a = 3.789;\t\t\t #van der Waals constant in Pa(m**3/mol)**2\n", "b = 2.37*10**-4;\t #van der Waals constant in m**3/mol\n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "\n", "# Calculations\n", "Vguess = (n*R*T)/(P*10**6);\t\t\t \n", "Vnew = (R*T)/((P*10**6)+(a/Vguess**2))+b\n", "tolerance = 1e-6\n", "\n", "while abs(Vguess-Vnew)>tolerance:\n", " Vguess = Vnew;\n", " Vnew = (R*T)/((P*10**6)+(a/Vguess**2))+b;\t\t\t #the iteration process to solve the system of equation\n", "\n", "V = Vnew;\t\t\t #The volume calculated using the van der Waals equation in m**3/mol\n", "\n", "# Results\n", "print ' The volume occupied by n-octane vapour obtained by van der Waals equation = %f m**3/mol'%(V);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane vapour obtained by van der Waals equation = 0.015675 m**3/mol\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.7 Page No : 55" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "n = 1.; \t\t\t #number of moles occupied by n-octane liquid in mol\n", "T = 427.85;\t\t\t #temperature in K\n", "P = 0.215;\t\t\t #saturation pressure in MPa\n", "a = 3.789;\t\t\t #van der Waals constant in Pa(m**3/mol)**2\n", "b = 2.37*10**-4;\t\t\t #van der Waals constant in m**3/mol\n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "\n", "# Calculations\n", "Vguess = b\n", "Vnew = (R*T)/((P*10**6)+(a/Vguess**2))+b\n", "tolerance = 1e-6\n", "while abs(Vguess-Vnew)>tolerance:\n", " Vguess = Vnew;\n", " Vnew = (R*T)/((P*10**6)+(a/Vguess**2))+b;\t\t\t #the iteration process to solve the system of equation\n", "\n", "V = Vnew;\t\t\t #The volume calculated using the van der Waals equation in m**3/mol\n", "\n", "# Results\n", "print ' The volume occupied by n-octane liquid obtained by van der Waals equation = %e m**3/mol'%(V);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane liquid obtained by van der Waals equation = 3.517652e-04 m**3/mol\n" ] } ], "prompt_number": 9 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.8 Page No : 57" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "import math\n", "\n", "# Variables\n", "T = 427.85; \t\t \t #temperature in K\n", "P = 0.215;\t \t\t #saturation pressure in MPa\n", "a = 3.789;\t\t \t #van der Waals constant in Pa(m**3/mol)**2\n", "b = 2.37*10**-4;\t\t\t #van der Waals constant in m**3/mol\n", "R = 8.314;\t\t \t #universal gas constant in (Pa m**3)/(mol K)\n", "Pcvc = 3\n", "RTc = 8.\n", "# Calculations\n", "#The Cardan's method simplifies the equation of state into a cubic equation which can be solved easily\n", "#The general form of the cubic equation is (Z**3)+(alpha*Z**2)+(beeta*Z)+gaamma = 0, where alpha,beeta and gaamma are determined using established relations\n", "\n", "A = (a*P*10**6)/(R*T)**2;\t\t\t\n", "B = (b*P*10**6)/(R*T);\t\t\t \n", "alpha = -1-B;\t\t\t \n", "beeta = A;\t\t\t \n", "gaamma = -(A*B);\t\n", "p = round(beeta-(alpha**2)/3,4)\n", "q = round(((2*alpha**3)/27)-((alpha*beeta)/3)+gaamma,4)\n", "D = (q**2/4)+(p**3/27);\t\n", "\n", "\n", "if D>0 :\n", " Z = ((-q/2)+(math.sqrt(D)))**(1./3)+((-q/2)-(math.sqrt(D)))**(1./3)-(alpha/3);\n", " vf = ((Z)*R*T)/(P*10**6);\t\t\n", " vg = ((Z)*R*T)/(P*10**6);\t\t\n", "elif D == 0:\n", " Z1 = ((-2*(q/2))**(1./3))-(alpha/3);\t\n", " Z2 = ((q/2)**(1./3))-(alpha/3);\n", " Z3 = ((q/2)**(1./3))-(alpha/3);\n", " Z = [Z1 ,Z2, Z3];\n", " vf = (min(Z)*R*T)/(P*10**6)\n", " vg = (max(Z)*R*T)/(P*10**6)\n", "else:\n", " r = math.sqrt((-(p**3)/27));\t\t\t # Calculations of r using Eq.(3.38)\n", " theta = math.cos((-(q)/2)*(1./r));\t\t\t # Calculations of theta in radians using Eq.(3.37)\n", " Z1 = (2*(r**(1./3))*math.cos(theta/3))-(alpha/3);\n", " Z2 = (2*(r**(1./3))*math.cos(((2*math.pi)+theta)/3))-(alpha/3);\t\t\t #Three unequal real roots given by Eqs.(3.34,3.35 and 3.36)\n", " Z3 = (2*(r**(1./3))*math.cos(((4*math.pi)+theta)/3))-(alpha/3);\n", " Z = [Z1, Z2, Z3];\n", " vf = (min(Z)*R*T)/(P*10**6)\n", " vg = (max(Z)*R*T)/(P*10**6)\n", "\n", "crit = Pcvc/RTc \n", "\n", "# Results\n", "print ' The volume occupied by n-octane saturated liquid obtained by Cardans method = %.3e m**3/mol'%(vf);\n", "print ' The volume occupied by n-octane saturated vapour obtained by Cardans method = %.2e m**3/mol'%(vg);\n", "print \" At the critical point, PcVc/RTc = %.3f\"%crit\n", "\n", "# Note: value of D is calculated wrongly in book. Please calculate manually." ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane saturated liquid obtained by Cardans method = -9.345e-04 m**3/mol\n", " The volume occupied by n-octane saturated vapour obtained by Cardans method = 1.55e-02 m**3/mol\n", " At the critical point, PcVc/RTc = 0.375\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.9 Page No : 60" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from numpy import *\n", "import math\n", "\n", "# Variables\n", "T = 427.85;\t\t\t #temperature in K\n", "P = 0.215;\t\t\t #saturation pressure in MPa\n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "Pc = 24.97;\t\t\t #critical pressure of n-octane in bar\n", "Tc = 569.4;\t\t\t #critical temperature of n-octane in K\n", "\n", "# Calculations\n", "a = (0.42748*R**2*Tc**2.5)/(Pc*100*10**3*math.sqrt(T));\t\t\t \n", "b = (0.08664*R*Tc)/(Pc*100*10**3);\t\t\t\n", "\n", "\n", "A = (a*P*10**6)/(R*T)**2;\t\t\t \n", "B = (b*P*10**6)/(R*T);\n", "alpha = -1.;\t\t\t\n", "beeta = A-B-B**2.;\t\n", "gaamma = -(A*B);\t\n", "p = beeta-(alpha**2)/3.\n", "q = ((2*alpha**3.)/27.)-((alpha*beeta)/3)+gaamma\n", "D = (((q)**2)/4.)+(((p)**3)/27.);\t\t\t \n", "#if D>0 then:\n", " # Z = ((-q/2)+(math.sqrt(D)))**(1./3)+((-q/2)-(math.sqrt(D)))**(1./3)-(alpha/3)\n", " # vf = ((Z)*R*T)/(P*10**6)\n", " # vg = ((Z)*R*T)/(P*10**6)\n", "#elif D == 0:\n", " # Z1 = ((-2*(q/2))**(1./3))-(alpha/3);\n", " # Z2 = ((q/2)**(1./3))-(alpha/3);\n", " # Z3 = ((q/2)**(1./3))-(alpha/3);\n", " # Z = [Z1 ,Z2, Z3];\n", " # vf = (min(Z)*R*T)/(P*10**6);\t\t\n", " # vg = (max(Z)*R*T)/(P*10**6);\t\t\n", "#else:\n", "\n", "r = math.sqrt((-(p**3)/27));\t\t\t\n", "theta = (math.acos((-(q)/2)*(1./r)));\n", "Z1 = (2*(r**(1./3))*math.cos(theta/3))-(alpha/3);\n", "Z2 = (2*(r**(1./3))*math.cos(((2*math.pi)+theta)/3))-(alpha/3);\t\n", "Z3 = (2*(r**(1./3))*math.cos(((4*math.pi)+theta)/3))-(alpha/3);\n", "Z = [Z1, Z2, Z3];\n", "vf = (min(Z)*R*T)/(P*10**6);\t\t\n", "vg = (max(Z)*R*T)/(P*10**6);\t\t\n", "\n", "# Results\n", "print ' The volume occupied by n-octane saturated vapour) using Redlich-Kwong equation of state = %f m**3/mol'%(vg);\n", "print ' The volume occupied by n-octane saturated liquid) using Redlich-Kwong equation of state = %f m**3/mol'%(vf);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane saturated vapour) using Redlich-Kwong equation of state = 0.015401 m**3/mol\n", " The volume occupied by n-octane saturated liquid) using Redlich-Kwong equation of state = 0.000244 m**3/mol\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.10 Page No : 67" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "# Variables\n", "T = 180.;\t\t\t #temperature of water in degree celsius\n", "P = 1.0027;\t\t\t #saturation pressure of water in MPa\n", "Tc = 647.3;\t\t\t #critical temperature of water in K\n", "Pc = 221.2;\t\t\t #critical pressure of water in bar\n", "Tr = 0.7;\t\t\t #reduced temperature at which acentric factor was defined by Pitzer \n", "\n", "# Calculations\n", "T1 = Tr*Tc; \t\t\t #calculating temperature in K using reduced temperature value\n", "T1 = T1-273.15;\t\t\t #conversion to degree celsius\n", "Pr = (P*10)/Pc;\t\t\t # Calculations of reduced pressure (no unit) using saturation pressure at t1. In this case t1 equals t, therefore the given saturation pressure is taken\n", "w = -math.log10(Pr)-1.0;\t\t\t # Calculations of acentric factor using Eq.(3.62)\n", "\n", "# Results\n", "print ' The acentric factor of water = %f '%(w);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The acentric factor of water = 0.343614 \n" ] } ], "prompt_number": 13 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.11 Page No : 72" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "T = 409.41;\t\t\t #temperature of n-octane in degree celsius\n", "P = 4.98;\t\t\t #pressure in bar\n", "Tc = 569.4;\t\t\t #critical temperature of n-octane in K\n", "Pc = 24.97;\t\t\t #critical pressure of n-octane in bar\n", "w = 0.398;\t\t\t #acentric factor (no unit)\n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "\n", "# Calculations\n", "Tr = (T+273.15)/Tc;\t\n", "Pr = P/Pc;\t\t\t\n", "z0 = 0.96;\t\t\t\n", "V1 = (z0*R*(T+273.15))/(P*10**5);\t\t\t \n", "z1 = 0.01;\t\t\t \n", "z = z0+(w*z1);\t\t\n", "V2 = (z*R*(T+273.15))/(P*10**5)\n", "\n", "# Results\n", "print ' The volume occupied by n-octane obtained by the two parameter compressibilty \\\n", " factor correlation = %f m**3/mol'%(V1);\n", "print ' The volume occupied by n-octane obtained by the three parameter compressibility \\\n", "factor correlation = %f m**3/mol'%(V2);\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane obtained by the two parameter compressibilty factor correlation = 0.010939 m**3/mol\n", " The volume occupied by n-octane obtained by the three parameter compressibility factor correlation = 0.010985 m**3/mol\n" ] } ], "prompt_number": 15 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.12 Page No : 72" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "V = 1.;\t \t\t #volume of the tank in m**3\n", "m = 180.;\t\t\t #mass of carbon dioxide in kg\n", "T = 91.8;\t\t\t #temperature of the tank in degree celsius after it is placed in the vicinity of a furnace\n", "Tc = 304.2;\t\t\t #critical temperature of carbon dioxide in K\n", "Pc = 73.87;\t\t\t #critical pressure of carbon dioxide in bar\n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "\n", "# Calculations\n", "mwt = 44.*10**-3\t #molecular weight of carbon dioxide in kg/mol\n", "n = m/mwt;\t\t\t # Calculations of number of moles of carbon dioxide in the tank in moles\n", "MV = V/n;\t\t\t # Calculations of molar volume in m**3/mol\n", "slope = (MV*Pc*10**5)/(R*(T+273.15));\t\t\t #slope of the straight line formed when z0 is plotted against Pr formed by using the relation z0 = (V*Pc*Pr)/(R*T)\n", "Tr = (T+273.15)/Tc;\t\t\t # Calculations of reduced temperature (no unit)\n", "\n", "#At the given conditions, the state of CO2 must lie on the curve corresponding to the obtained value of Tr. To determine the state of CO2, a straight line passing through the origin, with the obtained value of slope is drawn on the z0 vs Pr plot of Fig.3.12 and the point of intersection of this straight line with the Tr curve is obtained to get the value of z0\n", "z0 = 0.725;\t\t\t #value of compressibilty factor obtained by doing the above mentioned procedure\n", "P = (z0*R*10**-6*(T+273.15))/(MV)\t\t\t # Calculations of pressure in MPa using Eq.(3.59)\n", "\n", "# Results\n", "print ' The pressure developed by carbon dioxide = %.0f MPa'%(P);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The pressure developed by carbon dioxide = 9 MPa\n" ] } ], "prompt_number": 69 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.13 Page No : 73" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "\n", "# Variables\n", "V = 1.;\t\t\t #volume of the tank in m**3\n", "m = 180.;\t\t\t #mass of carbon dioxide in kg\n", "T = 91.8;\t\t\t #temperature of the tank in degree celsius after it is placed in the vicinity of a furnace\n", "Tc = 304.2;\t\t\t #critical temperature of carbon dioxide in K\n", "Pc = 73.87;\t\t\t #critical pressure of carbon dioxide in bar\n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "w = 0.239;\t\t\t #acentric factor (no unit)\n", "\n", "# Calculations\n", "mwt = 44.*10**-3\n", "n = m/mwt\n", "MV = V/n;\t\t\t\n", "Tr = (T+273.15)/Tc\n", "z0 = 0.725\n", "z_init = z0;\t\t\t \n", "slope = (MV*Pc*10**5)/(R*(T+273.15));\t\t\t \n", "Prguess = z_init/slope;\t\n", "z1guess = 0.1;\t\t\t \n", "tolerance = 1e-6;\t\t\t \n", "\n", "def solver_function(zi):\n", " return zi-(z0+(w*z1guess))\n", "\n", "z = fsolve(solver_function,z1guess)\n", "Pr = z/slope;\t\t\t \n", "P = ((Pc*10**5)*Pr)*10**-6\n", "\n", "# Results\n", "print ' The pressure developed by carbon dioxide = %f MPa'%(P);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The pressure developed by carbon dioxide = 9.295806 MPa\n" ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.14 Page No : 75" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from scipy.optimize import fsolve\n", "\n", "\n", "# Variables\n", "T = 427.85;\t\t\t #temperature of n-octane vapour in K\n", "P = 0.215;\t\t\t #pressure of n-ocatne vapour in MPa\n", "Tc = 569.4;\t\t\t #critical temperature of n-octane in K\n", "Pc = 2.497;\t\t\t #critical pressure of n-octane in MPa\n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "\n", "# Calculations\n", "Tr = T/Tc\n", "Pr = P/Pc\n", "z_init = 1\n", "h = (0.08664*Pr)/(z_init*Tr)\n", "tolerance = 1e-6;\t\t\t\n", "\n", "def solver_func(zi):\n", " return zi-((1./(1-h))-((h/(1+h))*(4.93398/(Tr**(3./2)))))\n", "\n", "z = fsolve(solver_func,h)\n", "V = (z*R*T)/(P*10**6);\t\t\t\n", "\n", "# Results\n", "print ' The volume occupied by n-octane vapour obtained by the generalized form of \\\n", " \\n Redlich-Kwong equation of state = %.2e m**3/mol'%(V);\n", "\n", "\n", "# Note : Answer may vary because of rouding off error." ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane vapour obtained by the generalized form of \n", " Redlich-Kwong equation of state = 1.55e-02 m**3/mol\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.15 Page No : 77" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "# Variables\n", "T = 427.85;\t\t\t #temperature in K\n", "P = 0.215;\t\t\t #saturation pressure in MPa\n", "Tc = 569.4;\t\t\t #critical temperature of n-octane in K\n", "Pc = 24.97;\t\t\t #critical pressure of n-octane in bar\n", "w = 0.398;\t\t\t #acentric factor (no unit) \n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "\n", "# Calculations\n", "#The Cardan's method simplifies the equation of state into a cubic equation which can be solved easily\n", "#The general form of the cubic equation is (Z**3)+(alpha*Z**2)+(beeta*Z)+gaamma = 0, where alpha,beeta and gaamma are determined using established relations\n", "\n", "Tr = T/Tc\n", "Pr = (P*10**6)/(Pc*10**5)\n", "S = 0.48+(1.574*w)-(0.176*w**2)\n", "alpha1 = (1+(S*(1-math.sqrt(Tr))))**2\n", "a = (0.42748*R**2*Tc**2*alpha1)/(Pc*10**5)\n", "b = (0.08664*R*Tc)/(Pc*10**5)\n", "A = (a*P*10**6)/(R*T)**2\n", "B = (b*P*10**6)/(R*T)\n", "alpha = -1.\n", "beeta = A-B-B**2\n", "gaamma = -(A*B)\n", "p = beeta-(alpha**2)/3\n", "q = ((2*alpha**3)/27)-((alpha*beeta)/3)+gaamma\n", "D = (((q)**2)/4.)+(((p)**3)/27.)\n", "\n", "if D>0:\n", " Z = ((-q/2)+(math.sqrt(D)))**(1./3)+((-q/2)-(math.sqrt(D)))**(1./3)-(alpha/3)\n", " vf = ((Z)*R*T)/(P*10**6)\n", " vg = ((Z)*R*T)/(P*10**6)\n", "elif D == 0:\n", " Z1 = ((-2*(q/2))**(1./3))-(alpha/3)\n", " Z2 = ((q/2)**(1./3))-(alpha/3);\n", " Z3 = ((q/2)**(1./3))-(alpha/3);\n", " Z = [Z1, Z2, Z3];\n", " vf = (min(Z)*R*T)/(P*10**6);\t\t\n", " vg = (max(Z)*R*T)/(P*10**6);\t\t\n", "else:\n", " r = math.sqrt((-(p**3)/27));\t\t\n", " theta = acos((-(q)/2)*(1./r));\t\t\n", " Z1 = (2*(r**(1./3))*math.cos(theta/3))-(alpha/3);\n", " Z2 = (2*(r**(1./3))*math.cos(((2*math.pi)+theta)/3))-(alpha/3)\n", " Z3 = (2*(r**(1./3))*math.cos(((4*math.pi)+theta)/3))-(alpha/3);\n", " Z = [Z1, Z2, Z3];\n", " vf = (min(Z)*R*T)/(P*10**6)\n", " vg = (max(Z)*R*T)/(P*10**6)\n", "\n", "# Results\n", "print ' The volume occupied by n-octane saturated vapour obtained by Soave-Redlich-Kwong \\\n", " equation of state = %f m**3/mol'%(vg);\n", "print ' The volume occupied by n-octane saturated liquid obtained by Soave-Redlich-Kwong \\\n", " equation of state = %f m**3/mol'%(vf);\n", "\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane saturated vapour obtained by Soave-Redlich-Kwong equation of state = 0.015207 m**3/mol\n", " The volume occupied by n-octane saturated liquid obtained by Soave-Redlich-Kwong equation of state = 0.000227 m**3/mol\n" ] } ], "prompt_number": 74 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 3.16 Page No : 78" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "# Variables\n", "T = 427.85;\t\t\t #temperature in K\n", "P = 0.215;\t\t\t #saturation pressure in MPa\n", "Tc = 569.4;\t\t\t #critical temperature of n-octane in K\n", "Pc = 24.97;\t\t\t #critical pressure of n-octane in bar\n", "w = 0.398;\t\t\t #acentric factor (no unit) \n", "R = 8.314;\t\t\t #universal gas constant in (Pa m**3)/(mol K)\n", "\n", "# Calculations\n", "Tr = T/Tc;\t\t\t\n", "Pr = (P*10**6)/(Pc*10**5)\n", "S = 0.37464+(1.54226*w)-(0.26992*w**2)\n", "alpha1 = (1+(S*(1-math.sqrt(Tr))))**2\n", "a = (0.45724*R**2*Tc**2*alpha1)/(Pc*10**5)\n", "b = (0.07780*R*Tc)/(Pc*10**5)\n", "A = (a*P*10**6)/(R*T)**2\n", "B = (b*P*10**6)/(R*T)\n", "alpha = -1+B;\t\n", "beeta = A-(2*B)-(3*B**2)\n", "gaamma = -(A*B)+(B**2)+(B**3)\n", "p = beeta-(alpha**2)/3;\t\t\n", "q = ((2*alpha**3)/27)-((alpha*beeta)/3)+gaamma\n", "D = (((q)**2)/4)+(((p)**3)/27)\n", "\n", "if D>0:\n", " Z = ((-q/2)+(math.sqrt(D)))**(1./3)+((-q/2)-(math.sqrt(D)))**(1./3)-(alpha/3)\n", " vf = ((Z)*R*t)/(P*10**6)\n", " vg = ((Z)*R*t)/(P*10**6)\n", "elif D == 0:\n", " Z1 = ((-2*(q/2))**(1./3))-(alpha/3)\n", " Z2 = ((q/2)**(1./3))-(alpha/3);\n", " Z3 = ((q/2)**(1./3))-(alpha/3);\n", " Z = [Z1 ,Z2, Z3];\n", " vf = (min(Z)*R*T)/(P*10**6)\n", " vg = (max(Z)*R*T)/(P*10**6)\n", "else:\n", " r = math.sqrt((-(p**3)/27))\n", " theta = .1533\n", " Z1 = (2*(r**(1./3))*math.cos(theta/3))-(alpha/3);\n", " Z2 = (2*(r**(1./3))*math.cos(((2*math.pi)+theta)/3))-(alpha/3);\t\t\n", " Z3 = (2*(r**(1./3))*math.cos(((4*math.pi)+theta)/3))-(alpha/3);\n", " Z = [Z1, Z2, Z3];\n", " vf = (min(Z)*R*T)/(P*10**6)\n", " vg = (max(Z)*R*T)/(P*10**6)\n", " \n", "# Results\n", "print ' The volume occupied by n-octane saturated vapour, obtained by Peng\\\n", "-Robinson equation of state = %.3e m**3/mol'%(vg);\n", "print ' The volume occupied by n-octane saturated liquid, obtained by Peng-Robinson\\\n", " equation of state = %.3e m**3/mol'%(vf);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The volume occupied by n-octane saturated vapour, obtained by Peng-Robinson equation of state = 1.514e-02 m**3/mol\n", " The volume occupied by n-octane saturated liquid, obtained by Peng-Robinson equation of state = 2.003e-04 m**3/mol\n" ] } ], "prompt_number": 33 } ], "metadata": {} } ] }