{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 4 : First law of thermodynamics and its applications" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.1 Page No : 94" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "Q1 = 50.;\t\t\t #Energy added as heat in kJ when the system undergoes a process 1-2\n", "W1 = 30.;\t\t\t #Work done by the system in kJ during the process 1-2\n", "Q2 = -40.;\t\t\t #Energy rejected as heat in kJ during the process 2-3\n", "W2 = -50.;\t\t\t #Work done on the system in kJ during the process 2-3\n", "Q3 = 0.\t \t\t #System undergoes an adiabatic process to return to initial state\n", "\n", "# Calculations\n", "U2_1 = Q1-W1\n", "U3_2 = Q2-W2\n", "U1_3 = (-U2_1)-(U3_2)\n", "W3 = Q3-U1_3\n", "net_work = W1+W2+W3\n", "\n", "# Results\n", "print ' The net work done by the system = %d kJ'%(net_work);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The net work done by the system = 10 kJ\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.3 Page No : 96" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "V = 1. \t\t\t #volume of tank in m**3;\n", "N = 200.;\t\t\t #number of moles of carbon dioxide in tank in mol\n", "T1 = 25.;\t\t\t #ambient temperature in degree celsius\n", "I = 5.; \t\t\t #current in amperes passed through the resistor place in the tank\n", "Voltage = 440.\t\t #voltage in volts existing across the resistor\n", "t = 10.;\t\t\t #time in minutes for which the current is passed\n", "a = 363.077*10**-3\t\t\t #van der waals constant in Pa (m**3/mol)**2\n", "b = 0.043*10**-3\t\t\t #van der waals constant in m**3/mol\n", "Cv = 32.34\t\t\t #molar heat capacity at constant volume in J/molK\n", "R = 8.314\t\t\t #universal gas constant in J/molK\n", "\n", "# Calculations\n", "MV = V/N;\t\t\t # Calculations of molar volume in m**3/mol\n", "Q = 0. \t\t\t #energy transfer as heat during the process\n", "W_Pdv = 0.;\t\t\t #mechanical work done by the system\n", "W_elec = -(Voltage*I*t*60)*(10**-6)\n", "U2_1 = Q-(W_Pdv+W_elec);\t\t\t\n", "T2 = ((U2_1*10**6)/(N*Cv))+(T1+273.15)\n", "P = (((R*T2)/(MV-b))-(a/(MV**2)))*10**-3\n", "\n", "# Results\n", "print ' The final pressure = %0.3f kPa '%(P);\n", "print ' The final temperature = %0.2f K'%(T2);\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The final pressure = 827.832 kPa \n", " The final temperature = 502.23 K\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.4 Page No : 97" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "V = 0.1;\t\t\t #volume of tank in m**3\n", "T1 = 200.;\t\t\t #initial temperature of saturated steam inside the tank in degree celsius\n", "T2 = 150.;\t\t\t #temperature in degree celsius that the tank attains after some time due to poor insulation\n", "P1 = 15.549;\t\t\t #pressure in bar obtained from steam tables corresponding to T1\n", "vg1 = 0.1272;\t\t\t #specific volume of saturated vapour in m**3/kg obtained from steam tables corresponding to T1\n", "hg1 = 2790.9;\t\t\t #specific enthalpy of saturated vapour in kJ/kg obtained from steam tables corresponding to T1\n", "P2 = 4.76;\t\t\t #pressure in bar obtained from steam tables corresponding to T2\n", "vf = 0.0010908;\t\t\t #specific volume of saturated liquid in m**3/kg obtained from steam tables corresponding to T2\n", "vg2 = 0.3924;\t\t\t #specific volume of saturated vapour in m**3/kg obtained from steam tables corresponding to T2\n", "hf = 632.15;\t\t\t #specific enthalpy of saturated liquid in kJ/kg obtained from steam tables corresponding to T1\n", "hg2 = 2745.4;\t\t\t #specific enthalpy of saturated vapour in kJ/kg obtained from steam tables corresponding to T1\n", "\n", "# Calculations\n", "ug1 = ((hg1*10**3)-(P1*10**5*vg1))*10**-3\n", "uf = ((hf*10**3)-(P2*10**5*vf))*10**-3\n", "ug2 = ((hg2*10**3)-(P2*10**5*vg2))*10**-3\n", "v2 = vg1\n", "X2 = (v2-vf)/(vg2-vf)\n", "u2 = (X2*ug2)+((1-X2)*uf)\n", "m = V/vg1\n", "Q = m*(u2-ug1)\n", "mf = m*(1-X2)\n", "mg = m*X2\n", "\n", "# Results\n", "print ' The energy transferred as heat = %f kJ'%(Q);\n", "print ' The mass of liquid in the tank in the final state = %0.3f kg'%(mf)\n", "print ' The mass of vapour in the tank in the final state = %0.3f kg'%(mg)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The energy transferred as heat = -1053.825572 kJ\n", " The mass of liquid in the tank in the final state = 0.533 kg\n", " The mass of vapour in the tank in the final state = 0.253 kg\n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.5 Page No : 102" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "W = 1.;\t \t\t #weight of steam in kg in the piston cylinder assembly\n", "X = 0.8;\t\t\t #quality of steam (no unit)\n", "T1 = 150.;\t\t\t #initial temperature of steam in degree celsius\n", "T2 = 200.;\t\t\t #final temperature of steam in degree celsius\n", "P1 = 476.;\t\t\t #pressure in kPa obatined from steam tables (corresponding to T1)\n", "vf = 0.0010908;\t\t\t #specific volume of saturated liquid in m**3/kg obatined from steam tables (corresponding to T1)\n", "vg = 0.3924;\t\t\t #specific volume of satuarted vapour in m**3/kg obatined from steam tables (corresponding to T1)\n", "hf = 632.15;\t\t\t #specific enthalpy of saturated liquid in kJ/kg obtained from steam tables (corresponding to T1)\n", "hg = 2745.4;\t\t\t #specific enthalpy of saturated vapour in kJ/kg obtained from steam tables (corresponding to T1)\n", "\n", "# Calculations\n", "V1 = (X*vg)+((1-X)*vf)\n", "h1 = (X*hg)+((1-X)*hf)\n", "P2 = 0.476;\t\t\t \n", "P_int1 = 0.4;\t\t\n", "P_int2 = 0.5;\t\t\n", "V_int1 = 0.5343;\t\n", "V_int2 = 0.4250;\t\n", "h_int1 = 2860.4;\t\n", "h_int2 = 2855.1;\t\n", "V2 = (((P2-P_int1)/(P_int2-P_int1))*(V_int2-V_int1))+V_int1\n", "h2 = (((P2-P_int1)/(P_int2-P_int1))*(h_int2-h_int1))+h_int1\n", "Q = (h2-h1)*W\n", "W = P1*(V2-V1)*W\n", "\n", "# Results\n", "print ' The work done by steam = %0.2f kJ '%(W);\n", "print ' The net energy transferred as heat = %0.2f kJ'%(Q);\n", "print ' The final state of superheated steam,Pressure = %0.3f MPa '%(P2);\n", "print ' The final state of superheated steam,Temperature = %d degree celsius '%(T2);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The work done by steam = 65.26 kJ \n", " The net energy transferred as heat = 533.62 kJ\n", " The final state of superheated steam,Pressure = 0.476 MPa \n", " The final state of superheated steam,Temperature = 200 degree celsius \n" ] } ], "prompt_number": 5 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.6 Page No : 103" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "W = 1. \t\t\t #weight of steam in kg in the piston cylinder assembly\n", "X = 0.8;\t\t\t #quality of steam (no unit)\n", "T1 = 150.\t\t\t #initial temperature of steam in degree celsius\n", "I = 5. \t\t\t #current passed in Amperes\n", "V = 220.\t\t\t #voltage in volts across the resistor\n", "t = 10. \t\t\t #time for which the current is passed in minutes\n", "P1 = 476.\t\t\t #pressure in kPa obatined from steam tables (corresponding to T1)\n", "vf = 0.0010908;\t\t\t #specific volume of saturated liquid in m**3/kg obatined from steam tables (corresponding to T1)\n", "vg = 0.3924;\t\t\t #specific volume of satuarted vapour in m**3/kg obatined from steam tables (corresponding to T1)\n", "hf = 632.15;\t\t\t #specific enthalpy of saturated liquid in kJ/kg obtained from steam tables (corresponding to T1)\n", "hg = 2745.4;\t\t\t #specific enthalpy of saturated vapour in kJ/kg obtained from steam tables (corresponding to T1)\n", "\n", "# Calculations\n", "V1 = (X*vg)+((1-X)*vf);\t\n", "h1 = (X*hg)+((1-X)*hf);\t\n", "Ws = -V*I*t*60*10**-3;\t\n", "h2 = h1-Ws;\t\t\t \n", "P2 = 0.476;\t\t\t \n", "T_int1 = 200;\t\t\n", "T_int2 = 300;\t\t\n", "V_int1 = 0.4512;\t\n", "V_int2 = 0.5544;\t\n", "h_int1 = 2856.37;\t\n", "h_int2 = 3065.38;\t\n", "V2 = (((h2-h_int1)/(h_int2-h_int1))*(V_int2-V_int1))+V_int1;\n", "T2 = (((h2-h_int1)/(h_int2-h_int1))*(T_int2-T_int1))+T_int1;\n", "W = (P1*10**3*(V2-V1)*W)*10**-3\n", "\n", "# Results\n", "print ' The work done by steam = %0.2f kJ '%(W);\n", "print ' The final temperature = %0.2f degree celsius'%(T2);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The work done by steam = 94.94 kJ \n", " The final temperature = 260.47 degree celsius\n" ] } ], "prompt_number": 6 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.7 Page No : 104" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "N = 1.\t\t\t #number of moles of carbon dioxide in kmol\n", "T1 = 298.\t\t\t #initial temperature in K\n", "T2 = 600.\t\t\t #final raised temperature in K\n", "a = 45.369\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "b = 8.688*10**-3\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "e = -9.619*10**5\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "\n", "# Calculations\n", "Q = N*10**3*((a*(T2-T1)+((b/2)*(T2**2-T1**2))-(e*((1./T2)-(1./T1)))))*10**-6\n", "\n", "# Results\n", "print ' The amount of energy to be transferred as heat = %0.3f MJ'%(Q);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The amount of energy to be transferred as heat = 13.255 MJ\n" ] } ], "prompt_number": 7 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.8 Page No : 104" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "T1 = 298. \t\t\t #initial temperature in K\n", "T2 = 600.\t \t\t #final raised temperature in K\n", "a = 45.369;\t\t \t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "b = 8.688*10**-3;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "e = -9.619*10**5;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "\n", "# Calculations\n", "Cpm = ((a*(T2-T1))+((b/2)*(T2**2-T1**2))-(e*((1./T2)-(1./T1))))/(T2-T1)\n", "\n", "# Results\n", "print ' The isobaric molar heat capacity = %0.2f J/molK'%(Cpm);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The isobaric molar heat capacity = 43.89 J/molK\n" ] } ], "prompt_number": 8 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.9 Page No : 105" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "N = 1.\t \t\t #number of moles of carbon dioxide in kmol\n", "T1 = 298.\t\t\t #initial temperature in K\n", "T2 = 600.\t\t\t #final raised temperature in K\n", "a = 45.369;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "b = 8.688*10**-3;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "e = -9.619*10**5;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "\n", "# Calculations\n", "Cpm = ((a*(T2-T1))+((b/2)*(T2**2-T1**2))-(e*((1./T2)-(1./T1))))/(T2-T1)\n", "Q = N*10**3*Cpm*(T2-T1)*10**-6\n", "\n", "# Results\n", "print ' The amount of energy to be transferred as heat = %0.3f MJ '%(Q);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The amount of energy to be transferred as heat = 13.255 MJ \n" ] } ], "prompt_number": 9 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.10 Page No : 105" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "N = 100.\t\t\t #number of moles of carbon dioxide in mol\n", "T1 = 298.\t\t\t #initial temperature in K\n", "Q = 1. \t\t\t #energy added as heat in MJ\n", "a = 45.369;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "b = 8.688*10**-3;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "e = -9.619*10**5;\t\t\t #coefficient in the specific heat capacity expression where Cp = a+bT+eT**-2\n", "\n", "# Calculations\n", "delh = Q*10**6/N\n", "Tguess = 520.\t\n", "Cpm_guess = a+(b*((T1+Tguess)/2))+(e/(T1*Tguess))\n", "T2_guess = T1+(delh/Cpm_guess)\n", "tolerance = 1e-6;\t\t\t\n", "while abs(T2_guess-Tguess)>tolerance:\n", " Tguess = T2_guess;\n", " Cpm_guess = a+(b*((T1+Tguess)/2))+(e/(T1*Tguess));\n", " T2_guess = T1+(delh/Cpm_guess)\n", "\n", "T2 = T2_guess\n", "\n", "# Results\n", "print ' The final temperature = %0.1f K'%(T2)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The final temperature = 531.1 K\n" ] } ], "prompt_number": 10 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.11 Page No : 107" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "volume_ratio = 1./15\t #final volume to the initial volume of air at the end of compression stroke (no unit)\n", "gaamma = 1.4\t\t\t #ratio of the molar heat capacities at constant pressure and constant volume for air (no unit)\n", "T1 = 300.\t\t\t #initial temperature of air in K\n", "P1 = 0.1;\t\t\t #initial pressure of air in MPa\n", "R = 8.314;\t\t\t #universal gas constant in J/molK\n", "\n", "# Calculations\n", "T2 = T1*((1./volume_ratio)**(gaamma-1))\n", "P2 = P1*((1./volume_ratio)**(gaamma))\n", "W = (R*(T1-T2)*10**-3)/(gaamma-1)\n", "\n", "# Results\n", "print ' The final temperature = %0.2f K'%(T2);\n", "print ' The final pressure = %0.4f MPa'%(P2);\n", "print ' Work done per mole of air = %0.3f kJ/mol'%(W);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The final temperature = 886.25 K\n", " The final pressure = 4.4313 MPa\n", " Work done per mole of air = -12.185 kJ/mol\n" ] } ], "prompt_number": 11 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.12 Page No : 110" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "volume_ratio = 1./15;\t\t\t #final volume to the initial volume of ideal gas at the end of compression (no unit)\n", "T1 = 300. \t\t\t #initial temperature of ideal gas in K\n", "P1 = 0.1;\t \t\t #initial pressure of ideal gas in MPa\n", "R = 8.314;\t\t \t #universal gas constant in J/molK\n", "n = 1.2;\t\t\t #index of expansion (no unit)\n", "gaamma = 1.4;\t\t\t #ratio of the molar heat capacities at constant pressure and constant volume for ideal gas (no unit)\n", "\n", "# Calculations\n", "P2 = P1*((1./volume_ratio)**n)\n", "T2 = T1*(P2/P1)*(volume_ratio)\n", "W = (R*(T1-T2)*10**-3)/(n-1)\n", "del_u = (R*(T2-T1)*10**-3)/(gaamma-1)\n", "q = del_u+W\n", "\n", "# Results\n", "print ' The final pressure = %0.3f MPa'%(P2);\n", "print ' The final temperature = %0.1f K'%(T2);\n", "print ' Work done on the gas = %f kJ/mol'%(W);\n", "print ' Heat interaction during the process = %f kJ/mol'%(q)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The final pressure = 2.578 MPa\n", " The final temperature = 515.6 K\n", " Work done on the gas = -8.963805 kJ/mol\n", " Heat interaction during the process = -4.481902 kJ/mol\n" ] } ], "prompt_number": 12 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.13 Page No : 112" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "V = 1.;\t \t\t #volume of tank in m**3\n", "T0 = 300.\t\t\t #initial temperature of ideal gas in K\n", "P0 = 0.1\t\t\t #initial pressure of ideal gas in MPa\n", "T = 500.\t\t\t #temperature of ideal gas in the pipeline in K\n", "P = 3.\t\t \t #pressure of ideal gas in the pipeline in MPa\n", "R = 8.314;\t\t\t #universal gas constant in J/molK\n", "gaamma = 1.4;\t\t\t #ratio of the molar heat capacities at constant pressure and constant volume for ideal gas (no unit)\n", "\n", "# Calculations\n", "Pf = 3.\n", "Tf = (Pf*10**6)/((((Pf*10**6)-(P0*10**6))/(gaamma*T))+((P0*10**6)/T0));\n", "N = (V/R)*(((Pf*10**6)/Tf)-((P0*10**6)/T0));\n", "\n", "# Results\n", "print ' The final temperature = %0.1f K'%(Tf);\n", "print ' The amount of gas that has entered the tank = %0.2f mol'%(N);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The final temperature = 670.2 K\n", " The amount of gas that has entered the tank = 498.30 mol\n" ] } ], "prompt_number": 13 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.14 Page No : 113" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from scipy.optimize import fsolve\n", "\n", "# Variables\n", "V = 3. \t\t\t #volume of tank in m**3\n", "T0 = 100.;\t\t\t #initial temperature of steam in degree celsius\n", "T = 300.;\t\t\t #temperature of superheated steam in the pipeline in degree celsius\n", "P = 3.;\t\t\t #pressure of superheated steam in the pipeline in MPa\n", "R = 8.314;\t\t\t #universal gas constant in J/molK\n", "\n", "# Calculations\n", "Ps = 101.33\n", "vg = 1.673\n", "hg = 2676.0\n", "h = 2995.1\n", "u0 = ((hg*10**3)-(Ps*10**3*vg))*10**-3\n", "m0 = V/vg;\t\t\t\n", "\n", "Tf = 418.\n", "vf = 0.102329\n", "uf = 2965.78\n", "\n", "mf_guess = V/vf\n", "\n", "def solver_func(ui):\n", " return (mf_guess*ui)-(m0*u0)-((mf_guess-m0)*h);\n", "\n", "uf_solved = fsolve(solver_func,mf_guess)\n", "mf = mf_guess\n", "mass = mf-m0\n", "\n", "# Results\n", "print \" The final state of steamsuperheated, Pressure = %d MPa\"%(P);\n", "print \" The final state of steamsuperheated, Temperature = %d degree celsius\"%(Tf);\n", "print \" The mass of steam that entered the tank = %0.3f kg\"%(mass);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The final state of steamsuperheated, Pressure = 3 MPa\n", " The final state of steamsuperheated, Temperature = 418 degree celsius\n", " The mass of steam that entered the tank = 27.524 kg\n" ] } ], "prompt_number": 15 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.15 Page No : 115" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "V = 0.1;\t\t\t #volume of cylinder in m**3\n", "T0 = 300.\t\t\t #initial temperature of nitrogen in K\n", "P0 = 14.\t\t\t #initial pressure of nitrogen in MPa\n", "P = 0.1;\t\t\t #ambient pressure in MPa\n", "Pf = 2. \t\t\t #final pressure of nitrogen in MPa\n", "R = 8.314;\t\t\t #universal gas constant in J/molK\n", "gaamma = 1.4;\t\t #ratio of the molar heat capacities at constant pressure and constant volume for nitrogen (no unit)\n", "\n", "# Calculations\n", "def solver_func(Ti):\n", " return ((P0*10**6)-(Pf*10**6))-((gaamma/2)*(T0+Ti)*(((P0*10**6)/T0)-((Pf*10**6)/Ti)));\n", "\n", "Tguess = 300.\n", "Tf = fsolve(solver_func,Tguess)\n", "\n", "N = (V/R)*(((P0*10**6)/T0)-((Pf*10**6)/Tf));\n", "\n", "# Results\n", "print ' The final temperature = %0.1f K'%(Tf);\n", "print ' The amount of gas that has escaped from the cylinder = %0.2f mol'%(N);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The final temperature = 181.2 K\n", " The amount of gas that has escaped from the cylinder = 428.52 mol\n" ] } ], "prompt_number": 16 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.16 Page No : 118" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "T0 = 300.;\t\t\t #initial temperature of superheated steam in degree celsius\n", "P0 = 3.;\t\t\t #initial pressure of superheated steam in MPa\n", "Xe = 0.85;\t\t\t #quality of steam leaving the turbine (no unit)\n", "Tf = 45.;\t\t\t #final temperature of steam leaving the turbine in degree celsius\n", "Vi = 10.;\t\t\t #velocity of steam at the entrance in m/s\n", "Ve = 40.;\t\t\t #exit velocity of steam in m/s\n", "Zi = 10.;\t\t\t #elevation at the entrance in m\n", "Ze = 4.;\t\t\t #elevation at the exit in m\n", "m = 1.;\t\t\t #mass flow rate of steam through turbine in kg/s\n", "g = 9.81;\t\t\t #accleration due to gravity in m/s**2\n", "\n", "# Calculations\n", "hi = 2995.1\n", "hf = 188.35\n", "hg = 2583.3\n", "he = ((1-Xe)*hf)+(Xe*hg)\n", "Q = 0.\t\t\t \n", "enthalpy_change = (he*10**3)-(hi*10**3)\n", "KE_change = ((Ve**2)-(Vi**2))/2\n", "PE_change = g*(Ze-Zi);\t\t\t\n", "Ws = Q-(m*(enthalpy_change+KE_change+PE_change)*10**-3)\n", "err_KE = ((KE_change)/(Ws*10**3))*100;\t\n", "err_PE = ((abs (PE_change)/(Ws*10**3)))*100\n", "err = err_KE+err_PE\n", "\n", "# Results\n", "print ' The percentage error when Kinetic energy change is ignored = %0.3f '%(err_KE);\n", "print ' The percentage error when Potential energy change is ignored = %0.4f '%(err_PE);\n", "print ' The percentage error when both Kinetic and Potential energy changes are ignored = %f '%(err);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The percentage error when Kinetic energy change is ignored = 0.097 \n", " The percentage error when Potential energy change is ignored = 0.0076 \n", " The percentage error when both Kinetic and Potential energy changes are ignored = 0.104999 \n" ] } ], "prompt_number": 17 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.17 Page No : 119" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "# Variables\n", "Pi = 5.;\t\t\t #pressure of dry saturated steam at the entrance in bar\n", "Pe = 2.;\t\t\t #pressure of dry saturated steam at the exit in bar\n", "Vi = 3.;\t\t\t #velocity of dry saturated steam at the entrance in m/s\n", "m = 1.; \t\t\t #flow rate of steam through the nozzle in kg/s\n", "g = 9.81;\t\t\t #acceleration due to gravity in m/s**2\n", "\n", "# Calculations\n", "hi = 2747.5\n", "he = 2706.3\n", "ve = 0.8854\n", "Zi = 0;\t\t\n", "Ze = 0;\t\t\n", "Q = 0;\t\t\n", "Ws = 0;\t\t\n", "Ve = math.sqrt (2*(((Q-Ws)/m)-(g*(Zi-Ze))-((he*10**3)-(hi*10**3)))+(Vi**2))\n", "A = (m*ve)/Ve\n", "\n", "# Results\n", "print ' The velocity of dry saturated steam at the exit = %0.2f m/s'%(Ve);\n", "print ' The cross sectional area of the nozzle at the exit = %0.3e m**2'%(A);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The velocity of dry saturated steam at the exit = 287.07 m/s\n", " The cross sectional area of the nozzle at the exit = 3.084e-03 m**2\n" ] } ], "prompt_number": 19 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.18 Page No : 123" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "T1 = 270.\t\t\t #temperature of wet steam in degree celsius\n", "T2 = 120.\t\t\t #final temperature of superheated steam in degree celsius\n", "P = 0.1;\t\t\t #pressure of superheated steam in MPa\n", "\n", "# Calculations\n", "hf = 1185.2 \t\t\t\n", "hg = 2789.9\t \t\t\n", "he = 2716.04\t\t\t\n", "Xi = (he-hf)/(hg-hf);\t\n", "\n", "# Results\n", "print ' The quality of wet steam = %0.3f '%(Xi);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The quality of wet steam = 0.954 \n" ] } ], "prompt_number": 20 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.20 Page No : 128" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "del_H = -90.135;\t\t\t #standard enthalpy change for the reaction CO(g)+2H2(g)--->CH3OH(g) at 298.15K in kJ\n", "\n", "# Calculations\n", "del_H1 = 2*del_H\n", "del_H2 = (1./2)*del_H\n", "\n", "# Results\n", "print ' The standard enthalpy change for the reaction 2COg)+4H2g)---->2CH3OHg \\\n", ") at 298.15K = %0.2f kJ'%(del_H1);\n", "print ' The standard enthalpy change for the reaction 1./2)COg)+H2g)---->1./2\\\n", ")CH3OHg) at 298.15K = %0.4f kJ'%(del_H2 );\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The standard enthalpy change for the reaction 2COg)+4H2g)---->2CH3OHg ) at 298.15K = -180.27 kJ\n", " The standard enthalpy change for the reaction 1./2)COg)+H2g)---->1./2)CH3OHg) at 298.15K = -45.0675 kJ\n" ] } ], "prompt_number": 21 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.22 Page No : 130" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "del_Hf_C4H10 = -74.943;\t\t\t #smath.tan(math.radiansard enthalpy of formation of C4H10(g) at 298.15K in kJ\n", "del_Hf_CO2 = -393.978;\t\t\t #smath.tan(math.radiansard enthalpy of formation of CO2(g) at 298.15K in kJ\n", "del_Hf_H2O = -241.997;\t\t\t #smath.tan(math.radiansard enthalpy of formation of H2O(g) at 298.15K in kJ\n", "\n", "# Calculations\n", "\n", "del_Hr = (5*del_Hf_H2O)+(4*del_Hf_CO2)-(del_Hf_C4H10);\n", "\n", "# Results\n", "print ' The standard enthalpy change for the reaction C4H10g)+13\\\n", "/2)O2g)---->4CO2g)+5H2Og) at 298.15K = %0.3f kJ'%(del_Hr);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The standard enthalpy change for the reaction C4H10g)+13/2)O2g)---->4CO2g)+5H2Og) at 298.15K = -2710.954 kJ\n" ] } ], "prompt_number": 22 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.23 Page No : 131" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "del_Hf_C4H10 = -74.943;\t\t\t #smath.tan(math.radiansard enthalpy of formation of C4H10(g) at 298.15K in kJ\n", "del_Hf_CO2 = -393.978;\t\t\t #smath.tan(math.radiansard enthalpy of formation of CO2(g) at 298.15K in kJ\n", "del_Hf_H2O = -241.997;\t\t\t #smath.tan(math.radiansard enthalpy of formation of H2O(g) at 298.15K in kJ\n", "del_H_vap = 43.966;\t\t\t #enthalpy of vaporization of H2O at 298.15K in kJ/mol\n", "\n", "# Calculations\n", "\n", "del_H1 = 0.\n", "del_H2 = 5*(-del_H_vap)\n", "del_H3 = 0.\n", "\n", "del_H = (5*del_Hf_H2O)+(4*del_Hf_CO2)-(del_Hf_C4H10);\n", "del_net_H = (del_H)+(del_H1)+(del_H2)+(del_H3)\n", "\n", "# Results\n", "print ' The standard enthalpy change for the reaction C4H10g)+13/2)O2g)---->4CO2g\\\n", ")+5H2Ol) at 298.15K = %0.3f kJ'%(del_net_H);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The standard enthalpy change for the reaction C4H10g)+13/2)O2g)---->4CO2g)+5H2Ol) at 298.15K = -2930.784 kJ\n" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.24 Page No : 132" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "del_H_comb = 2880.44;\t\t\t #gross heating value of n-buatne gas at 298.15K in kJ/mol\n", "del_Hf_CO2 = -393.978;\t\t\t #standard enthalpy of formation of CO2(g) at 298.15K in kJ\n", "del_Hf_H2O = -285.958;\t\t\t #standard enthalpy of formation of H2O(l) at 298.15K in kJ\n", "del_Hf_O2 = 0.;\t\t \t #standard enthalpy of formation of O2(g) at 298.15K in kJ\n", "\t\t\t \n", "# Calculations\n", "n_CO2 = 4.\n", "n_H2O = 5.\n", "n_O2 = -13./2\n", "n_C4H10 = -1.\n", "\t\t\t \n", "del_Hf_C4H10 = (n_CO2*del_Hf_CO2)+(n_H2O*del_Hf_H2O)+(n_O2*del_Hf_O2)-(-del_H_comb);\n", "\n", "\n", "# Results\n", "print ' The standard enthalpy of formation of n-butane gas at 298.15K = %0.3f kJ'%(del_Hf_C4H10);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The standard enthalpy of formation of n-butane gas at 298.15K = -125.262 kJ\n" ] } ], "prompt_number": 24 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.25 Page No : 133" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "del_Hc_A = -890.94;\t\t\t #enthalpy change accompanying reaction A in kJ\n", "del_Hc_B = -283.18;\t\t\t #enthalpy change accompanying reaction B in kJ\n", "del_Hc_C = -286.03;\t\t\t #enthalpy change accompanying reaction C in kJ\n", "del_H_vap = -43.966;\t\t\t #enthalpy change of vaporization of H2O at 298.15K in kJ/mol\n", "\n", "# Calculations\n", "del_H0 = (del_Hc_A)-(del_Hc_B)-(3*del_Hc_C)+(del_H_vap)\n", "\n", "# Results\n", "print ' The standard enthalpy change at 298.15K for the reaction \\\n", "CH4g)+H2Og)--->COg)+3H2g) = %0.3f kJ'%(del_H0);\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The standard enthalpy change at 298.15K for the reaction CH4g)+H2Og)--->COg)+3H2g) = 206.364 kJ\n" ] } ], "prompt_number": 25 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.26 Page No : 135" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "#The reaction is : C2H4(g)+H2O(g)--->C2H5OH(g)\n", "del_H_vap = 43.82\n", "\n", "del_Hf = [52.335,-241.997,0,-277.819]\n", "a = [4.196,28.850,20.691,0]\t\n", "b = [154.565*10**-3,12.055*10**-3,205.346*10**-3,0]\n", "c = [-81.076*10**-6,0,-99.793*10**-6,0]\n", "d = [16.813*10**-9,0,18.825*10**-9,0]\t\n", "e = [0,1.006*10**5,0,0];\t\t\n", "\n", "T1 = 298.15\t\t\n", "T2 = 400.\t\t\t\n", "n_C2H4 = -1.\n", "n_H2O = -1.\n", "n_C2H5OH = 1.\n", "\n", "# Calculations\n", "\n", "del_Hf_C2H5OH_g = del_Hf[3]+del_H_vap;\n", "del_Hr = (n_C2H5OH*del_Hf_C2H5OH_g)+(n_C2H4*del_Hf[0])+(n_H2O*del_Hf[1])\n", "del_a = (n_C2H4*a[0])+(n_H2O*a[1])+(n_C2H5OH*a[2])\t\t\t \n", "del_b = (n_C2H4*b[0])+(n_H2O*b[1])+(n_C2H5OH*b[2])\t\t\t \n", "del_c = (n_C2H4*c[0])+(n_H2O*c[1])+(n_C2H5OH*c[2])\t\t\t \n", "del_d = (n_C2H4*d[0])+(n_H2O*d[1])+(n_C2H5OH*d[2])\t\t\t \n", "del_e = (n_C2H4*e[0])+(n_H2O*e[1])+(n_C2H5OH*e[2])\t\t\t \n", "del_H0 = (del_Hr*10**3)-((del_a*T1)+((del_b/2)*T1**2)+((del_c/3)*T1**3)+((del_d/4)*T1**4)-(del_e/T1))\n", "del_Hr_T2 = (del_H0+((del_a*T2)+((del_b/2)*T2**2)+((del_c/3)*T2**3)+((del_d/4)*T2**4)-(del_e/T2)))*10**-3;\n", "\n", "# Results\n", "print ' The standard enthalpy change at 400K for the reaction\\\n", " C2H4g)+H2Og)--->C2H5OHg) = %f kJ'%(del_Hr_T2);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The standard enthalpy change at 400K for the reaction C2H4g)+H2Og)--->C2H5OHg) = -44.529472 kJ\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.28 Page No : 137" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "# Variables\n", " \n", "#The combustion reaction of methane is given by:\n", "# CH4(g)+2O2(g)--->CO2(g)+2H2O(g)\n", "\n", "n_O2 = 2.\t\t\t # stoichiometric amount of oxygen required for combustion\n", "n_CH4 = 1.\t\t\t #number of moles of CH4(g) in moles\n", "n_CO2 = 1.\t\t\t #number of moles of CO2(g) formed in the combustion reaction in moles\n", "n_H2O = 2.\t\t\t #number of moles of H2O(g) formed in the combustion reaction in moles\n", "del_Hf = [-74.943,0,-393.978,-241.997];\t\t\t # standard enthalpies of formation of CH4(g),O2(g),CO2(g),H2O(g) at 298.15K in kJ\n", "a = [45.369,28.850,30.255,27.270];\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g),H2O(g),O2(g),N2(g) in J/molK\n", "b = [8.688*10**-3,12.055*10**-3,4.207*10**-3,4.930*10**-3];\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g),H2O(g),O2(g),N2(g) in J/molK\n", "c = [0,0,0,0]; \t \t\t #coefficients to compute isobaric molar heat capacity of CO2(g),H2O(g),O2(g),N2(g) in J/molK\n", "d = [0,0,0,0];\t \t \t #coefficients to compute isobaric molar heat capacity of CO2(g),H2O(g),O2(g),N2(g) in J/molK\n", "e = [-9.619*10**5,1.006*10**5,-1.887*10**5,0.333*10**5];\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g),H2O(g),O2(g),N2(g) in J/molK\n", "per_excess_air = 50. \t\t\t #percentage excess of air supplied to the adiabatic burner\n", "T_amb = 298.15\t\t\t # temperature at which air and methane enter the burner in K\n", "per_N2 = 79.\t\t\t #percentage of N2 in the air supplied\n", "per_O2 = 21.\t\t\t #percentage of O2 in the air supplied\n", "\n", "# Calculations\n", "n_O2_actual = (1+(per_excess_air/100))*n_O2\n", "n_N2 = n_O2_actual*(per_N2/per_O2);\t\t\t\n", "n_O2_residual = n_O2_actual-n_O2;\t\t\t\n", "\n", "del_Hr = (n_CO2*del_Hf[2])+(n_H2O*del_Hf[3])-(n_O2*del_Hf[1])-(n_CH4*del_Hf[0])\n", "\n", "del_a = (n_CO2*a[0])+(n_H2O*a[1])+(n_O2_residual*a[2])+(n_N2*a[3])\n", "del_b = (n_CO2*b[0])+(n_H2O*b[1])+(n_O2_residual*b[2])+(n_N2*b[3])\n", "del_c = (n_CO2*c[0])+(n_H2O*c[1])+(n_O2_residual*c[2])+(n_N2*c[3])\n", "del_d = (n_CO2*d[0])+(n_H2O*d[1])+(n_O2_residual*d[2])+(n_N2*d[3])\n", "del_e = (n_CO2*e[0])+(n_H2O*e[1])+(n_O2_residual*e[2])+(n_N2*e[3]);\t\n", "tguess = 500.\n", "\n", "def solver_func(ti):\n", " return (-(del_Hr*10**3))-((del_a*(ti-T_amb))+((del_b/2)*((ti**2)-(T_amb**2)))+((del_c/3)*((ti**3)-(T_amb**3)))+((del_d/4)*((ti**4)-(T_amb**4)))+(del_e*((1./T_amb)-(1./ti))));\n", "\n", "T = fsolve(solver_func,tguess)\n", "\n", "# Results\n", "print ' The flame temperature when methane is burned with 50 percent excess air \\\n", "in an adiabatic burner = %f K'%(T);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The flame temperature when methane is burned with 50 percent excess air in an adiabatic burner = 1793.784965 K\n" ] } ], "prompt_number": 29 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 4.29 Page No : 139" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# Variables\n", "T_exit = 550.\t\t\t #temperature in K at which the combustion products leave the boiler\n", "percent_molar_comp_prdct = [6.28,3.14,7.85,82.73];\t\t\t # percentage molar composition of the combustion products CO2(g),CO(g),O2(g),N2(g) on dry basis\n", "T_ent = 298.15;\t\t\t #temperature in K at which Propane and air enter the combustion chamber\n", "del_Hf = [-393.978,-110.532,-241.997,0,0,-103.833];\t\t\t #smath.tan(math.radiansard enthalpies of formation of CO2(g),CO(g),H2O(g),O2(g),N2(g),C3H8(g) at 298.15K in kJ\n", "a = [45.369,28.068,30.255,27.270,28.850];\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g),CO(g),O2(g),N2(g),H2O(g) in J/molK\n", "\n", "#coefficients to compute isobaric molar heat capacity of CO2(g),CO(g),O2(g),N2(g),H2O(g) in J/molK\n", "b = [8.688*10**-3,4.631*10**-3,4.207*10**-3,4.930*10**-3,12.055*10**-3];\n", "c = [0,0,0,0,0];\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g),CO(g),O2(g),N2(g),H2O(g) in J/molK\n", "d = [0,0,0,0,0];\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g),CO(g),O2(g),N2(g),H2O(g) in J/molK\n", "e = [-9.619*10**5,-0.258*10**5,-1.887*10**5,0.333*10**5,1.006*10**5];\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g),CO(g),O2(g),N2(g),H2O(g) in J/molK\n", "per_N2 = 79.\t\t\t #percentage of nitrogen in air\n", "per_O2 = 21.\t\t\t #percentage of oxygen in air\n", "molar_mass_propane = 44.*10**-3;\t\t\t #molar mass of propane in kg/mole\n", "\n", "# Calculations\n", "# TAKE BASIS AS 100 mol OF DRY COMBUSTION PRODUCTS\n", "n_CO2 = percent_molar_comp_prdct[0]\t\t\t #number of moles of CO2(g) in the product stream\n", "n_CO = percent_molar_comp_prdct[1]\t\t\t #number of moles of CO(g) in the product stream\n", "n_O2 = percent_molar_comp_prdct[2]\t\t\t #number of moles of O2(g) in the product stream\n", "n_N2 = percent_molar_comp_prdct[3]\t\t\t #number of moles of N2(g) in the product stream\n", "\n", "x = (n_CO2+n_CO)/3;\n", "\n", "y = (2*n_N2)/(2*(per_N2/per_O2));\n", "\n", "z = (2*y)-(2*n_CO2)-(n_CO)-(2*n_O2);\n", "\n", "n_H2O = z\n", "n_C3H8 = x\n", "\n", "del_Hr = (n_CO2*del_Hf[0])+(n_CO*del_Hf[1])+(n_H2O*del_Hf[2])-(n_C3H8*del_Hf[5]);\n", "\n", "del_a = (n_CO2*a[0])+(n_CO*a[1])+(n_O2*a[2])+(n_N2*a[3])+(n_H2O*a[4])\t\n", "del_b = (n_CO2*b[0])+(n_CO*b[1])+(n_O2*b[2])+(n_N2*b[3])+(n_H2O*b[4])\t\n", "del_c = (n_CO2*c[0])+(n_CO*c[1])+(n_O2*c[2])+(n_N2*c[3])+(n_H2O*c[4])\t\n", "del_d = (n_CO2*d[0])+(n_CO*d[1])+(n_O2*d[2])+(n_N2*d[3])+(n_H2O*d[4])\t\n", "del_e = (n_CO2*e[0])+(n_CO*e[1])+(n_O2*e[2])+(n_N2*e[3])+(n_H2O*e[4])\t\n", "\n", "#calulation of del_Hp J\n", "del_Hp = (del_a*(T_exit-T_ent))+((del_b/2)*((T_exit**2)-(T_ent**2)))+((del_c/3)*((T_exit**3)-(T_ent**3)))+((del_d/4)*((T_exit**4)-(T_ent**4)))-(del_e*((1./T_exit)-(1./T_ent)));\n", "del_H = ((del_Hr*10**3)+(del_Hp))*10**-3;\t\t\t \n", "mass_propane = n_C3H8*molar_mass_propane;\t\t\t \n", "energy = (-(del_H*10**3)/mass_propane)*10**-6;\t\t\n", " \n", "# Results\n", "print ' The energy transferred as heat per kg propane = %f MJ'%(energy); \n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The energy transferred as heat per kg propane = 33.741510 MJ\n" ] } ], "prompt_number": 31 } ], "metadata": {} } ] }