diff options
Diffstat (limited to 'Chemical_Engineering_Thermodynamics_by_T._E._Daubert')
9 files changed, 4118 insertions, 0 deletions
diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/README.txt b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/README.txt new file mode 100644 index 00000000..bda52f46 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/README.txt @@ -0,0 +1,10 @@ +Contributed By: Savan Solanki +Course: btech +College/Institute/Organization: Freelancer +Department/Designation: Computer Science +Book Title: Chemical Engineering Thermodynamics +Author: T. E. Daubert +Publisher: McGraw Hill +Year of publication: 1986 +Isbn: 0070664366 +Edition: 1
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch1.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch1.ipynb new file mode 100755 index 00000000..6f94e64d --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch1.ipynb @@ -0,0 +1,66 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:de8d33c7b9d51e88746e761918ff52cb67c086883ba151d5269fcccdacab917b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 : Purpose, Usefulness, And Definitions of Thermodynamics" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1 page : 3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "P = 2050. \t\t\t#kPa\n", + "T = 700. \t\t\t#K\n", + "E = 10.\t \t\t#J\n", + "\t\t\t\n", + "# Calculations\n", + "Pe = P*10**3 *0.3048**2 /4.4482 /144\n", + "Te = T*1.8-460\n", + "Ee = E*10**8 /(1055.1)\n", + "\t\t\t\n", + "# Results\n", + "print \"Temperature = %d F\"%(Te)\n", + "print \" Pressure = %d lbf/in**2 \"%(Pe)\n", + "print \" Energy = %.2e Btu\"%(Ee)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Temperature = 800 F\n", + " Pressure = 297 lbf/in**2 \n", + " Energy = 9.48e+05 Btu\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch2.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch2.ipynb new file mode 100755 index 00000000..def15491 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch2.ipynb @@ -0,0 +1,360 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:847237c1ec4fe9b48879d56b25df72cea30519627c7c21f865146516f12f2299" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : PVT Properties of Fluids - Equations of State" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 page : 13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "basis = 1 \t\t\t#kmol n bumath.tane\n", + "P = 1.013*10**5 \t\t\t#N/m**2\n", + "R = 8.3143*10**3 \t\t\t#J/kmol K\n", + "T = 272.6 \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "V = basis*R*T/P\n", + "Ts = 373.1 \t\t\t#K\n", + "Vs = basis*R*Ts/P\n", + "\t\t\t\n", + "# Results\n", + "print \"Volume in case 1 = %.2f m**3\"%(V)\n", + "print \" Volume in case 2 = %.2f m**3\"%(Vs)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Volume in case 1 = 22.37 m**3\n", + " Volume in case 2 = 30.62 m**3\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 page : 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "Vb = 30 \t\t\t#m**3/kmol\n", + "P = 1.013*10**5 \t\t\t#Pa\n", + "R = 8.3143*10**3 \t\t\t#J/kmol K\n", + "T = 373.1 \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "Z = P*Vb/(R*T)\n", + "\t\t\t\n", + "# Results\n", + "print \"Compressibility factor = %.3f\"%(Z)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Compressibility factor = 0.980\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 page : 21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variables\n", + "Pc = 22.12*10**6 \t\t\t#Pa\n", + "Tc = 647.3 \t\t\t#K\n", + "Vc = 0.05697 \t\t\t#m**3/Kmol\n", + "R = 8.3143*10**3\n", + "Tr = 0.7\n", + "\t\t\t\n", + "# Calculations\n", + "Zc = Pc*Vc/(R*Tc) \n", + "T = Tr*Tc\n", + "Ps = 10**6 \t\t\t#Pa\n", + "w = -math.log10(Ps/Pc) -1\n", + "\t\t\t\n", + "# Results\n", + "print \"critical compressibility factor = %.3f\"%(Zc)\n", + "print \" Accentric factor = %.4f\"%(w)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "critical compressibility factor = 0.234\n", + " Accentric factor = 0.3448\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4A page : 28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "basis = 1 \t\t\t#kmol ammonia\n", + "P = 10**6 \t\t\t#pa\n", + "a = 4.19\n", + "b = 0.0373\n", + "R = 8314.3\n", + "Tc = 405.5\n", + "Pc = 11.28*10**6\n", + "\t\t\t\n", + "# Calculations\n", + "print (\"case a\")\n", + "print (\"Umath.sing vandwerwaals equation, \")\n", + "print (\"(P+a/v**2)*(V-b) = R*T, on solving by trail and error method,\")\n", + "V = 3\n", + "print \"Volume = %d m**3/kmol\"%(V)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "case a\n", + "Umath.sing vandwerwaals equation, \n", + "(P+a/v**2)*(V-b) = R*T, on solving by trail and error method,\n", + "Volume = 3 m**3/kmol\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4B page : 28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "basis = 1. \t\t\t#kmol ammonia\n", + "P = 10.**6 \t\t\t#pa\n", + "a = 4.19\n", + "b = 0.0373\n", + "R = 8314.3\n", + "Tc = 405.5\n", + "Pc = 11.28*10**6\n", + "\t\t\t\n", + "# Calculations\n", + "print (\"part b\")\n", + "an = 27*R**2*Tc**2 /(64*Pc)\n", + "bn = R*Tc/(8*Pc)\n", + "V = 3\n", + "\t\t\t\n", + "# Results\n", + "print \"Since an and bn are same as a and b, V is the same = %d m**3/kmol\"%(V)\n", + "\n", + "# note : rounding off error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part b\n", + "Since an and bn are same as a and b, V is the same = 3 m**3/kmol\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4C page : 28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "print (\"part c\")\n", + "print (\"USing SRK equation, P = RT/(V-b) -alph*a/(V*(V+b))\")\n", + "print (\"By trail and error method,\")\n", + "\t\t\t\n", + "# Calculations\n", + "v2 = 2.98\n", + "\t\t\t\n", + "# Results\n", + "print \"volume = %.2f m**3/kmol\"%(v2)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part c\n", + "USing SRK equation, P = RT/(V-b) -alph*a/(V*(V+b))\n", + "By trail and error method,\n", + "volume = 2.98 m**3/kmol\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 page : 36" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "Pc = 22.12*10**6 \t\t\t#Pa\n", + "Tc = 647.3 \t\t\t#K\n", + "Zc = 0.234\n", + "T = 973.1 \t\t\t#K\n", + "P = 25*10**6 \t\t\t#Pa\n", + "\t\t\t\n", + "# Calculations\n", + "Tr = T/Tc\n", + "Pr = P/Pc\n", + "Z = 0.916\n", + "Zn = Z+0.05*(Zc-0.27)\n", + "\t\t\t\n", + "# Results\n", + "print \"Compresson factor = %.3f \"%(Zn)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Compresson factor = 0.914 \n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 page : 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "w = 0.3448\n", + "Z0 = 0.898\n", + "Z1 = 0.08\n", + "\t\t\t\n", + "# Calculations\n", + "Z = Z0 + Z1*w\n", + "\t\t\t\n", + "# Results\n", + "print \"Compression factor = %.3f \"%(Z)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Compression factor = 0.926 \n" + ] + } + ], + "prompt_number": 10 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch3.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch3.ipynb new file mode 100755 index 00000000..266e4cee --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch3.ipynb @@ -0,0 +1,709 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:ef87408e4a8aa5645fed756dcb555fc2d4a33d3c6244d485bc79468e75ba8f65" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3 : Conservation of energy - First law of Thermodynamics" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.1 page : 47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "mass = 4000. \t\t\t#kg/m**2\n", + "Patm = 1.013*10**5 \t\t\t#pa\n", + "g = 9.807\n", + "M = 28.\n", + "R = 8.3143*10**3\n", + "T = 303. \t\t\t#K\n", + "P1 = 800.*10**3 \t\t\t#pa\n", + "\t\t\t\n", + "# Calculations\n", + "Ps = Patm+mass*g\n", + "n = 1/M\n", + "V1 = n*R*T/P1\n", + "W = Ps*(2*V1)\n", + "\t\t\t\n", + "# Results\n", + "print \"Work done on the surroundings = %d J\"%(W)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Work done on the surroundings = 31609 J\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.2a page : 51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "t1 = 1000. \t\t\t#K\n", + "p1 = 20. \t\t\t#Mpa\n", + "p2 = 10. \t\t\t#Mpa\n", + "ti = 600. \t\t\t#K\n", + "t2 = 700. \t\t\t#K\n", + "v1 = 0.02188\n", + "vi = 0.02008\n", + "v2 = 0.02825\n", + "Ei = 2617.5\n", + "E2 = 2893.1\n", + "E1 = 3441.8\n", + "x = 0.22\n", + "m = 1. \t\t\t#kg\n", + "cp = 4.186\n", + "t3 = 639. \t\t\t#K\n", + "H3 = 2409.5\n", + "H1 = 3879.3\n", + "\t\t\t\n", + "# Calculations\n", + "Tf = ti+ (v1-vi)/(v2-vi) *(t2-ti)\n", + "Ef = Ei+ x*(E2-Ei)\n", + "Q1 = Ef-E1\n", + "\t\t\t\n", + "# Results\n", + "print (\"part a\")\n", + "print \"Heat transfer = %.1f kJ/kg\"%(Q1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part a\n", + "Heat transfer = -763.7 kJ/kg\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.2b page : 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "t1 = 1000. \t\t\t#K\n", + "p1 = 20. \t\t\t#Mpa\n", + "p2 = 10. \t\t\t#Mpa\n", + "ti = 600. \t\t\t#K\n", + "t2 = 700. \t\t\t#K\n", + "v1 = 0.02188\n", + "vi = 0.02008\n", + "v2 = 0.02825\n", + "Ei = 2617.5\n", + "E2 = 2893.1\n", + "E1 = 3441.8\n", + "x = 0.22\n", + "m = 1. \t\t\t#kg\n", + "cp = 4.186\n", + "t3 = 639. \t\t\t#K\n", + "H3 = 2409.5\n", + "H1 = 3879.3\n", + "\t\t\t\n", + "# Calculations\n", + "Tf = ti+ (v1-vi)/(v2-vi) *(t2-ti)\n", + "Hf = H3 - m*cp*(t3-Tf)\n", + "Q2 = Hf-H1\n", + "\t\t\t\n", + "# Results\n", + "print (\"part b\")\n", + "print \"Heat transfer = %.f kJ/kg\"%(Q2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part b\n", + "Heat transfer = -1541 kJ/kg\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.3 page : 63" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "p1 = 2.181\n", + "p2 = 2.637\n", + "p3 = 3.163\n", + "vg1 = 0.09150\n", + "vg2 = 0.07585\n", + "vg3 = 0.06323\n", + "vl1 = 0.00118\n", + "vl2 = 0.00120\n", + "vl3 = 0.00122\n", + "M = 18.\n", + "t1 = 490. \t\t\t#K\n", + "t2 = 500. \t\t\t#K\n", + "t3 = 510. \t\t\t#K\n", + "R = 8.3143\n", + "\t\t\t\n", + "# Calculations\n", + "lam1 = (p2-p1)*10**3 *M*(vg2-vl2) *2.154/ math.log(t3/t1)\n", + "lam2 = math.log(p3/p1) *R/(1/t1 -1/t3)\n", + "err = (lam2-lam1)/lam1\n", + "\t\t\t\n", + "# Results\n", + "print \"latent heat umath.sing calyperon equation = %d kJ/kmol\"%(lam1)\n", + "print \" latent heat umath.sing the clasius calyperon equation = %d kJ/kmol\"%(lam2)\n", + "print \" Error = %d percent\"%(err*100)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "latent heat umath.sing calyperon equation = 32990 kJ/kmol\n", + " latent heat umath.sing the clasius calyperon equation = 38618 kJ/kmol\n", + " Error = 17 percent\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.4 page : 66" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "h1 = 147360 \n", + "h2 = 29790\n", + "\t\t\t\n", + "# Calculations\n", + "Hr = h1-h2\n", + "\t\t\t\n", + "# Results\n", + "print \"heat of reaction = %d kJ/kmol\"%(Hr)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "heat of reaction = 117570 kJ/kmol\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.5 page : 73" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "R = 8314.3\n", + "T = 700. \t\t\t#K\n", + "T2 = 437.5 \t\t\t#K\n", + "T3 = 350. \t\t\t#K\n", + "T4 = T3\n", + "p2 = 0.552 \t\t\t#Mpa\n", + "p1 = 2.758 \t\t\t#Mpa\n", + "cp = 29.3\n", + "R0 = 8.3\n", + "k = 1.4\n", + "\t\t\t\n", + "# Calculations\n", + "cv = cp-R0\n", + "Q1 = -R*T*math.log(p2/p1)\n", + "Q2 = cv*(T2-T)\n", + "dH2 = cp*(T2-T)\n", + "p3 = p2*T3/T2\n", + "p3 = 0.345\n", + "Q3 = cp*(T3-T2)\n", + "dE3 = cv*(T3-T2)\n", + "W3 = Q3-dE3\n", + "T5 = T4*(p1/p3)**((k-1)/k)\n", + "dH4 = cp*(T5-T4)\n", + "W4 = -cv*(T5-T4)\n", + "Q5 = cp*(T-T5)\n", + "dE5 = cv*(T-T5)\n", + "W5 = Q5-dE5\n", + "\t\t\t\n", + "# Results\n", + "print (\"part a isothermal\")\n", + "print \"dH = 0, dE = 0, Q = W = %.f kJ/kmol\"%(Q1/10**3)\n", + "print (\"part 2 isometric\")\n", + "print \"dH = %d kJ/kmol, W = 0, Q = dE = %.f kJ/kmol\"%(dH2,Q2)\n", + "print (\"part 3 isobaric\")\n", + "print \"dE = %.f kJ/kmol, W = %d kJ/kmol, Q = dH = %.f kJ/kmol\"%(dE3,W3,Q3)\n", + "print (\"part 4 adiabatic\")\n", + "print \"dH = %d kJ/kmol, W = -dE = %d kJ/kmol, Q = 0 kJ/kmol\"%(dH4,W4)\n", + "print (\"part 5 isobaric\")\n", + "print \"dE = %d kJ/kmol, W = %d kJ/kmol, Q = dH = %d kJ/kmol\"%(dE5,W5,Q5)\n", + "print (\"The graph cannot be plotted since volume axis values are not known. In the textbook it is randomly drawn to be of that shape.\")\n", + "\n", + "# rounding off error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part a isothermal\n", + "dH = 0, dE = 0, Q = W = 9363 kJ/kmol\n", + "part 2 isometric\n", + "dH = -7691 kJ/kmol, W = 0, Q = dE = -5512 kJ/kmol\n", + "part 3 isobaric\n", + "dE = -1838 kJ/kmol, W = -726 kJ/kmol, Q = dH = -2564 kJ/kmol\n", + "part 4 adiabatic\n", + "dH = 8317 kJ/kmol, W = -dE = -5961 kJ/kmol, Q = 0 kJ/kmol\n", + "part 5 isobaric\n", + "dE = 1388 kJ/kmol, W = 548 kJ/kmol, Q = dH = 1937 kJ/kmol\n", + "The graph cannot be plotted since volume axis values are not known. In the textbook it is randomly drawn to be of that shape.\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.6 page : 76" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "%matplotlib inline\n", + "from matplotlib.pylab import xlabel,ylabel,plot\n", + "import math \n", + "\t\t\t\n", + "# Variables\n", + "p = [2.75, 0.5, 0.31, 0.31, 2.75]\n", + "v = [116.17, 654.8, 654.8, 597, 110.65]\n", + "t = [440, 440, 170, 140, 410]\n", + "h = [3325, 3356, 2802.6, 2738.5, 3257.7]\n", + "e = [3005.6, 3028.6, 2602.6, 2553.6, 2953.4]\n", + "\t\t\t\n", + "# Calculations\n", + "dh1 = h[1] - h[0]\n", + "de1 = e[1] - e[0]\n", + "q2 = e[2] - e[1]\n", + "dh2 = h[2] - h[1]\n", + "dh3 = h[3] - h[2]\n", + "de3 = e[3] - e[2]\n", + "W3 = p[2] *(v[3] - v[2])\n", + "Q3 = de3+W3\n", + "dh4 = h[4] -h[3]\n", + "de4 = e[4] -e[3]\n", + "dh5 = h[0] - h[4]\n", + "de5 = e[0] - e[4]\n", + "W5 = p[4] *(v[0] - v[4])\n", + "q5 = de5+W5\n", + "\t\t\t\n", + "# Results\n", + "print \"In case 1 , dH = %.1f kJ/kg dE = %.1f kJ/kg W = pDv kJ/kg Q = %.1f + W kJ/kg\"%(dh1,de1,de1)\n", + "print \" In case 2, W = 0 kJ/kg Q = dE = %d kJ/kg dH = %.1f kJ/kg\"%(q2,dh2)\n", + "print \" In case 3, dH = %.1f kJ/kg dE = %.1f kJ/kg W = %.1f kJ/kg Q = %.1f kJ/kg\"%(dh3,de3,W3,Q3)\n", + "print \" In case 4, Q = 0 kJ/kg dH = %.1f kJ/kg dE = -W = %.1f kJ/kg\"%(dh4,de4)\n", + "print \" In case 5, dH = %.1f kJ/kg dE = %.1f kJ/kg W = %.1f kJ/kg Q = %.1f kJ/kg\"%(dh5,de5,W5,q5)\n", + "xlabel(\"Volume (m**3/kg)\")\n", + "ylabel(\"Pressure (Mpa)\")\n", + "plot(v,p)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In case 1 , dH = 31.0 kJ/kg dE = 23.0 kJ/kg W = pDv kJ/kg Q = 23.0 + W kJ/kg\n", + " In case 2, W = 0 kJ/kg Q = dE = -426 kJ/kg dH = -553.4 kJ/kg\n", + " In case 3, dH = -64.1 kJ/kg dE = -49.0 kJ/kg W = -17.9 kJ/kg Q = -66.9 kJ/kg\n", + " In case 4, Q = 0 kJ/kg dH = 519.2 kJ/kg dE = -W = 399.8 kJ/kg\n", + " In case 5, dH = 67.3 kJ/kg dE = 52.2 kJ/kg W = 15.2 kJ/kg Q = 67.4 kJ/kg\n" + ] + }, + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 2, + "text": [ + "[<matplotlib.lines.Line2D at 0x10a39acd0>]" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUh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G2Icsi4H9YLZzsLjefc87lwEDnvUbOvWRnWq/x1wznv1jgECmSMgeJRW9jlV1b\nYr/KV5O/7rwvyHsH+et/0+XzHPO788/DuZ5nv87+oTTduW5L7Mv2PoLLHXQO5DnXH0HOm200+QV7\nD6w42jZyupzakbPPcwDrImuNZT3Z7xXURrD/beJhfwKJAQoOEov2Yr+WXwBedd5biVVGPQ4boO2H\n9evnthuoho0/lMU26wlVAOsa6gNUdd6rjGUUeX2J1cl3Qyo5AaUuFhj+Tc7Wq7m/3N/HutrexTaT\n2gLUc/4O8s90Op6crEKkUOpWklj1GlZiua/zehc2jXMR9ot4HjmDrdlfmAewX/orsE1MNhZw7oJ2\nx9qEDTZ/gP1wOgDcBHyV57hPsD79z/NcnyCvi/tLvTN2nwecx/VYl9I52PhE3uvMxso1v42N09yE\nBY19WEDNff12/HWAWkREIqge9ms9mj4gZy/gwlTI9fwZbFtayNnnWz8IRURcNIPwFsG57R/YGM0G\nbEvTcs77vbCsSERERERERERERERERERERERERERERCSW/T/tRRjYWF8jNgAAAABJRU5ErkJggg==\n", + "text": [ + "<matplotlib.figure.Figure at 0x108041690>" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.7 page : 80" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "P = 0.1*10**6 \t\t\t#Pa\n", + "P2 = 0.55*10**6 \t\t\t#Pa\n", + "M = 28.84\n", + "R = 8314.4\n", + "T1 = 303.1 \t\t\t#K\n", + "T2 = 316.1 \t\t\t#K\n", + "d1 = 0.154 \t\t\t#m\n", + "d2 = 0.028 \t\t\t#m\n", + "mass = 0.25 \t\t\t#m**3/s\n", + "Q = 2.764*10**8 \t\t\t#J/h\n", + "cp = 29.3*10**3 \n", + "\t\t\t\n", + "# Calculations\n", + "rho1 = P*M/(T1*R)\n", + "u1 = mass/(math.pi/4 *d1**2)\n", + "rho2 = P2*M/(R*T2)\n", + "u2 = u1*d1**2 *rho1/(d2**2 *rho2)\n", + "Wsd = (u2**2 - u1**2 )/2 + cp/M *(T2-T1) + Q/(mass*rho1*3600)\n", + "mdot = u1*math.pi/4 *d1**2 *rho1\n", + "Ws = Wsd*mdot/745.7\n", + "\t\t\t\n", + "# Results\n", + "print \"Power input to the compressor = %d hp\"%(Ws)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Power input to the compressor = 109 hp\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.8 page : 81" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "u1 = 1.1 \t\t\t#m/s\n", + "rho1 = 1.21*10**3 \t\t\t#kg/m**3\n", + "d1 = 0.078\n", + "z1 = 4\n", + "h2 = 18 \t\t\t#m\n", + "g = 9.806\n", + "\t\t\t\n", + "# Calculations\n", + "mdot = u1*rho1*math.pi/4 *d1**2\n", + "Wsd = z1+h2\n", + "Ws = Wsd*mdot*g\n", + "dP = Ws*rho1/mdot\n", + "\t\t\t\n", + "# Results\n", + "print \"Power input = %d W\"%(Ws)\n", + "print \"Pressure drop = %.3f Mpa\"%(dP/10**6)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Power input = 1372 W\n", + "Pressure drop = 0.261 Mpa\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.9 page : 87" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "eff = 0.75\n", + "Hf = [-110600, -241980, -393770, 0]\n", + "Hc = [30.35, 36, 45.64, 29.30]\n", + "T2 = 540. \t \t\t#C\n", + "T1 = 25. \t\t \t#C\n", + "mass = 500. \t\t\t#kmol H2 produced\n", + "\t\t\t\n", + "# Calculations\n", + "dHr = Hf[2] + Hf[3] - Hf[0] -Hf[1]\n", + "dHpr = (eff*(Hc[2] +Hc[3]) + (1-eff)*(Hc[1]+Hc[0]))*(T2-T1)\n", + "q = dHr*eff +dHpr\n", + "heat = q*mass/eff\n", + "\t\t\t\n", + "# Results\n", + "print \"Heat produced = %.3e kJ\"%(heat)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Heat produced = 4.397e+06 kJ\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.10 page : 87" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "eff = 0.75\n", + "Hf = [-110600, -241980, -393770, 0]\n", + "Hc = [30.35, 36 ,45.64, 29.30]\n", + "T2 = 540. \t\t\t#C\n", + "T1 = 25. \t\t\t#C\n", + "mass = 500. \t\t\t#kmol H2 produced\n", + "work = 10.**6 \t\t\t#kJ\n", + "\t\t\t\n", + "# Calculations\n", + "dHr = Hf[2] + Hf[3] - Hf[0] -Hf[1]\n", + "dHpr = (eff*(Hc[2] +Hc[3]) + (1-eff)*(Hc[1]+Hc[0]))*(T2-T1)\n", + "q = dHr*eff +dHpr\n", + "heat = q*mass/eff\n", + "qe = heat-work\n", + "\t\t\t\n", + "# Results\n", + "print \"Heat produced = %.3e kJ\"%(qe)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Heat produced = 3.397e+06 kJ\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.11 page : 89" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import array\n", + "\t\t\t\n", + "# Variables\n", + "so3 = 6.\n", + "h2 = -296840. \t\t\t#kJ/kmol\n", + "h3 = -395720. \t\t\t#kJ/kmol\n", + "t2 = 400. \t\t\t#C\n", + "t1 = 25. \t\t\t#C\n", + "\t\t\t\n", + "# Calculations\n", + "Hr = so3*(h3-h2)\n", + "cp = array([1.059, 0.967, 0.714])\n", + "n = array([82.76, 11 ,8])\n", + "M = array([28, 32, 64])\n", + "Ht = sum(cp*n*M)\n", + "Hre = Ht*(t2-t1)\n", + "Hpr = Hre-Hr\n", + "Tf = t1 + Hpr/3261.6\n", + "\t\t\t\n", + "# Results\n", + "print \"temperature of exit gases = %d C\"%(Tf)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "temperature of exit gases = 570 C\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.12 page: 91" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import array\n", + "\t\t\t\n", + "# Variables\n", + "x = 0.25\n", + "Hr = 1.4278*10**6 \t\t\t#kJ/kmol\n", + "ti = 25. \t\t\t#C\n", + "cp = array([1.24, 2.39, 1.11])\n", + "M = array([44 ,18, 32])\n", + "z = array([12, 3, 0.5])\n", + "r = 4.186\n", + "\t\t\t\n", + "# Calculations\n", + "v = cp*M*z\n", + "v2 = sum(v)\n", + "T = ti+ Hr/(v2)\n", + "\t\t\t\n", + "# Results\n", + "print \"Theoretical temperature = %d C\"%(T)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Theoretical temperature = 1806 C\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch4.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch4.ipynb new file mode 100755 index 00000000..fe7ec17f --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch4.ipynb @@ -0,0 +1,1364 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:86a92304d7490362995032f0562ccedb12e93f4b49049a51c2746a179c0b276d" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 4 : The Second law of thermodynamics and its applications" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.1 page : 101" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "T = 500. \t\t\t#K\n", + "Qr = 5.*10**6 \t\t\t#kJ\n", + "T2 = 600. \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "dSS = Qr/T\n", + "dSS2 = -Qr/T2\n", + "Ds = dSS+dSS2\n", + "\t\t\t\n", + "# Results\n", + "print \"Entropy change of the system = %d kJ/K\"%(dSS)\n", + "print \" Entropy change of the surroundings = %d kJ/K\"%(dSS2)\n", + "print \" Entropy change if the universe = %.f kJ/K\"%(Ds)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy change of the system = 10000 kJ/K\n", + " Entropy change of the surroundings = -8333 kJ/K\n", + " Entropy change if the universe = 1667 kJ/K\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.2 page : 104" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "p1 = 2.758 \t\t\t#Mpa\n", + "p2 = 0.552 \t\t\t#Mpa\n", + "T1 = 700. \t\t\t#K\n", + "T2 = 700. \t\t\t#K\n", + "n = 1.\n", + "R = 8.3143\n", + "Cv = 21.\n", + "Cp = 29.3\n", + "\t\t\t\n", + "# Calculations\n", + "dsa = n*R*math.log(p1/p2)\n", + "T3 = 437.5 \t\t\t#K\n", + "dsb = Cv*math.log(T3/T2)\n", + "T4 = 350. \t\t\t#K\n", + "dsc = Cp*math.log(T4/T3)\n", + "T5 = 634. \t\t\t#K\n", + "dsd = 0.\n", + "T6 = 700. \t\t\t#K\n", + "dse = Cp*math.log(T6/T5)\n", + "dstotal = dsa+dsb+dsc+dsd+dse\n", + "\t\t\t\n", + "# Results\n", + "print \"Entropy change in case a = %.3f kJ/kmol K\"%(dsa)\n", + "print \" Entropy change in case b = %.3f kJ/kmol K\"%(dsb)\n", + "print \" Entropy change in case c = %.3f kJ/kmol K\"%(dsc)\n", + "print \" Entropy change in case d = %.3f kJ/kmol K\"%(dsd)\n", + "print \" Entropy change in case e = %.3f kJ/kmol K\"%(dse)\n", + "print \" Entropy change in total process = %.3f kJ/kmol K\"%(dstotal)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy change in case a = 13.375 kJ/kmol K\n", + " Entropy change in case b = -9.870 kJ/kmol K\n", + " Entropy change in case c = -6.538 kJ/kmol K\n", + " Entropy change in case d = 0.000 kJ/kmol K\n", + " Entropy change in case e = 2.902 kJ/kmol K\n", + " Entropy change in total process = -0.131 kJ/kmol K\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.3 page : 105" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "\t\t\t\n", + "# Variables\n", + "ratio = 1./2\n", + "R = 8.314\n", + "p1 = 0.5 \t\t\t#kPa\n", + "p2 = 0.1 \t\t\t#kPa\n", + "\t\t\t\n", + "# Calculations\n", + "ya = ratio/(1+ratio)\n", + "ds = -ya*R*math.log(ya) - (1-ya)*R*math.log(1-ya)\n", + "dss = R*math.log(p1/p2)\n", + "\t\t\t\n", + "# Results\n", + "print \"Entropy of mixing = %.3f kJ/kmol K\"%(ds)\n", + "print \" Total entropy change of the universe = %.2f kJ/kmol K\"%(dss)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy of mixing = 5.292 kJ/kmol K\n", + " Total entropy change of the universe = 13.38 kJ/kmol K\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.4 page : 106" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "s1 = 7.096 \t\t\t#kJ/kg K\n", + "s2 = 7.915 \t\t\t#kJ/kg K\n", + "s3 = 7.16 \t\t\t#kJ/kg K\n", + "s4 = 7.014 \t\t\t#kJ/kg K\n", + "s5 = 6.999 \t\t\t#kJ/kg K\n", + "\t\t\t\n", + "# Calculations\n", + "dsa = s2-s1\n", + "dsb = s3-s2\n", + "dsc = s4-s3\n", + "dsd = s5-s4\n", + "dse = s1-s5\n", + "dstotal = dsa+dsb+dsc+dsd+dse\n", + "\t\t\t\n", + "# Results\n", + "print \"Change in entropy in process a = %.3f kJ/kg K\"%(dsa)\n", + "print \" Change in entropy in process b = %.3f kJ/kg K\"%(dsb)\n", + "print \" Change in entropy in process c = %.2f kJ/kg K\"%(dsc)\n", + "print \" Change in entropy in process d = %.3f kJ/kg K\"%(dsd)\n", + "print \" Change in entropy in process e = %.3f kJ/kg K\"%(dse)\n", + "print \" Change in entropy in total process = %.3f kJ/kg K\"%(dstotal)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in entropy in process a = 0.819 kJ/kg K\n", + " Change in entropy in process b = -0.755 kJ/kg K\n", + " Change in entropy in process c = -0.15 kJ/kg K\n", + " Change in entropy in process d = -0.015 kJ/kg K\n", + " Change in entropy in process e = 0.097 kJ/kg K\n", + " Change in entropy in total process = 0.000 kJ/kg K\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.5 page : 106" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "m1 = 5000. \t\t\t#kg/h\n", + "cp1 = 3.2 \t\t\t#kJ/kg K\n", + "cp2 = 4.186 \t\t\t#kJ/kg K\n", + "t1 = 220. \t\t\t#C\n", + "t2 = 30. \t\t\t#C\n", + "T1 = 210. \t\t\t#C\n", + "T2 = 20. \t\t\t#C\n", + "\t\t\t\n", + "# Calculations\n", + "m2 = m1*cp1*(t1-t2)/(cp2*(T1-T2))\n", + "ds = m1*cp1*math.log((t2+273.1)/(t1+273.1)) + m2*cp2*math.log((T1+273.1)/(T2+273.1))\n", + "\t\t\t\n", + "# Results\n", + "print \"Change in entropy = %.f kJ/h K\"%(ds)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in entropy = 209 kJ/h K\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.6 page : 111" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "s1 = 218.8 \t\t\t#kJ/kmol K\n", + "s2 = 188.85 \t\t\t#kJ/kmol K\n", + "s3 = 237.8 \t\t\t#kJ/kmol K\n", + "s4 = 205.2 \t\t\t#kJ/kmol K\n", + "\t\t\t\n", + "# Calculations\n", + "ds = s1+s2-s3-0.5*s4\n", + "\t\t\t\n", + "# Results\n", + "print \"Entropy change = %.2f kJ/kmol K\"%(ds)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy change = 67.25 kJ/kmol K\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.7 page : 112" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "Q = 6. \t\t\t#kJ/kg\n", + "p1 = 1.5 \t\t\t#Mpa\n", + "p2 = 0.1 \t\t\t#Mpa\n", + "t1 = 500. \t\t\t#C\n", + "t2 = 140.8 \t\t\t#C\n", + "h1 = 3473.1 \t\t\t#kJ\n", + "h2 = 2758.1 \t\t\t#kJ\n", + "s1 = 7.5698 \t\t\t#kJ/K\n", + "s2 = 7.5698 \t\t\t#kJ/K\n", + "eff = 0.85\n", + "Ts = 293.1 \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "Wideal = h2-h1\n", + "Ws = eff*Wideal\n", + "dH = -Q-Ws\n", + "H2 = h1+dH\n", + "S2 = 7.8005\n", + "ds = S2-s1\n", + "Wlost = Ts*ds+Q\n", + "\t\t\t\n", + "# Results\n", + "print \"lost work = %.1f kJ\"%(Wlost)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "lost work = 73.6 kJ\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.8 page : 113" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "m = 5000. \t\t\t#/kg/h\n", + "cp = 3.2 \t\t\t#kJ/kg K\n", + "Ts = 30.+273.1 \t\t\t#K\n", + "t1 = 220. \t\t\t#C\n", + "t2 = 40. \t\t\t#C\n", + "Q = 2.88*10**6 \t\t\t#kJ\n", + "\t\t\t\n", + "# Calculations\n", + "Q = m*cp*(t2-t1)\n", + "dss = m*cp*math.log((t2+273.1)/(t1+273.1))\n", + "Wlost = Ts*dss-Q\n", + "eff = Ts*dss/Q\n", + "\t\t\t\n", + "# Results\n", + "print \"Lost work = %d kJ\"%round(Wlost,-4)\n", + "print \" Efficiency = %.3f\"%(eff)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Lost work = 680000 kJ\n", + " Efficiency = 0.765\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.9 page : 114" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "R = 8.314\n", + "cp = 35.58\n", + "n = 100./16\n", + "T1 = 300. \t\t\t#K\n", + "T2 = 500. \t\t\t#K\n", + "k = 1.305\n", + "P2 = 3. \t\t\t#Mpa\n", + "P1 = 0.5 \t\t\t#Mpa\n", + "Ts = 290. \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "cv = cp-R\n", + "Wi = n*R*T1/(k-1) *((P2/P1)**((k-1)/k) -1)\n", + "Hi = Wi\n", + "Ha = n*cp*(T2-T1)\n", + "eta = abs(Hi/Ha)\n", + "dss1 = cp*math.log(T2/T1) - R*math.log(P2/P1)\n", + "Wl1 = Ts*dss1\n", + "dss2 = n*cp*math.log(T2/T1)\n", + "dss3 = abs(Ha/Ts)\n", + "dsst = dss2+dss3\n", + "Wl2 = -Ts*dss2 +Ha\n", + "Wlost = Wl1+Wl2\n", + "\t\t\t\n", + "# Results\n", + "print \"Thermodynamic efficiency = %.3f\"%(eta)\n", + "print \" Net work lost = %d kJ\"%(Wlost)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thermodynamic efficiency = 0.598\n", + " Net work lost = 12483 kJ\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.10 page : 119" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "T1 = 673. \t\t\t#K\n", + "T2 = 293. \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "eta = (T1-T2)/T1\n", + "\t\t\t\n", + "# Results\n", + "if eta >= 0.5:\n", + " print \"Max efficiency = %.3f and an efficiency of 0.5 is possible\"%(eta)\n", + "else:\n", + " print \"Max efficiency = %.3f and an efficiency of 0.5 is not possible\"%(eta)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Max efficiency = 0.565 and an efficiency of 0.5 is possible\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.11 page : 121" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "T1 = 280. \t\t\t#K\n", + "T2 = 300. \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "cop = T1/(T2-T1)\n", + "\t\t\t\n", + "# Results\n", + "print \"coefficient of performance = %.1f\"%(cop)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "coefficient of performance = 14.0\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.12 page : 123" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "P = 2. \t\t\t#Mpa\n", + "T1 = 212.4+273.1 \t\t\t#K\n", + "T2 = 25+273.1 \t\t\t#K\n", + "h1 = 2799.5\n", + "h2 = 104.89\n", + "s1 = 6.3409\n", + "s2 = 0.3674\n", + "\t\t\t\n", + "# Calculations\n", + "dh = h1-h2\n", + "ds = s1-s2\n", + "exergy = dh-T2*ds\n", + "\t\t\t\n", + "# Results\n", + "print \"exergy = %.1f kJ/kg\"%(exergy)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "exergy = 913.9 kJ/kg\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.13 page : 126" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "R = 8314.3\n", + "T = 700. \t\t\t#K\n", + "T2 = 437.5 \t\t\t#K\n", + "T3 = 350. \t\t\t#K\n", + "T4 = T3\n", + "p2 = 0.552 \t\t\t#Mpa\n", + "p1 = 2.758 \t\t\t#Mpa\n", + "p3 = 0.345 \t\t\t#Mpa\n", + "cp = 29.3\n", + "R0 = 8.3143\n", + "k = 1.4\n", + "n = 1.\n", + "P0 = 0.103 \t\t\t#Mpa\n", + "\t\t\t\n", + "# Calculations\n", + "cv = cp-R0\n", + "p3 = p2*T3/T2\n", + "p3 = 0.345\n", + "T5 = T4*(p1/p3)**((k-1)/k)\n", + "G1 = n*R*T*math.log(p2/p1)\n", + "V700 = R*10**3 *T/(p2*10**9)\n", + "Sa = 209.\n", + "Sb = 199.2\n", + "Sc = 204.7\n", + "S2 = (T2-T)/6 *(Sa+4*Sc+Sb )\n", + "G2 = V700*(p3-p2)*10**3 -S2\n", + "saa = 199.2\n", + "sbb = 192.6\n", + "savg = (saa+sbb)*0.5\n", + "G3 = -savg*(T3-T2)\n", + "pmid = (p3+p2)/2\n", + "vmid = 2.88\n", + "sav = 192.7\n", + "v4 = 8.435 \t\t\t#m**3\n", + "v5 = 1.911 \t\t\t#m**3\n", + "integ = (p1-p3)*10**3 /6 *(v4+4*vmid+v5)\n", + "G4 = integ - sav*(T5-T3)\n", + "Sav = 194.25\n", + "G5 = -Sav*(T-T5)\n", + "Gt = G1/10**3 +G2+G3+G4+G5\n", + "\t\t\t\n", + "# Results\n", + "print \"in case 1, Change in gibbs free energy = %.f kJ\"%(G1/10**3)\n", + "print \" in case 2, Change in gibbs free energy = %.f kJ\"%(G2)\n", + "print \" in case 3, Change in gibbs free energy = %d kJ\"%(G3)\n", + "print \" in case 4, Change in gibbs free energy = %d kJ\"%(G4)\n", + "print \" in case 5, Change in gibbs free energy = %d kJ\"%(G5)\n", + "print \" Net change in gibbs energy = %d kJ\"%(Gt)\n", + "\n", + "# note : rounding off error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "in case 1, Change in gibbs free energy = -9363 kJ\n", + " in case 2, Change in gibbs free energy = 51499 kJ\n", + " in case 3, Change in gibbs free energy = 17141 kJ\n", + " in case 4, Change in gibbs free energy = -45908 kJ\n", + " in case 5, Change in gibbs free energy = -12844 kJ\n", + " Net change in gibbs energy = 523 kJ\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.14 page : 130" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "\t\t\t\n", + "# Variables\n", + "v = 1./430\n", + "pi = 4.08 \t\t\t#Mpa\n", + "pf = 10. \t\t\t#Mpa\n", + "pf2 = 1. \t\t\t#Mpa\n", + "pii = 0.1 \t\t\t#Mpa\n", + "R = 8314.3\n", + "n = 1./28\n", + "T = 273.1\n", + "\t\t\t\n", + "# Calculations\n", + "logpr = v*(pf-pii)*10**6 /(R*T*n)\n", + "pr = math.exp(logpr)\n", + "p = pr*pi\n", + "logpr = v*(pf2-pii)*10**6 /(R*T*n)\n", + "pr = math.exp(logpr)\n", + "p2 = pr*pi\n", + "\t\t\t\n", + "# Results\n", + "print \"Final pressure = %.2f Mpa\"%(p)\n", + "print \" Final pressure in case 2 = %.2f Mpa\"%(p2)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Final pressure = 5.42 Mpa\n", + " Final pressure in case 2 = 4.19 Mpa\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.15 page : 131" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "Hvap = 338.14 \t\t\t#kJ/kg\n", + "T = 409.3 \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "dss = Hvap/T\n", + "dg = 0\n", + "\t\t\t\n", + "# Results\n", + "print \"change in entropy and gibbs energy of system are %.3f kJ/kg K and %d kJ/kg respectivey\"%(dss,dg)\n", + "print \" change in entropy and gibbs energy of universe are %.3f kJ/kg K and %d kJ/kg respectivey\"%(-dss,-dg)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "change in entropy and gibbs energy of system are 0.826 kJ/kg K and 0 kJ/kg respectivey\n", + " change in entropy and gibbs energy of universe are -0.826 kJ/kg K and 0 kJ/kg respectivey\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.16 page : 134" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "T = 373.1 \t\t\t#K\n", + "R = 8314.3\n", + "Pd = 0.1013*10**6 \t\t\t#Pa\n", + "P = 10. \t\t\t#Mpa\n", + "p3 = 5.*10**6 \t\t\t#Pa\n", + "vf = 0.0373\n", + "a = 424.447\n", + "\t\t\t\n", + "# Calculations\n", + "Vd = R*T/Pd\n", + "V = 0.5\n", + "dss = -R*(math.log(p3/Pd) + math.log((V-vf)/(Vd-vf)))\n", + "dhh = R*T/10**3 - p3/10**3 *V+ a/V**2\n", + "\t\t\t\n", + "# Results\n", + "print \"Change in entropy = %.4f kJ/kmol K\"%(dss/10**3)\n", + "print \" change in enthalpy = %.f kJ/kmol\"%(dhh)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in entropy = 2.4285 kJ/kmol K\n", + " change in enthalpy = 2300 kJ/kmol\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.18 page : 141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "Tc = 647.3 \t\t\t#K\n", + "dh = 1.1\n", + "Db = -2\n", + "v2 = 0.234\n", + "v1 = 0.27\n", + "\t\t\t\n", + "# Calculations\n", + "dh2 = dh+Db*(v2-v1)\n", + "dhh = dh2*Tc\n", + "dhbar = dhh*4.18/18\n", + "h1 = 3777.5 \t\t\t#kJ/kg\n", + "h2 = 3928.2 \t\t\t#kJ/kg\n", + "dhs = h2-h1\n", + "err = abs(dhs-dhbar)/dhs\n", + "\t\t\t\n", + "# Results\n", + "print \"Enthalpy departure = %d kJ/kg\"%(dhbar)\n", + "print \" Percentage error = %.1f \"%(err*100)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enthalpy departure = 176 kJ/kg\n", + " Percentage error = 16.9 \n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.19 page : 155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "w = 0.3448\n", + "R = 8.3143\n", + "Tc = 647.3\n", + "\t\t\t\n", + "# Calculations\n", + "h0 = 0.57\n", + "h1 = 0.05\n", + "h2 = h0+w*h1\n", + "h3 = h2*R*Tc\n", + "dh = -h3\n", + "\t\t\t\n", + "# Results\n", + "print \"Enthalpy departure = %d kJ/kmol\"%(dh)\n", + "print (\"The answer is a bit different due to rounding off error in the textbook\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enthalpy departure = -3160 kJ/kmol\n", + "The answer is a bit different due to rounding off error in the textbook\n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.20 page : 164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "ta = 310. \t\t\t#K\n", + "pa = 80. \t\t\t#kPa\n", + "r = 10.\n", + "k = 1.4\n", + "R = 8.3143\n", + "n = 5./29\n", + "cv = 20.93\n", + "\t\t\t\n", + "# Calculations\n", + "Qab = 0\n", + "tb = ta*r**(k-1)\n", + "va = R*ta/pa\n", + "vb = va/r\n", + "pb = R*tb/vb\n", + "Wab = -n*R*ta/(k-1) *((pb/pa)**((k-1)/k) -1)\n", + "vc = vb\n", + "Qbc = 500 \t\t\t#kJ\n", + "Wbc = 0\n", + "tc = tb+ Qbc/(n*cv)\n", + "pc = R*tc/vc\n", + "Qcd = 0\n", + "td = tc/r**(k-1)\n", + "vd = va\n", + "pd = td/tc*(vc/vd)*pc\n", + "Wcd = -n*R*tc/(k-1) *((pd/pc)**((k-1)/k)-1)\n", + "Wda = 0\n", + "Qda = n*cv*(ta-td)\n", + "eta0 = 1-1/r**(k-1)\n", + "\t\t\t\n", + "# Results\n", + "print \"Efficiency of cycle = %.3f\"%(eta0)\n", + "p = [pa, pb, pc, pd]\n", + "t = [ta, tb, tc, td]\n", + "Q = [Qab, Qbc, Qcd, Qda]\n", + "W = [Wab, Wbc, Wcd, Wda]\n", + "print ('Pressure (kPa) = ')\n", + "print (p)\n", + "print (\"Temperature (K) = \")\n", + "print (t)\n", + "print (\"Heat (kJ) = \")\n", + "print (Q)\n", + "print (\"Work done (kJ) = \")\n", + "print (W)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Efficiency of cycle = 0.602\n", + "Pressure (kPa) = \n", + "[80.0, 2009.5091452076638, 2367.0758421853, 94.23498660179267]\n", + "Temperature (K) = \n", + "[310.0, 778.6847937679697, 917.2418888468039, 365.1605730819466]\n", + "Heat (kJ) = \n", + "[0, 500, 0, -199.05358527674872]\n", + "Work done (kJ) = \n", + "[-1679.6491296659615, 0, 1978.5214153723077, 0]\n" + ] + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.21 page : 168" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "ta = 310. \t\t\t#K\n", + "tc = 917.3 \t\t\t#K\n", + "td = 365.2 \t\t\t#K\n", + "n = 0.602\n", + "k = 1.4\n", + "\t\t\t\n", + "# Calculations\n", + "lntb = 1/(1-n)/k\n", + "tb = tc- lntb*(td-ta)\n", + "rc = (tb/ta)**(1/(k-1))\n", + "\t\t\t\n", + "# Results\n", + "print \"Temperature at B = %.1f K\"%(tb)\n", + "print \" Compression ratio = %d \"%(rc)\n", + "print (\"The answer given in textbook for rc is wrong. please check using a calculator\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Temperature at B = 818.2 K\n", + " Compression ratio = 11 \n", + "The answer given in textbook for rc is wrong. please check using a calculator\n" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.22 page : 170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "pr = 4.\n", + "k = 1.4\n", + "ta = 298. \t\t\t#K\n", + "pa = 0.1 \t\t\t#Mpa\n", + "pdr = 0.01\n", + "tc = 900. \t\t\t#K\n", + "pri = 0.005 \t\t\t#Mpa\n", + "\t\t\t\n", + "# Calculations\n", + "pb = pr*pa\n", + "nji = 1- (pr)**((1-k)/k)\n", + "tb = ta*(pb/pa)**((k-1)/k)\n", + "pc = pb-pdr\n", + "pd = pa+pri\n", + "td = tc*(pd/pc)**((k-1)/k)\n", + "\t\t\t\n", + "# Results\n", + "p = [pa, pb, pc, pd]\n", + "t = [ta, tb, tc, td]\n", + "print \"ideal thermal efficiency = %.3f \"%(nji)\n", + "print (\"pressure (Mpa) = \")\n", + "print (p)\n", + "print (\"temperature (K) = \")\n", + "print (t)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "ideal thermal efficiency = 0.327 \n", + "pressure (Mpa) = \n", + "[0.1, 0.4, 0.39, 0.10500000000000001]\n", + "temperature (K) = \n", + "[298.0, 442.8262981628106, 900.0, 618.6157783525422]\n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.23 page : 175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "sd = 4.9269\t\t\t#kJ/kg/K\n", + "sf = 1.1453\t\t\t#kJ/kg/K\n", + "sg = 7.5320\t\t\t#kJ/kg/K\n", + "hf = 359.86\t\t\t#kJ/kg\n", + "hg = 2653.5\t\t\t#kJ/kg\n", + "hd = 2409.7\t\t\t#kJ/kg\n", + "\t\t\t\n", + "# Calculations\n", + "x = (sd-sg)/(sf-sg)\n", + "he = x*hf+(1-x)*hg\n", + "etar = (hd-he)/(hd-hf)\n", + "\t\t\t\n", + "# Results\n", + "print \"Thermal efficiency = %.4f\"%(etar)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thermal efficiency = 0.3375\n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.23b page : 176 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "sd = 6.7039\t\t\t#kJ/kg/K\n", + "sf = 1.1453\t\t\t#kJ/kg/K\n", + "sg = 7.5320\t\t\t#kJ/kg/K\n", + "hf = 359.86\t\t\t#kJ/kg\n", + "hg = 2653.5\t\t\t#kJ/kg\n", + "hd = 3717.9\t\t\t#kJ/kg\n", + "\t\t\t\n", + "# Calculations\n", + "x = (sd-sg)/(sf-sg)\n", + "he = x*hf+(1-x)*hg\n", + "etar = (hd-he)/(hd-hf)\n", + "\t\t\t\n", + "# Results\n", + "print \"Thermal efficiency = %.4f\"%(etar)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thermal efficiency = 0.4055\n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.24 page : 178" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "ha = 2510.6 \t\t\t#kJ/kg\n", + "hd = 125.78 \t\t\t#kJ/kg\n", + "\t\t\t\n", + "# Calculations\n", + "kg = (10**6)/(ha-hd)\n", + "\t\t\t\n", + "# Results\n", + "print \"circulation rate = %d kg steam/h\"%(kg)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "circulation rate = 419 kg steam/h\n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.25 page : 179" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "tin = 298. \t\t\t#K\n", + "tout = 273. \t\t\t#K\n", + "tout2 = 308. \t\t\t#K\n", + "tin2 = 294. \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "eta1 = (tin-tout)/tin\n", + "eta2 = abs((tin2-tout2)/tin2)\n", + "\t\t\t\n", + "# Results\n", + "print \"Efficiency in case 1 = %.3f\"%(eta1)\n", + "print \" efficiency in case 2 = %.3f\"%(eta2)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Efficiency in case 1 = 0.084\n", + " efficiency in case 2 = 0.048\n" + ] + } + ], + "prompt_number": 36 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.26 page : 181" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "ma = 500. \t\t\t#kg/h\n", + "cp1 = 3.2 \t\t\t#kJ/kg K\n", + "ta = 20. \t\t\t#C\n", + "mb = 200.\n", + "mc = 300. \t\t\t#kg/h\n", + "cp2 = 2.8 \t\t\t#kJ/kg K\n", + "tc = 80. \t\t\t#C\n", + "tb = 80. \t\t\t#C\n", + "me = 50. \t\t\t#kg/h\n", + "te = 120. \t\t\t#C\n", + "td = 120. \t\t\t#C\n", + "hg = 503.7\n", + "he = 2706.3\n", + "\n", + "# Calculations\n", + "Ws = (mb+me)*hg + mc*cp2*(tc) - me*he -ma*cp1*(ta)\n", + "\t\t\t\n", + "# Results\n", + "print \"Net work done = %d kJ/h\"%(Ws)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Net work done = 25810 kJ/h\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.27 page : 184" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "hc = 150. \t\t\t#Btu/lb\n", + "he = -115. \t\t\t#Btu/lb\n", + "hg = 168. \t\t\t#Btu/lb\n", + "\t\t\t\n", + "# Calculations\n", + "frac = (hg-hc)/(hg-he)\n", + "\t\t\t\n", + "# Results\n", + "print \"Fraction of solid = %.3f\"%(frac)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Fraction of solid = 0.064\n" + ] + } + ], + "prompt_number": 38 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.28 page : 185" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "H = 2696.5 \t\t\t#kJ/kg\n", + "hg = 2706.7 \t\t\t#kJ/kg\n", + "hf = 504.7 \t\t\t#kJ/kg\n", + "\t\t\t\n", + "# Calculations\n", + "x = (H-hf)/(hg-hf)\n", + "x2 = 1\n", + "\t\t\t\n", + "# Results\n", + "print \"In case 1, fraction of vapor = %.3f\"%(x)\n", + "print \" In case 2, fraction of vapor = %.3f\"%(x2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In case 1, fraction of vapor = 0.995\n", + " In case 2, fraction of vapor = 1.000\n" + ] + } + ], + "prompt_number": 39 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch5.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch5.ipynb new file mode 100755 index 00000000..9c3f32b2 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch5.ipynb @@ -0,0 +1,74 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:c42287d60d2420025e9cb75cd5a29fe499f8ec6aad7d7b81c5d1437599962d5d" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 5 : Relationships among thermodynamic properties - Graphical representation of properties and processes" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.5 page : 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from scipy.optimize import fsolve\n", + "\t\t\t\n", + "# Variables\n", + "R = 8314.3\n", + "b = 0.0306 \t\t\t#m**3/kmol\n", + "a = 0.548*10**6 \t\t\t#pa m**6/kmol**6\n", + "T = 973.1\n", + "P = 25*10**6 \t\t\t#Pa\n", + "\t\t\t\n", + "# Calculations\n", + "Vi = R*T/P\n", + "#x = poly(0,'x')\n", + "def f(x):\n", + " return P*x**2 *(x-b) +a*(x-b) - R*T*(x**2)\n", + "#vec = roots(P*x**2 *(x-b) +a*(x-b) - R*T*(x**2))\n", + "#vec = roots([P,(P*b+R*T),a,-a*b])\n", + "vec = fsolve(f,0,full_output=1)\n", + "volume = vec[0]\n", + "dH = 8.0906*10**6 -P*volume +0.548*10**6 /volume\n", + "\t\t\t\n", + "# Results\n", + "print \"Change in enthalpy = %.2e J/kmol\"%(dH)\n", + "\n", + "\n", + "# Note : Answer is different because fsolve function calculates differently. Please check manually.\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in enthalpy = 2.21e+07 J/kmol\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch7.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch7.ipynb new file mode 100755 index 00000000..8c1eb232 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch7.ipynb @@ -0,0 +1,311 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:20736bf3d0b99872401315f1d4792e0a0a693067ab204fabe4415026bbd6d5a0" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 7 : Solution Properties and Physical Equilibria" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.2 page : 268" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "T = 154.5 \t\t\t#C\n", + "P = 8620.*10**3 \t\t\t#Pa\n", + "Tc = 135. \t\t\t#C\n", + "T0 = 273.1 \t\t\t#C\n", + "Pc = 3648.*10**3 \t\t\t#Pa\n", + "w = 0.1756\n", + "V = 0.154 \n", + "R = 8.3143*10**3\n", + "\t\t\t\n", + "# Calculations\n", + "Tr = (T+T0)/(T0+Tc)\n", + "Pr = P/Pc\n", + "Z = P*V/(R*(T+T0))\n", + "a = 0.42747*R**2 *(Tc+T0)**2 /Pc *(1+ (0.48508 + 1.55171*w - 0.15613*w**2)*(1-math.sqrt(Tr)))**2\n", + "b = 0.08664*R*(Tc+T0)/Pc\n", + "A = a*P/(R**2 *(T+T0)**2)\n", + "B = b*P/(R*(T+T0))\n", + "lnphi = (Z-1) - math.log(Z-B) - A/B *math.log((Z+B)/Z) \n", + "phi = math.exp(lnphi)\n", + "f = phi*P\n", + "\t\t\t\n", + "# Results\n", + "print \"fugacity = %d kPa\"%(f/10**3)\n", + "\t\t\t#The answer is a bit different due to rounding off error in textbook\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "fugacity = 3824 kPa\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.3 page : 273" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "T = 154.5 \t\t\t#C\n", + "P = 8620.*10**3 \t\t\t#Pa\n", + "Tc = 135. \t\t\t#C\n", + "T0 = 273.1 \t\t\t#C\n", + "Pc = 3648.*10**3 \t\t\t#Pa\n", + "w = 0.1756\n", + "V = 0.154 \n", + "R = 8.3143*10**3\n", + "D = 0.35\n", + "Vc = 0.263 \t\t\t#m**3/kmol\n", + "\t\t\t\n", + "# Calculations\n", + "Tr = (T+T0)/(T0+Tc)\n", + "Pr = P/Pc\n", + "Zc = Pc*Vc/(R*(Tc+T0))\n", + "phi1 = 0.44\n", + "phi2 = phi1*10**(D*(Zc-0.27))\n", + "f = phi2*P\n", + "\t\t\t\n", + "# Results\n", + "print \"fugacity = %d kPa\"%(f/10**3)\n", + "\n", + "# rounding off error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "fugacity = 3832 kPa\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.4 page : 277" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "f0 = 0.7\n", + "V = 5.1e-2\n", + "P1 = 0.77 \t\t\t#Mpa\n", + "P2 = 10. \t\t\t#Mpa\n", + "R = 8.3143*10**3\n", + "T = 298. \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "lnr = V/(R*T) *(P2-P1)*10**6\n", + "f = math.exp(lnr) *f0\n", + "\t\t\t\n", + "# Results\n", + "print \"Fugacity = %.3f Mpa\"%(f)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Fugacity = 0.846 Mpa\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.5 page : 280" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "Pt = 0.1013\n", + "ya = 0.605\n", + "P1 = 0.1373\n", + "P2 = 0.06\n", + "xa = 0.4\n", + "\t\t\t\n", + "# Calculations\n", + "if ya*Pt == xa*Pt and (1-ya)*Pt == (1-xa)*Pt:\n", + " print \"The system is ideal\"\n", + "else:\n", + " print \"The system is not ideal\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The system is not ideal\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.6 page : 282" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "Y = 0.06\n", + "X = 0.0012\n", + "P = 2.53 \t\t\t#Mpa\n", + "\t\t\t\n", + "# Calculations\n", + "y = Y/(1+Y)\n", + "x = X/(1+X)\n", + "H = y*P/x\n", + "\t\t\t\n", + "# Results\n", + "print \"Henrys law constant = %.2f Mpa\"%(H)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Henrys law constant = 119.48 Mpa\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7.7 page : 285" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "Hi = 55.\n", + "Pi = 11.8\n", + "xi = 0.514\n", + "H2 = 18.1\n", + "H3 = 26.9\n", + "Pi2 = 17.4\n", + "\t\t\t\n", + "# Calculations\n", + "ai = Pi/Hi\n", + "gam = ai/xi\n", + "a2 = Pi/H2\n", + "gam2 = a2/xi\n", + "a3 = Pi2/H3\n", + "gam3 = a3/(1-xi)\n", + "\t\t\t\n", + "# Results\n", + "print (\"part a\")\n", + "print \"Activity of acetic acid = %.4f \"%(ai)\n", + "print \" Activity coefficient = %.4f \"%(gam)\n", + "\n", + "print (\"part b\")\n", + "print \"Activity of acetic acid = %.4f \"%(a2)\n", + "print \" Activity coefficient = %.4f \"%(gam2)\n", + "\n", + "print (\"part c\")\n", + "print \"Activity of toluene = %.4f \"%(a3)\n", + "print \" Activity coefficient = %.4f \"%(gam3)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part a\n", + "Activity of acetic acid = 0.2145 \n", + " Activity coefficient = 0.4174 \n", + "part b\n", + "Activity of acetic acid = 0.6519 \n", + " Activity coefficient = 1.2684 \n", + "part c\n", + "Activity of toluene = 0.6468 \n", + " Activity coefficient = 1.3309 \n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch8.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch8.ipynb new file mode 100755 index 00000000..4c26dfce --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch8.ipynb @@ -0,0 +1,540 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:b2ee1c3d3e88f5241245b2aaba0096c6b15a6abe1de87d5ab25de8744d1af1f8" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8 : Physical Equilibria Among Phases" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.1 page : 293" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "def func(C,phi):\n", + " return C+2-phi\n", + "\n", + "# Calculations and results\n", + "print (\"part a\")\n", + "print \"degrees of freedom = %d \"%(func(2,2))\n", + "print (\"part b\")\n", + "print \"degrees of freedom = %d \"%(func(3,2))\n", + "print (\"part c\")\n", + "print \"degrees of freedom = %d \"%(func(3,3))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part a\n", + "degrees of freedom = 2 \n", + "part b\n", + "degrees of freedom = 3 \n", + "part c\n", + "degrees of freedom = 2 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.2 page : 297" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "T = 95. \t\t\t#C\n", + "P = 1013. \t\t\t#kPa\n", + "Tc = 135. \t\t\t#C\n", + "Pc = 3648. \t\t\t#kPa\n", + "T0 = 273.1 \t\t\t#C\n", + "D = 0.3\n", + "P0 = 1800. \t\t\t#kPa\n", + "D2 = 0.42\n", + "\t\t\t\n", + "# Calculations\n", + "Zc = 0.283\n", + "Tr = (T+T0)/(Tc+T0)\n", + "Pr = P/Pc\n", + "phic = 0.88\n", + "phi2 = phic*10**(D*0.013)\n", + "Prd = P0/Pc\n", + "phi3 = 0.78\n", + "phi4 = phi3*10**(D2*0.013)\n", + "gl = phi2*P/(phi3*P0)\n", + "\t\t\t\n", + "# Results\n", + "print \"equation is gl = %.3f *y/x\"%(gl)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "equation is gl = 0.641 *y/x\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.3 page :300" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "ye = 0.434\n", + "Pt = 40.25 \t\t\t#kPa\n", + "xe = 0.616\n", + "Pe1 = 22.9 \t\t\t#kPa\n", + "Pe2 = 29.6 \t\t\t#kPa\n", + "\t\t\t\n", + "# Calculations\n", + "ge = ye*Pt/(xe*Pe1)\n", + "gb = (1-ye)*Pt/((1-xe)*Pe2)\n", + "E = math.log10(ge) *(1+ (1-xe)*math.log(gb) /(xe*math.log(ge)))**2\n", + "B = math.log10(gb) *(1+ xe/(1-xe) *math.log(ge) /math.log(gb))**2\n", + "xe2 = 0.4\n", + "xb2 = 0.6\n", + "lnge2 = E/(1+ E*xe2/(B*xb2))**2\n", + "lngb2 = B/(1+ B*xb2/(E*xe2))**2\n", + "ge2 = 10**(lnge2)\n", + "gb2 = 10**(lngb2)\n", + "Pt1 = ge2*Pe1\n", + "Pt2 = gb2*Pe2\n", + "\t\t\t\n", + "# Results\n", + "print \"Total pressure in case 1 = %.2f kPa and in case 2 = %.2f kPa\"%(Pt1, Pt2 )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total pressure in case 1 = 40.78 kPa and in case 2 = 40.93 kPa\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.4 page : 310" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy.linalg import solve\n", + "\t\t\t\n", + "# Variables\n", + "k4 = 1.8\n", + "k5 = 0.8\n", + "\t\t\t\n", + "# Calculations\n", + "A = [[k4, k5],[1, 1]]\n", + "b = [[1],[1]]\n", + "C = solve(A,b)\n", + "x4 = C[0]\n", + "x5 = C[1]\n", + "y4 = k4*x4\n", + "y5 = k5*x5\n", + "\t\t\t\n", + "# Results\n", + "print \"Vapor and liquid mole fractions of component 1 = %.2f and %.2f respectively\"%(y4,x4)\n", + "print \" Vapor and liquid mole fractions of component 2 = %.2f and %.2f respectively\"%(y5,x5)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Vapor and liquid mole fractions of component 1 = 0.36 and 0.20 respectively\n", + " Vapor and liquid mole fractions of component 2 = 0.64 and 0.80 respectively\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.5 page : 312" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "v1 = 81. \t\t\t#cm**3/gmol\n", + "v2 = 97. \t\t\t#cm**3/gmol\n", + "d1 = 9.2 \t\t\t#(cal/cm**3)**0.5\n", + "d2 = 8.6 \t\t\t#(cal/cm**3)**0.5\n", + "R = 1.987\n", + "T = 373.1 \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "d = 0.5*(d1+d2)\n", + "lng1 = v1*(d1-d)**2 /(R*T)\n", + "lng2 = v2*(d2-d)**2 /(R*T)\n", + "g1 = math.exp(lng1)\n", + "g2 = math.exp(lng2)\n", + "\t\t\t\n", + "# Results\n", + "print \"Activity coeffecients of components are %.3f and %.3f respectively\"%(g1,g2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Activity coeffecients of components are 1.010 and 1.012 respectively\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.6 page : 319" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "xe = 0.3\n", + "xe2 = 0.9\n", + "Pe0 = 810.\n", + "Pa0 = 470.\n", + "ge = 1.85\n", + "ge2 = 1.05\n", + "ga = 1.15\n", + "ga2 = 3.\n", + "Pt = 820. \t\t\t#mm\n", + "Pt2 = 900. \t\t\t#mm\n", + "\t\t\t\n", + "# Calculations\n", + "ye = ge*xe*Pe0/Pt\n", + "ya = ga*(1-xe)*Pa0/Pt\n", + "yt = ye+ya\n", + "ye2 = ye/yt\n", + "ya2 = ya/yt\n", + "ye3 = ge2*xe2*Pe0/Pt2\n", + "ya3 = ga2*(1-xe2)*Pa0/Pt2\n", + "yt2 = ye+ya\n", + "ye4 = ye3/yt2\n", + "ya4 = ya3/yt2\n", + "\t\t\t\n", + "# Results\n", + "print \"In case 1, ye = %.3f and ya = %.3f\"%(ye2,ya2)\n", + "print \" In case 1, ye = %.3f and ya = %.3f\"%(ye4,ya4)\n", + "print ('The calculations of ya in case 1 in textbook is wrong. please use a calculator')\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In case 1, ye = 0.543 and ya = 0.457\n", + " In case 1, ye = 0.842 and ya = 0.155\n", + "The calculations of ya in case 1 in textbook is wrong. please use a calculator\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.7 page : 326" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "m1 = 121.\n", + "m2 = 18.\n", + "p1 = 0.0042\n", + "p2 = 0.0858\n", + "\t\t\t\n", + "# Calculations\n", + "massfrac = (p1*m1)/(p1*m1+p2*m2)\n", + "\t\t\t\n", + "# Results\n", + "print \"mass fractions of DMA and water are %.3f and %.3f respectively\"%(massfrac,1-massfrac)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "mass fractions of DMA and water are 0.248 and 0.752 respectively\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.9 page : 335" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import array\n", + "\t\t\t\n", + "# Variables\n", + "FR = 25.\n", + "FE = 19.\n", + "bf = 130. \t\t\t#kg\n", + "af = 85. \t\t\t#kg\n", + "\t\t\t\n", + "# Calculations\n", + "law = FR/FE\n", + "x1 = 45./150\n", + "x2 = 65./150\n", + "ER = 18.5/6\n", + "e = array([0.5, 0.1, 0.9])\n", + "r = array([0.28, 0.96, 0.04])\n", + "et = sum(e)\n", + "rt = sum(r)\n", + "ett = e/et\n", + "rtt = r/rt\n", + "\t\t\t\n", + "# Results\n", + "print \"the compositions of raffinate are \",\n", + "print (rtt)\n", + "print \"the compositions of extract are\",\n", + "print (ett)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the compositions of raffinate are [ 0.21875 0.75 0.03125]\n", + "the compositions of extract are [ 0.33333333 0.06666667 0.6 ]\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.10 page : 342" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "v1 = 0.1316\n", + "v2 = 0.2941\n", + "x1 = 0.5\n", + "x2 = 0.2\n", + "x3 = 0.8 \n", + "d1 = 14.87\n", + "d2 = 16.34\n", + "\t\t\t\n", + "# Calculations and results\n", + "vm = x1*(v1+v2)\n", + "phi1 = x1*v1/vm\n", + "phi2 = (1-x1)*v2/vm\n", + "Hl1 = vm*phi1*phi2*(d1-d2)**2 *10**3\n", + "print (\"case 1\")\n", + "print \"enthalpy = %.1f kJ/mol\"%(Hl1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "case 1\n", + "enthalpy = 98.2 kJ/mol\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.10b page : 343" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "v1 = 0.1316\n", + "v2 = 0.2941\n", + "x1 = 0.5\n", + "x2 = 0.2\n", + "x3 = 0.8 \n", + "d1 = 14.87\n", + "d2 = 16.34\n", + "\t\t\t\n", + "# Calculations and results\n", + "vm = (1-x2)*v1+x2*v2\n", + "phi1 = (1-x2)*v1/vm\n", + "phi2 = (x2)*v2/vm\n", + "Hl2 = vm*phi1*phi2*(d1-d2)**2 *10**3\n", + "print (\"case 2\")\n", + "print \"enthalpy = %.1f kJ/mol\"%(Hl2)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "case 2\n", + "enthalpy = 81.5 kJ/mol\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.10c page : 343" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "v1 = 0.1316\n", + "v2 = 0.2941\n", + "x1 = 0.5\n", + "x2 = 0.2\n", + "x3 = 0.8 \n", + "d1 = 14.87\n", + "d2 = 16.34\n", + "\t\t\t\n", + "# Calculations and results\n", + "vm = (1-x3)*v1+x3*v2\n", + "phi1 = (1-x3)*v1/vm\n", + "phi2 = (x3)*v2/vm\n", + "Hl3 = vm*phi1*phi2*(d1-d2)**2 *10**3\n", + "print (\"case 3\")\n", + "print \"enthalpy = %.1f kJ/mol\"%(Hl3)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "case 3\n", + "enthalpy = 51.2 kJ/mol\n" + ] + } + ], + "prompt_number": 11 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch9.ipynb b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch9.ipynb new file mode 100755 index 00000000..48832bc1 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch9.ipynb @@ -0,0 +1,684 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:96bec67660df87f03597152ea9aebaa9244c05006b79d30c85f08e05c1a87e20" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 9 : Chemical Equilibria" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.1.A page : 359" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "g11 = 178900 \t\t\t#kJ/kmol\n", + "g12 = 207037 \t\t\t#kJ/kmol\n", + "g21 = 211852 \t\t\t#kJ/kmol\n", + "g22 = 228097 \t\t\t#kJ/kmol\n", + "\t\t\t\n", + "# Calculations\n", + "dG = g21-g11\n", + "\t\t\t\n", + "# Results\n", + "print \"Standard free energy change = %d kJ/kmol\"%(dG)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Standard free energy change = 32952 kJ/kmol\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.1B page : 359" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "m1 = 54.1\n", + "m2 = 56.1\n", + "m3 = 2.\n", + "cp1 = 2.122 \t\t\t#kJ/kmol K\n", + "cp2 = 2.213 \t\t\t#kJ/kmol K\n", + "cp3 = 14.499 \t\t\t#kJ/kmol K\n", + "hf1 = 110200. \t\t\t#kJ/kmol\n", + "hf2 = -126. \t\t\t#kJ/kmol\n", + "T = 700. \t\t\t#K\n", + "Ts = 298. \t \t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "hf = hf1-hf2\n", + "cpn = cp1*m1-cp2*m2+cp3*m3\n", + "h700 = hf+ cpn*(T-Ts)\n", + "s298 = 103.7\n", + "s700 = s298 + cpn*math.log(T/Ts)\n", + "G700 = h700-T*s700\n", + "\t\t\t\n", + "# Results\n", + "print \"Change in gibbs energy = %d kJ/kmol\"%(G700)\n", + "print (\"The answer is a bit different due to rounding off error in textbook\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in gibbs energy = 33888 kJ/kmol\n", + "The answer is a bit different due to rounding off error in textbook\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.2 page : 361" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables\n", + "g1 = 150670. \t\t\t#kJ/kmol\n", + "g2 = 71500. \t\t\t#kJ/kmol\n", + "R = 8.314\n", + "Ts = 298. \t\t\t#K\n", + "T = 700. \t\t\t#K\n", + "\n", + "#calculation\n", + "G = g1-g2\n", + "G2 = 33875 \t\t\t#kJ/kmol\n", + "K1 = math.exp(-G/R/Ts)\n", + "K2 = math.exp(-G2/R/T)\n", + "\t\t\t\n", + "# Results\n", + "print \"In case 1, equilibrium constant = %.2e\"%(K1)\n", + "print \" In case 2, equilibrium constant = %.5f\"%(K2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In case 1, equilibrium constant = 1.33e-14\n", + " In case 2, equilibrium constant = 0.00297\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.3 page : 363" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from scipy.integrate import quad\n", + "\t\t\t\n", + "# Variables\n", + "R = 8.3143\n", + "T1 = 1273 \t\t\t#K\n", + "T2 = 2273 \t\t\t#K\n", + "k2 = 0.0018\n", + "A = 123.94\n", + "B = 7.554\n", + "C = 8.552*10**-3\n", + "D = -13.25e-6\n", + "E = 7.002e-9\n", + "F = 13.494e-13\n", + "\t\t\t\n", + "# Calculations\n", + "def cp(T):\n", + " return A/T**2 +B/T +C +D*T +E*T**2 -F*T**3\n", + "\n", + "\n", + "lnk = 1/R * quad(cp,T1,T2)[0]\n", + "k1 = k2/ math.exp(lnk)\n", + "\t\t\t\n", + "# Results\n", + "print \"Equilibrium constant = %.5f \"%(k1)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Equilibrium constant = 0.00112 \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.4 page : 368" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from scipy.optimize import fsolve\n", + "\t\t\t\n", + "# Variables\n", + "G = -30050. \t\t\t#kJ/kmol\n", + "R = 8.314\n", + "T = 573. \t\t\t#K\n", + "\t\t\t\n", + "# Calculations\n", + "lnk = G/(R*T)\n", + "k = math.exp(lnk)\n", + "\n", + "def f(x):\n", + " return 4*x**2 - k*(1-x)**2\n", + "\n", + "vec = fsolve(f,0,full_output=1)\n", + "\n", + "x2 = vec[0]\n", + "# Results\n", + "print \"Mole fraction of HCN = %.4f\"%(x2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mole fraction of HCN = 0.0209\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.4B page : 368" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from numpy import roots\n", + "\t\t\t\n", + "# Variables\n", + "G = -30050. \t\t\t#kJ/kmol\n", + "R = 8.314\n", + "T = 573. \t\t\t#K\n", + "phi1 = 0.980\n", + "phi2 = 0.915\n", + "phi3 = 0.555\n", + "\t\t\t\n", + "# Calculations\n", + "lnk = G/(R*T)\n", + "k = math.exp(lnk)\n", + "kexp = k*phi1*phi2/phi3**2 /4\n", + "vec = roots([1-kexp,2*kexp,-kexp])\n", + "x2 = vec[1]\n", + "\t\t\t\n", + "# Results\n", + "print \"Mole fraction of HCN = %.4f\"%(x2)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mole fraction of HCN = 0.0351\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.5 page : 370" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from scipy.optimize import fsolve\n", + "\t\t\t\n", + "# Variables\n", + "kp = 74.\n", + "kp2 = kp**2\t\t\t\n", + "# Calculations\n", + "def fun(f):\n", + " return f**2 *(100-6*f) - kp**2 *(1-f)**2 *(9-6*f)\n", + "\n", + "vec = fsolve(fun,0,full_output=1)\n", + "fn = vec[0]\n", + "\t\t\t\n", + "# Results\n", + "print \"Fractional conversion = %.3f\"%(fn)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Fractional conversion = 0.934\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.6 page : 372" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "C = 3.\n", + "phi = 3.\n", + "R = 1.\n", + "Sc = 0.\n", + "\n", + "def fun(C,phi,R,Sc):\n", + " return 2+C-phi-R-Sc\n", + "\t\t\t\n", + "# Calculations\n", + "V = fun(C,phi,R,Sc)\n", + "\t\t\t\n", + "# Results\n", + "print \"Degrees of freedom = %d \"%(V)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Degrees of freedom = 1 \n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.6B page : 373" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "C = 3.\n", + "phi = 1.\n", + "R = 1.\n", + "Sc = 1.\n", + "\n", + "def fun(C,phi,R,Sc):\n", + " return 2+C-phi-R-Sc\n", + "\n", + "# Calculations\n", + "V = fun(C,phi,R,Sc)\n", + "\t\t\t\n", + "# Results\n", + "print \"Degrees of freedom = %d \"%(V)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Degrees of freedom = 2 \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.6C page : 373" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "C = 6.\n", + "phi = 1.\n", + "R = 3.\n", + "Sc = 0.\n", + "\n", + "def fun(C,phi,R,Sc):\n", + " return 2+C-phi-R-Sc\n", + "\n", + "\t\t\t\n", + "# Calculations\n", + "V = fun(C,phi,R,Sc)\n", + "\t\t\t\n", + "# Results\n", + "print \"Degrees of freedom = %d \"%(V)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Degrees of freedom = 4 \n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.7 page : 377" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables\n", + "a1 = 0.956\n", + "y = 0.014\n", + "x = 0.956\n", + "M = 18.\n", + "z = 0.475\n", + "P = 8.37 \t\t\t#Mpa\n", + "\t\t\t\n", + "# Calculations\n", + "m = y/(x*M) *10**3\n", + "w = 0.0856\n", + "phi1 = -0.04\n", + "phi2 = 0.06\n", + "phi = 10**(phi1+ w*phi2)\n", + "f = z*phi*P\n", + "K = m/(f*a1)\n", + "\t\t\t\n", + "# Results\n", + "print \"Equilibrium constant = %.3f\"%(K)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Equilibrium constant = 0.232\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.9 page : 385" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import array\n", + "\t\t\t\n", + "# Variables\n", + "y = 0.18\n", + "z = 0.6\n", + "\t\t\t\n", + "# Calculations\n", + "mole = array([1-y-z, 5-y-2*z, y, 3*y+4*z, z])\n", + "s = sum( mole)\n", + "molef = mole/s\n", + "\t\t\t\n", + "# Results\n", + "print \"Product composition moles = \",\n", + "print (mole)\n", + "print \"Mole fraction = \",\n", + "print (molef)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Product composition moles = [ 0.22 3.62 0.18 2.94 0.6 ]\n", + "Mole fraction = [ 0.02910053 0.47883598 0.02380952 0.38888889 0.07936508]\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.10 page : 388" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sympy import Symbol,solve\n", + "\t\t\t\n", + "# Variables\n", + "kp = 1.09\n", + "\t\t\t\n", + "# Calculations\n", + "x = Symbol('x')\n", + "vec = solve(kp/4**4 /4 *(1-x)*(5-2*x)**2 *(6+2*x)**2 -x**5)\n", + "x = vec[0]\n", + "pro = [1-x, 5-2*x, x, 4*x, 0]\n", + "\t\t\t\n", + "# Results\n", + "print \"Equlibrium composition (moles) = \",\n", + "print (pro)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Equlibrium composition (moles) = [0.273026192093833, 3.54605238418767, 0.726973807906167, 2.90789523162467, 0]\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.10B page : 390" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from numpy import array\n", + "from scipy.optimize import fsolve\n", + "\t\t\t\n", + "# Variables\n", + "kp = 1.09\n", + "kp2 = 0.154\n", + "feed = array([ 1, 5, 0, 0, 0 ])\n", + "\t\t\t\n", + "# Calculations\n", + "\n", + "def f1(x):\n", + " return kp/4**4 /4 *(1-x)*(5-2*x)**2 *(6+2*x)**2 -x**5\n", + "\n", + "vec = fsolve(f1,0,full_output=1)[0]\n", + "x = vec[0]\n", + "pro = feed - array([x, 2*x, -x, -4*x, 0])\n", + "\n", + "def f2(y):\n", + " return kp2*(0.273-y)*(0.727-y)*(7.454+2*y)**2 - 4*y**2 *(2.908+2*y)**2 *4\n", + "\n", + "vec2 = fsolve(f2,0,full_output=1)[0] \n", + "y = vec2[0]\n", + "pro2 = pro- array([ y, 0, y, -2*y, -2*y])\n", + "\n", + "def f3(z):\n", + " return kp*(0.189-z)*(3.546-2*z)**2 *(7.622+2*z)**2 -(0.643+z)*(3.076+4*z)**4 *4\n", + " \n", + "vec3 = fsolve(f3,0,full_output=1)[0]\n", + "z = vec3[0]\n", + "pro3 = pro2 - array([z, 2*z, -z, -4*z, 0])\n", + "\n", + "def f4(w):\n", + " return kp2*(0.229-w)*(0.603-w)*(7.542+2*w) - (2.916+2*w)**2 *(0.168+2*w)**2 *4\n", + "\n", + "vec4 = fsolve(f4,0,full_output=1)[0]\n", + "w = vec4[0]\n", + "w = 0.01\n", + "pro4 = pro3 - array([w, 0, w, -2*w, -2*w])\n", + "\t\t\t\n", + "# Results\n", + "print \"feed = \",\n", + "print (feed)\n", + "print \"After reactor 1,\",\n", + "print (pro)\n", + "print \"After reactor 2,\",\n", + "print (pro2)\n", + "print \"After reactor 3,\",\n", + "print (pro3)\n", + "print \"After reactor 4\",\n", + "print (pro4)\n", + "print (\"The answers are a bit different due to rounding off error in textbook\")\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "feed = [1 5 0 0 0]\n", + "After reactor 1, [ 0.27302619 3.54605238 0.72697381 2.90789523 0. ]\n", + "After reactor 2, [ 0.18846228 3.54605238 0.6424099 3.07702305 0.16912782]\n", + "After reactor 3, [ 0.22284245 3.61481272 0.60802973 2.93950238 0.16912782]\n", + "After reactor 4 [ 0.21284245 3.61481272 0.59802973 2.95950238 0.18912782]\n", + "The answers are a bit different due to rounding off error in textbook\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |