diff options
Diffstat (limited to 'Chemical_Engineering_Thermodynamics/ch3_2.ipynb')
-rw-r--r-- | Chemical_Engineering_Thermodynamics/ch3_2.ipynb | 1577 |
1 files changed, 1577 insertions, 0 deletions
diff --git a/Chemical_Engineering_Thermodynamics/ch3_2.ipynb b/Chemical_Engineering_Thermodynamics/ch3_2.ipynb new file mode 100644 index 00000000..dd655676 --- /dev/null +++ b/Chemical_Engineering_Thermodynamics/ch3_2.ipynb @@ -0,0 +1,1577 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3 : The First Law and Its Applications" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.1 Page number - 80 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of temperature\n", + "\n", + "from scipy.optimize import fsolve \n", + "import math \n", + "\n", + "\n", + "# Variables\n", + "V_vessel = 4.*10**(-3);\t\t\t#[m**(-3)] - Volume of vessel\n", + "T = 200+273.15;\t\t\t#[K] - Temperature\n", + "R = 8.314;\t\t\t#[J/mol*K] - Universal fas constant\n", + "P = 1.5*10**(6);\t\t\t#[Pa] - Pressure\n", + "Q = 40.*1000;\t\t\t#[J] - Heat input\n", + "\t\t\t# From steam table at 200 C,Psat=1.55549 MPa,therefore the steam is superheated.\n", + "\n", + "# Calculations and Results\n", + "\t\t\t# (1)\n", + "\t\t\t# Using steam table,at 1.5 MPa and 200 C,\n", + "V_1 = 0.1325;\t\t\t#[m**(3)/mol] - Specific volume\n", + "U_1 = 2598.1;\t\t\t#[kJ/kg] - Specific internal energy\n", + "\t\t\t# From first law under constant pressure,\n", + "\t\t\t# Q - m*P*(V2 - V1) = m*(U2 - U1)\n", + "m = V_vessel/V_1;\t\t\t#[kg] - Mass of system\n", + "\t\t\t# Putting the values,the above equation becomes\n", + "\t\t\t# 45283*(V2 - 0.1325) + 30.1887*(U2 - 2598.1) = 40000\n", + "\t\t\t# From steam table at 700 C LHS is 33917.0 and at 800 C,it is 40925.3.\n", + "\t\t\t# Therefore the final temperature lies between 700 and 800 C\n", + "print \" 1.From steam table the final temperature lies between 700 and 800 C\";\n", + "\n", + "\t\t\t# Alternate method\n", + "\t\t\t# Here we use first law at constant pressure,\n", + "\t\t\t# Q = m*(H_2 - H_1)\n", + "H_1 = 2796.8;\t\t\t#[kJ/kg]\n", + "\t\t\t# Substituting the values,\n", + "\t\t\t# 40 = 0.0301887*(H_2 - 2796.8)\n", + "H_2 = (40/0.0301887) + 2796.9;\t\t\t#[kJ/kg]\n", + "\t\t\t# Threfore,final enthalpy is (H2) 4121.8 [kJ/kg] and pressure is 1.5 [MPa].\n", + "\t\t\t# From steam table at 1.5 [MPa]and 700 C,enthalpy is 3920.3 [kj/kg] and at 1.5 [MPa]and 800 C,enthalpy is 4152.6 [kj/kg]\n", + "print \"\\tAlternate method\";\n", + "print \"\\tBy linear interpolation we get the temperature at which enthlpy is 4121.8 kJ/kg to be 786.74 C\";\n", + "\n", + "\t\t\t# (2)\n", + "\t\t\t# Assuming ideal behaviour.\n", + "n = (P*V_vessel)/(R*T);\t\t\t#[mol] - No of moles\n", + "M = 18.015;\t\t\t# Molecular weight of water\n", + "m_2 = n*M;\t\t\t#[g] - mass of moles\n", + "Cp_1 = 7.7 + 0.04594*10**(-2)*T + 0.2521*10**(-5)*T**(2) - 0.8587*10**(-9)*T**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant presure\n", + "R0 = 1.987;\t\t\t#[cal/mol*K] - universal gas constant\n", + "Cv_1 = Cp_1 - R0;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n", + "Cv_1 = Cv_1*4.184/M;\t\t\t#[J/g*K]\n", + "T1 = T;\n", + "\t\t\t# From 1st law energy balance for constant pressure, we have Q-W= m*(delta_U)\n", + "\t\t\t# Q = P*(V2 - V1)*m = m*Cv*(T2 - T1)\n", + "\t\t\t# Q = P*((T2/T1)-1)*V1*m = m*Cv*(T2-T1)\n", + "\t\t\t# But, (V1*Cv)=initial total volume of system = V_vessel\n", + "\t\t\t# Q-P((T2/T1)-1)*V_vessel = m_2*Cv_0*(T2-T1);\n", + "def f(T2): \n", + "\t return Q-P*((T2/T1)-1)*V_vessel-m_2*Cv_1*(T2-T1)\n", + "T2_1 = fsolve(f,1)\n", + "\t\t\t#The heat capacity should be evaluted at mean temperature\n", + "T_mean = (T1 + T2_1)/2;\n", + "Cp_2 = 7.7 + 0.04594*10**(-2)*T_mean+0.2521*10**(-5)*T_mean**(2) - 0.8587*10**(-9)*T_mean**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant presure\n", + "Cv_2 = Cp_2-R0;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n", + "Cv_2 = Cv_2*4.184/M;\t\t\t#[J/g*K]\n", + "\t\t\t#Now again solving the equation Q=P*((T2/T1)-1)*V1*m = m*Cv*(T2-T1),for Cv=Cv_2\n", + "def f1(T2): \n", + "\t return Q-P*((T2/T1)-1)*V_vessel-m_2*Cv_2*(T2-T1)\n", + "T2_2 = fsolve(f1,1)\n", + "print \" 2).The temperature assuming ideal behaviour is %f K\"%(T2_2);\n", + "\n", + "\t\t\t# Alternate method\n", + "\t\t\t# From 1st law at constant pressure, we have Q = m*Cp(T2-T1)\n", + "T2_3 = Q/(m_2*(Cp_1*4.184/M))+T1;\n", + "\t\t\t#We can calculate the mean temperature as done above\n", + "T_mean1 = (T1 + T2_3)/2;\t\t\t#[J/g*K]\n", + "\t\t\t#The heat capacity should be evaluted at mean temperature\n", + "Cp_3 = 7.7 + 0.04594*10**(-2)*T_mean1 + 0.2521*10**(-5)*T_mean1**(2)-0.8587*10**(-9)*T_mean1**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant presure\n", + "Cp_3 = Cp_3*4.184/M;\t\t\t#[J/g*K]\n", + "\t\t\t# Again solving the equation Q = m*Cp(T2-T1), for Cp=Cp_3\n", + "T2_4 = Q/(m_2*Cp_3) + T1;\n", + "print \"\\tAlternate method\";\n", + "print \"\\tThe temperature assuming ideal behaviour alternate method) is %f K\"%(T2_4);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 1.From steam table the final temperature lies between 700 and 800 C\n", + "\tAlternate method\n", + "\tBy linear interpolation we get the temperature at which enthlpy is 4121.8 kJ/kg to be 786.74 C\n", + " 2).The temperature assuming ideal behaviour is 1141.732355 K\n", + "\tAlternate method\n", + "\tThe temperature assuming ideal behaviour alternate method) is 1141.738180 K\n" + ] + }, + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the \n", + " improvement from the last ten iterations.\n", + " warnings.warn(msg, RuntimeWarning)\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.2 Page number - 83" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of heat required\n", + "\n", + "import math\n", + "\n", + "# Variables\n", + "V_tank = 1;\t\t\t#[m**(3)] - Volume of the tank\n", + "V_liq = 0.05;\t\t\t#[m**(3)] - Volume of saturated water\n", + "V_vap = 0.95;\t\t\t#[m**(3)] - Volume of saturated vapour\n", + "P = 1;\t\t\t#[bar] - Pressure\n", + "V_liq_sat = 0.001043;\t\t\t#[m**(3)/kg] - Specific volume of saturated water\n", + "V_vap_sat = 1.6940;\t\t\t#[m**(3)/kg] - Specific volume of saturated vapour\n", + "U_liq_sat = 417.4;\t\t\t#[kJ/kg] - Saturated liquid internal energy\n", + "U_vap_sat = 2506.1;\t\t\t#[kJ/kg] - Saturated vapour internal energy\n", + "\n", + "# Calculations\n", + "m = (V_liq/V_liq_sat) + (V_vap/V_vap_sat);\t\t\t#[kg] - Total mass of water\n", + "U_1 = (V_liq/V_liq_sat)*U_liq_sat + (V_vap/V_vap_sat)*U_vap_sat;\t\t\t#[kJ] - Total internal energy\n", + "\n", + "\t\t\t# At final state,which is saturated vapour\n", + "V = V_tank/m;\t\t\t#[m**(3)/kg] - Molar volume\n", + "\t\t\t# From saturated steam table at 8 MPa,as reported in the book V_vap = 0.02352[m**(3)/kg] and U_vap = 2569.8[kJ/kg]\n", + "\t\t\t# At 9 MPa, Vv = 0.02048[m**(3)/kg] and Uv = 2557.8[kJ/kg]\n", + "\t\t\t# Therefore final state pressure of the system (from interpolation) is 8.954 [MPa] and internal energy of saturated vapour is 2558.35 [kJ/kg]\n", + "U_2 = m*2558.35;\t\t\t#[kJ] - Final total internal energy\n", + "del_Ut = U_2 - U_1;\t\t\t#[kJ] \n", + "\t\t\t#we have, del_U = Q - W\n", + "\t\t\t#Here work done is zero because volume is rigid.\n", + "Q = del_Ut;\t\t\t#[kJ]\n", + "Q = del_Ut*10**(-3);\t\t\t#[MJ]\n", + "\n", + "# Results\n", + "print \" The amount of heat to be added is %f MJ\"%( Q);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The amount of heat to be added is 102.663530 MJ\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.3 Page number - 83" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of temperature internal energy and enthalpy\n", + "\n", + "# Variables\n", + "M_vap_sat = 0.22;\t\t\t#[kg] - mass of saturated vapour\n", + "M_liq_sat = 1.78;\t\t\t#[kg] - mass of saturated liquid\n", + "P = 700;\t\t\t#[kPa] - Pressure\n", + "\n", + "#At P=700 kPa,the systen is saturated,from steam table as reported in the book\n", + "T_sat1 = 164.97;\t\t\t#[C]\n", + "V_liq_1 = 0.001108;\t\t\t#[m**(3)/kg] \n", + "V_vap_1 = 0.2729;\t\t\t#[m**(3)/kg]\n", + "\n", + "# Calculations and Results\n", + "Vt_1 = V_liq_1*M_liq_sat + V_vap_1*M_vap_sat;\t\t\t#[m**(3)] - total volume\n", + "\n", + "\t\t\t#At final state,P = 8 MPa\n", + "T_sat2 = 295.06;\t\t\t#[C]\n", + "V_liq_2 = 0.001384;\t\t\t#[m**(3)/kg] \n", + "V_vap_2=0.02352;\t\t\t#[m**(3)/kg]\n", + "Vt_2 = Vt_1;\t\t\t# Since the volume is rigid.\n", + "\t\t\t# Since the volume of 2 kg of vapour is 0.062 [m**(3)]\n", + "V = Vt_2/2;\t\t\t#[m**(3)/kg] - specific volume\n", + "\n", + "\t\t\t# (a)\n", + "\t\t\t# From steam table at 8 [MPa]and 350 [C],V=0.02995[m**(3)/kg]; \n", + "V_1 = 0.02995;\t\t\t#[m**(3)/kg]\n", + "\t\t\t# And at 8 [MPa]and 400 [C],\n", + "V_2 = 0.03432;\t\t\t#[m**(3)/kg]\n", + "\t\t\t# By interpolation,\n", + "T = ((V-V_1)/(V_2 - V_1))*(400-350)+350;\n", + "print \" a).The final temperature is %f c\"%(T);\n", + "\n", + "\t\t\t# (b)\n", + "\t\t\t# From steam table \n", + "U_1 = 2747.7;\t\t\t#[kJ/kg]\n", + "H_1 = 2987.3;\t\t\t#[kJ/kg]\n", + "\t\t\t# And at 8 [MPa]and 400 C,\n", + "U_2 = 2863.8;\t\t\t#[kJ/kg]\n", + "H_2 = 3138.3;\t\t\t#[kJ/kg]\n", + "\t\t\t# Therefore at T = 362.01 C\n", + "U = U_1+((U_2 - U_1)/(400 - 350))*(T - 350);\n", + "print \" b).The internal energy is %f kJ/kg\"%(U);\n", + "\n", + "\t\t\t#(c)\n", + "H = H_1+((H_2 - H_1)/(400 - 350))*(T - 350);\n", + "print \" b).The enthalpy is %f kJ/kg\"%(H);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " a).The final temperature is 362.072311 c\n", + " b).The internal energy is 2775.731907 kJ/kg\n", + " b).The enthalpy is 3023.758380 kJ/kg\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.4 Page number - 85" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of work done\n", + "\n", + "from scipy.optimize import fsolve \n", + "import math \n", + "from scipy.integrate import quad \n", + "\n", + "# Variables\n", + "T = 300;\t\t\t#[K] - Temperature\n", + "P1 = 1;\t\t\t#[bar] - Initial pressure\n", + "P1 = P1*10**(5);\t\t\t#[N/m**(2)]\n", + "P2 = 8;\t\t\t#[bar] - Final pressure\n", + "P2 = P2*10**(5);\t\t\t#[N/m**(2)]\n", + "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n", + "Tc = 126.2;\t\t\t#[K] - Critical temperature\n", + "Pc = 34;\t\t\t#[bar] - Critical pressure\n", + "Pc = Pc*10**(5);\t\t\t#[N/m**(2)]\n", + "w = 0.038;\t\t\t# Acentric factor\n", + "\n", + "# Calculations and Results\n", + "\t\t\t# w = integral(Pdv)\n", + "\t\t\t# Z = 1 + (B/V)\n", + "\t\t\t# (P*V)/(R*T) = 1 + (B/V)\n", + "\t\t\t# P = (R*T)/V + (B*R*T)/V**(2)\n", + "\n", + "def f29(V): \n", + "\t return (R*T/V) + (B*R*T)/V**(2)\n", + "\n", + "\t\t\t# w = quad(f29,V1,V2)[0]\n", + "\n", + "\t\t\t# Under isothermal conditions,\n", + "\t\t\t# w = R*T*math.log(V2/V1) - B*R*T*((1/V2) - (1/V1));\n", + "\t\t\t# The second virial coefficient at state 1 is same as at state 2,as the temperature is the same i.e, T=300 [K]\n", + "Tr = T/Tc;\n", + "B_0 = 0.083 - (0.422/(Tr)**(1.6));\n", + "B_1 = 0.139 - (0.172/(Tr)**(4.2));\n", + "B = ((B_0+(w*B_1))*(R*Tc))/Pc;\t\t\t#[m**(3)/mol]\n", + "\n", + "\t\t\t# Now we have to calculate molar volume i.e V1 and V2 at given conditions\n", + "\t\t\t# At state 1,\n", + "def f(V): \n", + "\t return V**(2)-(R*T/P1)*V-(B*R*T)/P1\n", + "V_1 = fsolve(f,-1)\n", + "V_2 = fsolve(f,1)\n", + "\t\t\t# We will take root near to (R*T)/P, i.e V_2\n", + "V1 = V_2;\n", + "\n", + "\t\t\t# At state 2,\n", + "def f1(V): \n", + "\t return V**(2)-(R*T/P2)*V-(B*R*T)/P2\n", + "V_3=fsolve(f1,-1)\n", + "V_4=fsolve(f1,1)\n", + "V2 = V_4;\n", + "\t\t\t# The work done is thus,\n", + "w = R*T*math.log(V2/V1) - B*R*T*((1/V2) - (1/V1));\t\t\t#[J]\n", + "w = w*10**(-3);\t\t\t#[kJ]\n", + "\n", + "print \" The work done is %f kJ/mol\"%(w);\n", + "print \" Negative sign indicates that work is done on the gas\";\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The work done is -5.186547 kJ/mol\n", + " Negative sign indicates that work is done on the gas\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.5 Page number - 86" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of work done\n", + "\n", + "# Variables\n", + "\n", + "T = 300;\t\t\t#[K] - Temperature\n", + "P1 = 1;\t\t\t#[bar] - Initial pressure\n", + "P1 = P1*10**(5);\t\t\t#[N/m**(2)]\n", + "P2 = 8;\t\t\t#[bar] - Final pressure\n", + "P2 = P2*10**(5);\t\t\t#[N/m**(2)]\n", + "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n", + "y1 = 0.21;\t\t\t# Mole fraction of component 1 (oxygen)\n", + "y2 = 0.79;\t\t\t# Mole fraction of component 1 (nitroen)\n", + "\n", + "# For component 1 (Oxygen)\n", + "Tc_1 = 154.6;\t\t\t#[K]\n", + "Pc_1 = 50.43*10**(5);\t\t\t#[N/m**(2)]\n", + "Vc_1 = 73.4;\t\t\t#[cm**(3)/mol]\n", + "Zc_1 = 0.288;\n", + "w_1 = 0.022;\n", + "\n", + "\t\t\t#For component 2 (Nitrogen)\n", + "Tc_2 = 126.2;\t\t\t#[K]\n", + "Pc_2 = 34*10**(5);\t\t\t#[N/m**(2)]\n", + "Vc_2 = 89.2;\t\t\t#[cm**(3)/mol]\n", + "Zc_2 = 0.289;\n", + "w_2 = 0.038;\n", + "\n", + "# Calculations\n", + "\t\t\t#For component 1\n", + "Tr_1 = T/Tc_1;\t\t\t#Reduced temperature\n", + "\t\t\t#At reduced temperature\n", + "B1_0 = 0.083 - (0.422/(Tr_1)**(1.6));\n", + "B1_1 = 0.139 - (0.172/(Tr_1)**(4.2));\n", + "\t\t\t# We know,(B*Pc)/(R*Tc) = B_0+(w*B_1)\n", + "B_11 = ((B1_0+(w_1*B1_1))*(R*Tc_1))/Pc_1;\t\t\t#[m**(3)/mol]\n", + "\n", + "\t\t\t# Similarly for component 2\n", + "Tr_2 = T/Tc_2;\t\t\t#Reduced temperature\n", + "\t\t\t# At reduced temperature Tr_2,\n", + "B2_0 = 0.083 - (0.422/(Tr_2)**(1.6));\n", + "B2_1 = 0.139 - (0.172/(Tr_2)**(4.2));\n", + "B_22 = ((B2_0 + (w_2*B2_1))*(R*Tc_2))/Pc_2;\t\t\t#[m**(3)/mol]\n", + "\n", + "\t\t\t#For cross coeffcient\n", + "Tc_12 = (Tc_1*Tc_2)**(1/2);\t\t\t#[K]\n", + "w_12 = (w_1 + w_2)/2;\n", + "Zc_12 = (Zc_1+Zc_2)/2;\n", + "Vc_12 = (((Vc_1)**(1/3)+(Vc_2)**(1/3))/2)**(3);\t\t\t#[cm**(3)/mol]\n", + "Vc_12 = Vc_12*10**(-6);\t\t\t#[m**(3)/mol]\n", + "Pc_12 = (Zc_12*R*Tc_12)/Vc_12;\t\t\t#[N/m**(2)]\n", + "\n", + "\t\t\t# Now we have,(B_12*Pc_12)/(R*Tc_12) = B_0 + (w_12*B_1)\n", + "\t\t\t# where B_0 and B_1 are to be evaluated at Tr_12\n", + "Tr_12 = T/Tc_12;\n", + "\t\t\t# At reduced temperature Tr_12\n", + "B_0 = 0.083 - (0.422/(Tr_12)**(1.6));\n", + "B_1 = 0.139 - (0.172/(Tr_12)**(4.2));\n", + "B_12 = ((B_0+(w_12*B_1))*R*Tc_12)/Pc_12;\t\t\t#[m**(3)/mol]\n", + "\n", + "\t\t\t# For the mixture\n", + "B = y1**(2)*B_11 + 2*y1*y2*B_12+y2**(2)*B_22;\t\t\t#[m**(3)/mol]\n", + "\t\t\t# Now we have to calculate molar volume i.eV1 and V2 at given conditions\n", + "\n", + "\t\t\t# At state 1,\n", + "def f(V): \n", + "\t return V**(2)-(R*T/P1)*V-(B*R*T)/P1\n", + "V_1=fsolve(f,-1)\n", + "V_2=fsolve(f,1)\n", + "\t\t\t# We will take root near to (R*T)/P, i.e V_2\n", + "V1 = V_2;\t\t\t#[m**(3)/mol]\n", + "\n", + "\t\t\t# At state 2,\n", + "def f1(V): \n", + "\t return V**(2)-(R*T/P2)*V-(B*R*T)/P2\n", + "V_3=fsolve(f1,-1)\n", + "V_4=fsolve(f1,1)\n", + "V2 = V_4;\t\t\t#[m**(3)/mol]\n", + "\n", + "\t\t\t# Work done per mole of air is given by, w=integral(Pdv)\n", + "\t\t\t# Z = 1 + (B/V)\n", + "\t\t\t# (P*V)/(R*T) = 1 +( B/V)\n", + "\t\t\t# P = (R*T)/V+(B*R*T)/V**(2)\n", + "\n", + "def f43(V): \n", + "\t return (R*T/V)+(B*R*T)/V**(2)\n", + "\n", + "\t\t\t# w = quad(f43,V1,V2)[0]\n", + "\n", + "\t\t\t# Under isothermal conditions,\n", + "w = R*T*math.log(V2/V1)-B*R*T*((1/V2)-(1/V1));\n", + "w = w*10**(-3);\t\t\t#[kJ/mol]\n", + "\n", + "# Results\n", + "print \" The work done is %f kJ/mol\"%(w);\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The work done is -5.186545 kJ/mol\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.6 Page number - 88" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of work done\n", + "\n", + "# Variables\n", + "T = 125+273.15;\t\t\t#[K] - Temperature\n", + "P1 = 1;\t\t\t#[bar] - Initial pressure\n", + "P1 = P1*10**(5);\t\t\t#[N/m**(2)]\n", + "P2 = 60;\t\t\t#[bar] - Final pressure\n", + "P2 = P2*10**(5);\t\t\t#[N/m**(2)]\n", + "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n", + "Tc = 416.3;\t\t\t#[K] - Critical temperature\n", + "Pc = 66.80*10**(5);\t\t\t#[N/m**(2)] - Critical pressure\n", + "\n", + "\t\t\t# (1)\n", + "\t\t\t# Virial equation of state, Z = 1 + (B/V)+(C/V**(2))\n", + "\t\t\t# (P*V)/(R*T) = 1 + (B/V)+(C/V**(2))\n", + "\t\t\t# P = (R*T)/V+(B*R*T)/V**(2)+(C*R*T)/V**(3)\n", + "\t\t\t# w = integral(PdV)=R*T*math.log(V2/V1)-(B*R*T)*(1/V2-1/V1)-(C*R*T/2)*(1/V2**(2)-1/V1**(2))\n", + "\n", + "B = -207.5;\t\t\t#[cm**(3)/mol] - Second virial coefficient\n", + "B = -207.5*10**(-6);\t\t\t#[m**(3)/mol]\n", + "C = 18200;\t\t\t#[cm**(6)/mol**(2)] - Third virial coefficient\n", + "C = 18200*10**(-12);\t\t\t#[m**(6)/mol**(2)]\n", + "\n", + "# Calculations and Results\n", + "\t\t\t# We need to calculate molar volume at state 1 and 2,\n", + "\t\t\t# At state 1,P = P1,\n", + "\t\t\t# V**(3)-(R*T/P)*V**(2)-(B*R*T/P)*V-(C*R*T/P)=0\n", + "\t\t\t# Solving the cubic equation\n", + "def f1(V): \n", + "\t return V**(3)-(R*T/P1)*V**(2)-(B*R*T/P1)*V-(C*R*T/P1)\n", + "V_1=fsolve(f1,-1)\n", + "V_2=fsolve(f1,0)\n", + "V_3=fsolve(f1,10)\n", + "\t\t\t# The cubic equation has only 1 real root,other two roots are imaginary.\n", + "V1 = V_3;\n", + "\n", + "\t\t\t# Similarly at state 2,P=P2\n", + "\t\t\t# V**(3) - (R*T/P)*V**(2) - (B*R*T/P)*V - (C*R*T/P) = 0\n", + "\t\t\t# Solving the cubic equation\n", + "def f2(V): \n", + "\t return V**(3)-(R*T/P2)*V**(2)-(B*R*T/P2)*V-(C*R*T/P2)\n", + "V_4=fsolve(f2,-1)\n", + "V_5=fsolve(f2,0)\n", + "V_6=fsolve(f2,1)\n", + "V2 = V_6;\n", + "\t\t\t# Finally work done is given by,\n", + "w1 = R*T*math.log(V2/V1)-(B*R*T)*(1/V2-1/V1)-(C*R*T/2)*(1/V2**(2)-1/V1**(2));\t\t\t#[J/mol]\n", + "w1 = w1*10**(-3);\t\t\t#[kJ/mol]\n", + "print \" 1).The work done using given virial equation of state is %f kJ/mol\"%(w1);\n", + "\n", + "\t\t\t# (2)\n", + "\t\t\t# Virial equation of state, Z = 1+(B*P)/(R*T)+((C-B**(2))/(R*T)**(2))*P**(2)\n", + "\t\t\t# (P*V)/(R*T)= 1+(B*P)/(R*T)+((C-B**(2))/(R*T)**(2))*P**(2)\n", + "\t\t\t# V = (R*T)/P+B+((C-B**(2))/(R*T))*P\n", + "\t\t\t# Differentiating both sides by P and integrating we get,\n", + "\t\t\t# w = integral(PdV)=-(R*T)*math.log(P2/P1)+((C-B**(2))/(2*R*T))*(P2**(2)-P1**(2))\n", + "w2 = -(R*T)*math.log(P2/P1) + ((C-B**(2))/(2*R*T))*(P2**(2)-P1**(2));\t\t\t#[J/mol]\n", + "w2 = w2*10**(-3);\t\t\t#[kJ/mol]\n", + "print \" 2).The work done using given virial equation of state is %f kJ/mol\"%(w2);\n", + "\n", + "\t\t\t# (3)\n", + "\t\t\t# Van der Walls equation of state is given by,\n", + "a = (27*(R**(2))*(Tc**(2)))/(64*Pc);\t\t\t#[Pa*m**(6)/mol**(2)]\n", + "b = (R*Tc)/(8*Pc);\t\t\t#[m**(3)/mol]\n", + "\t\t\t# P = ((R*T)/(V-b))-a/(V**(2));\t\t\t#[N/m**(2)]\n", + "\t\t\t# w = integral(PdV)=R*T*math.log((V2-b)/(V1-a))+a*(1/V2-1/V1)\n", + "\t\t\t# The cubic form of van der Walls equation of state is given by,\n", + "\t\t\t# V**(3) - (b+(R*T)/P)*V**(2) + (a/P)*V - (a*b)/P = 0\n", + "\t\t\t# Solving the cubic equation for P=P1\n", + "def f3(V): \n", + "\t return V**(3)-(b+(R*T)/P1)*V**(2)+(a/P1)*V-(a*b)/P1\n", + "V2_1=fsolve(f3,1)\n", + "V2_2=fsolve(f3,10)\n", + "V2_3=fsolve(f3,100)\n", + "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V2_3).\n", + "\n", + "\t\t\t# Similarly at state 2,for P=P2,\n", + "def f4(V): \n", + "\t return V**(3)-(b+(R*T)/P2)*V**(2)+(a/P2)*V-(a*b)/P2\n", + "V2_4=fsolve(f4,1)\n", + "V2_5=fsolve(f4,10)\n", + "V2_6=fsolve(f4,100)\n", + "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V2_6).\n", + "\t\t\t# Finally work done is given by\n", + "w3 = R*T*math.log((V2_6-b)/(V2_3-b))+a*(1/V2_6-1/V2_3);\t\t\t#[J/mol]\n", + "w3 = w3*10**(-3);\t\t\t#[kJ/mol]\n", + "print \" 3).The work done using van der Walls equation of state is %f kJ/mol\"%(w3);\n", + "\n", + "\t\t\t# (4)\n", + "\t\t\t# Redlich Kwong equation of state,\n", + "a_1 = (0.42748*(R**(2))*(Tc**(2.5)))/Pc;\t\t\t#[Pa*m**(6)*K**(1/2)/mol]\n", + "b_1 = (0.08664*R*Tc)/Pc;\t\t\t#[m**(3)/mol]\n", + "\t\t\t# P = ((R*T)/(V-b_1))-(a_1/(T**(1/2)*V*(V+b_1)));\t\t\t#[N/m**(2)]\n", + "\t\t\t# Work done is given by\n", + "\n", + "def f4(V): \n", + "\t return (V2-b)/(V1-b)-a/T**(1./2)*integrate(1/V*(V+b))\n", + "\n", + "\t\t\t# w = R*T*math.log((V2-b)/(V1-b))-a/T**(1/2)* quad(f4,V1,V2)[0]\n", + "\n", + "\t\t\t# Using the factorization 1/(V*(V+b))=(1/b)*((1/V)-(1/V+b)),we get\n", + "\t\t\t# w = R*T*math.log((V2-b)/(V1-b))-(a/(b*T**(1/2)))*(math.log(V2/V1)-math.log((V2+b)/(V1+b))\n", + "\t\t\t# Now we have calculate V1 and V2,\n", + "\t\t\t# The cubic form of Redlich Kwong equation of state is given by,\n", + "\t\t\t# V**(3) - ((R*T)/P)*V**(2) - ((b_1**(2)) + ((b_1*R*T)/P) - (a/(T**(1/2)*P))*V - (a*b)/(T**(1/2)*P) = 0\n", + "\t\t\t# Solving the cubic equation at state 1,\n", + "def f5(V): \n", + "\t return V**(3)-((R*T)/P1)*V**(2)-((b_1**(2))+((b_1*R*T)/P1)-(a_1/(T**(1./2)*P1)))*V-(a_1*b_1)/(T**(1./2)*P1)\n", + "V3_1=fsolve(f5,1)\n", + "V3_2=fsolve(f5,10)\n", + "V3_3=fsolve(f5,100)\n", + "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V3_3).\n", + "\n", + "\t\t\t# Similarly at state 2,for P = P2,\n", + "def f6(V): \n", + "\t return V**(3)-((R*T)/P2)*V**(2)-((b_1**(2))+((b_1*R*T)/P2)-(a_1/(T**(1./2)*P2)))*V-(a_1*b_1)/(T**(1./2)*P2)\n", + "V3_4=fsolve(f6,1)\n", + "V3_5=fsolve(f6,10)\n", + "V3_6=fsolve(f6,100)\n", + "\t\t\t# The above equation has 1 real and 2 imaginary roots. We consider only real root (V3_6).\n", + "\t\t\t# Finally work done is given by\n", + "w4 = R*T*math.log((V3_6-b_1)/(V3_3-b_1))-(a_1/(b_1*T**(1./2)))*(math.log(V3_6/V3_3)-math.log((V3_6+b_1)/(V3_3+b_1)));\t\t\t#[J/mol]\n", + "w4 = w4*10**(-3);\t\t\t#[kJ/mol]\n", + "print \" 3).The work done using Redlich Kwong equation of state is %f kJ/mol\"%(w4);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 1).The work done using given virial equation of state is -13.848149 kJ/mol\n", + " 2).The work done using given virial equation of state is -13.688301 kJ/mol\n", + " 3).The work done using van der Walls equation of state is -14.802420 kJ/mol\n", + " 3).The work done using Redlich Kwong equation of state is -14.704965 kJ/mol\n" + ] + }, + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the \n", + " improvement from the last five Jacobian evaluations.\n", + " warnings.warn(msg, RuntimeWarning)\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.8 Page number - 93" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of work done\n", + "\n", + "# Variables\n", + "T = 20 + 273.15;\t\t\t#[K] - Temperature\n", + "P_1 = 140.;\t\t\t#[kPa] - Initial pressure\n", + "P_1 = P_1*10.**(3);\t\t\t#[Pa]\n", + "P_2 = 560.;\t\t\t#[kPa] - Final pressure\n", + "P_2 = P_2*10.**(3);\t\t\t#[Pa]\n", + "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n", + "\n", + "# Calculations\n", + "\t\t\t# Cp_0 = 1.648+4.124*10**(-2)*T - 1.53*10**(-5)*T**(2) + 1.74*10**(-9)*T**(3)\n", + "\t\t\t# Using adiabatic compression, P*V**(Y)=constant. For ideal gases\n", + "\t\t\t# P*(R*T/P)**(Y) = constant\n", + "\t\t\t# P**(1-Y)*T**(Y) = constant or,P1**(1-Y)*T1**(Y)=P2**(1-Y)*T2**(Y)\n", + "\t\t\t# Now,at state 1, i.e at T=20[C]\n", + "Cp_1 = 1.648+4.124*10**(-2)*T-1.53*10**(-5)*T**(2)+1.74*10**(-9)*T**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant pressure\n", + "Cv_1 = Cp_1 - R;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n", + "Y1 = Cp_1/Cv_1;\t\t\t# Ratio of heat capacities\n", + "\n", + "\t\t\t# Now calculatung the temperature at state 2 (T2)\n", + "\t\t\t# (T2/T1)=(P1/P2)**((1-Y1)/Y1)\n", + "T_1 = T;\n", + "T_2 = ((P_1/P_2)**((1-Y1)/Y1))*T_1;\t\t\t#[K]\n", + "\n", + "\t\t\t# Now calculating the mean temperature\n", + "T_mean = (T_1 + T_2)/2;\t\t\t#[K]\n", + "\t\t\t# At mean temperature\n", + "Cp_2 = 1.648+4.124*10**(-2)*T_mean - 1.53*10**(-5)*T_mean**(2) + 1.74*10**(-9)*T_mean**(3);\t\t\t#[cal/mol*K] - Heat capacity at constant pressure\n", + "Cv_2 = Cp_2 - R;\t\t\t#[cal/mol*K] - Heat capacity at constant volume\n", + "Y2 = Cp_2/Cv_2;\n", + "\n", + "\t\t\t# Calculating exit temperature\n", + "\t\t\t# Again using the realation,(T2/T1)=(P1/P2)**((1-Y1)/Y1)\n", + "T_exit = ((P_1/P_2)**((1-Y2)/Y2))*T_1;\t\t\t#[K]\n", + "\t\t\t# Since value of mean temperature has not changed much the molar heat capacity ratio can be assumed to be same.Therefore\n", + "\t\t\t# w = -delta(U)=Cv_0*(T2-T1)\n", + "w = Cv_2*(T_1 - T_exit);\t\t\t#[cal/mol]\n", + "w = w*4.184;\t\t\t#[J/mol]\n", + "\n", + "# Results\n", + "print \" The work done for adiabatic compression is %f J/mol\"%(w);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The work done for adiabatic compression is -3198.427072 J/mol\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.9 Page number - 93" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of final temperature\n", + "\n", + "# Variables\n", + "m_ice = 1000;\t\t\t#[g] - Mass of ice\n", + "m_water = 1000;\t\t\t#[g] - Mass of water\n", + "T_ice = 273.15;\t\t\t#[K] - Temperature of ice\n", + "T_water = 373.15;\t\t\t#[K] - Temperature of water\n", + "L = 79.71;\t\t\t#[cal/g] - Latent heat of melting of ice.\n", + "\n", + "# Calculations and Results\n", + "\t\t\t#(1)\n", + "Cp_1 = 1;\t\t\t#[cal/g-K] - Heat capacity at constant pressure\n", + "\t\t\t# Let the final temperature be T\n", + "\t\t\t# We assume that all of the ice melts.Energy taken up by ice is\n", + "\t\t\t# E1 = L*m_ice + m_ice*Cp_1*(T - T_ice)\n", + "\t\t\t# Energy given by hot water is,\n", + "\t\t\t# E2 = m_water*Cp_1*(T_water - T)\n", + "\t\t\t# No heat exchange with surrounding.Solving for T\n", + "T_1 = (m_ice*Cp_1*T_ice + m_water*Cp_1*T_water - L*m_ice)/(m_ice*Cp_1 + m_water*Cp_1);\t\t\t#[K]\n", + "T_1 = T_1 - 273.15;\t\t\t#[C]\n", + "\n", + "print \" 1).The final temperature taking Cp_water = 1 cal/g-K) is %f C\"%(T_1);\n", + "\t\t\t#Since the final temperature is greater than 273.15 K,so our assumption that all of ice melts is correct\n", + "\n", + "\t\t\t# (2)\n", + "\t\t\t# Cp_2 = 1.00874-0.7067*10**(-3)*T+15.93*10**(-6)*T**(2)-83.8*10**(-9)*T**(3);\n", + "\n", + "def f15(T): \n", + "\t return Cp_2\n", + "\n", + "\t\t\t# From energy balance,we get L*m_ice + m_ice* quad(f15,0,T) + m_water*integrate(Cp_2)[0]\n", + "\n", + "\t\t\t# On putting the values and then simplifying we get\n", + "\t\t\t# 2.01748*T - 0.0007067*T**(2) + 1.062*10**(-5)*T**(3) - 4.19*10**(-8)*T**(4) - 20.8455 = 0\n", + "\t\t\t# Solving the above equation we get\n", + "def f1(T): \n", + "\t return 2.01748*T - 0.0007067*T**(2) + 1.062*10**(-5)*T**(3) - 4.19*10**(-8)*T**(4) - 20.8455\n", + "T_0 = fsolve(f1,1)\n", + "print \" 2).The final temperature using specific heat capacity equation is %f C\"%(T_0);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 1).The final temperature taking Cp_water = 1 cal/g-K) is 10.145000 C\n", + " 2).The final temperature using specific heat capacity equation is 10.364452 C\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.11 Page number - 97" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of final pressure\n", + "\n", + "# Variables\n", + "n = 1.5;\t\t\t# - ratio of heat capacities\n", + "T_1 = 500.;\t\t\t#[K] - Initial temperature\n", + "T_2 = 1000.;\t\t\t#[K] - Final temperature\n", + "P_1 = 1.;\t\t\t#[bar] - Initial pressure\n", + "P_1 = P_1*10.**(5);\t\t\t#[Pa]\n", + "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n", + "\n", + "# Calculations and Results\n", + "\t\t\t# The compression path is given by, P*V**(1.5) = constant\n", + "\t\t\t# P*(R*T/P)**(1.5) = constant\n", + "\t\t\t# P1**(-0.5)*T1**(1.5) = P2**(-0.5)*T2**(1.5)\n", + "P_2 = P_1*(T_1/T_2)**(-3);\t\t\t#[Pa]\n", + "P_2_final = P_2*10**(-5);\t\t\t#[bar] - Final pressure in bar\n", + "print \" The final pressure is %f bar\"%(P_2_final);\n", + "\n", + "\t\t\t# From first law q - w = delta(U). \n", + "\t\t\t# First w and delta(U) are calculated and thereafter heat exchange is determined.\n", + "V_1 = R*T_1/P_1;\t\t\t#[m**(3)/mol] - Initial volume\n", + "V_2 = R*T_2/P_2;\t\t\t#[m**(3)/mol] - Final volume\n", + "w = ((P_1*V_1)/(n - 1))*(1 - (P_2/P_1)**(1 - 1/n));\t\t\t#[J/mol] - work done\n", + "\n", + "\t\t\t# Mean temperature is given by,\n", + "T_mean = (T_1 + T_2)/2;\t\t\t#[K]\n", + "\n", + "\t\t\t#Now, heat capacity at T_mean is given by,\n", + "Cp_0 = R*(3.3 + 0.63*10**(-3)*T_mean);\t\t\t#[J/mol*K]\n", + "Cv_0 = Cp_0 - R;\t\t\t#[J/mol*K]\n", + "\t\t\t#Therefore delta(U) is given by\n", + "del_U = Cv_0*(T_2 - T_1);\t\t\t#[J/mol] - Change in internal energy\n", + "q = w + del_U;\t\t\t#[J/mol] - heat change\n", + "print \" The amount of heat supplied to the system is %f J/mol\"%(q);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The final pressure is 8.000000 bar\n", + " The amount of heat supplied to the system is 3211.282500 J/mol\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.12 Page number - 99" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of slope and work done\n", + "\n", + "# Variables\n", + "P_1 = 150*10**(3);\t\t\t#[Pa] - Initial pressure\n", + "V_1 = 0.001;\t\t\t#[m**(3)] - Initial volume\n", + "P_2 = 1000*10**(3);\t\t\t#[Pa] - Final pressure\n", + "V_2 = 0.003;\t\t\t#[m**(3)] - Final volume\n", + "\n", + "# Calculations and Results\n", + "\t\t\t# At x = 0, Vt(total volume) = 0.001 m**(3), therefore x = (V_t - V_1)/A; where A is area of cross section and x is length\n", + "\t\t\t# Force exerted b sprig is given by, F = Ps*A = k*x = k*(V_t - V_1)/A\n", + "\t\t\t# Ps = (k/A**(2))*(V_t - V_1)\n", + "\t\t\t# Total pressure = Initial pressre + Pressre due to spring\n", + "\t\t\t# P = P_1 + (k/A**(2))*(V_t - V_1)\n", + "\t\t\t# Let (k/A**(2)) = t (say)\n", + "\t\t\t# At state 2, i.e at P2 and V_t = V_2.\n", + "def f(t): \n", + "\t return P_2-P_1 - t*(V_2-V_1)\n", + "t = fsolve(f,1000)\n", + "\t\t\t# Therefore,pressure is related to total volume as P = P_1-t*(V_t - V_1)\n", + "\n", + "\t\t\t# (a)\n", + "\t\t\t#slope = (k/A**(2))\n", + "print \" a).The slope of the line on P-Vt diagram is %e N/m**5)\"%(t);\n", + "\n", + "\t\t\t# (b)\n", + "\t\t\t# Work done by the gas is given by w=integral(PdVt)\n", + "\n", + "def f30(V_t): \n", + "\t return P_1+t*(V_t-V_1)\n", + "\n", + "w = quad(f30,V_1,V_2)[0]\n", + "\n", + "w = w*10**(-3);\t\t\t#[kJ]\n", + "print \" b).The work done by gas is %f kJ\"%(w);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " a).The slope of the line on P-Vt diagram is 4.250000e+08 N/m**5)\n", + " b).The work done by gas is 1.150000 kJ\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.13 Page number - 99" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of work done and final temperature\n", + "\n", + "# Variables\n", + "V = 36;\t\t\t#[L] - Vol of gas on each side\n", + "P_1 = 1;\t\t\t#[atm] - pressure on left side of the piston\n", + "P_1 = P_1*101325;\t\t\t#[Pa]\n", + "T = 273.15;\t\t\t#[K]\n", + "P_2 = 3.375;\t\t\t#[atm] - Pressure on right side of the piston\n", + "P_2 = P_2*101325;\t\t\t#[Pa]\n", + "Y = 1.44;\t\t\t# Ratio of heat capacities\n", + "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constnt\n", + "\n", + "# Calculations and Results\n", + "\t\t\t# (a)\n", + "\t\t\t# For total system, del(U_total) = Q. \n", + "\t\t\t# Onto gas on right hand side no heat is supplied,as the piston is non conducting. Therefore,for gas on the right hand side, del(U) = -W.\n", + "\t\t\t# As heat is slowly supplied to the left hand side,expansion on right hand side is slow and process is adiabatic.\n", + "\t\t\t# For gas on right hand side, PV**(Y) = constant.\n", + "\t\t\t# T_2/T_1 = (P_2/P_1)**((Y - 1)/Y)\n", + "T_right = T*(P_2/P_1)**((Y - 1)/Y);\t\t\t#[K]\n", + "\n", + "Cv_0 = R/(Y-1);\t\t\t#[J/mol*K] - Heat capacity at constant volume.\n", + "\t\t\t# Now work done on the gas on right hand side is given by\n", + "\t\t\t# W = (P_1*V_1 - P_2*V_2)/(Y - 1) = R*(T_2 - T_1)/(Y - 1) = Cv_0*(T_1 - T_2)\n", + "W_left = Cv_0*(T - T_right);\t\t\t#[J/mol]\n", + "\t\t\t# Negative sign for the work done on LHS gas implies work is done on the gas\n", + "\n", + "\t\t\t# For right hand side of the gas\n", + "\t\t\t# P*Vt = n*R*T\n", + "n = P_1*(V*10**(-3))/(R*T);\t\t\t# number of moles\n", + "W_right = (-W_left)*n;\t\t\t#[J] - We used negative sign for 'W_left' because it is negative in magnitude.\n", + "W_right = W_right/1000;\t\t\t#[kJ]\n", + "print \" a).Total work done on gas on the right hand side is %f kJ\"%(W_right);\n", + "\n", + "\t\t\t#(b)\n", + "print \" b).The final temperature of the gas on right side is %f K\"%(T_right);\n", + "\n", + "\t\t\t# (c)\n", + "\t\t\t# Pressure is same on both sides as piston is frictionless.\n", + "\t\t\t# The number of moles on both sides are also same as they have same temperature,presure and volume.\n", + "\t\t\t# We have (P_left*V_left)/T_left = (P_right*V_right)/T_right.\n", + "\t\t\t# Since P_left = P_right, (V_left/T_left) = (V_right/T-right) and also P*V**(Y) = constant.\n", + "V_right = V*(P_1/P_2)**(1/Y);\t\t\t#[L] - The total volume on right side \n", + "\n", + "\t\t\t# The total volume on right side can also be calculated using P2*V2 = n*R*T2.\n", + "\t\t\t# Since total volume = 72 [L], therefore volume of left side is\n", + "V_left = 2*V - V_right;\t\t\t#[L]\n", + "T_left = T_right*(V_left/V_right);\n", + "print \" c).Final temperature of the gas on the left side is %f K\"%(T_left);\n", + "\n", + "\t\t\t#(d)\n", + "\t\t\t#The first law applied to the total system (left side and right side) gives.\n", + "\t\t\t#Q - W = del(U_left) + del(U_right)\n", + "\t\t\t#There is no net work done by the total system as the cylinder is closed at both ends.\n", + "Q = n*Cv_0*(T_left-T) + n*Cv_0*(T_right-T);\t\t\t#[J]\n", + "Q = Q/1000;\t\t\t#[kJ]\n", + "print \" d).Amount of heat added to the gas on the left side is %f kJ\"%(Q);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " a).Total work done on gas on the right hand side is 3.731958 kJ\n", + " b).The final temperature of the gas on right side is 396.112176 K\n", + " c).Final temperature of the gas on the left side is 1447.650324 K\n", + " d).Amount of heat added to the gas on the left side is 39.378580 kJ\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.14 Page number - 105" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of powerand discharge head\n", + "\n", + "# Variables\n", + "P_2 = 0.2;\t\t\t#[bar]\n", + "P_2 = P_2*10**(5);\t\t\t#[Pa]\n", + "int_dia_2 = 2.4*10**(-2);\t\t\t#[m] - internal diameter at state 2.\n", + "Q = 5*10**(-3);\t\t\t#[cubic metre/s] - Flow rate at point 2.\n", + "den = 1000;\t\t\t#[kg/cubic metre] - density\n", + "delta_z = 1;\t\t\t#[m] - Difference in height\n", + "g = 9.81;\t\t\t#[m/s**(2)] - Acceleration due to gravity\n", + "\n", + "# Calculations and Results\n", + "\t\t\t# (1)\n", + "\t\t\t# Pressure at state 1 is atmospheric pressure and at state 2 is gauze pressure at state 2 + atmospheric pressure,thus\n", + "\t\t\t# (delta(P)/den) = (P2-P1)/den = P2/den\n", + "Vel_2 = Q/(3.14*(int_dia_2/2)**(2));\t\t\t#[m/s] - Velocity of water at state 2.\n", + "\t\t\t# Velocity at state 1 i negligible as compared to velocity at state 2,because the diameter of reservoir is very large as compared to diameter of pipe at state 2\n", + "\n", + "\t\t\t# From bernaulli equation we get,\n", + "\t\t\t# -w = (delta(P)/den) + delta(v**(2))/2 + g*delta_z\n", + "w = -((P_2/den )+ (Vel_2**(2)/2) + (g*delta_z));\t\t\t#[J/kg]\n", + "\t\t\t# w multiplied by m = (den*Q), will give the fluid power.\n", + "m = den*Q;\t\t\t#[kg/s]\n", + "W_net = m*w;\t\t\t#[Watt]\n", + "print \" 1).The fluid power is %f Watt\"%(W_net);\n", + "\n", + "\t\t\t#(2)\n", + "\t\t\t# Total discharge head developed by the pump is given by\n", + "\t\t\t# h = (delta(P)/den*g) + (Vel_2**(2)/2*g) + delta_z\n", + "h = (P_2/(den*g)) + (Vel_2**(2)/(2*g)) + delta_z;\t\t\t#[m]\n", + "print \" 2).Total discharge head developed by the pump is given by h = %f m\"%(h);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 1).The fluid power is -454.750210 Watt\n", + " 2).Total discharge head developed by the pump is given by h = 9.271156 m\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.15 Page number - 106" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of discharge velocity\n", + "\n", + "# Variables\n", + "T_1 = 1000.;\t\t\t#[K] - Temperature at entry\n", + "P_1 = 0.6;\t\t\t#[MPa] - Pressure at entry\n", + "P_2 = 0.2;\t\t\t#[MPa] - Exit pressure\n", + "Vel_1 = 50.;\t\t\t#[m/s] - Entry velocity \n", + "Y = 1.4;\t\t\t# Ratio of heat capacities\n", + "Mol_wt = 28.;\t\t\t#[g/mol] - Molecular weight of air\n", + "Cp = 29.099;\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n", + "Cp = (Cp/Mol_wt)*1000;\t\t\t#[J/kg-K]\n", + "\n", + "# Calculations\n", + "\t\t\t# We know that for a flow process \n", + "\t\t\t# delta_H + delta_V**(2)/2 + delta_(g*z) = q - w\n", + "\t\t\t# Since process is adiabatic,therefore q = 0 and since no work is done by the gas, therefore w = 0\n", + "\t\t\t# Assuming there is no change in the potenial energy between entry and exit, we have\n", + "\t\t\t# delta_H + delta_V**(2)/2 = 0\n", + "\n", + "\t\t\t# For a reversible process P*V**(Y) = constant and thus (T_2/T_1) = (P_2/P_1)**((Y-1)/Y)\n", + "T_2 = T_1*(P_2/P_1)**((Y-1)/Y);\t\t\t#[K] - Exit temperature\n", + "\n", + "\t\t\t# delta_H + delta_V**(2)/2 = 0\n", + "\t\t\t# Vel_2**(2)/2 - Vel_1**(2)/2 - (H_1 - H_2)= 0\n", + "\t\t\t# Vel_2**(2)/2 - Vel_1**(2)/2 - Cp*(T_1 - T_2) = 0\n", + "Vel_2_square = 2*(Vel_1**(2.)/2 - Cp*(T_2 - T_1));\t\t\t#[m**(2)/s**(2)]\n", + "Vel_2 = (Vel_2_square)**(1./2);\t\t\t#[m/s]\n", + "\n", + "# Results\n", + "print \" The discharge velocity is %f m/s\"%(Vel_2);\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The discharge velocity is 749.965327 m/s\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.16 Page number - 107" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of change in enthalpy\n", + "\n", + "# Variables\n", + "P_entry = 10;\t\t\t#[bar] - Pressure at entry\n", + "V_entry = 200;\t\t\t#[m/s] - Velocity at entry\n", + "P_exit = 1;\t\t\t#[bar] - Vressure at exit\n", + "V_exit = 800;\t\t\t#[m/s] - Velocity at exit\n", + "g = 9.81;\t\t\t#[m/s**(2)] - Acceleration due to gravity\n", + "\n", + "# Calculations\n", + "\t\t\t#Heat balance gives\n", + "\t\t\t# delta_H + (delta_V**(2))/2 + g*delta_z = q - w\n", + "\t\t\t#delta_H = q - w - (delta_V**(2))/2 \n", + "\t\t\t#From nozzle no work is extracted,therefore\n", + "delta_H = -(V_exit**(2)- V_entry**(2))/2;\t\t\t#[J/kg]\n", + "delta_H = delta_H*10**(-3);\t\t\t#[kJ/kg]\n", + "\n", + "# Results\n", + "print \" The change in enthalpy per kg of steam is %f kJ/kg\"%(delta_H);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The change in enthalpy per kg of steam is -300.000000 kJ/kg\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.17 Page number - 111" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of work done and change in enthalpy\n", + "\n", + "# Variables\n", + "T_1 = 280;\t\t\t#[K] - Temperature at entry\n", + "P_1 = 100;\t\t\t#[kPa] - Pressure at entry\n", + "T_2 = 400;\t\t\t#[K] - Temperature at exit\n", + "P_2 = 600;\t\t\t#[kPa] - Pressure at exit\n", + "m = 0.02;\t\t\t#[kg/s] - Mass flow rate\n", + "m = m*10**(3);\t\t\t#[g/s]\n", + "heat_loss = 16;\t\t\t#[kJ/kg]\n", + "\n", + "# Calculations and Results\n", + "\t\t\t#Cp_0 = 28.11 + 0.1967*10**(-2)*T + 0.4802*10**(-5)*T**(2) - 1.966*10**(-9)*T**(3)\n", + "\t\t\t#delta_H = q - w (neglecting kinetic and potential changes)\n", + "\t\t\t#delta_H = integral(Cp_0*dT)\n", + "\n", + "def f22(T): \n", + "\t return 28.11 + 0.1967*10**(-2)*T + 0.4802*10**(-5)*T**(2) - 1.966*10**(-9)*T**(3)\n", + "\n", + "delta_H = quad(f22,T_1,T_2)[0]\n", + "\n", + "print \" Change in enthalpy is %f J/mol\"%(delta_H);\n", + "\n", + "\t\t\t#Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n", + "Mol_wt = 28.84;\t\t\t#[g/mol]\n", + "q = - (heat_loss*Mol_wt);\t\t\t#[J/mol]\n", + "w = q - delta_H;\t\t\t#[J/mol]\n", + "print \" The work done per mole of air is %f J/mol\"%(w);\n", + "\t\t\t#the negative sign implies that work is done on the compressor.\n", + "\n", + "n = m/Mol_wt;\t\t\t#[mol/s] - Mole flow rate\n", + "W_net = delta_H*n;\t\t\t#[W]\n", + "W_net = -W_net*10**(-3);\t\t\t#[kW]\n", + "print \" And the necessary power input to the compressor is %f kW\"%(W_net);\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Change in enthalpy is 3511.197066 J/mol\n", + " The work done per mole of air is -3972.637066 J/mol\n", + " And the necessary power input to the compressor is -2.434949 kW\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.18 Page number - 112" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of work done per unit mass\n", + "\n", + "# Variables\n", + "T_1 = 300;\t\t\t#[K] - Temperature at entry\n", + "P_1 = 100;\t\t\t#[kPa] - Pressure at entry\n", + "P_2 = 900;\t\t\t#[kPa] - Pressure at exit\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# Reversible adiabatic compression\n", + "Y = 1.4;\t\t\t#Ratio of specific heat capacities\n", + "\t\t\t# For ideal gas, P*V**(Y)= constant and it takes the form of (T_2/T_1) = (P_2/P_1)**((Y-1)/Y)\n", + "T_2 = T_1*(P_2/P_1)**((Y - 1)/Y);\t\t\t#[K]\n", + "\t\t\t# The work exchange for adiabatic process is given by\n", + "\t\t\t# W_adia = -delta_H = -Cp*(T2-T1) = Cp*(T1-T2) = ((Y*R)/(Y-1))*(T1-T2)\n", + "W_adia = ((Y*R)/(Y - 1))*(T_1 - T_2);\t\t\t#[J/mol] -work done\n", + "\t\t\t# Molecular weight of air(21 vol% O2 and 79 vol% N2)=(0.21*32)+(0.79*28)= 28.84 g/mol\n", + "Mol_wt = 28.84;\t\t\t#[g/mol]\n", + "W_adia = W_adia/Mol_wt;\t\t\t#[J/g]\n", + "print \" a).The compressor work done for reversible adiabatic compession is %f J/g\"%(W_adia);\n", + "\n", + "\t\t\t#(b)\n", + "\t\t\t#Isothermal compression\n", + "\t\t\t#W_iso = -integral(V*dP) = -integral((R*T/P)*dP) = R*T*ln(P_2/P_1)\n", + "W_iso = -R*T_1*math.log(P_2/P_1);\t\t\t#[J/mol]\n", + "W_iso = W_iso/Mol_wt;\t\t\t#[J/g]\n", + "print \" b).The compressor work done for isothermal compession is %f J/g\"%(W_iso);\n", + "\t\t\t#Note that in isothermal compression between the same states work done is less as compared to reversible adiabatic compression.\n", + "\n", + "\t\t\t#(c)\n", + "\t\t\t#Ideal two-stage compression \n", + "n = 1.3;\t\t\t#Polytropic exponent.\n", + "\t\t\t#Minimum work done in two stage compression is given by\n", + "\t\t\t#W_comp = ((2*n*R*T_1)/(n-1))*[1-(P_x/P_1)**(n-1)/n]\n", + "\t\t\t#where for minimum work, (P_x/P_1) = (P_x/P_2), and thus\n", + "P_x = (P_1*P_2)**(1./2);\t\t\t#[kPa]\n", + "\t\t\t#therefore, work done is given by,\n", + "W_comp = ((2*n*R*T_1)/(n-1))*(1-(P_x/P_1)**((n-1)/n));\t\t\t#[J/mol]\n", + "W_comp = W_comp/Mol_wt;\t\t\t#[J/g]\n", + "print \" c).The compressor work done for ideal two-stage compession is %f J/g\"%(W_comp);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " a).The compressor work done for reversible adiabatic compession is -264.386412 J/g\n", + " b).The compressor work done for isothermal compession is -190.024880 J/g\n", + " c).The compressor work done for ideal two-stage compession is -216.284501 J/g\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.19 Page number - 113" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculation of inlet and outlet velocity and power\n", + "\n", + "# Variables\n", + "T_1 = 600;\t\t\t#[C] - Temperature at entry\n", + "P_1 = 15;\t\t\t#[MPa] - Pressure at entry\n", + "T_2 = 400;\t\t\t#[K] - Temperature at exit\n", + "P_2 = 100;\t\t\t#[kPa] - Pressure at exit\n", + "A_in = 0.045;\t\t\t#[metre square] - flow in area\n", + "A_out = 0.31;\t\t\t#[metre square] - flow out area\n", + "m = 30;\t\t\t#[kg/s] - mass flow rate.\n", + "\n", + "# Calculations and Results\n", + "\t\t\t#At 15 MPa and 600 C,it has been reported in the book that the properties of steam are,\n", + "Vol_1 = 0.02491;\t\t\t#[m**(3)/kg] - Specific volume\n", + "H_1 = 3582.3;\t\t\t#[kJ/kg] - Enthalpy\n", + "\t\t\t# m = den*vel*A = (Vel*A)/Vol, substituting the values\n", + "vel_1 = (m*Vol_1)/A_in;\t\t\t#[m/s] - Velocity at point 1.\n", + "print \" The inlet velocity is %f m/s\"%(vel_1);\n", + "\n", + "\t\t\t#At 100 MPa (saturated vapour),it has been reported in the book that the properties of steam are, T_sat = 99.63 C, and\n", + "Vol_vap_2 = 1.6940;\t\t\t#[m**(3)/kg] - specific volume of saturated vapour.\n", + "H_vap_2 = 2675.5;\t\t\t#[kJ/kg] - Enthalpy os saturated vapour.\n", + "vel_2 = (m*Vol_vap_2)/A_out;\t\t\t#[m/s] - Velocity at point 2.\n", + "print \" The exit velocity is %f m/s\"%(vel_2);\n", + "\n", + "\t\t\t#From first law we get, q - w =delta_H + delta_V**(2)/2\n", + "\t\t\t#q = 0, therefore, -w = delta_H + delta_V**(2)/2\n", + "delta_H = H_vap_2 - H_1;\t\t\t#[kJ/kg] - change in enthalpy.\n", + "delta_V_square = (vel_2**(2) - vel_1**(2))/2;\t\t\t#[J/kg]\n", + "delta_V_square = delta_V_square*10**(-3);\t\t\t#[kJ/kg]\n", + "w = -(delta_H + delta_V_square);\t\t\t#[J/kg] \n", + "W_net = w*m;\t\t\t#[kW]\n", + "W_net = W_net*10**(-3);\t\t\t#[MW] - power produced.\n", + "print \" The power that can be produced by the turbine is %f MW\"%(W_net);\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The inlet velocity is 16.606667 m/s\n", + " The exit velocity is 163.935484 m/s\n", + " The power that can be produced by the turbine is 26.805014 MW\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.20 Page number - 117" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Proving a mathematical relation\n", + "\n", + "# Variables,\n", + "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n", + "Cp_0 = 2.5*R;\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n", + "Cv_0 = 1.5*R;\t\t\t#[J/mol-K] - Specific heat capacity at constant volume\n", + "T_L = 300;\t\t\t#[K] - Temperature at which port properties are constant.\n", + "\n", + "# Calculations\n", + "Y = Cp_0/Cv_0;\t\t\t# Ratio of heat capacities.\n", + "\t\t\t#From part(1) we obtained the relation,\n", + "\t\t\t# T_2 = 1/(((P_2-P_1)/(Y*T_L*P_2))+(P_1/(P_2*T_1)))\n", + "\t\t\t# Not that when P_2 >> P_1 ,T_2 approaches Y*T_L and thus\n", + "T_2 = Y*T_L;\t\t\t#[K]\n", + "\n", + "# Results\n", + "print \" b).The final temperature is %f K\"%(T_2);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " b).The final temperature is 500.000000 K\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.21 Page number - 119" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determination of equilibrium temperature\n", + "\n", + "# Variables\n", + "T_1 = 40 + 273.15;\t\t\t#[K] - Initial temperature.\n", + "P_1 = 1;\t\t\t#[bar] - Initial pressure.\n", + "P_1 = P_1*10**(5);\t\t\t#[Pa]\n", + "Vol_1 = 0.01;\t\t\t#[cubic metre] - Initial volume of the cylinder.\n", + "T_2 = 100 + 273.15;\t\t\t#[K] - Final temperature.\n", + "P_2 = 100;\t\t\t#[kPa] - Final pressure.\n", + "P_2 = P_2*10**(5);\t\t\t#[Pa]\n", + "Vol_2 = 0.02;\t\t\t#[cubic metre] - Final volume of the cylinder.\n", + "Cp = 1.005;\t\t\t#[J/g-K] - Specific heat capacity at constant pressure.\n", + "Cv = 0.718;\t\t\t#[J/g-K] - Specific heat capacity at constant volume.\n", + "Mol_wt = 28.84;\t\t\t#[g/mol] - Molecular weight of air.\n", + "R = 8.314;\t\t\t#[J/mol-K] - universal gas constant\n", + "\n", + "# Calculations\n", + "delta_Vol = Vol_2 - Vol_1;\t\t\t# [cubic metre] - Change in volume.\n", + "\t\t\t# Assuming ideal gas P*V = R*T\n", + "V_1 = (R*T_1)/P_1;\t\t\t# [m**(3)/mol] - Initial specific volume.\n", + "\t\t\t# Therefore,the total number of moles initially in the system is,\n", + "n_1 = (Vol_1/V_1);\t\t\t# [mol]\n", + "m_1 = n_1*Mol_wt;\t\t\t# [g] - Initial mass of the system.\n", + "Y = Cp/Cv;\t\t\t#Ratio of heat capacities\n", + "\n", + "\t\t\t# The energy balance equation is given by\n", + "\t\t\t# -P*delta_Vol + H_liq*(m_2 - m_1) = m_2*Cv*(P*V2)/R - m_1*Cv*T_1\n", + "\t\t\t# m_2*Cv*(P*V2)/R = (Cv*P_1*Vol_2)/R\n", + "\t\t\t# Cv/R = 1/(Y-1)\n", + "\t\t\t# Since pressure of the gas in system is assumed constant,therefore it remains at 1 bar and thus P = P_1,\n", + "H_liq = Cp*T_2;\t\t\t# [J/g] - Enthalpy of liquid\n", + "m_2 = (P_1*delta_Vol + ((P_1*Vol_2)/(Y-1)) + H_liq*m_1 - m_1*Cv*T_1)/H_liq;\t\t\t#[g]\n", + "\n", + "\t\t\t#The mass entering the assembly during the filling process is given by\n", + "m = m_2 - m_1;\t\t\t#[g]\n", + "n_2 = m_2/Mol_wt;\t\t\t#[mol] - Number of moles in the final state.\n", + "V_2 = Vol_2/n_2;\t\t\t#[m**(3)/mol] - Final specific volume.\n", + "\t\t\t# Therfore,final temperature is given by,\n", + "T_2 = (P_1*V_2)/R;\t\t\t#[K] - Final temperature.\n", + "\n", + "# Results\n", + "print \" The final equilibrium temperature is %f K\"%(T_2);\n", + "print \" The mass entering through the valve is %f g\"%(m);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The final equilibrium temperature is 339.343160 K\n", + " The mass entering through the valve is 9.367211 g\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example - 3.22 Page number - 122" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determination of mass\n", + "\n", + "# Variables\n", + "V_total = 5;\t\t\t#[L] - Volume of pressure cooker.\n", + "V_total = V_total*10**(-3);\t\t\t#m**(3)\n", + "P_gauze = 15;\t\t\t#[psi] - Operating pressure (gauze)of pressure cooker.\n", + "P_gauze = (P_gauze/14.5)*10**(5);\t\t\t#[N/m**(2)]\n", + "P_atm = 0.966*10**(5);\t\t\t#[N/m**(2)] - Atmospheric pressure.\n", + "m_1 = 1;\t\t\t#[kg] - Initial mass.\n", + "t = 30*60;\t\t\t#[s] - Total time.\n", + "J = 500;\t\t\t#[W] - Rate of heat supply\n", + "\n", + "# Calculations\n", + "P_abs = P_gauze + P_atm;\t\t\t#[N/m**(2)] - Absolute pressure.\n", + "\t\t\t#The energy balance equqtion gives,\n", + "\t\t\t# Q = m_e*H_e +(m_2*U_2 - m_1*U_1), where 'm_e' is the mass exit from the system and 'H_e' is enthalpy at exit conditions.\n", + "\n", + "\t\t\t#It has been reported in the book that from steam table at P_abs,\n", + "T_sat = 120.23;\t\t\t#[K]- Saturated temperature\n", + "V_liq = 0.001061;\t\t\t#[m**(3)/kg] - specific volume of liquid.\n", + "V_vap = 0.8857;\t\t\t#[m**(3)/kg] - specific volume of vapour.\n", + "U_liq = 504.49;\t\t\t#[kJ/kg] - specific internal energy of liquid.\n", + "U_vap = 2529.5;\t\t\t#[kJ/kg] - specific internal energy of vapour.\n", + "H_liq = 504.70;\t\t\t#[kJ/kg] - specific enthalpy of liquid.\n", + "H_vap = 2706.7;\t\t\t#[kJ/kg] - specific internal energy of vapour.\n", + "\n", + "\t\t\t#We know that total volume occupied by 1 kg of fluid is \n", + "\t\t\t#V_total = (1-x)*V_liq + x*V_vap\n", + "x1 = (V_liq - V_total)/(V_liq - V_vap);\t\t\t#[g]\n", + "\n", + "\t\t\t#Internal energy at this state is\n", + "U_1 = (1-x1)*U_liq + x1*U_vap;\t\t\t#[kJ/kg] - specific internal energy\n", + "U_1_net = m_1*U_1;\t\t\t#[kJ] - Internal energy\n", + "\n", + "\t\t\t#The amount of heat suplied is given by,\n", + "J_net = J*t;\t\t\t#[J] - Net heat supplied.\n", + "J_net = J_net*10**(-3);\t\t\t#[kJ]\n", + "\n", + "\t\t\t#Let the dryness factor at the end of the process be x\n", + "\t\t\t#The specific properties of the liquid and vapour remain same as P and T_sat are the same in the cooker.\n", + "\t\t\t#Let the total mass of H2O (liquid + vapour) at the end of the process be 'm' kg.\n", + "\t\t\t# V_total/m = (1-x)*(V_liq) + x*V_vap ......equqtion(1)\n", + "\n", + "\t\t\t#the specific internal energy at the end of process is\n", + "\t\t\t#U = (1-x)*U_liq + x*U_vap\n", + "\t\t\t#The total internal energy at the end of the process is\n", + "\t\t\t#U_net = m*U = x*[(1-x)*U_liq + x*U_vap]\n", + "\n", + "\t\t\t#The energy balance equqtion gives,\n", + "\t\t\t# Q = m_e*H_e +(m_2*U_2 - m_1*U_1), where 'm_e' is the mass exit from the system and 'H_e' is enthalpy at exit conditions.\n", + "\t\t\t#Since the vapour which exits out have enthalpy equal to that of saturated vapour,we get on simplification\n", + "\t\t\t# 900 = (1-m)*(2706.7) + m*((1-x)*504.49 + x*2529.5) - 513.5..........equation(2)\n", + "\t\t\t# The second equation on simplification becomes\n", + "\t\t\t# x = ((0.005/m) - 0.001061)/0.884639\n", + "\n", + "\t\t\t# Putting the expression of x in first equation and then simplifying, we get\n", + "\t\t\t# - 1293.2 = -2202.21*m + 11.445 - 2.429*m\n", + "m = (11.445+1293.2)/(2202.21+2.429);\t\t\t#[kg]\n", + "\n", + "\t\t\t# Therefore x can be calculated as\n", + "x = ((0.005/m) - 0.001061)/0.884639;\n", + "\n", + "\t\t\t# Therfore total water (liquid + vapour) present in the pressure cooker at the end of the process is m kg.\n", + "m_vapour = x*m;\t\t\t#[kg] - Mass of vapour\n", + "m_liquid = (1-x)*m;\t\t\t#[kg] - Mass of vapour\n", + "\n", + "# Results\n", + "print \" Total water liquid + vapour) present in the pressure cooker at the end of the process is %f kg\"%(m);\n", + "print \" The mass of vapour is %f kg\"%(m_vapour);\n", + "print \" The mass of liquid is %f kg\"%(m_liquid);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Total water liquid + vapour) present in the pressure cooker at the end of the process is 0.591773 kg\n", + " The mass of vapour is 0.004942 kg\n", + " The mass of liquid is 0.586830 kg\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 20 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |