summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics/ch4_2.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Chemical_Engineering_Thermodynamics/ch4_2.ipynb')
-rw-r--r--Chemical_Engineering_Thermodynamics/ch4_2.ipynb1540
1 files changed, 1540 insertions, 0 deletions
diff --git a/Chemical_Engineering_Thermodynamics/ch4_2.ipynb b/Chemical_Engineering_Thermodynamics/ch4_2.ipynb
new file mode 100644
index 00000000..2e333961
--- /dev/null
+++ b/Chemical_Engineering_Thermodynamics/ch4_2.ipynb
@@ -0,0 +1,1540 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 4 : The Secomd Law and Its Applications"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.1 Page Number : 148"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of entropy change\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "# Variables\n",
+ "n = 1000.;\t\t\t#[mol]\n",
+ "T = 400.;\t\t\t#[K]\n",
+ "P_1 = 100.;\t\t\t#[kPa]\n",
+ "P_2 = 1000.;\t\t\t#[kPa]\n",
+ "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t#(a)\n",
+ "T_surr = 400.;\t\t\t#[K] - surrounding temperature\n",
+ "\t\t\t# Total change in entropy of the system is given by\n",
+ "\t\t\t# delta_S_sys = n*(Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1))\n",
+ "\t\t\t# The process being isothermal the first term is zero and the total entropy change of the system is\n",
+ "delta_S_sys_a = - n*R*math.log(P_2/P_1);\t\t\t#[J/K]\n",
+ "delta_S_sys_a = delta_S_sys_a*10**(-3);\t\t\t#[kJ/K]\n",
+ "\n",
+ "\t\t\t# Since the process is reversible therefore\n",
+ "Q_sys = T_surr*delta_S_sys_a;\t\t\t#[kJ] - Heat change in the system\n",
+ "\t\t\t# Negative sign in the value of Q_sys implies that heat is released from the system and is released to the surroundings,therefore\n",
+ "Q_surr = - Q_sys;\t\t\t#[kJ] - Heat change in the surrounding\n",
+ "delta_S_surr_a = Q_surr/T_surr;\t\t\t#[kJ/K]\n",
+ "\n",
+ "delta_S_univ_a = delta_S_sys_a + delta_S_surr_a;\t\t\t#[kJ/K]\n",
+ "\t\t\t# We get delta_S_univ = 0, which is true for a reversible process\n",
+ "\n",
+ "print \" a).The entropy change of the gas is given by delta_S_sys = %f kJ/K \"%(delta_S_sys_a);\n",
+ "print \" The entropy change of the surrounding is delta_S_surr = %f kJ/K \"%(delta_S_surr_a);\n",
+ "print \" The total entropy change of the gas is delta_S_univ = %f kJ/K \"%(delta_S_univ_a);\n",
+ "\n",
+ "\t\t\t#(b)\n",
+ "T_surr_b = 300.;\t\t\t#[K] - surrounding temperature\n",
+ "\t\t\t# Since the initial and final states are fixed therefore the entropy change of the system is same whether the process is carried out reversibly or irreversibly.\n",
+ "delta_S_sys_b = delta_S_sys_a;\n",
+ "\n",
+ "\t\t\t# Work done under reversible condition is given by\n",
+ "\t\t\t# W = integral(P*dV) = integral(((R*T)/V)*dV) = R*T*math.log(V_2/V_1)\n",
+ "\t\t\t# For ideal gas we have, P1*V1/T1 = P2*V2/T2 or, V2/V1 = P1/P2 (for isothermal conditions)\n",
+ "W = R*T*math.log(P_1/P_2);\t\t\t#[J/mol]\n",
+ "W = W*10**(-3);\t\t\t#[kJ/mol]\n",
+ "\t\t\t# 20% extra work has to be done for the system to reach the same final state as under reversible conditions. Therefore\n",
+ "W = W*(120./100);\t\t\t#[kJ/mol]\n",
+ "W = W*n;\t\t\t#[kJ] - Total work done for n moles\n",
+ "\n",
+ "\t\t\t# Using the first law we have delta_U = Q - W. Now under isothermal conditions for ideal gas, delta_U = 0. Therefore,\n",
+ "Q = -W;\n",
+ "\t\t\t# It implies that whatever work is done on the system is lost as heat to the surroundings.\n",
+ "\t\t\t# Since heat is gained by the surroundings therefore\n",
+ "delta_S_surr_b = Q/T_surr_b;\t\t\t#[kJ/K]\n",
+ "\n",
+ "delta_S_univ_b = delta_S_sys_b + delta_S_surr_b;\t\t\t#[kJ/K]\n",
+ "\n",
+ "print \" b).The entropy change of the gas is given by delta_S_sys = %f kJ/K \"%(delta_S_sys_b);\n",
+ "print \" The entropy change of the surrounding is delta_S_surr = %f kJ/K \"%(delta_S_surr_b);\n",
+ "print \" The total entropy change of the gas is delta_S_univ = %f kJ/K \"%(delta_S_univ_b);\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " a).The entropy change of the gas is given by delta_S_sys = -19.143692 kJ/K \n",
+ " The entropy change of the surrounding is delta_S_surr = 19.143692 kJ/K \n",
+ " The total entropy change of the gas is delta_S_univ = 0.000000 kJ/K \n",
+ " b).The entropy change of the gas is given by delta_S_sys = -19.143692 kJ/K \n",
+ " The entropy change of the surrounding is delta_S_surr = 30.629908 kJ/K \n",
+ " The total entropy change of the gas is delta_S_univ = 11.486215 kJ/K \n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.2 Page Number : 148"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Determination of whether the process is reversible or not\n",
+ "\n",
+ "# Variables\n",
+ "T = 400.;\t\t\t#[K] - Temperature\n",
+ "P_1 = 500.*10**(3);\t\t\t#[Pa] - Initial pressure\n",
+ "P_2 = 100.*10**(3);\t\t\t#[Pa] - Final pressure\n",
+ "V_1 = 750.*10**(-6);\t\t\t#[m**(3)] - Initial volume\n",
+ "W_actual = 0.55*10**(3);\t\t\t#[J] - Actual work done\n",
+ "R = 8.314;\t\t\t#[J/mol*K] - Universal fas constant\n",
+ "\n",
+ "# Calculations\n",
+ "\t\t\t# Suppose that the surroundings are at 400 K.\n",
+ "\t\t\t# Therefore the process is externally reversible as temperature of the surroundings is same as system temperature.\n",
+ "\t\t\t# The number of moles is given by\n",
+ "n = (P_1*V_1)/(R*T);\t\t\t#[mol]\n",
+ "\t\t\t# The entropy change of ideal gas under isothermal condition is given by\n",
+ "delta_S_sys = - n*R*math.log(P_2/P_1);\t\t\t#[J/mol]\n",
+ "\n",
+ "\t\t\t# The heat supplied to the system in the internally reversible process is\n",
+ "Q_theot = T*delta_S_sys;\t\t\t#[J]\n",
+ "\t\t\t# Since the process is isothermal therefore, workdone is given by\n",
+ "W_theot = Q_theot;\t\t\t#[J] - Theoritical work done\n",
+ "\t\t\t# Since actual work done by the gas is 0.55 kJ therefore actual heat supplied is also 0.55 kJ because under isothermal conditions delta_U = 0\n",
+ "Q_actual = W_actual;\n",
+ "\n",
+ "# Results\n",
+ "\t\t\t# Since Q_theot > Q_actual, so the process is irreversible\n",
+ "print \" Since Q_theot = %f J is greater than Q_actual = %f J\"%(Q_theot,Q_actual);\n",
+ "print \" Therefore, the process is internally irreversible\"\n",
+ "\n",
+ "\t\t\t# Moreover delta_S_sys is same whether the process is reversible or irreversible as the initial and final states is the same.\n",
+ "\t\t\t# In the reversible process higher amount of heat is supplied (as compared to irreversible) due to which delta_S_sys take place.\n",
+ "\t\t\t# In the irreversible process the entropy of system increases due two reasons : heat supplied and entropy generation\n",
+ "\t\t\t# So in the irreversible case amount of heat supplied is less as compared to reversible case as entropy generation term also adds to the entropy change of system\n",
+ "\t\t\t# delta_S_sys = Q/T_b + S_gen\n",
+ "S_gen = delta_S_sys - (Q_theot/T);\t\t\t#[J/K]\n",
+ "\t\t\t# The entropy generated may be due to friction and other dissipayive effects or due to non-quasi-static expansion\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Since Q_theot = 603.539217 J is greater than Q_actual = 550.000000 J\n",
+ " Therefore, the process is internally irreversible\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.3 Page Number : 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of final pressure temperature and increase in entropy\n",
+ "\n",
+ "# Variables\n",
+ "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
+ "\t\t\t# For side A\n",
+ "V_A = 1;\t\t\t#[L] - Volume\n",
+ "V_A = V_A*10**(-3);\t\t\t#[m**(3)]\n",
+ "T_A = 300;\t\t\t#[K] - Temperature\n",
+ "P_A = 2;\t\t\t#[atm] - Pressure\n",
+ "P_A = P_A*101325;\t\t\t#[Pa]\n",
+ "\n",
+ "\t\t\t# For side B\n",
+ "V_B = 1;\t\t\t#[L] - volume\n",
+ "V_B = V_B*10**(-3);\t\t\t#[m**(3)]\n",
+ "T_B = 300;\t\t\t#[K] - Temperature\n",
+ "P_B = 1;\t\t\t#[atm] - Pressure\n",
+ "P_B = P_B*101325;\t\t\t#[Pa]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# From first law final temperature and pressure are given by (example 3.30)\n",
+ "\t\t\t# T = ((n_A*T_A) + (n_B*T_B))/(n_A + n_B)\n",
+ "\t\t\t# P = ((P_A*V_A) + (P_A*V_B))/(V_A + V_B)\n",
+ "\n",
+ "\t\t\t# Since in this case T_A = T_B, therefore final pressure is given by\n",
+ "P = ((P_A*V_A) + (P_B*V_B))/(V_A + V_B);\t\t\t#[Pa]\n",
+ "P = P/101325;\t\t\t#[atm]\n",
+ "\n",
+ "print \" The final temperature is %f K\"%(T_A);\n",
+ "print \" The final pressure is %f atm\"%(P);\n",
+ "\n",
+ "\t\t\t# The number of moles of air on each side are\n",
+ "n_A = (P_A*V_A)/(R*T_A);\t\t\t#[mol]\n",
+ "n_B = (P_B*V_B)/(R*T_B);\t\t\t#[mol]\n",
+ "\n",
+ "delta_S_A = -n_A*R*math.log((P*101325)/P_A);\t\t\t#[J/K] - Entropy change on side A\n",
+ "delta_S_B = -n_B*R*math.log((P*101325)/P_B);\t\t\t#[J/K] - Entropy change on side B\n",
+ "delta_S_sys = delta_S_A + delta_S_B;\t\t\t#[J/K] - Total entropy change of system\n",
+ "\n",
+ "\t\t\t# Since the system is insulated there is no heat exchange with the surroundings, therefore entropy change of surrounding is zero\n",
+ "delta_S_surr = 0;\t\t\t#[J/K]\n",
+ "delta_S_univ = delta_S_sys + delta_S_surr;\t\t\t#[J/K]\n",
+ "print \" The total increase in entropy is %f J/K\"%(delta_S_univ);\n",
+ "\n",
+ "\t\t\t# The entropy change of the system can also be writtten as\n",
+ "\t\t\t# delta_s_sys = Q/T_b + S_gen\n",
+ "\t\t\t# Since there is no heat transfer, therefore\n",
+ "S_gen = delta_S_univ;\t\t\t#[J/K]\n",
+ "\t\t\t# The process is reversible because of entropy generation due to spontaneous release of piston.\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " The final temperature is 300.000000 K\n",
+ " The final pressure is 1.500000 atm\n",
+ " The total increase in entropy is 0.057383 J/K\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.4 Page Number : 151"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# CAlculation of final temperature heat transfer and change of entropy\n",
+ "\n",
+ "# Variables\n",
+ "V_vessel = 0.2;\t\t\t#[m**(3)] - Volume of the vessel\n",
+ "P_1 = 10;\t\t\t#[bar] - Initial pressure inside the vessel\n",
+ "P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
+ "P_2 = 3.5;\t\t\t#[bar] - Final pressure inside the vessel\n",
+ "P_2 = P_2*10**(5);\t\t\t#Pa\n",
+ "T_1 = 250 + 273.15;\t\t\t#[K] - Initial temperature of the vesssel\n",
+ "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# (a)\n",
+ "\t\t\t# At 10 bar and 250 C the steam is superheated. From steam table as reported in book we have\n",
+ "V_1 = 0.2327;\t\t\t#[m**(3)/kg] - specific volume\n",
+ "U_1 = 2709.9;\t\t\t#[kJ/kg] - specific internal energy\n",
+ "H_1 = 2942.6;\t\t\t#[kj/kg] - Specific enthalpy\n",
+ "S_1 = 6.9247;\t\t\t#[kJ/kg-K] - Specific entropy\n",
+ "\t\t\t# the quantity of steam is given by\n",
+ "m = V_vessel/V_1;\t\t\t#[kg]\n",
+ "\n",
+ "\t\t\t# At final state \n",
+ "V_2 = 0.2327;\t\t\t#[m**(3)/kg] - Molar volume\n",
+ "V_liq_2 = 0.001079;\t\t\t# [m**(3)/kg]\n",
+ "V_vap_2 = 0.5243;\t\t\t# [m**(3)/kg]\n",
+ "\t\t\t# Since overall volume lies between saturated liquid and saturated vapour therefore the steam is saturated and its dryness fraction at final state is given by\n",
+ "x = (V_2 - V_liq_2)/(V_vap_2 - V_liq_2);\n",
+ "\t\t\t# Final temperature = T_sat (at 3 bar) from steam table\n",
+ "T_final = 138.88;\t\t\t#[C]\n",
+ "\n",
+ "\t\t\t# At 3.5 bar saturated conditions \n",
+ "S_liq = 1.7275;\t\t\t#[kJ/kg-K] - Entropy of saturated liquid\n",
+ "S_vap = 6.9405;\t\t\t#[kJ/kg-K] - Entropy of saturated vapour\n",
+ "U_liq = 583.95;\t\t\t#[kJ/kg] - Internal energy of saturated liquid\n",
+ "U_vap = 2548.9;\t\t\t#[kJ/kg] - Internal energy of saturated vapour\n",
+ "\t\t\t# Therefore at final state \n",
+ "U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg]\n",
+ "S_2 = S_liq*(1 - x) + x*S_vap;\t\t\t#[kJ/kg-K]\n",
+ "Q_1 = m*(U_2 - U_1);\t\t\t#[kJ]\n",
+ "delta_S_1 = m*(S_2 - S_1);\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "print \" a).The final temperature is %f C\"%(T_final);\n",
+ "print \" The amount of heat transfer is %f kJ\"%(Q_1);\n",
+ "print \" The change of entropy is %f kJ/kg-K\"%(delta_S_1);\n",
+ "\n",
+ "\t\t\t# (b)\n",
+ "Y = 1.4;\t\t\t# Ratio of heat capacities for air\n",
+ "\t\t\t# (P_1*V_1)/T_1 = (P_2*V_2)/T_2 and since V_1 = V_2\n",
+ "T_2 = (P_2/P_1)*T_1;\t\t\t#[K]\n",
+ "\n",
+ "\t\t\t# Since the volume is fixed therefore work done (W) = 0 and from first law we get\n",
+ "\t\t\t# Q = delta_U = n*Cv_0*(T_2 - T_1)\n",
+ "Cv_0 = R/(Y - 1);\t\t\t#[J/mol-K] - Heat capacity at constant volume\n",
+ "Cp_0 = (Y*R)/(Y - 1);\t\t\t#[J/mol-K] - Heat capacity at constant pressure\n",
+ "n = (P_1*V_vessel)/(R*T_1);\t\t\t#[mol] - No. of moles\n",
+ "Q_2 = n*Cv_0*(T_2 - T_1);\t\t\t#[J] - Heat change\n",
+ "Q_2 = Q_2*10**(-3);\t\t\t#[kJ]\n",
+ "\n",
+ "delta_S_2 = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
+ "delta_S_2 = n*delta_S_2*10**(-3);\t\t\t#[kJ/K]\n",
+ "\n",
+ "print \" b).The final temperature is %f C\"%(T_2);\n",
+ "print \" The amount of heat transfer is %f kJ\"%(Q_2);\n",
+ "print \" The change of entropy is %f kJ/K\"%(delta_S_2);\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " a).The final temperature is 138.880000 C\n",
+ " The amount of heat transfer is -1079.587621 kJ\n",
+ " The change of entropy is -2.483450 kJ/kg-K\n",
+ " b).The final temperature is 183.102500 C\n",
+ " The amount of heat transfer is -325.000000 kJ\n",
+ " The change of entropy is -1.003366 kJ/K\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.5 Page Number : 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of final temperature work and heat transfer\n",
+ "\n",
+ "from math import *\n",
+ "# Variables\n",
+ "m = 1000.;\t\t\t#[g] - Mass of fluid\n",
+ "P_1 = 20.;\t\t\t#[bar] - Initial pressure\n",
+ "P_1 = P_1*10.**(5);\t\t\t#[Pa]\n",
+ "P_2 = 2;\t\t\t#[bar] - Final pressure\n",
+ "P_2 = P_2*10.**(5);\t\t\t#Pa\n",
+ "T_1 = 250 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "n = 1.25;\n",
+ "R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
+ "Y = 1.4;\t\t\t# Index of expansion\n",
+ "Cv_0 = R/(Y- 1);\t\t\t#[J/mol-K]\n",
+ "Cp_0 = R + Cv_0;\t\t\t#[J/mol-K]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t#(a)\n",
+ "\t\t\t# For steam at 20 bar and 250 C, from steam table as reported in the book\n",
+ "V_1 = 0.11144;\t\t\t#[m**(3)/kg]\n",
+ "U_1 = 2679.6;\t\t\t#[kJ/kg]\n",
+ "S_1 = 6.5453;\t\t\t#[kJ/kg-K]\n",
+ "\t\t\t# P_1*V_1**(n) = P_2*V_2**(n)\n",
+ "V_2 = ((P_1*V_1**(n))/P_2)**(1/n);\t\t\t#[m**(3)/kg]\n",
+ "\n",
+ "\t\t\t# At 2 bar under saturated conditions,from steam table as reported in the book\n",
+ "V_liq = 0.001061;\t\t\t#[m**(3)/kg]\n",
+ "V_vap = 0.8857;\t\t\t#[m**(3)/kg]\n",
+ "x = (V_2 - V_liq)/(V_vap - V_liq);\t\t\t# Dryness fraction\n",
+ "T_sat = 120.23;\t\t\t#[C] - The final temperature\n",
+ "U_liq = 504.49;\t\t\t#[kJ/kg] - Internal energy of saturate liquid\n",
+ "U_vap = 2529.5;\t\t\t#[kJ/kg] - Internal energy of saturate vapour\n",
+ "\t\t\t# Therefore, internal energy at state 2 is given by\n",
+ "U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# Work transfer is given by\n",
+ "W = (P_1*V_1 - P_2*V_2)/(n - 1);\t\t\t#[J/kg]\n",
+ "W = W*10**(-3);\t\t\t#[kJ/kg]\n",
+ "delta_U = U_2 - U_1;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# From first law, q - W = delta_U\n",
+ "q = W + delta_U;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# At final state (2 bar saturated), as reported in the book\n",
+ "S_liq = 1.5301;\t\t\t#[kJ/kg-K] - Entropy of saturated liquid\n",
+ "S_vap = 7.1271;\t\t\t#[kJ/kg-K] - Entropy of saturated vapour\n",
+ "\t\t\t# Therefore, entropy at state 2 is given by\n",
+ "S_2 = S_liq*(1 - x) + x*S_vap;\t\t\t#[kJ/kg-K]\n",
+ "delta_S = S_2 - S_1;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "print \" a).The final temperature is %f C\"%(T_sat);\n",
+ "print \" The work done is equal to %f kJ/kg\"%(W);\n",
+ "print \" The heat change is equal to %f kJ/kg\"%(q);\n",
+ "print \" The entropy change is equal to %f kJ/kg-K\"%(delta_S);\n",
+ "\n",
+ "\t\t\t#(b)\n",
+ "\t\t\t# P*V**(n) = constant\n",
+ "\t\t\t# Since the gas behaves as ideal we can write\n",
+ "\t\t\t# P_1**(1-n)*T_1**(n) = P_2**(1-n)*T_2**(n)\n",
+ "T_2 = T_1*(P_1/P_2)**((1-n)/n);\t\t\t#[K]\n",
+ "\n",
+ "\t\t\t# Molar volume is given by\n",
+ "V_2_1 = (R*T_1)/P_1;\t\t\t#[m**(3)/mol] - At state 1\n",
+ "V_2_2 = (R*T_2)/P_2;\t\t\t#[m**(3)/mol] - At state 2\n",
+ "\n",
+ "\t\t\t# Work transfer is given by\n",
+ "w_2 = ((P_1*V_2_1) - (P_2*V_2_2))/(n-1);\t\t\t#[J/mol]\n",
+ "Mol_wt_air = 0.21*32 + 0.79*28;\t\t\t#[g/mol] - Molecular weight of air\n",
+ "n_mole = m/Mol_wt_air;\n",
+ "\t\t\t# Total work transfer is given by\n",
+ "W_2 = w_2*n_mole*10**(-3);\t\t\t#[kJ]\n",
+ "\t\t\t# Internal energy change is given by\n",
+ "delta_U = n_mole*Cv_0*(T_2 - T_1)*10**(-3);\t\t\t#[kJ]\n",
+ "\n",
+ "\t\t\t# Heat transfer is given by\n",
+ "Q = W_2 + delta_U;\t\t\t#[kJ]\n",
+ "\n",
+ "\t\t\t# Entropy change is given by\n",
+ "delta_S_2 = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);\t\t\t#[J/mol-K]\n",
+ "delta_S_2 = delta_S_2*n_mole;\t\t\t#[J/mol]\n",
+ "\n",
+ "print \" b).The final temperature is %f C\"%(T_2);\n",
+ "print \" The work done is equal to %f kJ/kg\"%(W_2);\n",
+ "print \" The total heat change is equal to %f kJ\"%(Q);\n",
+ "print \" The entropy change is equal to %f J/kg-K\"%(delta_S_2);\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " a).The final temperature is 120.230000 C\n",
+ " The work done is equal to 329.008908 kJ/kg\n",
+ " The heat change is equal to -238.988250 kJ/kg\n",
+ " The entropy change is equal to -0.573241 kJ/kg-K\n",
+ " b).The final temperature is 330.085335 C\n",
+ " The work done is equal to 222.626855 kJ/kg\n",
+ " The total heat change is equal to 83.485071 kJ\n",
+ " The entropy change is equal to 199.136884 J/kg-K\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.6 Page Number : 154"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of final temperature and work done\n",
+ "\n",
+ "# Variables\n",
+ "m = 1000;\t\t\t#[g] - Mass of fluid\n",
+ "P_1 = 20;\t\t\t#[bar] - Initial pressure\n",
+ "P_2 = 2;\t\t\t#[bar] - Final ressure\n",
+ "T_1 = 250 + 273.15;\t\t\t#[K] - Initial tempearture\n",
+ "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
+ "\n",
+ "\t\t\t# (a).\n",
+ "\t\t\t# At 20 bar and 250 C as reported in the book\n",
+ "V_1 = 0.11144;\t\t\t#[m**(3)/kg] - Specific volume\n",
+ "U_1 = 2679.6;\t\t\t#[kJ/kg] - Specific internal energy\n",
+ "S_1 = 6.5453;\t\t\t#[kJ/kg-K] - Specific entropy\n",
+ "S_2 = S_1;\t\t\t# Isentropic expansion\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# At 2 bar under saturated conditions \n",
+ "S_liq = 1.5301;\t\t\t#[kJ/kg-K]\n",
+ "S_vap = 7.1271;\t\t\t#[kJ/kg-K]\n",
+ "U_liq = 504.49;\t\t\t#[kJ/kg-K]\n",
+ "U_vap = 2529.5;\t\t\t#[kJ/kg-K]\n",
+ "\t\t\t# Therefore dryness factor can be determined as\n",
+ "x = (S_1 - S_liq)/(S_vap - S_liq);\n",
+ "U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg] - Specific internal energy at final state\n",
+ "delta_U = U_2 - U_1;\t\t\t#[kJ/kg] - change in internal energy\n",
+ "W = - delta_U;\t\t\t# - Work done\n",
+ "\n",
+ "\t\t\t# The final saturated temperature at 2 bar from steam table is\n",
+ "T_2 = 120.23;\t\t\t#[C]\n",
+ "\n",
+ "print \" a).The final temperature is %f C\"%(T_2);\n",
+ "print \" The work done is equal to %f kJ/kg\"%(W);\n",
+ "\n",
+ "\t\t\t# (b).\n",
+ "Y = 1.4;\t\t\t# Index of expansion for air\n",
+ "Cv_0 = R/(Y-1);\t\t\t#[J/mol*K] - Specific heat capacity at constant volume\n",
+ "\t\t\t# Ideal gas under isentropic expansion P_1**(1-Y)*T_1**(Y) =P_2**(1-Y)*T_2**(Y)\n",
+ "T_2_prime = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K] - Final temperature\n",
+ "delta_U_prime = Cv_0*(T_2_prime - T_1);\t\t\t#[J/mol] - change in internal energy\n",
+ "\n",
+ "\t\t\t# Number of moles is given by\n",
+ "n = m/28.84;\t\t\t#[mol]\n",
+ "delta_U_prime = delta_U_prime*n*10**(-3);\t\t\t#[kJ]\n",
+ "W_prime = - delta_U_prime;\t\t\t# Work done\n",
+ "\n",
+ "print \" b).The final temperature is %f C\"%(T_2_prime);\n",
+ "print \" The work done is equal to %f kJ/kg\"%(W_prime);\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " a).The final temperature is 120.230000 C\n",
+ " The work done is equal to 360.596841 kJ/kg\n",
+ " b).The final temperature is 270.964218 C\n",
+ " The work done is equal to 181.750398 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.7 Page Number : 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Determination of index of isentropic expansion\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 15.;\t\t\t#[bar] - Initial pressure\n",
+ "P_2 = 0.15;\t\t\t#[bar] - Final pressure\n",
+ "\n",
+ "\t\t\t# We know that during isentropic expansion\n",
+ "\t\t\t# W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n",
+ "\n",
+ "\t\t\t# At 15 bar (saturated vapour), from steam table as reported in the book\n",
+ "V_1 = 0.13177;\t\t\t#[m**(3)/kg]\n",
+ "U_1 = 2594.5;\t\t\t#[kJ/kg]\n",
+ "S_1 = 6.4448;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "\t\t\t# Now at state 2 (P_2 = 0.15 bar),from steam table as reported in the book\n",
+ "S_2 = S_1;\t\t\t# Isentropic expansion\n",
+ "S_liq = 0.7549;\t\t\t#[kJ/kg-K]\n",
+ "S_vap = 8.0085;\t\t\t#[kJ/kg-K]\n",
+ "U_liq = 225.92;\t\t\t#[kJ/kg]\n",
+ "U_vap = 2448.7;\t\t\t#[kJ/kg]\n",
+ "V_liq = 0.001014;\t\t\t#[m**(3)/kg]\n",
+ "V_vap = 10.02;\t\t\t#[m**(3)/kg]\n",
+ "\n",
+ "# Calculations\n",
+ "\t\t\t# Therefore dryness factor can be calculated as\n",
+ "x = round((S_1 - S_liq)/(S_vap - S_liq),3);\n",
+ "U_2 = round(U_liq*(1 - x) + x*U_vap,2);\t\t\t#[kJ/kg] - Specific internal energy at final state\n",
+ "delta_U = U_2 - U_1;\t\t\t#[kJ/kg] - change in internal energy\n",
+ "W = - delta_U;\t\t\t# - Work done\n",
+ "\n",
+ "\t\t\t# The specific volume at the final state is\n",
+ "V_2 = round(V_liq*(1 - x) + x*V_vap,3);\t\t\t#[m**(3)/kg]\n",
+ "\n",
+ "\t\t\t# From work done under adiabatic conditions we get\n",
+ "\t\t\t# W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n",
+ "Y = (((P_1*V_1) - (P_2*V_2))*10**2/W) + 1;\n",
+ "\n",
+ "# Results\n",
+ "print \" The index of expansion is given by Y = %.4f\"%(Y);\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " The index of expansion is given by Y = 1.1275\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.8 Page Number : 157"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Determination of entropy production\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 40;\t\t\t#[bar] - Initial pressure\n",
+ "T_1 = 500;\t\t\t#[C] - Initial temperature\n",
+ "Vel_1 = 140;\t\t\t#[m/s] - Initial velocity\n",
+ "T_2 = 100;\t\t\t#[C] - Final temperature\n",
+ "Vel_2 = 80;\t\t\t#[m/s] - Final velocity\n",
+ "W = 746.0;\t\t\t#[kJ/kg] - Work output\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# (a).\n",
+ "\t\t\t# From steam table as reported in the book\n",
+ "H_1 = 3445.3;\t\t\t#[kJ/kg]\n",
+ "H_2 = 2676.1;\t\t\t#[kJ/kg]\n",
+ "S_1 = 7.0901;\t\t\t#[kJ/kh-K]\n",
+ "S_2 = 7.3549;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "\t\t\t# The temperature at which heat exchange take place is given by \n",
+ "T_b =(T_1 + T_2)/2 + 273.15;\t\t\t#[K]\n",
+ "\n",
+ "\t\t\t# From first law in a control volume \n",
+ "\t\t\t# q - W = delta_H + (delta_V**(2))/2 , therefore\n",
+ "q = W*10**(3) + (H_2 - H_1)*10**(3) + (Vel_2**(2) - Vel_1**(2))/2;\t\t\t#[J/kg]\n",
+ "q = q*10**(-3);\t\t\t#[kJ/kg]\n",
+ "\n",
+ "S_gen = (S_2 - S_1) - (q/T_b);\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "print \" a).The specific entropy production within turbine is %f kJ/kg-K\"%(S_gen);\n",
+ "\n",
+ "\t\t\t#(b)\n",
+ "\t\t\t# If control volume is too large to include the turbine and the environment then T_b becomes equal to 289 K. In this case\n",
+ "T_b_prime = 298;\t\t\t#[K]\n",
+ "\n",
+ "\t\t\t# The entropy change of the sysytem is given by \n",
+ "\t\t\t#delta_S = q/T_b + S_gen\n",
+ "S_gen = (S_2 - S_1) - (q/T_b_prime);\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "print \" b).The specific entropy production within turbine is %f kJ/kg-K\"%(S_gen);\n",
+ "\n",
+ "\t\t\t# In the first part only irreversibilities within the turbine are evaluated\n",
+ "\t\t\t# whereas in part (2) irreversible heat transfer between the turbine cover and environment are also included.\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " a).The specific entropy production within turbine is 0.316793 kJ/kg-K\n",
+ " b).The specific entropy production within turbine is 0.364800 kJ/kg-K\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.9 Page Number : 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Determination of work required and exit temperature\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 1.;\t\t\t#[MPa] - Initial pressure\n",
+ "T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "P_2 = 8.;\t\t\t#[MPa] - Final pressure\n",
+ "Y = 1.4;\t\t\t# Index of expansion of gas\n",
+ "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t#(1)\n",
+ "\t\t\t# The exit temperature for ideal gas under isentropic conditions is given by \n",
+ "T_2 = round(T_1*(round((P_2/P_1)**((Y-1)/Y),2)),1);\t\t\t#[K] - Exit temperature\n",
+ "\n",
+ "Cp_0 = round(Y*R/(Y-1),1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
+ "\t\t\t# For isentropic conditions the enthalpy change for ideal gas is given by\n",
+ "delta_H_s = Cp_0*(T_2 - T_1);\t\t\t#[J/mol]\n",
+ "\t\t\t# Therefore work is given by\n",
+ "W = - delta_H_s;\t\t\t#[J/mol]\n",
+ "\n",
+ "print \" 1).The exit temperature of steam is %.2f K\"%(T_2);\n",
+ "print \" The required work is %.2f J/mol\"%(W);\n",
+ "\n",
+ "\t\t\t#(2)\n",
+ "eff = 0.8;\t\t\t# Adiabatic efficiency\n",
+ "\t\t\t# delta_H_s/delta_H_a = 0.8\n",
+ "delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
+ "W_a = - delta_H_a;\t\t\t#[J/mol]\n",
+ "\n",
+ "\t\t\t# The ideal gas enthalpy is a function only of temperature,therefore actual exit temperature T_2a is given by \n",
+ "\t\t\t# delta_H_a = Cp_0*(T_2a - T_1)\n",
+ "T_2a = (delta_H_a/Cp_0) + T_1;\n",
+ "\n",
+ "print \" 2).The exit temperature of steam is %.2f K\"%(T_2a);\n",
+ "print \" The required work is %.2f J/mol\"%(W_a);\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1).The exit temperature of steam is 856.40 K\n",
+ " The required work is -11152.58 J/mol\n",
+ " 2).The exit temperature of steam is 952.21 K\n",
+ " The required work is -13940.72 J/mol\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.10 Page Number : 161"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Determination of work required and exit temperature\n",
+ "\n",
+ "from scipy.optimize import fsolve \n",
+ "import math \n",
+ "from scipy.integrate import quad \n",
+ "\t\t\t\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
+ "T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "P_2 = 8;\t\t\t#[MPa] - Final pressure\n",
+ "Y = 1.4;\t\t\t# Index of expansion of gas\n",
+ "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
+ "\t\t\t# Cp_0 = 7.7 + 0.04594*10**(-2)*T + 0.2521*10**(-5)*T**(2) - 0.8587*10**(-9)*T**(3), here T is in K and Cp_0 is in cal/mol-K\n",
+ "a = 7.7;\n",
+ "b = 0.04594*10**(-2);\n",
+ "c = 0.2521*10**(-5);\n",
+ "d = - 0.8587*10**(-9);\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# delta_S = integral((Cp_0/T)*dT) - R*math.log(P_2/P_1) = 0\n",
+ "\t\t\t# delta_S = integral(((a + b*T + c*T**(2) + d*T**(3))/T)*dT) - R*math.log(P_2/P_1) = 0\n",
+ "\t\t\t# delta_S = a*math.log(T_2/T_1) + b*(T_2 - T_1) + (c/2)*(T_2**(2) - T_1**(2)) + (d/3)*(T_2**(3) - T_1**(3)) - R*math.log(P_2/P_1) = 0\n",
+ "\t\t\t# Solving for T_2 in the above equation we get\n",
+ "def f(T_2): \n",
+ "\t return a*math.log(T_2/T_1)+b*(T_2-T_1)+(c/2)*(T_2**(2)-T_1**(2))+(d/3)*(T_2**(3)-T_1**(3))-R*math.log(P_2/P_1)\n",
+ "T_2 = fsolve(f,100)\n",
+ "\n",
+ "\t\t\t# Now let us calculate the enthalpy change under these conditions \n",
+ "\n",
+ "def f0(T): \n",
+ "\t return 7.7+0.04594*10**(-2)*T+0.2521*10**(-5)*T**(2)-0.8587*10**(-9)*T**(3)\n",
+ "\n",
+ "delta_H_s = quad(f0,T_1,T_2)[0]\n",
+ "\n",
+ "delta_H_s = delta_H_s*4.184;\t\t\t#[J/mol]\n",
+ "\t\t\t# Therefore isentropic work done is\n",
+ "W = - delta_H_s;\n",
+ "\n",
+ "print \" 1).The exit temperature of steam is %f K\"%(T_2);\n",
+ "print \" The required work is %f J/mol\"%(W);\n",
+ "\n",
+ "\t\t\t#(2)\n",
+ "eff = 0.8;\n",
+ "delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
+ "\t\t\t# Therefore actual work done is given by \n",
+ "W_a = - delta_H_a;\t\t\t#[J/mol]\n",
+ "\n",
+ "\t\t\t# Now we have to determine the exit temperature under actual conditions\n",
+ "\t\t\t# delta_H_a = integral(Cp_0*dT) from limit T_1 = 473.15 K to T_2\n",
+ "\t\t\t# On putting the values and simplifying we get\n",
+ "\t\t\t# 7.7*T_2 + 0.02297*10**(-2)*T_2**(2) + 0.084*10**(-5)*T_2**(3) - 0.214675*10**(-9)*T_2**(4) - 6907.106 = 0\n",
+ "\n",
+ "def f1(T_2_prime): \n",
+ "\t return a*(T_2_prime-T_1)+(b/2)*(T_2_prime**(2)-T_1**(2))+(c/3)*(T_2_prime**(3)-T_1**(3))+(d/4)*(T_2_prime**(4)-T_1**(4))-(delta_H_a/4.184)\n",
+ "T_2_prime = fsolve(f1,100)\n",
+ "\n",
+ "print \" 2).The exit temperature of steam is %f K\"%(T_2_prime);\n",
+ "print \" The required work is %f J/mol\"%(W_a);\n",
+ "\n",
+ "# Answers are vary because of rounding error. Calculations are correct. "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1).The exit temperature of steam is 760.037501 K\n",
+ " The required work is -10499.128839 J/mol\n",
+ " 2).The exit temperature of steam is 828.044888 K\n",
+ " The required work is -13123.911049 J/mol\n"
+ ]
+ }
+ ],
+ "prompt_number": 31
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.11 Page Number : 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Determination of work required and exit temperature\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
+ "T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "P_2 = 8;\t\t\t#[MPa] - Final pressure\n",
+ "Y = 1.4;\t\t\t# Index of expansion of gas\n",
+ "\n",
+ "\t\t\t# At state 1 (1 MPa and 200 C) from steam table as reported in the book\n",
+ "H_1 = 2827.9;\t\t\t#[kJ/kg]\n",
+ "S_1 = 6.694;\t\t\t#[kJ/kg]\n",
+ "\t\t\t# At state 2 (8 MPa)\n",
+ "S_2 = S_1;\t\t\t# Isentropic process\n",
+ "\t\t\t# From steam table at 8 MPa and 450 C\n",
+ "S_21 = 6.5551;\t\t\t#[kJ/kg-K]\n",
+ "\t\t\t# From steam table at 8 MPa and 500 C\n",
+ "S_22 = 6.7240;\t\t\t#[kJ/kg-K]\n",
+ "\t\t\t# Therefore temperature at which entropy of steam is 6.694 kJ/kg-K is given by\n",
+ "T_2 = 450 + (500-450)/(S_22-S_21)*(S_2-S_21);\t\t\t#[C]\n",
+ "T_2 = T_2 + 273.15;\t\t\t#[K]\n",
+ "\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# Enthalpy of steam at 8 MPa and 450 C from steam table as reported in the book \n",
+ "H_21 = 3272.0;\t\t\t#[kJ/kg]\n",
+ "\t\t\t# And at 8 MPA and 500 C\n",
+ "H_22 = 3398.3;\t\t\t#[kJ/kg]\n",
+ "\t\t\t# Therefore enthalpy of steam at 8 MPa and T_2 \n",
+ "H_2 = H_21 + ((H_22-H_21)/(500-450))*((T_2-273.15) - 450); \n",
+ "\t\t\t# Work done is given by \n",
+ "\t\t\t# W = - delta_H_s\n",
+ "W = - (H_2 - H_1);\t\t\t#[J/g]\n",
+ "W = W*18.015;\t\t\t#[J/mol]\n",
+ "delta_H_s = - W;\n",
+ "\n",
+ "print \" 1).The exit temperature of steam is %f K\"%(T_2);\n",
+ "print \" The required work is %f J/mol\"%(W);\n",
+ "\n",
+ "\t\t\t#(2)\n",
+ "eff = 0.8;\t\t\t# Adiabatic efficiency\n",
+ "\t\t\t# delta_H_s/delta_H_a = 0.8\n",
+ "delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
+ "\t\t\t# Therefore actual work done \n",
+ "W_a = - delta_H_a;\t\t\t#[J/mol]\n",
+ "\t\t\t# Enthalpy at actual exit conditions is \n",
+ "H_2_a = H_1 + delta_H_a/18.015;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# Enthalpy of steam at 8 MPa and 500 C from steam table as reported in the book \n",
+ "H_21_a = 3398.3;\t\t\t#[kJ/kg]\n",
+ "\t\t\t# And at 8 MPA and 550 C\n",
+ "H_22_a = 3521.0;\t\t\t#[kJ/kg]\n",
+ "\t\t\t# Therefore temperature at H_22_a is given by\n",
+ "T_2_a = 500 + ((550-500)*(H_2_a - H_21_a))/(H_22_a - H_21_a);\t\t\t#[C]\n",
+ "T_2_a = T_2_a + 273.15;\t\t\t#[K]\n",
+ "\n",
+ "print \" 2).The exit temperature of steam is %f K\"%(T_2_a);\n",
+ "print \" The required work is %f J/mol\"%(W_a);\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1).The exit temperature of steam is 764.269005 K\n",
+ " The required work is -9871.618433 J/mol\n",
+ " 2).The exit temperature of steam is 819.832257 K\n",
+ " The required work is -12339.523042 J/mol\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.12 Page Number : 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Determination of work required and discharge temperature\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 140.;\t\t\t#[kPa] - Initial pressure\n",
+ "T_1 = 20. + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "P_2 = 560.;\t\t\t#[kPa] - Final pressure\n",
+ "eff = 0.75;\t\t\t# Compressor efficiency\n",
+ "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
+ "\t\t\t# Cp_0 = 4.750 + 1.200*10**(-2)*T + 0.3030*10**(-5)*T**(2) - 2.630*10**(-9)*T**(3), here T is in K and Cp_0 is in cal/mol-K\n",
+ "a = 7.7;\n",
+ "b = 0.04594*10**(-2);\n",
+ "c = 0.2521*10**(-5);\n",
+ "d = - 0.8587*10**(-9);\n",
+ "\n",
+ "# Calculations and Results\n",
+ "# At 20 C,as reported in the book\n",
+ "Cp_0 = 8.46;\t\t\t#[cal/mol-K] - Specific heat capacity at constant pressure\n",
+ "Cv_0 = Cp_0 - R;\t\t\t#[cal/mol-K] - Specific heat capacity at constant volume\n",
+ "Y = Cp_0/Cv_0;\t\t\t# Index of expansion\n",
+ "\n",
+ "\t\t\t# Assuming 100 % efficiency,for reversible and adiabatic process the final temperature is given by\n",
+ "\t\t\t# P*V**(Y) = constant or, P*((R*T)/P)**(Y) = constant\n",
+ "T_2 = ((P_1/P_2)**((1-Y)/Y))*T_1;\t\t\t#[K]\n",
+ "\n",
+ "\t\t\t# Since at final temperature the value of heat capacity ratio would have changed \n",
+ "\t\t\t# So let us determine Y at mean temperature and then calculating final temperature\n",
+ "T_mean = (T_1 + T_2)/2;\t\t\t#[K]\n",
+ "\n",
+ "\t\t\t# At T_mean,as reported in the book\n",
+ "Cp_0_new = 9.153;\t\t\t#[cal/mol-K]\n",
+ "Cv_0_new = Cp_0_new - R;\t\t\t#[cal/mol-K]\n",
+ "Y_new = Cp_0_new/Cv_0_new;\n",
+ "T_2_new = T_1*((P_1/P_2)**((1-Y_new)/Y_new));\t\t\t#[K]\n",
+ "\n",
+ "\t\t\t# The enthalpy change is given by \n",
+ "\n",
+ "def f23(T): \n",
+ "\t return 4.750+1.200*10**(-2)*T+0.3030*10**(-5)*T**(2)-2.630*10**(-9)*T**(3)\n",
+ "\n",
+ "delta_H = quad(f23,T_1,T_2_new)[0]\n",
+ "\n",
+ "\n",
+ "\t\t\t#For adiabatic process\n",
+ "W = - delta_H;\t\t\t#[cal/mol]\n",
+ "\t\t\t# Now actual work done on the system is given by \n",
+ "W_a = W/eff;\t\t\t#[cal/mol]\n",
+ "\n",
+ "\t\t\t# Since the actual process is adiabatic the work done is change in negative of enthalpy\n",
+ "\t\t\t# Therefore actual change in enthalpy is - W_a, or\n",
+ "\t\t\t# - W_a = 4.750*(T_2-T_1) + (1.2*10**(-2)/2)*(T_2**(2)-T_1**(2)) + (0.3030*10**(-5)/3)*(T_2**(3)-T_1**(3)) - (2.63*10**(-9)/4)*(T_2***(4)-T_1**(4));\n",
+ "\t\t\t# Solving for T_2 in the above equation\n",
+ "def f1(T_2_prime): \n",
+ "\t return 4.750*(T_2_prime-T_1)+((1.2*10**(-2))/2)*(T_2_prime**(2)-T_1**(2))+((0.3030*10**(-5))/3)*(T_2_prime**(3)-T_1**(3))-((2.63*10**(-9))/4)*(T_2_prime**(4)-T_1**(4))+W_a\n",
+ "T_2_prime=fsolve(f1,100)\n",
+ "\n",
+ "print \" The required work is %f cal/mol\"%(W_a);\n",
+ "print \" The discharge temperature of methane is %f K\"%(T_2_prime);\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " The required work is -1254.158148 cal/mol\n",
+ " The discharge temperature of methane is 427.374758 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.13 Page Number : 164"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Dtermination of power output entropy and exit temperature\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 10;\t\t\t#[bar] - Initial pressure\n",
+ "T_1 = 500 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "P_2 = 2;\t\t\t#[psia] - Final pressure\n",
+ "P_2 = P_2/14.5;\t\t\t#[bar]\n",
+ "P_2 = P_2*10**(2);\t\t\t#[kPa]\n",
+ "m = 1.8;\t\t\t#[kg/s] - Mass flux\n",
+ "eff = 0.8;\t\t\t# Efficiency\n",
+ "\n",
+ "\t\t\t# At state 1, from steam table\n",
+ "H_1 = 3478.5;\t\t\t#[kJ/kg]\n",
+ "S_1 = 7.7622;\t\t\t#[kJ/kg-K]\n",
+ "S_2 = S_1;\t\t\t# Adiabatic process\n",
+ "\n",
+ "\t\t\t# From saturated steam table at 10 kPa\n",
+ "S_liq_1 = 0.6493;\t\t\t#[kJ/kg-K]\n",
+ "S_vap_1 = 8.1502;\t\t\t#[kJ/kg-K]\n",
+ "\t\t\t# From saturated steam table at 15 kPa\n",
+ "S_liq_2 = 0.7549;\t\t\t#[kJ/kg-K]\n",
+ "S_vap_2 = 8.0085;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# Threfore at P_2 \n",
+ "S_liq = S_liq_1 + ((S_liq_2-S_liq_1)/(15-10))*(P_2-10);\n",
+ "S_vap = S_vap_1 + ((S_vap_2-S_vap_1)/(15-10))*(P_2-10);\n",
+ "\n",
+ "\t\t\t# The dryness fraction at exit state is\n",
+ "x_2 = (S_1-S_liq)/(S_vap-S_liq);\n",
+ "\t\t\t# The enthalpy at exit to be determined. At 10 kPa\n",
+ "H_liq_1 = 191.83;\t\t\t#[kJ/kg]\n",
+ "H_vap_1 = 2584.7;\t\t\t#[kJ/kg]\n",
+ "\t\t\t# At 15 kPa\n",
+ "H_liq_2 = 225.94;\t\t\t#[kJ/kg]\n",
+ "H_vap_2 = 2599.1;\t\t\t#[kJ/kg]\n",
+ "\t\t\t# Therfore at P_2\n",
+ "H_liq = H_liq_1 + ((H_liq_2-H_liq_1)/(15-10))*(P_2-10);\n",
+ "H_vap = H_vap_1 + ((H_vap_2-H_vap_1)/(15-10))*(P_2-10);\n",
+ "\n",
+ "\t\t\t# Enthalpy at state 2\n",
+ "H_2_s = H_liq*(1-x_2) + x_2*H_vap;\t\t\t#[kJ/kg]\n",
+ "W = m*(H_1 - H_2_s);\t\t\t#[kW]\n",
+ "\n",
+ "print \" 1).The power output is %f kW\"%(W);\n",
+ "\n",
+ "\t\t\t#(2)\n",
+ "\t\t\t# If the process is 80 % efficient the enthalpy change is\n",
+ "\t\t\t# H_1 - H_2_a = eff*(H_1 - H_2_s)\n",
+ "H_2_a = H_1 - (0.8*(H_1 - H_2_s));\n",
+ "\n",
+ "\t\t\t# Now under these conditions temperature and entropy have to be determined. From superheated steam tables,as reported in the book\n",
+ "\t\t\t# At 10 kPa and 100 C\n",
+ "H_2_1 = 2687.5;\t\t\t#[kJ/kg]\n",
+ "S_2_1 = 8.4479;\t\t\t#[kJ/kg-k]\n",
+ "\t\t\t# At 10 kPa and 150 C\n",
+ "H_2_2 = 2783.0;\t\t\t#[kJ/kg]\n",
+ "S_2_2 = 8.6882;\t\t\t#[kJ/kg-k]\n",
+ "\t\t\t# At 50 kPa and 100 C\n",
+ "H_3_1 = 2682.5;\t\t\t#[kJ/kg]\n",
+ "S_3_1 = 7.6947;\t\t\t#[kJ/kg-k]\n",
+ "\t\t\t# At 50 kPa and 150 C\n",
+ "H_4_1 = 2780.1;\t\t\t#[kJ/kg]\n",
+ "S_4_1 = 7.9401;\t\t\t#[kJ/kg-k]\n",
+ "\t\t\t# Therefore at P_2 and 100 C\n",
+ "H_prime_1 = H_2_1 + ((H_3_1-H_2_1)/(50-10))*(P_2-10);\t\t\t#[kJ/kg]\n",
+ "S_prime_1 = S_2_1 + ((S_3_1-S_2_1)/(50-10))*(P_2-10);\t\t\t#[kJ/kg-K]\n",
+ "\t\t\t# Therefore at P_2 and 150 C\n",
+ "H_prime_2 = H_2_2 + ((H_4_1-H_2_2)/(50-10))*(P_2-10);\t\t\t#[kJ/kg]\n",
+ "S_prime_2 = S_2_2 + ((S_4_1-S_2_2)/(50-10))*(P_2-10);\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "\t\t\t# Enthalpy at exit is H_2_a. So at this condition temperature can be nom be determined\n",
+ "T_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(150-100) + 100;\t\t\t#[C]\n",
+ "\t\t\t# The entropy at exit is\n",
+ "S_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(S_prime_2 - S_prime_1) + S_prime_1;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "print \" 2).The entropy at exit is %f kJ/kg-K\"%(S_exit);\n",
+ "print \" The temperature of the exit state is %f C\"%(T_exit);\n",
+ "\n",
+ "print \" The irreversibility is advatageous because the exit steam is superheated and therefore\";\n",
+ "print \" the blades of the turbine are not eroded by water droplets which get formed when the process is isentropic\";\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1).The power output is 1753.346828 kW\n",
+ " 2).The entropy at exit is 8.906311 kJ/kg-K\n",
+ " The temperature of the exit state is 100.002552 C\n",
+ " The irreversibility is advatageous because the exit steam is superheated and therefore\n",
+ " the blades of the turbine are not eroded by water droplets which get formed when the process is isentropic\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.14 Page Number : 166"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of work output per unit mass\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 6;\t\t\t#[MPa] - Initial pressure\n",
+ "T_1 = 500 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "P_2 = 10;\t\t\t#[kPa] - Final pressure\n",
+ "out_qlty = 0.9;\t\t\t# Output quality\n",
+ "\n",
+ "\t\t\t# At 6 MPa and 500 C, from steam table as reported in the book\n",
+ "H_1 = 3422.2;\t\t\t#[kJ/kg]\n",
+ "S_1 = 6.8803;\t\t\t#[kJ/kg-K]\n",
+ "S_2 = S_1;\t\t\t# Adiabatic reversible conditions\n",
+ "\t\t\t# At 10 kPa saturated\n",
+ "H_liq = 191.83;\t\t\t#[kJ/kg]\n",
+ "H_vap = 2584.7;\t\t\t#[kJ/kg]\n",
+ "S_liq = 0.6493;\t\t\t#[kJ/kg-K]\n",
+ "S_vap = 8.1502;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# The dryness fraction is given by \n",
+ "x = (S_1-S_liq)/(S_vap-S_liq);\n",
+ "\n",
+ "\t\t\t# Now the exit enthalpy is given by\n",
+ "H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg]\n",
+ "W = - (H_2 - H_1);\t\t\t#[kJ/kg] - Under isentropic conditions\n",
+ "\n",
+ "\t\t\t# We know that, delta_S = q/T_b + S_gen\n",
+ "\t\t\t# Since delta_S = 0, therefore under isentropic conditions\n",
+ "S_gen = 0;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "\t\t\t# Now for output quality 0.9\n",
+ "H_2_a = H_liq*(1-out_qlty) + out_qlty*H_vap;\t\t\t#[kJ/kg]\n",
+ "S_2_a = S_liq*(1-out_qlty) + out_qlty*S_vap;\t\t\t#[kJ/kg]\n",
+ "W_a = - (H_2_a - H_1);\t\t\t#[kJ/kg]\n",
+ "delta_S_a = S_2_a - S_1;\t\t\t#[kJ/kg-k]\n",
+ "\t\t\t# Again, delta_S = q/T_b + S_gen\n",
+ "\t\t\t# Since q = 0, therefore under isentropic conditions\n",
+ "S_gen_a = delta_S_a;\t\t\t#[kJ/kg-K\n",
+ "\t\t\t# Now efficiency is given by eff = delta_H_a/delta_H_s\n",
+ "eff = W_a/W;\n",
+ "\n",
+ "print \" For output quality = 0.9\";\n",
+ "print \" The work output per unit mass is %f kJ/kg\"%(W_a);\n",
+ "print \" The entropy generation is given by S_gen = %f kJ/kg-K\"%(S_gen_a);\n",
+ "print \" The efficiency with respect to reversible adiabatic case is given by eff = %f\"%(eff);\n",
+ "\n",
+ "\t\t\t# Now for output quality 1\n",
+ "out_qlty_1 = 1;\n",
+ "H_2_a_1 = H_liq*(1-out_qlty_1) + out_qlty_1*H_vap;\t\t\t#[kJ/kg]\n",
+ "S_2_a_1 = S_liq*(1-out_qlty_1) + out_qlty_1*S_vap;\t\t\t#[kJ/kg]\n",
+ "W_a_1 = - (H_2_a_1 - H_1);\t\t\t#[kJ/kg]\n",
+ "delta_S_a_1 = S_2_a_1 - S_1;\t\t\t#[kJ/kg-k]\n",
+ "\t\t\t# Again, delta_S = q/T_b + S_gen\n",
+ "\t\t\t# Since q = 0, therefore under isentropic conditions\n",
+ "S_gen_a_1 = delta_S_a_1;\t\t\t#[kJ/kg-K\n",
+ "\t\t\t# Now efficiency is given by eff = delta_H_a/delta_H_s\n",
+ "eff_1 = W_a_1/W;\n",
+ "\n",
+ "print \" For output quality = 1.0\";\n",
+ "print \" The work output per unit mass is %f kJ/kg\"%(W_a_1);\n",
+ "print \" The entropy generation is given by S_gen = %f kJ/kg-K\"%(S_gen_a_1);\n",
+ "print \" The efficiency with respect to reversible adiabatic case is given by eff = %f\"%(eff_1);\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " For output quality = 0.9\n",
+ " The work output per unit mass is 1076.787000 kJ/kg\n",
+ " The entropy generation is given by S_gen = 0.519810 kJ/kg-K\n",
+ " The efficiency with respect to reversible adiabatic case is given by eff = 0.866551\n",
+ " For output quality = 1.0\n",
+ " The work output per unit mass is 837.500000 kJ/kg\n",
+ " The entropy generation is given by S_gen = 1.269900 kJ/kg-K\n",
+ " The efficiency with respect to reversible adiabatic case is given by eff = 0.673983\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.15 Page Number : 168"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Estimation of final velocity\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 3.;\t\t\t#[bar] - Initial pressure\n",
+ "T_1 = 150. + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "Vel_1 = 90.;\t\t\t#[m/s] - Initial velocity\n",
+ "P_2 = 1.;\t\t\t#[bar] - Final pressure\n",
+ "eff = 0.95;\t\t\t# Adiabatic effciciency of the nozzle\n",
+ "R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
+ "\n",
+ "\t\t\t# At 3 bar and 150 C, from steam table\n",
+ "S_1 = 7.0778;\t\t\t#[kJ/kg-K]\n",
+ "H_1 = 2761.0;\t\t\t#[kJ/kg]\n",
+ "S_2 = S_1;\t\t\t# \n",
+ "\n",
+ "\t\t\t# At 1 bar saturated\n",
+ "S_liq = 1.3026;\t\t\t#[kJ/kg-K]\n",
+ "S_vap = 7.3594;\t\t\t#[kJ/kg-K]\n",
+ "H_liq = 417.46;\t\t\t#[kJ/kg]\n",
+ "H_vap = 2675.5;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# The dryness factor of exit steam can be determined as\n",
+ "x = (S_1-S_liq)/(S_vap-S_liq);\n",
+ "\t\t\t# Enthalpy of exit steam is given by \n",
+ "H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg]\n",
+ "delta_H_s = H_2 - H_1;\t\t\t#[kJ/kg] - Enthalpy change\n",
+ "delta_H_a = eff*delta_H_s;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# Assuming no heat exchange with surroundings and since no work is done\n",
+ "\t\t\t# delta_H + (delta_V**(2))/2 = 0\n",
+ "delta_Vel_square = 2*(-delta_H_a)*1000;\t\t\t#[m**(2)/s**(2)]\n",
+ "Vel_2 = (delta_Vel_square + Vel_1**(2))**(1./2);\t\t\t#[m/s]\n",
+ "\n",
+ "print \" 1).The final velocity when fluid is steam) is %f m/s\"%(Vel_2);\n",
+ "\n",
+ "\t\t\t# (2)\n",
+ "Y = 1.4;\t\t\t# Index of expansion\n",
+ "Cp_0 = (Y*R)/(Y-1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
+ "\t\t\t# The final temperature has to be determined such that entropy change is zero. Under isentropic conditions\n",
+ "\t\t\t# P_1**(1-Y)*T_1**(Y) = P_2**(1-Y)*T_2**(Y)\n",
+ "T_2 = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K]\n",
+ "delta_H_s_2 = Cp_0*(T_2 - T_1);\t\t\t#[J/mol]\n",
+ "delta_H_a_2 = eff*delta_H_s_2;\t\t\t#[J/mol]\n",
+ "delta_H_a_2 = (delta_H_a_2*1000)/28.84;\t\t\t#[J/kg]\n",
+ "\n",
+ "delta_Vel_square_2 = 2*(-delta_H_a_2);\t\t\t#[m**(2)/s**(2)]\n",
+ "Vel_2_2 = (delta_Vel_square_2 + Vel_1**(2))**(1./2);\t\t\t#[m/s]\n",
+ "\n",
+ "print \" 2).The final velocity when fluid is air which behaves as an ideal gas) is %f m/s\"%(Vel_2_2);\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1).The final velocity when fluid is steam) is 608.291583 m/s\n",
+ " 2).The final velocity when fluid is air which behaves as an ideal gas) is 476.065890 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.16 Page Number : 169"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of final velocity and increase in entropy\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 300.;\t\t\t#[kPa] - Initial pressure\n",
+ "T_1 = 450.;\t\t\t#[K] - Initial temperature\n",
+ "Vel_1 = 90.;\t\t\t#[m/s] - Initial velocity\n",
+ "P_2 = 180.;\t\t\t#[kPa] - Final pressure\n",
+ "eff = 0.95;\t\t\t# Adiabatic effciciency of the nozzle\n",
+ "R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
+ "Cp = 5.19;\t\t\t#[kJ/kg-K] - Specific heat capacity at constant pressure\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t#(a)\n",
+ "\t\t\t# Exit velocity is highest when drop in enthalpy is highest or when isentropic conditions are maintained\n",
+ "\n",
+ "Mol_wt_He = 4;\t\t\t#[g/mol] - Molecular weight of helium\n",
+ "R_He = R/Mol_wt_He;\t\t\t# 'R' for helium\n",
+ "Y = Cp/(Cp - R_He);\n",
+ "\n",
+ "\t\t\t# Now temperature at exit to be determined\n",
+ "T_2s = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K]\n",
+ "delta_H_2s = Cp*(T_2s - T_1);\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# Since no work is done and heat exchange is zero,from first law we get\n",
+ "\t\t\t# delta_H + delta_Vel**(2)/2 = 0\n",
+ "delta_Vel_square = 2*(-delta_H_2s)*1000;\t\t\t#[m**(2)/s**(2)]\n",
+ "Vel_2 = (delta_Vel_square)**(1./2);\t\t\t#[m/s] - ( as Vel_1 << Vel_2)\n",
+ "\n",
+ "print \" a).The maximum exit velocity is %f m/s\"%(Vel_2);\n",
+ "\n",
+ "\t\t\t#(b)\n",
+ "T_2a = 373;\t\t\t#[K] - Measured temperature of helium\n",
+ "delta_H_a = Cp*(T_2a - T_1);\t\t\t#[kJ/kg]\n",
+ "delta_Vel_square_a = 2*(-delta_H_a)*1000;\t\t\t#[m**(2)/s**(2)]\n",
+ "Vel_2a = (delta_Vel_square_a)**(1./2);\t\t\t#[m/s] - ( as Vel_1 << Vel_2a)\n",
+ "\n",
+ "print \" b).The actual exit velocity is %f m/s\"%(Vel_2a);\n",
+ "\n",
+ "\t\t\t#(c)\n",
+ "delta_S_sys = Cp*math.log(T_2a/T_1) - R_He*math.log(P_2/P_1);\n",
+ "\t\t\t# we know that delta_S_sys = q/T_b + S_gen and since q = 0, therfore\n",
+ "S_gen = delta_S_sys;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "print \" c).The increasse in entropy per unit mass is %f kJ/kg-K\"%(S_gen);\n",
+ "\n",
+ "\t\t\t# The source of irreversibility is friction in the nozzle.\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " a).The maximum exit velocity is 929.607346 m/s\n",
+ " b).The actual exit velocity is 894.013423 m/s\n",
+ " c).The increasse in entropy per unit mass is 0.087748 kJ/kg-K\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.17 Page Number : 170"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of work done and heat transfer\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 1;\t\t\t#[bar] - Initial pressure\n",
+ "T_1 = 150 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "V_2 = 0.28;\t\t\t#[m**(3)/kg] - Final specific volume\n",
+ "T_2 = T_1;\t\t\t#[K] - Isothermal process\n",
+ "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
+ "\n",
+ "\t\t\t# At 1 bar and 150 C, from steam table\n",
+ "S_1 = 7.6134;\t\t\t#[kJ/kg-K]\n",
+ "H_1 = 2776.4;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# At 150 C saturated\n",
+ "V_liq = 0.001091;\t\t\t#[m**(3)/kg]\n",
+ "V_vap = 0.3928;\t\t\t#[m**(3)/kg]\n",
+ "H_liq = 632.2;\t\t\t#[kJ/kg]\n",
+ "H_vap = 2746.5;\t\t\t#[kJ/kg]\n",
+ "S_liq = 1.8418;\t\t\t#[kJ/kg-K]\n",
+ "S_vap = 6.8379;\t\t\t#[kJ/kg-K]\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# The dryness factor of exit steam can be determined as\n",
+ "x = (V_2 - V_liq)/(V_vap - V_liq);\n",
+ "S_2 = S_liq*(1-x) + x*S_vap;\t\t\t#[kJ/kg-K] -Entropy \n",
+ "H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg] -Enthalpy \n",
+ "delta_H = H_2 - H_1;\t\t\t#[kJ/kg] - Enthalpy change\n",
+ "delta_S = S_2 - S_1;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# Since the compression is reversible\n",
+ "q = T_1*delta_S;\t\t\t#[kJ/kg] - Heat transfer\n",
+ "\t\t\t# From first law q - W = delta_H\n",
+ "W = q - delta_H;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "print \" 1).The amount of heat transfer when fluid is steam) is %f kJ/kg\"%(q)\n",
+ "print \" The amount of work transfer when fluid is steam) is %f kJ/kg\"%(W)\n",
+ "\n",
+ "\t\t\t#(2)\n",
+ "V_2 = V_2*(28.84/1000);\t\t\t#[m**(3)/mol] - Molar volume at exit\n",
+ "\t\t\t# Pressure at exit is given by \n",
+ "P_2 = ((R*T_2)/V_2);\t\t\t#[N/m**(2)]\n",
+ "P_2 = P_2*10**(-5);\t\t\t#[bar]\n",
+ "\n",
+ "\t\t\t# Entropy change is given by, delta_S_2 = Cp*math.log(T_2/T_1) - R*math.log(P_2/P_1), but since T_1 = T_2, therfore\n",
+ "delta_S_2 = - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
+ "\n",
+ "q_2 = T_1*delta_S_2;\t\t\t#[J/mol] - Heat change\n",
+ "q_2 = q_2/28.84;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# Enthalpy change is given by, delta_H_2 = Cp*(T_2 - T_1) = 0 (as T_1 = T_2)\n",
+ "delta_H_2 = 0;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "\t\t\t# From first law q - W = delta_H, therefore\n",
+ "W_2 = q_2 - delta_H_2;\t\t\t#[kJ/kg]\n",
+ "\n",
+ "print \" 2).The amount of heat transfer when fluid is ideal gas) is %f kJ/kg\"%(q_2)\n",
+ "print \" The amount of work transfer when fluid is ideal gas) is %f kJ/kg\"%(W_2)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 1).The amount of heat transfer when fluid is steam) is -936.947741 kJ/kg\n",
+ " The amount of work transfer when fluid is steam) is -298.195149 kJ/kg\n",
+ " 2).The amount of heat transfer when fluid is ideal gas) is -179.526401 kJ/kg\n",
+ " The amount of work transfer when fluid is ideal gas) is -179.526401 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.18 Page Number : 171"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Calculation of air velocity and change in entropy\n",
+ "\n",
+ "# Variables\n",
+ "P_1 = 7*10**(5);\t\t\t#[Pa] - Initial pressure\n",
+ "T_1 = 95 + 273.15;\t\t\t#[K] - Initial temperature\n",
+ "P_2 = 3.5*10**(5);\t\t\t#[Pa] - Final pressure\n",
+ "dia = 15*10**(-2);\t\t\t#[m] - Diameter of pipe\n",
+ "m = 2;\t\t\t#[kg/s] - Mass flow rate\n",
+ "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
+ "Y = 1.4;\t\t\t# Index of expansion\n",
+ "Cp_0 = (R*Y)/(Y-1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
+ "Cp_0 = (Cp_0/28.84)*1000;\t\t\t#[J/kg-K]\n",
+ "rho_1 = 6.6;\t\t\t#[kg/m**(3)] - Density\n",
+ "\n",
+ "# Calculations and Results\n",
+ "\t\t\t# velocity before throttling is to be determined m = rho*Vol*Area\n",
+ "V_1 = (R*T_1)/P_1;\t\t\t#[m**(3)/mol] - Specific volume\n",
+ "V_1 = (V_1/28.84)*1000;\t\t\t#[m**(3)/kg]\n",
+ "Vel_1 = m/(rho_1*3.14*(dia/2)**(2));\t\t\t#[m/s] - Velocity before throttling\n",
+ "\n",
+ "\t\t\t# Let the temperature after throttling be T_2, then\n",
+ "\t\t\t# V_2 = (((R*T_2)/P_2)/28.84)*1000\n",
+ "\t\t\t# Vel_2 = m/(rho_2*Area) = (m*V_2)/(3.14*(dia/2)**(2))\n",
+ "\t\t\t# From first law, since q = W = 0, we get\n",
+ "\t\t\t# delta_H + (delta_V**(2))/2 = 0\n",
+ "\t\t\t# Cp_0*(T_2 - T_1) + ((Vel_2)**(2) - (Vel_1)**(2))/2 = 0\n",
+ "\t\t\t#Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)))**(2) - (Vel_1)**(2))/2 = 0\n",
+ "\t\t\t# Solving the above equation for T_2, we get\n",
+ "def f1(T_2): \n",
+ "\t return Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)))**(2) - (Vel_1)**(2))/2\n",
+ "T_2 =fsolve(f1,100)\n",
+ "\t\t\t# Therefore velocity of air downstream of restriction is given by \n",
+ "Vel_2 = ((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)));\t\t\t#[m/s]\n",
+ "\n",
+ "print \" The velocity of air downstream of restriction is %f m/s\"%(Vel_2);\n",
+ "\n",
+ "delta_T = (T_2 - T_1);\n",
+ "\t\t\t# Since temperature difference (delta_T) is very small, therefore enthalpy change is also very small\n",
+ "\n",
+ "\t\t\t# Entropy change is given by, delta_S = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1), but since T_1 and T_2 are almost equal\n",
+ "delta_S = - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
+ "\n",
+ "print \" The change in entropy is %f kJ/mol-k\"%(delta_S);\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " The velocity of air downstream of restriction is 34.295216 m/s\n",
+ " The change in entropy is 5.762826 kJ/mol-k\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file