summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics/ch13_1.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Chemical_Engineering_Thermodynamics/ch13_1.ipynb')
-rwxr-xr-xChemical_Engineering_Thermodynamics/ch13_1.ipynb312
1 files changed, 0 insertions, 312 deletions
diff --git a/Chemical_Engineering_Thermodynamics/ch13_1.ipynb b/Chemical_Engineering_Thermodynamics/ch13_1.ipynb
deleted file mode 100755
index 3cee342e..00000000
--- a/Chemical_Engineering_Thermodynamics/ch13_1.ipynb
+++ /dev/null
@@ -1,312 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:894f18dec91baf4a10867e0d301a68220274d02a1e24c4e2bef1038061daa009"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "\n",
- "Chapter 13 : Fugacity of a Component in a Mixture by Equations of State"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 13.2 Page Number : 433"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "import math \n",
- "\n",
- "\n",
- "# Variables\n",
- "T = 310.93;\t\t\t#[K] - Temperature\n",
- "P = 2.76*10**(6);\t\t\t#[Pa] - Pressure\n",
- "y1 = 0.8942;\t\t\t#[mol] - mole fraction of component 1\n",
- "y2 = 1 - y1;\t\t\t#[mol] - mole fraction of component 2\n",
- "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "\n",
- "#For component 1 (methane)\n",
- "Tc_1 = 190.6;\t\t\t#[K] - Critical temperature\n",
- "Pc_1 = 45.99*10**(5);\t\t\t#[N/m**(2)] - Critical pressure\n",
- "Vc_1 = 98.6;\t\t\t#[cm**(3)/mol] - Critical molar volume\n",
- "Zc_1 = 0.286;\t\t\t# - Critical compressibility factor\n",
- "w_1 = 0.012;\t\t\t# - Critical acentric factor\n",
- "#Similarly for component 2 (n-Butane)\n",
- "Tc_2 = 425.1;\t\t\t#[K]\n",
- "Pc_2 = 37.96*10**(5);\t\t\t#[N/m**(2)]\n",
- "Vc_2 = 255;\t\t\t#[cm**(3)/mol]\n",
- "Zc_2=0.274;\n",
- "w_2=0.2;\n",
- "\n",
- "# Calculations\n",
- "#For component 1\n",
- "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n",
- "#At reduced temperature\n",
- "B1_0 = 0.083-(0.422/(Tr_1)**(1.6));\n",
- "B1_1 = 0.139-(0.172/(Tr_1)**(4.2));\n",
- "#We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n",
- "B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#Similarly for component 2\n",
- "Tr_2 = T/Tc_2;\t\t\t#Reduced temperature\n",
- "#At reduced temperature Tr_2,\n",
- "B2_0 = 0.083-(0.422/(Tr_2)**(1.6));\n",
- "B2_1 = 0.139-(0.172/(Tr_2)**(4.2));\n",
- "B_22 = ((B2_0+(w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#For cross coeffcient\n",
- "Tc_12 = (Tc_1*Tc_2)**(1./2);\t\t\t#[K]\n",
- "w_12 = (w_1+w_2)/2;\n",
- "Zc_12 = (Zc_1+Zc_2)/2;\n",
- "Vc_12 = (((Vc_1)**(1./3)+(Vc_2)**(1./3))/2)**(3);\t\t\t#[cm**(3)/mol]\n",
- "Vc_12 = Vc_12*10**(-6);\t\t\t#[m**(3)/mol]\n",
- "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n",
- "\n",
- "# Variables, Z = 1 + (B*P)/(R*T)\n",
- "#Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n",
- "#where B_0 and B_1 are to be evaluated at Tr_12\n",
- "Tr_12 = T/Tc_12;\n",
- "#At reduced temperature Tr_12\n",
- "B_0 = 0.083-(0.422/(Tr_12)**(1.6));\n",
- "B_1 = 0.139-(0.172/(Tr_12)**(4.2));\n",
- "B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n",
- "#For the mixture\n",
- "B = y1**(2)*B_11+2*y1*y2*B_12+y2**(2)*B_22;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#Now del_12 can be calculated as,\n",
- "del_12 = 2*B_12 - B_11 - B_22;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#We have the relation, math.log(phi_1) = (P/(R*T))*(B_11 + y2**(2)*del_12), therefore\n",
- "phi_1 = math.exp((P/(R*T))*(B_11 + y2**(2)*del_12));\n",
- "#Similarly for component 2\n",
- "phi_2 = math.exp((P/(R*T))*(B_22 + y1**(2)*del_12));\n",
- "\n",
- "# Results\n",
- "print \" The value of fugacity coefficient of component 1 phi_1) is %f\"%(phi_1);\n",
- "print \" The value of fugacity coefficient of component 2 phi_2) is %f\"%(phi_2);\n",
- "\n",
- "#Finally fugacity coefficient of the mixture is given by\n",
- "#math.log(phi) = y1*math.log(phi_1) + y2*math.log(phi_2);\n",
- "phi = math.exp(y1*math.log(phi_1) + y2*math.log(phi_2));\n",
- "\n",
- "print \" The value of fugacity coefficient of the mixture phi) is %f \"%(phi);\n",
- "#The fugacity coefficient of the mixture can also be obtained using\n",
- "#math.log(phi) = (B*P)/(R*T)\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The value of fugacity coefficient of component 1 phi_1) is 0.965152\n",
- " The value of fugacity coefficient of component 2 phi_2) is 0.675374\n",
- " The value of fugacity coefficient of the mixture phi) is 0.929376 \n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 13.7 Page Number : 447"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "from scipy.optimize import fsolve \n",
- "import math \n",
- "\n",
- "# Variables\n",
- "T = 460.;\t\t\t#[K] - Temperature\n",
- "P = 40.*10**(5);\t\t\t#[Pa] - Pressure\n",
- "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
- "# component 1 = nitrogen\n",
- "# component 2 = n-Butane\n",
- "y1 = 0.4974;\t\t\t# Mole percent of nitrogen\n",
- "y2 = 0.5026;\t\t\t# Mole percent of n-Butane\n",
- "Tc_nit = 126.2;\t\t\t#[K]\n",
- "Pc_nit = 34.00*10**(5);\t\t\t#[Pa]\n",
- "Tc_but = 425.1;\t\t\t#[K]\n",
- "Pc_but = 37.96*10**(5);\t\t\t#[Pa]\n",
- "\n",
- "# (1). van der Walls equation of state\n",
- "\n",
- "# The fugacity coefficient of component 1 in a binary mixture following van der Walls equation of state is given by,\n",
- "# math.log(phi_1) = b_1/(V-b) - math.log(Z-B) -2*(y1*a_11 + y2*a_12)/(R*T*V)\n",
- "# and for component 2 is given by,\n",
- "# math.log(phi_2) = b_2/(V-b) - math.log(Z-B) -2*(y1*a_12 + y2*a_22)/(R*T*V)\n",
- "# Where B = (P*b)/(R*T)\n",
- "\n",
- "# Calculations\n",
- "# For componenet 1 (nitrogen)\n",
- "a_1 = (27*R**(2)*Tc_nit**(2))/(64*Pc_nit);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_1 = (R*Tc_nit)/(8*Pc_nit);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Similarly for componenet 2 (n-Butane)\n",
- "a_2 = (27*R**(2)*Tc_but**(2))/(64*Pc_but);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_2 = (R*Tc_but)/(8*Pc_but);\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# Here\n",
- "a_11 = a_1;\n",
- "a_22 = a_2;\n",
- "# For cross coefficient\n",
- "a_12 = (a_1*a_2)**(1./2);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "\n",
- "# For the mixture \n",
- "a = y1**(2)*a_11 + y2**(2)*a_22 + 2*y1*y2*a_12;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b = y1*b_1 + y2*b_2;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The cubic form of the van der Walls equation of state is given by,\n",
- "# V**(3) - (b+(R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n",
- "# Substituting the value and solving for V, we get\n",
- "# Solving the cubic equation\n",
- "def f(V): \n",
- " return V**(3)-(b+(R*T)/P)*V**(2)+(a/P)*V-(a*b)/P\n",
- "V_1=fsolve(f,-1)\n",
- "V_2=fsolve(f,0)\n",
- "V_3=fsolve(f,1)\n",
- "# The molar volume V = V_3, the other two roots are imaginary\n",
- "V = V_3;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The comprssibility factor of the mixture is \n",
- "Z = (P*V)/(R*T);\n",
- "# And B can also be calculated as\n",
- "B = (P*b)/(R*T);\n",
- "\n",
- "# The fugacity coefficient of component 1 in the mixture is\n",
- "phi_1 = math.exp(b_1/(V-b) - math.log(Z-B) -2*(y1*a_11 + y2*a_12)/(R*T*V));\n",
- "# Similarly fugacity coefficient of component 2 in the mixture is \n",
- "phi_2 = math.exp(b_2/(V-b) - math.log(Z-B) -2*(y1*a_12 + y2*a_22)/(R*T*V));\n",
- "\n",
- "# The fugacity coefficient of the mixture is given by,\n",
- "# math.log(phi) = y1*math.log(phi_1) + y2*math.log(phi_2)\n",
- "phi = math.exp(y1*math.log(phi_1) + y2*math.log(phi_2));\n",
- "\n",
- "# Also the fugacity coefficient of the mixture following van der Walls equation of state is given by,\n",
- "# math.log(phi) = b/(V-b) - math.log(Z-B) -2*a/(R*T*V)\n",
- "phi_dash = math.exp(b/(V-b) - math.log(Z-B) -2*a/(R*T*V));\n",
- "# The result is same as obtained above\n",
- "\n",
- "# Results\n",
- "print \" 1van der Walls equation of state\";\n",
- "print \" The value of fugacity coefficient of component 1 nitrogen) is %f\"%(phi_1);\n",
- "print \" The value of fugacity coefficient of component 2 n-butane) is %f\"%(phi_2);\n",
- "print \" The value of fugacity coefficient of the mixture is %f\"%(phi);\n",
- "print \" Also the fugacity coefficient of the mixture from van der Walls equation of state is %f which is same as above)\"%(phi_dash);\n",
- "\n",
- "# (2). Redlich-Kwong equation of state\n",
- "\n",
- "# For component 1,\n",
- "a_1_prime = (0.42748*R**(2)*Tc_nit**(2.5))/Pc_nit;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_1_prime = (0.08664*R*Tc_nit)/Pc_nit;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "#similarly for component 2,\n",
- "a_2_prime = (0.42748*R**(2)*Tc_but**(2.5))/Pc_but;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_2_prime = (0.08664*R*Tc_but)/Pc_but;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# For cross coefficient\n",
- "a_12_prime = (a_1_prime*a_2_prime)**(1./2);\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "# For the mixture\n",
- "a_prime = y1**(2)*a_1_prime + y2**(2)*a_2_prime +2*y1*y2*a_12_prime;\t\t\t#[Pa-m**(6)/mol**(2)]\n",
- "b_prime = y1*b_1_prime +y2*b_2_prime;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "\n",
- "#The cubic form of Redlich Kwong equation of state is given by,\n",
- "# V**(3)-((R*T)/P)*V**(2)-((b**(2))+((b*R*T)/P)-(a/(T**(1/2)*P))*V-(a*b)/(T**(1/2)*P)=0\n",
- "# Solving the cubic equation\n",
- "def f1(V): \n",
- " return V**(3)-((R*T)/P)*V**(2)-((b_prime**(2))+((b_prime*R*T)/P)-(a_prime/(T**(1./2)*P)))*V-(a_prime*b_prime)/(T**(1./2)*P)\n",
- "V_4=fsolve(f1,1)\n",
- "V_5=fsolve(f1,0)\n",
- "V_6=fsolve(f1,-1)\n",
- "# The molar volume V = V_4, the other two roots are imaginary\n",
- "V_prime = V_4;\t\t\t#[m**(3)/mol]\n",
- "\n",
- "# The compressibility factor of the mixture is\n",
- "Z_prime = (P*V_prime)/(R*T);\n",
- "# And B can also be calculated as\n",
- "B_prime = (P*b_prime)/(R*T);\n",
- "\n",
- "# The fugacity coefficient of component 1 in the binary mixture is given by\n",
- "# math.log(phi_1) = b_1/(V-b) - math.log(Z-B) + ((a*b_1)/((b**(2)*R*T**(3/2))))*(math.log((V+b)/V)-(b/(V+b)))-(2*(y1*a_1+y2*a_12)/(R*T**(3/2)b))*(math.log(V+b)/b)\n",
- "\n",
- "phi_1_prime = math.exp((b_1_prime/(V_prime-b_prime))-math.log(Z_prime-B_prime)+((a_prime*b_1_prime)/((b_prime**(2))*R*(T**(3./2))))*(math.log((V_prime+b_prime)/V_prime)-(b_prime/(V_prime+b_prime)))-(2*(y1*a_1_prime+y2*a_12_prime)/(R*(T**(3./2))*b_prime))*(math.log((V_prime+b_prime)/V_prime)));\n",
- "\n",
- "\n",
- "# Similarly fugacity coefficient of component 2 in the mixture is \n",
- "phi_2_prime = math.exp((b_2_prime/(V_prime-b_prime))-math.log(Z_prime-B_prime)+((a_prime*b_2_prime)/((b_prime**(2))*R*(T**(3./2))))*(math.log((V_prime+b_prime)/V_prime)-(b_prime/(V_prime+b_prime)))-(2*(y1*a_12_prime+y2*a_2_prime)/(R*(T**(3./2))*b_prime))*(math.log((V_prime+b_prime)/V_prime)));\n",
- "\n",
- "# The fugacity coefficient of the mixture is given by,\n",
- "# math.log(phi) = y1*math.log(phi_1) + y2*math.log(phi_2)\n",
- "phi_prime = math.exp(y1*math.log(phi_1_prime) + y2*math.log(phi_2_prime));\n",
- "\n",
- "# Also the fugacity coefficient for the mixture following Redlich-kwong equation of state is also given by\n",
- "# math.log(phi) = b/(V-b) - math.log(Z-B) - (a/(R*T**(3/2)))*(1/(V+b)+(1/b)*math.log((V+b)/V))\n",
- "phi_prime_dash = math.exp(b_prime/(V_prime-b_prime) - math.log(Z_prime-B_prime) - (a_prime/(R*T**(3./2)))*(1/(V_prime+b_prime)+(1./b_prime)*math.log((V_prime+b_prime)/ V_prime)));\n",
- "\n",
- "print \" \\nRedlich-Kwong equation of state\";\n",
- "print \" The value of fugacity coefficient of component 1 nitrogen) is %f\"%(phi_1_prime);\n",
- "print \" The value of fugacity coefficient of component 2 n-butane) is %f\"%(phi_2_prime);\n",
- "print \" The value of fugacity coefficient of the mixture is %f\"%(phi_prime);\n",
- "print \" Also the fugacity coefficient for the mixture from Redlich-kwong equation of state is %f which is same as above)\"%(phi_prime_dash);\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1van der Walls equation of state\n",
- " The value of fugacity coefficient of component 1 nitrogen) is 1.057500\n",
- " The value of fugacity coefficient of component 2 n-butane) is 0.801865\n",
- " The value of fugacity coefficient of the mixture is 0.920192\n",
- " Also the fugacity coefficient of the mixture from van der Walls equation of state is 0.920192 which is same as above)\n",
- " \n",
- "Redlich-Kwong equation of state\n",
- " The value of fugacity coefficient of component 1 nitrogen) is 1.071129\n",
- " The value of fugacity coefficient of component 2 n-butane) is 0.793063\n",
- " The value of fugacity coefficient of the mixture is 0.920948\n",
- " Also the fugacity coefficient for the mixture from Redlich-kwong equation of state is 0.920948 which is same as above)\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file