summaryrefslogtreecommitdiff
path: root/Engineering_&_Chemical_Thermodynamics/ch2.ipynb
diff options
context:
space:
mode:
authornice2014-09-15 12:50:58 +0530
committernice2014-09-15 12:50:58 +0530
commit2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c (patch)
tree680c46833c53f5ecbbceb773bec170a89ac94152 /Engineering_&_Chemical_Thermodynamics/ch2.ipynb
parentf77c828fecc4db415b42d5b0e28a75dd135476d4 (diff)
downloadPython-Textbook-Companions-2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c.tar.gz
Python-Textbook-Companions-2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c.tar.bz2
Python-Textbook-Companions-2792e8d6ecab454e3cb8fb1ea1f26f1613bc1e1c.zip
added books
Diffstat (limited to 'Engineering_&_Chemical_Thermodynamics/ch2.ipynb')
-rwxr-xr-xEngineering_&_Chemical_Thermodynamics/ch2.ipynb1120
1 files changed, 1120 insertions, 0 deletions
diff --git a/Engineering_&_Chemical_Thermodynamics/ch2.ipynb b/Engineering_&_Chemical_Thermodynamics/ch2.ipynb
new file mode 100755
index 00000000..e1006ddc
--- /dev/null
+++ b/Engineering_&_Chemical_Thermodynamics/ch2.ipynb
@@ -0,0 +1,1120 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 2 : The First law of Thermodynamics"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.1 Page No : 38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "import math \n",
+ "\n",
+ "z1 = 10. \t\t\t#[m]\n",
+ "z2 = 0. \t\t\t#[m],Taking ground as state 2,reference\n",
+ "v1 = 0.\n",
+ "g = 9.81 #m/s\n",
+ "\n",
+ "#From conservation of total energy we get\n",
+ "# (1/2*m*v2**2-1 / 2*m*v1**2)+(m*g*z2 - m*g*z1) = 0\n",
+ "# 1/2*m*v2**2 - m*g*z1 = 0\n",
+ "v2 = math.sqrt(2 * g * z1) ; \t\t\t#[m/s]\n",
+ "\n",
+ "# Results\n",
+ "print 'Final velocity = %.f m/s'%(v2);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Final velocity = 14 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.2 Page No : 41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variables\n",
+ "V2 = 14. \t\t\t# [m/s]\n",
+ "u_cap_l1 = 104.86 ; \t\t\t#[kJ/kg],at 25*C internal energy of saturated water\n",
+ "u_cap_l_t25 = 104.86 ; \t\t\t#[kJ/kg], From steam table \n",
+ "u_cap_l_t30 = 125.77 ; \t\t\t#[kJ/kg], From steam table\n",
+ "T1 = 25. \t\t \t#[*C]\n",
+ "T2 = 30. \t\t \t #[*C]\n",
+ "\n",
+ "# Calculations\n",
+ "#For unit mass change in kinetic energy\n",
+ "Delta_e_cap_k = 1./2 * V2**2 * 10**-3 ; \t\t\t#[kJ/kg]\n",
+ "Delta_u_cap = Delta_e_cap_k ;\n",
+ "#For final state of water:\n",
+ "u_cap_l2 = Delta_u_cap + u_cap_l1 ;\n",
+ "\n",
+ "x = (u_cap_l2 - u_cap_l_t25) / (u_cap_l_t30 - u_cap_l_t25) ;\n",
+ "T_unknown = T1 + x*(T2 - T1) ;\n",
+ "\n",
+ "# Results\n",
+ "print 'Final temperature of water = %.2f degreeC'%(T_unknown);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Final temperature of water = 25.02 degreeC\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.3 Page No : 43"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "import math \n",
+ "import scipy.integrate\n",
+ "\n",
+ "# Variables\n",
+ "P_ex = 1*10**5 ; \t\t\t#[Pa]}\n",
+ "\n",
+ "# Calculations\n",
+ "#To calculte work done\n",
+ "def f(x):\n",
+ " return 1\n",
+ " \n",
+ "I = scipy.integrate.quadrature(f,10,15.2)[0]\n",
+ "W = -P_ex * I * 10**-3 ; \t\t\t#[J]\n",
+ "\n",
+ "# Results\n",
+ "print 'Work done = %g J'%(W);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Work done = -520 J\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.4 page no : 57"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from scipy.integrate import quad\n",
+ "\n",
+ "# Variables\n",
+ "V = 1.0 # m**3\n",
+ "m = 10 # kg\n",
+ "p1p2 = .2\n",
+ "u1 = 2600.3 #kJ/kg\n",
+ "P1 = 20\n",
+ "v1 = 0.1\n",
+ "\n",
+ "# Calculations\n",
+ "v = V/m\n",
+ "v2 = (p1p2*v**1.5)**(1./1.5)\n",
+ "\n",
+ "def fun(v):\n",
+ " return P1*v1**1.5/v**1.5\n",
+ "\n",
+ "w = -quad(fun,0.1,.0342)[0]\n",
+ " \n",
+ "u2 = 3045.8 + (3144.5 - 3045.8) * (v2 - .03279)/(.03564 - .03279)\n",
+ "T2 = 500 + (550 - 500) * (v2 - .03279)/(.03564 - .03279)\n",
+ "\n",
+ "# results\n",
+ "print \"The specific volume of initial state = %.2f m**3/kg\"%v\n",
+ "print \"V2 = %.4f m**3/kg\"%v2\n",
+ "print \"Work done = %.f kJ/kg\"%(w*100)\n",
+ "print \"U2 = %.1f kJ/kg\"%u2\n",
+ "print \"T2 = %.f C\"%T2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The specific volume of initial state = 0.10 m**3/kg\n",
+ "V2 = 0.0342 m**3/kg\n",
+ "Work done = 284 kJ/kg\n",
+ "U2 = 3094.6 kJ/kg\n",
+ "T2 = 525 C\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.5 Page No : 63"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# variables\n",
+ "#From steam table specific enthalpy at state1 and state2 are\n",
+ "h_cap_1 = 3373.6 \t\t\t#[kJ/kg]\n",
+ "h_cap_2 = 2675.5 \t\t\t#[kJ/kg]\n",
+ "m_dot1 = 10. \t\t\t#[kg/s],As we are dealing with steady state\n",
+ "m_dot2 = 10. \t \t\t#[kg/s]\n",
+ "\n",
+ "# Calculations\n",
+ "Ws_dot = m_dot1 * (h_cap_2 - h_cap_1) ; \t\t\t#[kW]\n",
+ "\n",
+ "# Results\n",
+ "print 'Power generated = %g kW'%(Ws_dot);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Power generated = -6981 kW\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.6 Page No : 64"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variables\n",
+ "h_cap_in = 3241.\t\t#[kJ/kg] , From steam table\n",
+ "P_final = 10. \t\t\t#[MPa]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "u_cap_2 = h_cap_in ;\n",
+ "T2 = 600. ; \t\t\t# From steam table .No calculation is involved .\n",
+ "print 'a) The final temperature of the system = %g *C'%(T2);\n",
+ "\n",
+ "u_cap_2 = h_cap_in ;\n",
+ "# So temperature is T2 = 600*C (From table).\n",
+ "#Solution(b)\n",
+ "print \"(b) The temperature of the fluid increases in the system due to the receipent of flow work .\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a) The final temperature of the system = 600 *C\n",
+ "(b) The temperature of the fluid increases in the system due to the receipent of flow work .\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.7 Page No : 72"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import scipy.integrate.quadrature \n",
+ "\n",
+ "# Variables\n",
+ "n = 2. \t\t\t#[mol]\n",
+ "A = 3.470 ;\n",
+ "B = 1.450*10**-3 ;\n",
+ "D = 0.121*10**5 ;\n",
+ "T1 = 473. ; \t\t\t#[K]\n",
+ "T2 = 773. ; \t\t\t#[K]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "def f(T):\n",
+ " return 8.314*(A + B*T + D*T**-2)\n",
+ " \n",
+ "Delta_h = scipy.integrate.quadrature(f,T1,T2)[0]\n",
+ "\n",
+ "Q = n * Delta_h ;\n",
+ "\n",
+ "print 'a)Heat required = %d J'%(Q);\n",
+ "\n",
+ "#From steam table\n",
+ "h_cap_1 = 2827.9 ; \t\t\t#[kJ/kg]\n",
+ "h_cap_2 = 3478.4 ; \t\t\t#[kJ/kg]\n",
+ "m = 2*0.018 ; \t\t\t#[kg]\n",
+ "\n",
+ "Delta_h_cap = (h_cap_2 - h_cap_1) * 10**3 ; \t\t\t#[J/kg]\n",
+ "Q = m * Delta_h_cap;\n",
+ "print 'b)Heat required = %g J'%(Q);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a)Heat required = 21981 J\n",
+ "b)Heat required = 23418 J\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.8 Page No : 73"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "T1 = 298.;\n",
+ "T2_start = 300.;\n",
+ "A = 3.355;\n",
+ "B = 0.575*10**-3;\n",
+ "D = -0.016*10**5;\n",
+ "\n",
+ "# Calculations\n",
+ "def f(T):\n",
+ " return 8.314*(A*T + B/2*T**2 - D/T)\n",
+ "\n",
+ "for T2_start in range(300,1000+1,100):\n",
+ " del_h = f(T2_start) - f(T1);\n",
+ " Cp = del_h /(T2_start - 298);\n",
+ " print 'At temperatureK %g, Molar heat capacity J/molK, %.2f'%(T2_start,Cp); \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "At temperatureK 300, Molar heat capacity J/molK, 29.17\n",
+ "At temperatureK 400, Molar heat capacity J/molK, 29.45\n",
+ "At temperatureK 500, Molar heat capacity J/molK, 29.71\n",
+ "At temperatureK 600, Molar heat capacity J/molK, 29.97\n",
+ "At temperatureK 700, Molar heat capacity J/molK, 30.22\n",
+ "At temperatureK 800, Molar heat capacity J/molK, 30.46\n",
+ "At temperatureK 900, Molar heat capacity J/molK, 30.71\n",
+ "At temperatureK 1000, Molar heat capacity J/molK, 30.95\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.9 Page No : 73"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "n_dot_air = 10. ; \t\t\t#[mol/min]\n",
+ "C_bar_P_900 = 30.71 ; \t\t\t#[J/molK]\n",
+ "C_bar_P_600 = 29.97 ; \t\t\t#[J/molK]\n",
+ "T1 = 600. ; \t\t\t#[K]\n",
+ "T2 = 900. ; \t\t\t#[K]\n",
+ "T_ref = 298. ; \t\t\t#[K]\n",
+ "\n",
+ "# Calculations\n",
+ "# Q_dot = n_dot_air * (h_900 - h_600)...........Eqn E2.8A\n",
+ "Q_dot = n_dot_air * (C_bar_P_900 * (T2 - T_ref) - C_bar_P_600 * (T1 - T_ref)); \n",
+ "\n",
+ "# Results\n",
+ "print 'Heat rate required = %.3f J/min'%(Q_dot/1000);\n",
+ "\n",
+ "# note: answer may vary because of rounding error."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Heat rate required = 94.365 J/min\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.10 Page No : 74"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "# Variables\n",
+ "P1 = 100000. ; \t\t\t # [N/m**2]\n",
+ "T1 = 298. ; \t\t \t#[K]\n",
+ "V1 = 0.1 * 0.1 ; \t\t\t# [m**3]\n",
+ "T2 = 373. ; \t\t\t # [N]\n",
+ "P_ext = 100000. ; \t\t\t#[N/m**2]\n",
+ "k = 50000. \t\t\t#[N/m]\n",
+ "A = 0.1 ; \t\t \t#[m**2]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "a = k / (T2 * A**2) ;\n",
+ "b = (P_ext / T2) - k * V1 / (A**2 * T2) ;\n",
+ "c = -P1 * V1 / T1 ;\n",
+ "V2 = (-b + math.sqrt ( b**2 - (4*a*c))) / (2 * a) ;\n",
+ "W = -P_ext * (V2 - V1) - ( k * (V2 - V1)**2)/(2 * A**2);\t\t\t#From eqn E2.9C\n",
+ "\n",
+ "print 'a) Work required = %.f J '%(W);\n",
+ "\n",
+ "\n",
+ "A = 3.355 ;\n",
+ "B = 0.575 * 10**-3 ;\n",
+ "D = -0.016 * 10**5 ;\n",
+ "P1 = 10**5 ; \t\t\t#[N/m**2]\n",
+ "V1 = 0.01 ; \t\t\t#[m**3]\n",
+ "R = 8.314 ;\n",
+ "T1 = 298 ;\n",
+ "\n",
+ "n = (P1 * V1) / (R * T1) ;\n",
+ "def f(T):\n",
+ " return R*((A - 1) * T + B/2 * T**2 -D/T)\n",
+ "\n",
+ "del_u = f(373) - f(298) ;\n",
+ "del_U = n * del_u ;\n",
+ "Q = del_U - W;\n",
+ "print 'b).Heat transfered = %.f J'%(Q);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a) Work required = -166 J \n",
+ "b).Heat transfered = 803 J\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.11 Page No : 78"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "n_dot = 10. \t \t\t#[mol/s]\n",
+ "T1 = 298.2 \t\t\t#[K]\n",
+ "T2 = 342. \t\t\t #[K]\n",
+ "T3 = 373.2 \t\t \t#[K]\n",
+ "Cp_298_342 = 216.3 \t\t\t#[J/molK]\n",
+ "A = 3.025 \n",
+ "B = 53.722 * 10**-3\n",
+ "C = -16.791 * 10**-6\n",
+ "del_h_vap = 28.88 \t\t\t#[kJ/mol]\n",
+ "\n",
+ "# Calculations\n",
+ "del_h_1 = Cp_298_342 * (T2 - T1) * 10**-3 ; \t\t\t#[kJ/mol]\n",
+ "del_h_2 = del_h_vap ;\n",
+ "def f(T):\n",
+ " return 8.314*(A*T + (B/2)*(T**2) + (C/3)*(T**3))* 10**-3 ;\n",
+ "\n",
+ "del_h_3 = f(T3) - f(T2) ;\n",
+ "Q = n_dot * (del_h_1 + del_h_2 + del_h_3) ;\n",
+ "\n",
+ "print 'Rate of heat supplied = %d kJ/s'%(Q );\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Rate of heat supplied = 435 kJ/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.12 Page No : 79"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variables\n",
+ "m_1_v = 4.3 \t\t\t#[kg]\n",
+ "m_1_l = 50. \t\t\t#[kg]\n",
+ "u_cap_1_v = 2437.9 \t\t\t#[kJ/kg],From steam table\n",
+ "u_cap_1_l = 191.8 \t\t\t#[kJ/kg],From steam table\n",
+ "v_cap_1_v = 14.67 \t \t\t#[m**3],From steam table\n",
+ "v_cap_1_l = 0.001 \t\t \t#[m**3],From steam table\n",
+ "\n",
+ "# Calculations\n",
+ "V2 = m_1_l * v_cap_1_l + m_1_v * v_cap_1_v ;\n",
+ "m_2_v = m_1_l + m_1_v ;\n",
+ "v_cap_2_v = V2 / m_2_v ; \t\t\t#[m**3/kg]\n",
+ "P2= 0.15 \t\t\t#[MPa]\n",
+ "u_cap_2_v = 2519.6 \t\t\t#(kJ/kg)\n",
+ "Q = ((m_2_v * u_cap_2_v) -(m_1_l * u_cap_1_l + m_1_v * u_cap_1_v))*1000;\n",
+ "\n",
+ "# Results\n",
+ "print 'Minimum amount of heat required = %.2e J'%(Q);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Minimum amount of heat required = 1.17e+08 J\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.13 Page No : 83"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "del_h0_f_CO2 = -393.51 ; \t\t\t# [kJ/mol]\n",
+ "del_h0_f_H2 = 0 ; \t\t\t# [kJ/mol]\n",
+ "del_h0_f_H2O = -241.82 ; \t\t\t# [kJ/mol]\n",
+ "del_h0_f_CH3OH = -200.66 ; \t\t\t# [kJ/mol]\n",
+ "\n",
+ "# Calculations\n",
+ "del_h0 = del_h0_f_CO2 + 3 * del_h0_f_H2 - del_h0_f_H2O - del_h0_f_CH3OH ;\n",
+ "\n",
+ "# Results\n",
+ "print 'Enthalpy of reaction = %.f kJ/mol'%(del_h0);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enthalpy of reaction = 49 kJ/mol\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.14 page no : 84"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# variables\n",
+ "Vp = 3*10**6 *0.7*10**6\n",
+ "MW = 114.2 # g/mol\n",
+ "\n",
+ "\n",
+ "#Calculations\n",
+ "n = Vp/MW\n",
+ "H = -9.3 * 10**16 # J\n",
+ "Ep = 200 * 0.10*24*3600 # energy density\n",
+ "A = -H/Ep\n",
+ "\n",
+ "# Results\n",
+ "print \"a) Area A = %.1e m**2\"%A\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a) Area A = 5.4e+10 m**2\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.15 Page No : 85"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "import math \n",
+ "from numpy import *\n",
+ "from scipy.integrate import *\n",
+ "\n",
+ "# Variables\n",
+ "del_h0_f_CO2 = -393.51 \t\t\t#[kJ/mol], From Appendix A.3 \n",
+ "del_h0_f_CO = -110.53 \t \t\t#[kJ/mol], From Appendix A.3\n",
+ "del_h0_f_H2O = -241.82 \t\t\t#[kJ/mol], From Appendix A.3\n",
+ "del_h0_f_C3H8 = -103.85 \t\t\t#[kJ/mol], From Appendix A.3\n",
+ "del_h0_f_O2 = 0. \t\t\t #[kJ/mol], From Appendix A.3\n",
+ "A_CO2 = 5.457 \t\t\t # From table E2.13\n",
+ "B_CO2 = 1.05 * 10**-3 \n",
+ "D_CO2 = -1.16 * 10**5 \n",
+ "A_CO = 3.379 \n",
+ "B_CO = 5.57 * 10**-4\n",
+ "D_CO = -3.1 * 10**3 \n",
+ "A_H2O = 3.470 \n",
+ "B_H2O = 1.45 * 10**-3\n",
+ "D_H2O = 1.21 * 10**4 \n",
+ "A_N2 = 3.280 \n",
+ "B_N2 = 5.93 * 10**-4 \n",
+ "D_N2 = 4.00 * 10**3 \n",
+ " \n",
+ "# Calculations \n",
+ "n_C3H8 = 10. \t\t\t#[mol]\n",
+ "n_N2 = (0.79/0.21) * (9.7/2) * n_C3H8 ; \t\t\t#[mol]\n",
+ "n_CO2 = 2.7 * n_C3H8 ; \t\t\t#[mol]\n",
+ "n_CO = 0.3 * n_C3H8 ; \t\t\t#[mol]\n",
+ "n_H2O = 4 * n_C3H8 ; \t\t\t#[mol]\n",
+ "n_O2 = (9.7 / 2)* n_C3H8 \t\t#[mol]\n",
+ "T_reff = 298. \t\t\t#[K]\n",
+ "del_H_rxn_298 = n_CO2 * del_h0_f_CO2 + n_CO * del_h0_f_CO + n_H2O * del_h0_f_H2O - n_C3H8 * del_h0_f_C3H8 - n_O2 * del_h0_f_O2 ; \t\t\t#[kJ]\n",
+ "\n",
+ "#The co-efficients of T2 in the equation of degree 3 are\n",
+ "a = 8.314*(n_CO2 * (B_CO2/2) + n_CO * (B_CO/2) + n_H2O * (B_H2O/2) + n_N2 * (B_N2/2));\n",
+ "b = 8.314*(n_CO2 * A_CO2 + n_CO * A_CO + n_H2O * A_H2O + n_N2 * A_N2) ;\n",
+ "d =8.314*(- n_CO2 * D_CO2 - n_CO * D_CO - n_H2O * D_H2O -n_N2 * D_N2) ;\n",
+ "c = (del_H_rxn_298 *1000) + 8.314 * (n_CO2 * (- T_reff * A_CO2 - B_CO2/2 * T_reff**2 + D_CO2/T_reff) + n_CO * (- T_reff * A_CO - B_CO/2 * T_reff**2 + D_CO/T_reff) + n_H2O * (- T_reff * A_H2O - B_H2O/2 * T_reff**2 + D_H2O/T_reff) + n_N2 * (-T_reff * A_N2 - B_N2/2 * T_reff**2 + D_N2/T_reff));\n",
+ "\n",
+ "T2=poly1d([a,b,c,d])\n",
+ "M = roots(T2);\n",
+ "\n",
+ "\n",
+ "# Results\n",
+ "print \"T2 = %.f [K]\"%(round(round(M[1]),-1))\n",
+ "\n",
+ "# Note: python has only 1 method to find roots so part 1-2 can be calculated same way here."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "T2 = 2350 [K]\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.16 pageno : 89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# variables\n",
+ "\n",
+ "# Calculations\n",
+ "deltaH1rxn298 = (-393.51) - 1*(-110.53) -0 # Reaction 1\n",
+ "deltaH2rxn298 = 1*(-110.53) -0 - 0 # Reaction 2\n",
+ "E1 = 3\n",
+ "E2 = 1\n",
+ "\n",
+ "deltaHrxn = E1*deltaH1rxn298*1000 + E2*deltaH2rxn298*1000\n",
+ "nCO2 = 4 - E1 + E2\n",
+ "nO22 = 4 - (1./2*E1) - 1./2*E2\n",
+ "nCO22 = 0 + E1\n",
+ "nC2 = 2 - E2\n",
+ "s = 52000.\n",
+ "Q = deltaHrxn + s\n",
+ "\n",
+ "# Results\n",
+ "print \"extensive enthalpy of reaction %.2e J\"%deltaHrxn\n",
+ "print \"amount of energy transferred by heat %.1e J\"%Q"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "extensive enthalpy of reaction -9.59e+05 J\n",
+ "amount of energy transferred by heat -9.1e+05 J\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.18 Page No : 96"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from numpy import *\n",
+ "\n",
+ "# Variables\n",
+ "V1 = 350. \t\t \t#[m/s]\n",
+ "A = 3.355 \n",
+ "B = 0.575*10**-3\n",
+ "D = -0.016*10**5\n",
+ "Tin = 283. \t \t\t#[K]\n",
+ "MW = 29.*10**-3 ; \t\t\t#[kg/mol]\n",
+ "\n",
+ "ek = 1./2 * MW * V1**2 \n",
+ "a = B/2.\n",
+ "b = A ;\n",
+ "c = -(Tin * A + Tin**2*B/2 - (D/Tin) + ek/8.314)\n",
+ "d=-D \n",
+ "\n",
+ "T2=poly1d([a,b,c,d])#'T2',0);\n",
+ "M = roots(T2);\n",
+ "\n",
+ "\n",
+ "# Results\n",
+ "print \"Temperature T2 = %.f [K]\"%M[1]\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature T2 = 344 [K]\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.19 Page No : 97"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variables\n",
+ "V_dot_2 = 0.001 ; \t\t\t#[m**3/kg]\n",
+ "v_cap_2 = 0.001 ; \t\t\t#[m**3/kg], Specific volume of water\n",
+ "z2 = 250. \t\t\t#[m] ; Taking ground as the reference level\n",
+ "e_cap_2 = 9.8 * z2 \t\t\t#[kg*m**2/s**2]\n",
+ "\n",
+ "# Calculations\n",
+ "m_dot_2 = V_dot_2 / v_cap_2 \t\t\t#[kg/s]\n",
+ "W_dot_s = m_dot_2 * e_cap_2 * 10**-3 ;\n",
+ "\n",
+ "# Results\n",
+ "print 'Minimum power required is = %.1f kW'%(W_dot_s);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Minimum power required is = 2.5 kW\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.20 Page No : 98"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "n_dot = 10. \t\t\t#[mol/min]\n",
+ "del_h_vap_CO2 = 10400. ; \t\t\t#[J/mol]\n",
+ "A_CO2 = 5.457 ; \t\t \t#From appendix A.3\n",
+ "B_CO2 = 1.045 * 10**-3 ;\n",
+ "D_CO2 = -1.157 * 10**5 ;\n",
+ "A_air = 3.355 ; \n",
+ "B_air = 0.575 * 10**-3 ;\n",
+ "D_air = -0.016 * 10**5 ;\n",
+ "T1 = 273. ; \t\t\t#[K]\n",
+ "T2 = 283. ; \t\t\t#[K]\n",
+ "T3 = 323. ; \t\t\t#[K]\n",
+ "T4 = 293. ; \t\t\t#{k}\n",
+ "\n",
+ "def f1(T):\n",
+ " return 8.314 * (A_CO2 * T + (B_CO2/2) * T**2 - D_CO2/T)\n",
+ "\n",
+ "sen_heat_CO2 = f1(T2) - f1(T1) ;\n",
+ "Q_dot = n_dot * (del_h_vap_CO2 + sen_heat_CO2) ; \t\t\t#[J/min]\n",
+ "\n",
+ "def f2(T):\n",
+ " return 8.314 * (A_air * T + B_air/2*T**2 - D_air /T)\n",
+ "\n",
+ "sen_heat_air = f2(T4) - f2(T3);\n",
+ "n_dot_air = - Q_dot / sen_heat_air ;\n",
+ "print 'Air required = %.F mol/min'%(n_dot_air); \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Air required = 123 mol/min\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.21 Page No : 100"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "m_dot_1 = 10. \t\t\t#[kg/s]\n",
+ "h_cap_1 = 3238.2 ;\t\t\t#[kJ/kg], Super heated steam at 500*C & 200bar\n",
+ "h_cap_2 = 93.3 ;\t\t\t#[kL/kg], subcooled liquid at 20*C & 100bar\n",
+ "h_cap_3 = 2724.7 ;\t\t\t#{kJ/kg}, Super heated vapour at 100bar \n",
+ "\n",
+ "# Calculations\n",
+ "m_dot_2 = m_dot_1 * (h_cap_1 - h_cap_3) / (h_cap_3 - h_cap_2);\n",
+ "\n",
+ "# Results\n",
+ "print 'Flow of liquid stream = %.2f kg/s'%(m_dot_2);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Flow of liquid stream = 1.95 kg/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.22 Page No : 101"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variables\n",
+ "h_cap_st_1 = 2923.4 ; \t\t\t# [kJ/kg]\n",
+ "h_cap_200 = 2875.3 ; \t\t\t# {kJ/kg} , At 100kPa\n",
+ "h_cap_250 = 2974.3 ; \t\t\t# {kJ/kg} , At 100 kPa\n",
+ "del_T = 250.-200 ;\n",
+ "T1 = 200. \t\t\t#[K]\n",
+ "\n",
+ "# Calculations\n",
+ "h_cap_st_2 = h_cap_st_1 ;\t\t\t#Assumimg bulk kinetic energy of the stream and heat transfered is negligible\n",
+ "T2 = T1 + del_T * (h_cap_st_2 - h_cap_200) / (h_cap_250 - h_cap_200) ;\n",
+ "\n",
+ "# Results\n",
+ "print 'The exit temperature is = %d *C'%(T2) ;\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The exit temperature is = 224 *C\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.23 Page No : 105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "from numpy import zeros\n",
+ "\n",
+ "# Variables\n",
+ "Cv = 3./2 * 8.314 ;\n",
+ "Cp = 5./2 * 8.314 ;\n",
+ "n = 1.; \n",
+ "R = 8.314 ; \n",
+ "T1 = 1000. ; \t\t\t#[K]\n",
+ "P1 = 10. ; \t \t\t#[bar]\n",
+ "T2 = 1000. ; \t\t\t#[K]\n",
+ "P2 = 0.1 ; \t\t\t#[bar]\n",
+ "T3 = 300. ; \t\t\t#[K]\n",
+ "T4 = 300. ; \t\t\t#[K]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "k = Cp / Cv ;\n",
+ "P3 = P2 * (T3 / T2)**(k/(k-1)); \t\t\t#[bar]\n",
+ "P4 = P1 * (T4 / T1)**(k/(k-1)) ; \t\t\t#[bar]\n",
+ "\n",
+ "del_U_12 = 0 ; \t\t\t# As process 1-2 is isothermal \n",
+ "W_12 = n * R * T1 * math.log(P2 / P1);\n",
+ "Q_h_12 = W_12 ;\n",
+ "print 'a) 1) del_U = %d J'%(del_U_12) ;\n",
+ "print ' Work = %d J'%(W_12) ;\n",
+ "print ' Heat = %d J'%(Q_h_12) ;\n",
+ "\n",
+ "Q_23 = 0 ; \t\t\t# As adiabatic process\n",
+ "del_U_23 = n * Cv *(T3 - T2) ;\n",
+ "W_23 = del_U_23 ;\n",
+ "print ' 2) del_U = %g J'%(round(del_U_23,-1)) ;\n",
+ "print ' Work J = %d J'%(round(W_23,-1)) ;\n",
+ "print ' Heat J = %d J'%(Q_23) ;\n",
+ "\n",
+ "del_U_34 = 0 ; \t\t\t# As isothermal process\n",
+ "W_34 = n * R * T3 * math.log(P4 / P3) ; \t\t\t# Eqn E2.20.A\n",
+ "Q_c_34 = del_U_34 - W_34 ;\n",
+ "print ' 3) del_U = %g J'%(del_U_34) ;\n",
+ "print ' Work = %d J'%(W_34) ;\n",
+ "print ' Heat = %d J'%(Q_c_34) ;\n",
+ "\n",
+ "Q_41 = 0 ; \t\t\t# As adiabatic process\n",
+ "del_U_41 = n * Cv * (T1 - T4) ;\n",
+ "W_41 = del_U_41 ;\n",
+ "print ' 4) del_U = %g J'%(round(del_U_41,-1)) ;\n",
+ "print ' Work = %d J'%(round(W_41,-1)) ;\n",
+ "print ' Heat = %d J'%(Q_41) ;\n",
+ "\n",
+ "#Solution (c)\n",
+ "W_total = W_12 + W_23 + W_34 + W_41 ;\n",
+ "Q_absor = Q_h_12 ;\n",
+ "effi = W_total / Q_absor ;\n",
+ "print 'c) efficiency = %g'%(effi)\n",
+ "\n",
+ "#Solution (d)\n",
+ "x = 1 - T3 / T1 ;\n",
+ "print 'd) 1 - Tc/Th = %g'%(x);\n",
+ "print \" i.e Efficiency = 1 - Tc/Th\"\n",
+ "\n",
+ "#Solution (e)\n",
+ "print \"(e) The process can be made more efficient by raimath.sing Th or by lowering Tc .\"\n",
+ "print \"Table E2.20B\"\n",
+ "print \" T(K) P(bar) v(m**3/mol)\"\n",
+ "P = [P1 , P2 , P3 , P4 ] ;\n",
+ "T = [T1 , T2 , T3 , T4 ] ;\n",
+ "v = zeros(4)\n",
+ "for i in range(4):\n",
+ " v[i] = R * T[i] * 10**-5/ P[i] ;\n",
+ " print \" %6d %8.4f %.4f \"%(T[i],P[i],v[i]) ;\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a) 1) del_U = 0 J\n",
+ " Work = -38287 J\n",
+ " Heat = -38287 J\n",
+ " 2) del_U = -8730 J\n",
+ " Work J = -8730 J\n",
+ " Heat J = 0 J\n",
+ " 3) del_U = 0 J\n",
+ " Work = 11486 J\n",
+ " Heat = -11486 J\n",
+ " 4) del_U = 8730 J\n",
+ " Work = 8730 J\n",
+ " Heat = 0 J\n",
+ "c) efficiency = 0.7\n",
+ "d) 1 - Tc/Th = 0.7\n",
+ " i.e Efficiency = 1 - Tc/Th\n",
+ "(e) The process can be made more efficient by raimath.sing Th or by lowering Tc .\n",
+ "Table E2.20B\n",
+ " T(K) P(bar) v(m**3/mol)\n",
+ " 1000 10.0000 0.0083 \n",
+ " 1000 0.1000 0.8314 \n",
+ " 300 0.0049 5.0597 \n",
+ " 300 0.4930 0.0506 \n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file