diff options
author | nice | 2014-09-15 12:50:58 +0530 |
---|---|---|
committer | nice | 2014-09-15 12:50:58 +0530 |
commit | 2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c (patch) | |
tree | 680c46833c53f5ecbbceb773bec170a89ac94152 /Engineering_&_Chemical_Thermodynamics/ch5.ipynb | |
parent | f77c828fecc4db415b42d5b0e28a75dd135476d4 (diff) | |
download | Python-Textbook-Companions-2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c.tar.gz Python-Textbook-Companions-2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c.tar.bz2 Python-Textbook-Companions-2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c.zip |
added books
Diffstat (limited to 'Engineering_&_Chemical_Thermodynamics/ch5.ipynb')
-rwxr-xr-x | Engineering_&_Chemical_Thermodynamics/ch5.ipynb | 313 |
1 files changed, 313 insertions, 0 deletions
diff --git a/Engineering_&_Chemical_Thermodynamics/ch5.ipynb b/Engineering_&_Chemical_Thermodynamics/ch5.ipynb new file mode 100755 index 00000000..be3b6851 --- /dev/null +++ b/Engineering_&_Chemical_Thermodynamics/ch5.ipynb @@ -0,0 +1,313 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 5 : The thermodynamic web" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.2 Page No : 278" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "T_c = 370. ; \t\t\t#[K]\n", + "P_c = 41.58 * 10**5 ;\t\t\t#[N/m**2]\n", + "R = 8.314 ;\n", + "V1 = 0.001 ;\t\t\t#[m**3]\n", + "V2 = 0.04 ; \t\t\t#[m**3]\n", + "q = 10400. ; \t\t\t#[J]\n", + "\n", + "# Calculations\n", + "a = 27./64 * (R **2)*(T_c)**2 / P_c ;\n", + "del_U = -0.96 * (1 / V2 - 1 / V1) ; \n", + "W = round(del_U - q,-1) ;\n", + "\n", + "# Results\n", + "print \" Work done for the expansion = %.f J/mol\"%(W) ;\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Work done for the expansion = -9460 J/mol\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.4 Page No : 282" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from scipy.optimize import fsolve \n", + "from scipy.integrate import quad\n", + "import math \n", + "\n", + "# Variables\n", + "P_1 = 9.43 * 10**5 ; \t\t\t#[N/m**2]\n", + "P_2 = 18.9 * 10**5 ; \t\t\t#[N/m**2]\n", + "T_1 = 80 + 273 ; \t\t\t#[K]\n", + "T_2 = 120 + 273 ; \t\t\t#[K]\n", + "A = 1.935 ;\n", + "B = 36.915 * 10**-3 ;\n", + "C = -11.402 * 10**-6 ;\n", + "T_c = 425.2 ; \t\t\t# [K]\n", + "P_c = 37.9 * 10**5 ;\t\t\t#[N/m**2]\n", + "R = 8.314 ;\n", + "\n", + "\n", + "del_h_1 = 1368 ; \t\t\t#[J/mol]\n", + "del_h_3 = -2542 ; \t\t\t#[J/mol]\n", + "Ws = 2100. ; \t\t\t#[J/mol]\n", + "\n", + "a = 0.42748 * R**2 * T_c**2.5 / P_c ;\n", + "b = 0.08664 * R * T_c / P_c ;\n", + " \n", + "\n", + "def f1(v):\n", + " return R * T_1 / (v - b) - a / (math.sqrt(T_1) * v *(v + b)) - P_1;\n", + "\n", + "za= fsolve( f1,0.001)\n", + "\n", + "def f2(v):\n", + " return R * T_2 / (v - b) - a / (math.sqrt(T_2) * v *(v + b)) - P_2;\n", + "\n", + "zb= fsolve( f2,0.001)\n", + "v1 = zb\n", + "v2 = zb\n", + "def f3(v):\n", + " T = 353.15\n", + " return b*R*T/(v-b) + a/T**0.5 * (3./(2*b) * math.log(v/(v+b)) - 1./(v+b))\n", + " \n", + "delta_h1 = quad(f3,za,zb)\n", + "\n", + " \n", + "def f(T):\n", + " return R * ( A * T + B/2 * T**2 + C/3 * T**3) ;\n", + "\n", + "del_h_2 = f(T_2) - f(T_1) ;\n", + "del_h_total = del_h_1 + del_h_2 + del_h_3 ;\n", + "q = del_h_total - Ws ;\n", + "\n", + "# Results\n", + "print \"v1 = %.2e m**3/mol, v2 = %.2e m**3/mol\"%(za,zb ) ;\n", + "print \"The heat input = %.f J/mol\"%(q);\n", + "\n", + "# Note : answer is slightly different because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "v1 = 2.60e-03 m**3/mol, v2 = 1.27e-03 m**3/mol\n", + "The heat input = 1421 J/mol\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.6 Page No : 289" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sympy import log\n", + "from sympy.solvers import solve\n", + "from sympy import Symbol\n", + "\n", + "#Variables\n", + "A = 2.104 ; \n", + "B = 2.98 * 10**-3 ;\n", + "R = 8.314 ;\n", + "Beta = 3.5 * 10**-5 ;\n", + "v = 7.1 * 10**-6 # m**3/mol\n", + "P2 = 10000*10**5 ; \t\t#[N/m**2]\n", + "P1 =1 ;\t\t\t #[N/m**2] \n", + "\n", + "#Calculations\n", + "T2 = Symbol('T2')\n", + "q = solve(A*R*log(T2/1000)+B*R*(T2-1000)-(Beta*v*(P2-P1)),T2)\n", + "\n", + "#Result \n", + "print \"Heat input = \",q,\"J/mol\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Heat input = [1005.88624122037] J/mol\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.7 page no : 296" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from scipy.integrate import quad\n", + "\n", + "# Variables ( same as example 5.4)\n", + "R = 8.314\n", + "Tc = 425.2 # K \n", + "Pc = 37.9 # bar \n", + "w = 0.199\n", + "T1 = 353.15 # K\n", + "Tc = 425.2 # K\n", + "P1 = 9.47 # bar\n", + "Pc = 38. # bar\n", + "T2 = 393.15 # K\n", + "P2 = 18.9 # bar\n", + "R = 8.314\n", + "\n", + "# calculations\n", + "T1r = T1/Tc\n", + "P1r = P1/Pc\n", + "T2r = T2/Tc\n", + "P2r = P2/Pc\n", + "\n", + "def f(T):\n", + " return 1.935 + 36.915 * 10**-3 * T - 11.402 * 10**-6 * T**2\n", + "\n", + "cpDt = R * quad(f,353,393)[0]\n", + "h2h1 = .536 * R*Tc +cpDt - .969*R*Tc\n", + "\n", + "# Results\n", + "print \"the heat capacity = %.f J/mol\"%cpDt\n", + "print \"h2 - h1 = %.f J/mol\"%h2h1\n", + "\n", + "# Note : answer is slightly differnt becuase of rounding off error. and this problem is same as 5.4" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the heat capacity = 4695 J/mol\n", + "h2 - h1 = 3164 J/mol\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.10 Page No : 302" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from scipy.integrate import quad\n", + "\n", + "# Variables\n", + "T_c = 126.2; \t \t\t#[K] , From appendix A.1\n", + "P_c = 33.8 * 10**5 ; \t\t\t#[N/m**2] , From appendix A.1\n", + "w = 0.039 ; \t\t \t# From appendix A.1\n", + "enth_dep_1 = -2.81 ; \t\t\t# From table C.1 Appendix C\n", + "A = 3.28 ;\t\t\t # From Appendix A.2\n", + "B = 0.593 * 10**-3 ;\t\t\t# From Appendix A.2\n", + "del_h_dep_l = -5.1 ; \n", + "del_h_dep_v = -0.1 ;\n", + "T1 = 151. \t\t\t#[K]\n", + "P1 = 100. * 10**5 ; \t \t\t#[N/m**2]\n", + "P2 = 1. * 10**5 ; \t\t \t#[N/m**2]\n", + "T2_r = 0.61 ; \t\t\t # From figure 5.4\n", + "\n", + "# Calculations\n", + "T1_r = T1 / T_c ;\n", + "P1_r = round(P1 / P_c) ;\n", + "P2_r = P2 / P_c ;\n", + "T2 = round(T2_r * T_c) ; \t\t\t#[K]\n", + "\n", + "def f(T):\n", + " #return A * T + B/2 * T**2 \n", + " return A + B*T\n", + "\n", + "ans = quad(f,151,T2)[0]\n", + "\n", + "x = 1. / T_c *ans\n", + "y = enth_dep_1 - x ;\n", + "\n", + "# Results\n", + "X = ( y - del_h_dep_l) / (del_h_dep_v - del_h_dep_l);\n", + "print \"Quality = %.2f\"%(X) ;\n", + "\n", + "# Note: answer is different because of quad is giving different value -1.9 instead of -1.28. " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Quality = 0.85\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |