summaryrefslogtreecommitdiff
path: root/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb
diff options
context:
space:
mode:
authorroot2014-07-14 15:31:28 +0530
committerroot2014-07-14 15:31:28 +0530
commitcea77a632f1b20598ba2a1be1b77e6587920c2a0 (patch)
tree0ac530caf18d10bd82bf11ffc1c96bfda13d0e39 /Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb
parent7b7e179ba5b3287d04539fc1826eba5d433eef6c (diff)
downloadPython-Textbook-Companions-cea77a632f1b20598ba2a1be1b77e6587920c2a0.tar.gz
Python-Textbook-Companions-cea77a632f1b20598ba2a1be1b77e6587920c2a0.tar.bz2
Python-Textbook-Companions-cea77a632f1b20598ba2a1be1b77e6587920c2a0.zip
adding books
Diffstat (limited to 'Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb')
-rwxr-xr-xEngineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb1173
1 files changed, 1173 insertions, 0 deletions
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb
new file mode 100755
index 00000000..4a7535ce
--- /dev/null
+++ b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb
@@ -0,0 +1,1173 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 6 : Availability and Irreversibility"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.1 Page no : 313"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "T0 = 293.; \t\t\t#K\n",
+ "T1 = 300.; \t\t\t#K\n",
+ "T2 = 370.; \t\t\t#K\n",
+ "cv = 0.716;\n",
+ "cp = 1.005;\n",
+ "R = 0.287;\n",
+ "p1 = 1.; \t\t\t#bar\n",
+ "p2 = 6.8; \t\t\t#bar\n",
+ "m = 1.; \t\t\t#kg\n",
+ "\n",
+ "# Calculations\n",
+ "Wmax = -(cv*(T2-T1) - T0*(cp*math.log(T2/T1)-R*math.log(p2/p1)));\n",
+ "n = 1/(1-(math.log(T2/T1)/math.log(p2/p1)));\n",
+ "Wact = m*R*(T1-T2)/(n-1);\n",
+ "I = Wmax - Wact;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Irreversibility = %.3f\")%(I),(\"kJ/kg\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Irreversibility = 13.979 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.2 Page no : 313"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "T1 = 1000.; \t\t\t#K\n",
+ "T2 = 500.; \t\t\t#K\n",
+ "T0 = 300.; \t\t\t#K\n",
+ "Q = 7200.; \t\t\t#kJ/min\n",
+ "\n",
+ "# Calculations and Results\n",
+ "print (\"(i) Net change of entropy :\")\n",
+ "dS_source = -Q/T1;\n",
+ "dS_system = Q/T2;\n",
+ "dS_net = dS_source+dS_system;\n",
+ "print (\"dS_net = \"), (dS_net), (\"kJ/min.K\")\n",
+ "\n",
+ "\n",
+ "print (\"(ii) Decrease in available energy :\")\n",
+ "AE_source = (T1-T0)*(-dS_source); \t\t\t#Available energy with the source\n",
+ "AE_system = (T2-T0)*dS_system; \t\t\t#Available energy with the system\n",
+ "dAE = AE_source - AE_system; \t\t\t#Decrease in available energy\n",
+ "print (\"dAE = \"), (dAE), (\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i) Net change of entropy :\n",
+ "dS_net = 7.2 kJ/min.K\n",
+ "(ii) Decrease in available energy :\n",
+ "dAE = 2160.0 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.3 Page no : 315"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "m = 8.; \t\t\t#kg\n",
+ "T1 = 650.; \t\t\t#K\n",
+ "p1 = 5.5*10**5; \t\t\t#Pa\n",
+ "p0 = 1*10.**5; \t\t\t#Pa\n",
+ "T0 = 300.; \t\t\t#K\n",
+ "cp = 1.005; \t\t\t#kJ/kg.K\n",
+ "cv = 0.718;\n",
+ "R = 0.287;\n",
+ "#p1*v1/T1 = p0*v0/T0\n",
+ "#Let r = v1/v0 = 1/2.54\n",
+ "r = 1/2.54;\n",
+ "\n",
+ "# Calculations and Results\n",
+ "print (\"(i) Change in available energy(for bringing the system to dead state) = \")\n",
+ "ds = cv*math.log(T1/T0) + R*math.log(r);\n",
+ "dAE = m*(cv*(T1-T0) - T0*ds);\n",
+ "#dAE is the change in available energy in kJ\n",
+ "V1 = m*R*10**3*T1/p1;\n",
+ "V0 = V1/r;\n",
+ "L = p0*(V0 - V1)/10**3;\n",
+ "print (\"Loss of availability, L = \"), (L), (\"kJ\")\n",
+ "\n",
+ "print (\"(ii) Available Energy and Effectiveness\")\n",
+ "Q = m*cp*(T1-T0);\n",
+ "ds = m*cp*math.log(T1/T0);\n",
+ "Unavailable_energy = T0*ds;\n",
+ "Available_energy = Q - Unavailable_energy;\n",
+ "print (\"Available energy = %.3f\")% (Available_energy), (\"kJ\")\n",
+ "\n",
+ "Effectiveness = Available_energy/dAE;\n",
+ "print (\"Effectiveness = %.3f\")% (Effectiveness)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i) Change in available energy(for bringing the system to dead state) = \n",
+ "Loss of availability, L = 417.872 kJ\n",
+ "(ii) Available Energy and Effectiveness\n",
+ "Available energy = 949.066 kJ\n",
+ "Effectiveness = 0.719\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.4 Page no : 316"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "c_pg = 1.; \t\t\t#kJ/kgK\n",
+ "h_fg = 1940.7; \t\t\t#kJ/kg\n",
+ "Ts = 473.; \t \t\t#K ; Temperature of saturation of steam\n",
+ "T1 = 1273.; \t\t\t#K ; Initial temperature of gases\n",
+ "T2 = 773.; \t\t \t#K ; Final temperature of gases\n",
+ "T0 = 293.; \t\t\t #K ; atmospheric temperature\n",
+ "\n",
+ "# Calculations\n",
+ "#Heat lost by gases = Heat gained by 1 kg saturated water when it is converted to steam at 200 0C\n",
+ "m_g = h_fg/c_pg/(T1-T2);\n",
+ "dS_g = m_g*c_pg*math.log(T2/T1);\n",
+ "dS_w = h_fg/Ts;\n",
+ "dS_net = dS_g + dS_w;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Net change in entropy = %.3f\")% (dS_net), (\"kJ/K\")\n",
+ "\n",
+ "E = T0*dS_net; \t\t\t#Increase in unavailable energy due to hea transfer\n",
+ "print (\"Increase in unavailable energy = %.3f\")%(E), (\"kJ per kg of steam formed\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Net change in entropy = 2.167 kJ/K\n",
+ "Increase in unavailable energy = 634.847 kJ per kg of steam formed\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.5 Page no : 317"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "# Variables\n",
+ "m_g = 3.; \t\t\t#kg\n",
+ "p1 = 2.5; \t\t\t#bar\n",
+ "T1 = 1200.; \t\t\t#K; Temperature of infinite source\n",
+ "T1a = 400.; \t\t\t#K; Initial temperature\n",
+ "Q = 600.; \t\t\t#kJ\n",
+ "cv = 0.81; \t\t\t#kJ/kg.K\n",
+ "T0 = 290.; \t\t\t#K; Surrounding Temperature\n",
+ "\n",
+ "# Calculations\n",
+ "#final temperature = T2a\n",
+ "T2a = Q/m_g/cv + T1a;\n",
+ "AE = (T1-T0)*Q/T1; \t\t\t#Available energy with the source\n",
+ "dS = m_g*cv*math.log(T2a/T1a); \t\t\t#Change in entropy of the gas\n",
+ "UAE = T0*dS; \t\t\t#Unavailability of the gas \n",
+ "A = Q-UAE; \t\t\t#Available energy with the gas\n",
+ "loss = AE-A;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Loss in available energy due to heat transfer = %.3f\")%(loss),(\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Loss in available energy due to heat transfer = 193.783 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.6 Page no : 318"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "from scipy.integrate import quad \n",
+ "\n",
+ "# Variables\n",
+ "m = 60.; \t\t\t#kg\n",
+ "T1 = 333.; \t\t\t#K\n",
+ "T0 = 279.; \t\t\t#K\n",
+ "p = 1.; \t\t\t#atm\n",
+ "cp = 4.187;\n",
+ "\n",
+ "# Calculations\n",
+ "def f16( T): \n",
+ "\t return m*cp*(1-T0/T)\n",
+ "\n",
+ "Wmax = quad(f16, T0, T1)[0]\n",
+ "Q1 = m*cp*(T1-T0);\n",
+ "#Let unavailable energy = E\n",
+ "E = Q1-Wmax;\n",
+ "\n",
+ "# Results\n",
+ "print (\"unavailable energy = %.3f\")%(E), (\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "unavailable energy = 12401.141 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.7 Page no : 319"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "m = 15.; \t\t\t#kg\n",
+ "T1 = 340.; \t\t\t#K\n",
+ "T0 = 300.; \t\t\t#K\n",
+ "cp = 4.187; \t\t\t#kJ/kgK\n",
+ "\n",
+ "# Calculations\n",
+ "#Work added during churning = Increase in enthalpy of water\n",
+ "W = m*cp*(T1-T0);\n",
+ "ds = cp*math.log(T1/T0);\n",
+ "AE = m*(cp*(T1-T0)-T0*ds);\n",
+ "AE_loss = W-AE; \t\t\t#Loss in availability\n",
+ "\n",
+ "# Results\n",
+ "print (\"Loss in availability %.3f\")% (AE_loss), (\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Loss in availability 2358.261 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.8 Page no : 320"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "m = 5.; \t\t\t#kg\n",
+ "T1 = 550.; \t\t\t#K\n",
+ "p1 = 4*10.**5; \t\t\t#Pa\n",
+ "T2 = 290.; \t\t\t#K\n",
+ "T0 = T2;\n",
+ "p2 = 1.*10**5; \t\t\t#Pa\n",
+ "p0 = p2;\n",
+ "cp = 1.005; \t\t\t#kJ/kg K\n",
+ "cv = 0.718; \t\t\t#kJ/kg K\n",
+ "R = 0.287; \t\t\t#kJ/kg K\n",
+ "\n",
+ "# Calculations and Results\n",
+ "print (\"(i) Availability of the system :\")\n",
+ "ds = cp*math.log(T1/T0) - R*math.log(p1/p0);\n",
+ "Availability = m*(cv*(T1-T0) - T0*ds);\n",
+ "print (\"Availability of the system = %.3f\")% (Availability), (\"kJ\")\n",
+ "\n",
+ "print (\"(ii) Available energy and Effectiveness\")\n",
+ "Q = m*cp*(T1-T0);\n",
+ "dS = m*cp*math.log(T1/T0);\n",
+ "E = T0*dS; \t\t\t#Unavailable energy\n",
+ "AE = Q-E;\n",
+ "print (\"Available Energy = %.3f\")%(AE), (\"kJ\")\n",
+ "\n",
+ "Effectiveness = AE/Availability;\n",
+ "print (\"Effectiveness = %.3f\")%(Effectiveness)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i) Availability of the system :\n",
+ "Availability of the system = 577.612 kJ\n",
+ "(ii) Available energy and Effectiveness\n",
+ "Available Energy = 373.806 kJ\n",
+ "Effectiveness = 0.647\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.9 Page no : 321"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "R = 0.287; \t\t\t#kJ/kgK\n",
+ "cp = 1.005; \t\t\t#kJ/kgK\n",
+ "m = 25./60; \t\t\t#kg/s\n",
+ "p1 = 1.; \t\t\t#bar\n",
+ "p2 = 2.; \t\t\t#bar\n",
+ "T1 = 288.; \t\t\t#K\n",
+ "T0 = T1;\n",
+ "T2 = 373.; \t\t\t#K\n",
+ "\n",
+ "# Calculations and Results\n",
+ "W_act = cp*(T2-T1); \t\t\t#W_actual\n",
+ "W_total = m*W_act;\n",
+ "\n",
+ "print (\"Total actual power required = %.3f\")%(W_total), (\"kW\")\n",
+ "\n",
+ "ds = cp*math.log(T2/T1) - R*math.log(p2/p1);\n",
+ "Wmin = cp*(T2-T1) - T0*(ds);\n",
+ "\n",
+ "\n",
+ "W = m*Wmin;\n",
+ "print (\"Minimuumm work required = %.3f\")%(W), (\"kW\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total actual power required = 35.594 kW\n",
+ "Minimuumm work required = 28.276 kW\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.10 Page no : 322"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "m_O2 = 1.; \t\t\t#kg\n",
+ "m_H2 = 1.; \t\t\t#kg\n",
+ "p = 1*10.**5; \t\t\t#Pa\n",
+ "T_O2 = 450.; \t\t\t#K\n",
+ "T_H2 = 450.; \t\t\t#K\n",
+ "T0 = 290.; \t\t\t#K\n",
+ "R0 = 8.314;\n",
+ "M_O2 = 32.;\n",
+ "M_H2 = 2.;\n",
+ "\n",
+ "# Calculations\n",
+ "R_O2 = R0/M_O2;\n",
+ "v_O2 = m_O2*R_O2*T_O2/p;\n",
+ "R_H2 = R0/M_H2;\n",
+ "v_H2 = m_H2*R_H2*T_H2/p;\n",
+ "v_f = v_O2 + v_H2; \t\t\t#total volume after mixing\n",
+ "dS_O2 = R_O2*math.log(v_f/v_O2);\n",
+ "dS_H2 = R_H2*math.log(v_f/v_H2);\n",
+ "dS_net = dS_O2 + dS_H2;\n",
+ "#Let E be the loss in availability \n",
+ "E = T0*dS_net;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Loss in availability = %.3f\")% (E), (\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Loss in availability = 286.555 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.11 Page no : 323"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "from scipy.integrate import quad \n",
+ "\n",
+ "# Variables\n",
+ "T0 = 283.; \t\t\t#K\n",
+ "cp = 4.18; \t\t\t#kJ/kgK\n",
+ "m1 = 20.; \t\t\t#kg\n",
+ "T1 = 363.; \t\t\t#K\n",
+ "m2 = 30.; \t\t\t#kg\n",
+ "T2 = 303.; \t\t\t#K\n",
+ "T3 = 327.; \t\t\t#K\n",
+ "\n",
+ "\n",
+ "# Calculations\n",
+ "def f13( T): \n",
+ "\t return m1*cp*(1-T0/T)\n",
+ "\n",
+ "AE1 = quad(f13, T0, T1)[0]\n",
+ "\n",
+ "def f14( T): \n",
+ "\t return m2*cp*(1-T0/T)\n",
+ "\n",
+ "AE2 = quad(f14, T0, T2)[0]\n",
+ "AE_total = AE1 + AE2; \t\t\t#before mixing\n",
+ "#If T K is the final temperature after mixing\n",
+ "T = (m1*T1+m2*T2)/(m1+m2);\n",
+ "m_total = m1+m2;\n",
+ "\n",
+ "#Available energy of 50kg of water at 54 0C\n",
+ "AE3 = m_total*cp*((T3-T0) - T0*math.log(T3/T0));\n",
+ "\n",
+ "#Decrease in available energy due to mixing dAE\n",
+ "dAE = AE_total - AE3;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Decrease in avialble energy = %.3f\")% (dAE), (\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Decrease in avialble energy = 234.184 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.12 Page no : 324"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "# Variables\n",
+ "T_w1 = 323.; \t\t\t#K\n",
+ "T_w2 = 343.; \t\t\t#K\n",
+ "T_o1 = 513.; \t\t\t#K\n",
+ "T_o2 = 363.; \t\t\t#K\n",
+ "SG_oil = 0.82;\n",
+ "c_po = 2.6; \t\t\t#kJ/kg K\n",
+ "c_pw = 4.18; \t\t\t#kJ/kg K\n",
+ "T0 = 300.; \t\t\t#K\n",
+ "m_o = 1.; \t\t\t#kg\n",
+ "\n",
+ "# Calculations\n",
+ "#Heat lost by oil = Heat gained by water\n",
+ "m_w = (m_o*c_po*(T_o1-T_o2))/(c_pw*(T_w2-T_w1));\n",
+ "dS_w = m_w*c_pw*math.log(T_w2/T_w1);\n",
+ "dS_o = m_o*c_po*math.log(T_o2/T_o1);\n",
+ "dAE_w = m_w*(c_pw*(T_w2-T_w1))-T0*dS_w;\n",
+ "dAE_o = m_o*(c_po*(T_o2-T_o1))-T0*dS_o;\n",
+ "\n",
+ "# Loss in availability E = \n",
+ "E = dAE_w+dAE_o;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Loss in availability = %.3f\")%(E),(\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Loss in availability = -81.676 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.13 Page no : 325"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "m_i = 1.; \t\t\t#kg\n",
+ "T_i = 273.; \t\t\t#K\n",
+ "m_w = 12.; \t\t\t#kg\n",
+ "T_w = 300.; \t\t\t#K\n",
+ "T0 = 288.; \t\t\t#K\n",
+ "c_pw = 4.18; \t\t\t#kJ/kg K\n",
+ "c_pi = 2.1; \t\t\t#kJ/kg K\n",
+ "L_i = 333.5; \t\t\t#kJ/kg\n",
+ "\n",
+ "# Calculations\n",
+ "Tc = (m_w*c_pw*T_w + m_i*c_pw*T_i - L_i)/(m_w*c_pw + m_i*c_pw);\n",
+ "dS_w = m_w*c_pw*math.log(Tc/T_w);\n",
+ "dS_i = m_i*c_pw*math.log(Tc/T_i) + L_i/T_i;\n",
+ "dS_net = dS_w+dS_i;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Increase in entropy = %.3f\")% (dS_net), (\"kJ/K\")\n",
+ "\n",
+ "dAE = T0*dS_net;\n",
+ "print (\"Increase in unavailable energy = %.3f\")% (dAE),(\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Increase in entropy = 0.107 kJ/K\n",
+ "Increase in unavailable energy = 30.878 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.14 Page no : 326"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "T1 = 673.; \t\t\t#K\n",
+ "T2 = 473.; \t\t\t#K\n",
+ "T0 = 303.; \t\t\t#K\n",
+ "T1a = T2;\n",
+ "\n",
+ "# Calculations\n",
+ "UAE = T0*(T1-T1a)/T1a/(T1-T0);\n",
+ "\n",
+ "# Results\n",
+ "print (\"the fraction of energy that becomes unavailable = %.3f\")%(UAE)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the fraction of energy that becomes unavailable = 0.346\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.15 Page no : 327"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "T1 = 293.; \t\t\t#K\n",
+ "T2 = 353.; \t\t\t#K\n",
+ "Tf = 1773.; \t\t\t#K\n",
+ "T0 = 288.; \t\t\t#K\n",
+ "c_pl = 6.3; \t\t\t#kJ/kg K\n",
+ "\n",
+ "# Calculations\n",
+ "dAE = c_pl*(T2-T1) - T0*c_pl*math.log(T2/T1);\n",
+ "n = (1-T0/Tf); \t\t\t#efficiency\n",
+ "E = c_pl*(T2-T1)*n;\n",
+ "Effectiveness = dAE/E;\n",
+ "\n",
+ "# Results\n",
+ "print (\"Effectiveness of the heating process = %.3f\")%(Effectiveness)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Effectiveness of the heating process = 0.126\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.16 Page no : 328"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "T0 = 293.; \t\t\t#K\n",
+ "T1 = 293.; \t\t\t#K\n",
+ "T2 = 373.; \t\t\t#K\n",
+ "T3 = 323.; \t\t\t#K\n",
+ "cp = 1.005;\n",
+ "\n",
+ "# Calculations and Results\n",
+ "print (\"(i) The ratio of mass flow\")\n",
+ "x = (T3-T1)/(T2-T3);\n",
+ "print (\"x = \"), (x)\n",
+ "\n",
+ "ds_13 = cp*math.log(T3/T1);\n",
+ "ds_32 = cp*math.log(T2/T3);\n",
+ "A = cp*(T3-T1) - T1*ds_13; \t \t\t#Increase of availability of system\n",
+ "B = x*(cp*(T2-T3)-T0*(ds_32));\t\t\t# Loss of availability of surroundings\n",
+ "Effectiveness = A/B;\n",
+ "print (\"Effectiveness of heating process = %.3f\")%(Effectiveness)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i) The ratio of mass flow\n",
+ "x = 0.6\n",
+ "Effectiveness of heating process = 0.306\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.17 Page no : 329"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "m = 2.5; \t\t\t#kg\n",
+ "p1 = 6.*10**5; \t\t\t#Pa\n",
+ "r = 2.; \t\t\t#r = V2/V1\n",
+ "cv = 0.718; \t\t\t#kJ/kg K\n",
+ "R = 0.287; \t\t\t#kJ/kg K\n",
+ "T1 = 363.; \t\t\t#K\n",
+ "p2 = 1.*10**5; \t\t\t#Pa\n",
+ "T2 = 278.; \t\t\t#K\n",
+ "V1 = m*R*T1/p1;\n",
+ "V2 = 2*V1;\n",
+ "T0 = 278.; \t\t\t#K\n",
+ "p0 = 1.*10**5; \t\t\t#Pa\n",
+ "Q = 0.; \t\t\t#adiabatic process\n",
+ "\n",
+ "# Calculations and Results\n",
+ "dS = m*cv*math.log(T2/T1) + m*R*math.log(V2/V1);\n",
+ "Wmax = m*(cv*(T1-T2)) + T0*(cv*math.log(T2/T1) + R*math.log(V2/V1));\n",
+ "print (\"(i)The maximum work\"),(\"Wmax = %.3f\")% (Wmax), (\"kJ\")\n",
+ "\n",
+ "dA = Wmax+p0*(V1-V2);\n",
+ "print (\"(ii)Change in availability = %.3f\")%(dA), (\"kJ\")\n",
+ "\n",
+ "I = T0*m*(cv*math.log(T2/T1)+R*math.log(V2/V1));\n",
+ "print (\"(iii)Irreversibility = %.3f\")% (I),(\"kJ\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i)The maximum work Wmax = 154.628 kJ\n",
+ "(ii)Change in availability = 111.219 kJ\n",
+ "(iii)Irreversibility = 5.132 kJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.18 Page no : 330"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "m = 1.; \t\t\t#kg\n",
+ "p1 = 7.*10**5; \t\t\t#Pa\n",
+ "T1 = 873.; \t\t\t#K\n",
+ "p2 = 1.*10**5; \t\t\t#Pa\n",
+ "T2 = 523.; \t\t\t#K\n",
+ "T0 = 288.; \t\t\t#K\n",
+ "Q = -9.; \t\t\t#kJ/kg\n",
+ "cp = 1.005; \t\t\t#kJ/kg K\n",
+ "R = 0.287; \t\t\t#kJ/kg K\n",
+ "\n",
+ "# Calculations and Results\n",
+ "print (\"(i) The decrease in availability \")\n",
+ "dA = cp*(T1-T2) - T0*(R*math.log(p2/p1) - cp*math.log(T2/T1));\n",
+ "print (\"dA = %.3f\")%(dA), (\"kJ/kg\")\n",
+ "\n",
+ "print (\"(ii) The maximum work\")\n",
+ "Wmax = dA; \t\t\t#change in availability\n",
+ "print (\"Wmax %.3f\")% (Wmax), (\"kJ/kg\")\n",
+ "\n",
+ "\n",
+ "W = cp*(T1-T2) + Q;\n",
+ "I = Wmax - W;\n",
+ "print (\"(iii)Irreversibility = %.3f\")%(I), (\"kJ/kg\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i) The decrease in availability \n",
+ "dA = 364.295 kJ/kg\n",
+ "(ii) The maximum work\n",
+ "Wmax 364.295 kJ/kg\n",
+ "(iii)Irreversibility = 21.545 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.19 Page no : 331"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "\n",
+ "# Variables\n",
+ "cp = 1.005; \t\t\t#kJ/kg K\n",
+ "cv = 0.718; \t\t\t#kJ/kg K\n",
+ "R = 0.287; \t\t\t#kJ/kg K\n",
+ "m = 1.; \t\t\t#kg\n",
+ "T1 = 290.; \t\t\t#K\n",
+ "T0 = 290.; \t\t\t#K\n",
+ "T2 = 400.; \t\t\t#K\n",
+ "p1 = 1.; \t\t\t#bar\n",
+ "p0 = 1.; \t\t\t#bar\n",
+ "p2 = 6.; \t\t\t#bar\n",
+ "\n",
+ "# Calculations and Results\n",
+ "#Wrev = change in internal energy - T0*change in entropy\n",
+ "Wrev = -(cv*(T2-T1) - T0*(cp*math.log(T2/T1) - R*math.log(p2/p1)));\n",
+ "n = (1./(1-math.log(T2/T1)/math.log(p2/p1)));\n",
+ "Wact = m*R*(T1-T2)/(n-1);\n",
+ "\n",
+ "I = Wrev-Wact;\n",
+ "print (\"(i)Irreversibility = %.3f\")% (I), (\"kJ\")\n",
+ "\n",
+ "effectiveness = Wrev/Wact*100;\n",
+ "print (\"(ii)The effectiveness = %.3f\")%(effectiveness), (\"%\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i)Irreversibility = 9.945 kJ\n",
+ "(ii)The effectiveness = 93.109 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.20 Page no : 333"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math \n",
+ "from scipy.integrate import quad \n",
+ "\n",
+ "# Variables\n",
+ "I = 0.62; \t\t\t#kg/m**2\n",
+ "N1 = 2500.; \t\t\t#rpm\n",
+ "w1 = 2*math.pi*N1/60; \t\t\t#rad/s\n",
+ "m = 1.9; \t\t\t#kg; Water equivalent of shaft bearings\n",
+ "cp = 4.18;\n",
+ "T0 = 293.; \t\t\t#K\n",
+ "t0 = 20.; \t\t\t#0C\n",
+ "\n",
+ "# Calculations and Results\n",
+ "print (\"(i)Rise in temperature of bearings\")\n",
+ "KE = 1./2*I*w1**2/1000; \t\t\t#kJ\n",
+ "dT = KE/(m*cp); \t\t\t#rise in temperature of bearings\n",
+ "print (\"dT = %.3f\")% (dT), (\"0C\")\n",
+ "\n",
+ "t2 = t0+dT;\n",
+ "print (\"Final temperature of the bearings = %.3f\")% (t2), (\"0C\")\n",
+ "\n",
+ "T2 = t2+273;\n",
+ "print (\"(ii)Final r.p.m. of the flywheel\")\n",
+ "def f15( T): \n",
+ "\t return m*cp*(1-T0/T)\n",
+ "\n",
+ "AE = quad(f15, T0, T2)[0]\n",
+ "UE = KE - AE;\n",
+ "\n",
+ "print (\"Available energy = %.3f\")% (AE), (\"kJ\")\n",
+ "\n",
+ "UAE = KE-AE;\n",
+ "print (\"Unavailable energy = %.3f\")%(UAE), (\"kJ\")\n",
+ "\n",
+ "w2 = math.sqrt(AE*10**3*2/I);\n",
+ "N2 = w2*60/2/math.pi;\n",
+ "print (\"Final rpm of the flywheel = %.3f\")%(N2), (\"rpm\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i)Rise in temperature of bearings\n",
+ "dT = 2.675 0C\n",
+ "Final temperature of the bearings = 22.675 0C\n",
+ "(ii)Final r.p.m. of the flywheel\n",
+ "Available energy = 0.096 kJ\n",
+ "Unavailable energy = 21.151 kJ\n",
+ "Final rpm of the flywheel = 168.407 rpm\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 6.21 Page no : 334"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "# Variables\n",
+ "p1 = 8.; \t\t\t#bar\n",
+ "T1 = 453.; \t\t\t#K\n",
+ "p2 = 1.4; \t\t\t#bar\n",
+ "T2 = 293.; \t\t\t#K\n",
+ "T0 = T2;\n",
+ "p0 = 1.; \t\t\t#bar\n",
+ "m = 1.; \t\t\t#kg\n",
+ "C1 = 80.; \t\t\t#m/s\n",
+ "C2 = 40.; \t\t\t#m/s\n",
+ "cp = 1.005; \t\t\t#kJ/kg K\n",
+ "R = 0.287; \t\t\t#kJ/kg K \n",
+ "\n",
+ "# Calculations and Results\n",
+ "print (\"(i) Reversible work and actual work \")\n",
+ "A1 = cp*(T1-T0)-T0*(cp*math.log(T1/T0)-R*math.log(p1/p0))+C1**2/2/10**3; \t\t\t#Availability at the inlet\n",
+ "A2 = cp*(T2-T0)-T0*(cp*math.log(T2/T0)-R*math.log(p2/p0))+C2**2/2/10**3; \t\t\t#Availability at the exit\n",
+ "\n",
+ "W_rev = A1-A2;\n",
+ "print (\"W_rev = %.3f\")%(W_rev), (\"kJ/kg\")\n",
+ "\n",
+ "W_act = cp*(T1-T2) + (C1**2-C2**2)/2/10**3;\n",
+ "print (\"W_act = %.3f\")%(W_act),(\"kJ/kg\")\n",
+ "\n",
+ "print (\"(ii) Irreversibilty and effectiveness = \")\n",
+ "\n",
+ "I = W_rev-W_act;\n",
+ "print (\"Irreversibilty = %.3f\")% (I), (\"kJ/kg\")\n",
+ "\n",
+ "Effectiveness = W_act/W_rev*100;\n",
+ "print (\"Effectiveness = %.3f\")%(Effectiveness),(\"%\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i) Reversible work and actual work \n",
+ "W_rev = 181.464 kJ/kg\n",
+ "W_act = 163.200 kJ/kg\n",
+ "(ii) Irreversibilty and effectiveness = \n",
+ "Irreversibilty = 18.264 kJ/kg\n",
+ "Effectiveness = 89.935 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ " Example 6.22 Page no : 335 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Variables\n",
+ "p1 = 20.; \t\t\t#bar\n",
+ "t1 = 400.; \t\t\t#0C\n",
+ "p2 = 4.; \t\t\t#bar\n",
+ "t2 = 250.; \t\t\t#0C\n",
+ "t0 = 20.; \t\t\t#0C\n",
+ "T0 = t0+273;\n",
+ "h1 = 3247.6; \t\t\t#kJ/kg\n",
+ "s1 = 7.127; \t\t\t#kJ/kg K\n",
+ "#let h2' = h2a and s2' = s2a\n",
+ "h2a = 2964.3; \t\t\t#kJ/kg\n",
+ "s2a = 7.379; \t\t\t#kJ/kg K\n",
+ "s2 = s1;\n",
+ "s1a = s1;\n",
+ "#By interpolation, we get\n",
+ "h2 = 2840.8; \t\t\t#kJ/kg\n",
+ "\n",
+ "# Calculations and Results\n",
+ "n_isen = (h1-h2a)/(h1-h2);\n",
+ "print (\"(i)Isentropic efficiency = %.3f\")%(n_isen)\n",
+ "\n",
+ "A = h1-h2a + T0*(s2a-s1a);\n",
+ "print (\"(ii)Loss of availability = %.3f\")%(A), (\"kJ/kg\")\n",
+ "\n",
+ "Effectiveness = (h1-h2a)/A;\n",
+ "print (\"(iii)Effectiveness = %.3f\")% (Effectiveness)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(i)Isentropic efficiency = 0.696\n",
+ "(ii)Loss of availability = 357.136 kJ/kg\n",
+ "(iii)Effectiveness = 0.793\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file