diff options
author | Thomas Stephen Lee | 2015-08-28 16:53:23 +0530 |
---|---|---|
committer | Thomas Stephen Lee | 2015-08-28 16:53:23 +0530 |
commit | 4a1f703f1c1808d390ebf80e80659fe161f69fab (patch) | |
tree | 31b43ae8895599f2d13cf19395d84164463615d9 /Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch4.ipynb | |
parent | 9d260e6fae7328d816a514130b691fbd0e9ef81d (diff) | |
download | Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.tar.gz Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.tar.bz2 Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.zip |
add books
Diffstat (limited to 'Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch4.ipynb')
-rwxr-xr-x | Chemical_Engineering_Thermodynamics_by_T._E._Daubert/ch4.ipynb | 1364 |
1 files changed, 1364 insertions, 0 deletions
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 |