{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 10: Properties of gases and gas mixture" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.1:pg-366" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.1\n", "\n", "\n", " The final equilibrium pressure is 1.16869318853 MPa\n", "\n", " The amount of heat transferred to the surrounding is -226.04503125 kJ\n", " \n", "\n", " If the vessel is perfectly insulated\n", "\n", " The final temperature is 45.4545454545 degree Celsius\n", "\n", " The final pressure is 1.24058552709 MPa\n" ] } ], "source": [ "import math\n", "Pa = 1.5 # Pressure in vessel A in MPa\n", "Ta = 50 # Temperature in vessel A in K\n", "ca = 0.5 # Content in vessel A in kg mol\n", "Pb = 0.6 # Pressure in vessel B in MPa\n", "Tb = 20 # Temperature in vessel B in K\n", "mb = 2.5 # Content in vessel B in kg mol\n", "R = 8.3143 # Universal gas constant\n", "Va = (ca*R*(Ta+273))/(Pa*1e03) # volume of vessel A\n", "ma = ca*28 # mass of gas in vessel A\n", "Rn = R/28 # Gas content to of nitrogen\n", "Vb = (mb*Rn*(Tb+273))/(Pb*1e03) # volume of vessel B\n", "V = Va + Vb # Total volume\n", "m = ma + mb # Total mass\n", "Tf = 27 # Equilibrium temperature in degree Celsius\n", "P = (m*Rn*(Tf+273))/V # Equilibrium pressure \n", "g = 1.4 # Heat capacity ratio\n", "cv = Rn/(g-1) # Heat capacity at constant volume\n", "U1 = cv*(ma*Ta+mb*Tb) # Initial internal energy \n", "U2 = m*cv*Tf# Final internal energy \n", "Q = U2-U1 # heat transferred\n", "\n", "print \"\\n Example 10.1\"\n", "print \"\\n\\n The final equilibrium pressure is \",P/1e3 ,\" MPa\"\n", "print \"\\n The amount of heat transferred to the surrounding is \",Q ,\" kJ\"\n", "#The answers vary due to round off error\n", "\n", "T_ = (ma*Ta+mb*Tb)/m # final temperature\n", "P_ = (m*Rn*(T_+273))/V # final pressure\n", "print \" \\n\\n If the vessel is perfectly insulated\"\n", "print \"\\n The final temperature is \",T_ ,\" degree Celsius\"\n", "print \"\\n The final pressure is \",P_/1e3 ,\" MPa\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.2:pg-368" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.2\n", "\n", "\n", " Gas constant of the gas is 0.461 kJ/kg K \n", "\n", " Molecular weight the gas is 18.0347071584 kg/kg mol\n", "\n", " The heat transfer at constant volume is 286.33 kJ\n", "\n", " Work done is 0 kJ\n", "\n", " The change in internal energy is 286.33 kJ\n", "\n", " The change in enthalpy is 373.92 kJ\n", "\n", " The change in entropy is 0.885987320143 kJ/k\n" ] } ], "source": [ "import math\n", "cp = 1.968 # Heat capacity in kJ/kg\n", "cv = 1.507 # Heat capacity in kJ/kg\n", "R_ = 8.314 # Gas constant\n", "V = 0.3 # Volume of chamber in m**3\n", "m = 2 # mass of gas in kg\n", "T1 = 5.0# Initial gas temperature in degree Celsius\n", "T2 = 100.0 # Final gas temperature in degree Celsius\n", "R = cp-cv # Universal gas constant\n", "mu = R_/R # molecular weight\n", "Q12 = m*cv*(T2-T1) # The heat transfer at constant volume\n", "W12 = 0 # work done\n", "U21 = Q12 # change in internal energy\n", "H21= m*cp*(T2-T1) # change in enthalpy\n", "S21 = m*cv*math.log((T2+273)/(T1+273)) #change in entropy \n", "\n", "print \"\\n Example 10.2\"\n", "print \"\\n\\n Gas constant of the gas is \",R ,\" kJ/kg K \"\n", "print \"\\n Molecular weight the gas is \",mu ,\" kg/kg mol\"\n", "print \"\\n The heat transfer at constant volume is \",Q12 ,\" kJ\"\n", "print \"\\n Work done is \",0 ,\" kJ\"\n", "print \"\\n The change in internal energy is \",U21 ,\" kJ\"\n", "print \"\\n The change in enthalpy is \",H21 ,\" kJ\"\n", "print \"\\n The change in entropy is \",S21 ,\" kJ/k\"\n", "#The answers vary due to round off error\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.3:pg-369" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.3\n", "\n", " The work done in the expansion is 300.72200185 kJ\n" ] } ], "source": [ "import math\n", "from scipy import integrate\n", "m = 1.5 # Mass of gas in kg\n", "P1 = 5.6 # Initial pressure of gas in MPa\n", "V1 = 0.06 # Initial volume of gas in m**3\n", "T2_ = 240 # Final temperature of gas in degree Celsius\n", "a = 0.946 # Constant\n", "b = 0.662 # Constant\n", "k = 1e-4 # Constant\n", "# Part (b)\n", "R = a-b # constant\n", "T2 = T2_+273 # Final temperature of gas in KK\n", "T1 = (P1*1e03*V1)/(m*R) # Initial temperature\n", "W12,er =integrate.quad(lambda T:m*(b+k*T),T1,T2) # Work done\n", "\n", "print \"\\n Example 10.3\"\n", "print \"\\n The work done in the expansion is \",-W12 ,\" kJ\"\n", "#The answers vary due to round off error\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.5:pg-371" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.5\n", "\n", " The work transfer for the whole path is 93.4986082985 kJ\n", "\n", " The heat transfer for the whole path 571.638005316 kJ\n" ] } ], "source": [ "import math\n", "m = 0.5 # mass of air in kg\n", "P1 = 80 # Initial pressure kPa\n", "T1 = 60 # Initial temperature in degree Celsius\n", "P2 = 0.4 # Final pressure in MPa\n", "R = 0.287 # Gas constant\n", "V1 = (m*R*(T1+273))/(P1) # Volume of air at state 1\n", "g = 1.4 # Heat capacity ratio\n", "T2 = (T1+273)*(P2*1e3/P1)**((g-1)/g)# Final temperature\n", "W12 = (m*R*(T1+273-T2))/(g-1) # Work done in \n", "V2 = V1*((P1/(P2*1e3))**(1/g)) # Final volume\n", "W23 = P2*(V1-V2)*1e3 # # Work done\n", "W = W12+W23 # Net work done\n", "V3 = V1 # constant volume\n", "T3 = (T2)*(V3/V2) # Temperature at state 3\n", "cp = 1.005 # Heat capacity at constant volume in kJ/kgK\n", "Q = m*cp*(T3-T2)# Heat transfer\n", "print \"\\n Example 10.5\"\n", "print \"\\n The work transfer for the whole path is \",W ,\" kJ\"\n", "#The answers vary due to round off error\n", "print \"\\n The heat transfer for the whole path \",Q ,\" kJ\"\n", "#The answer provided in the textbook is wrong\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.6:pg-372" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.6\n", "\n", " The heat received in the cycle is 137.268292683 kJ\n", "\n", " The heat rejected in the cycle 84.2666952566 kJ\n", "\n", " The efficiency of the cycle is 39.0 percent\n" ] } ], "source": [ "import math\n", "P1 = 700 # Initial pressure of gas in kPa\n", "T1 = 260 # Initial temperature of gas in degree Celcius \n", "T3 = T1 # Temperature at state 3\n", "V1 = 0.028 # Initial volume of gas in m**3\n", "V2 = 0.084 # Final volume of gas in m**3\n", "R = 0.287 # Gas constant\n", "m = (P1*V1)/(R*(T1+273)) # mass of gas \n", "P2 = P1 # Pressure at state 2\n", "T2 = (T1+273)*((P2*V2)/(P1*V1)) # Temperature at state 2\n", "n = 1.5 # polytropic index \n", "P3 = P2*(((T3+273)/(T2))**(n/(n-1))) # Pressure at state 3\n", "cp = 1.005 # COnstant pressure heat capacity in kJ/kgK\n", "cv = 0.718 # COnstant volume heat capacity in kJ/kgK\n", "Q12 = m*cp*(T2-T1-273) # HEat transfer\n", "Q23 = m*cv*(T3+273-T2) + (m*R*(T2-T3-273))/(n-1) # Heat transfer\n", "Q31 = m*R*(T1+273)*math.log(P3/P2) # Heat transfer\n", "Q1 = Q12 # Heat equivalance\n", "Q2 = -(Q23+Q31) # Net heat transfer\n", "e = 1-(Q2/Q1) # First law efficiency\n", "\n", "print \"\\n Example 10.6\"\n", "print \"\\n The heat received in the cycle is \",Q1 ,\" kJ\"\n", "print \"\\n The heat rejected in the cycle \",Q2 ,\" kJ\"\n", "print \"\\n The efficiency of the cycle is \",math. ceil(e*100) ,\" percent\"\n", "#The answers vary due to round off error" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.7:pg-374" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.7\n", "\n", " Cv of the gas is 0.661000944287 kJ/kg K\n", "\n", " Cp of the gas is 0.89896128423 kJ/kg K\n", "\n", " Increase in the entropy of the gas is 0.080159241414 kJ/kg K\n" ] } ], "source": [ "import math\n", "P1 = 300 # Initial gas pressure in kPa\n", "V1 = 0.07 # Initial volume of gas in m**3\n", "m = 0.25 # Mass of gas in kg\n", "T1 = 80 # Initial temperature of gas in degree Celsius\n", "R = (P1*V1)/(m*(T1+273)) # constant\n", "P2 = P1 # process condition\n", "V2 = 0.1 # Final volume in m**3\n", "T2 = (P2*V2)/(m*R) # Final temperature in K\n", "W = -25 #Work done in kJ\n", "cv = -W/(m*(T2-T1-273)) # Constant volume heat capacity in kJ/kg\n", "cp = R+cv #Constant pressure heat capacity in kJ/kg\n", "S21 = m*cp*math.log(V2/V1) # Entropy change\n", "print \"\\n Example 10.7\"\n", "print \"\\n Cv of the gas is \",cv ,\" kJ/kg K\"\n", "print \"\\n Cp of the gas is \",cp ,\" kJ/kg K\"\n", "print \"\\n Increase in the entropy of the gas is \",S21 ,\" kJ/kg K\"\n", "#The answers vary due to round off error\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.8:pg-374" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.8\n", "\n", "\n", " Mole fraction of N2 is 0.485294117647\n", "\n", " Mole fraction of CO2 is 0.514705882353\n", "\n", " Equivalent molecular weight of mixture is 36.2352941176 kg/kg mol\n", "\n", "\n", " The equivalent gas constant of the mixture is 0.229444805195 kJ/kg K\n", "\n", "\n", " Partial pressures of nitrogen and CO2 are \n", " 145.588235294 kPa and 154.411764706 kPa respectively\n", "\n", " Partial volume of nitrogen and CO2 are \n", " 0.870000714286 kPa and 0.922728030303 kPa respectively\n", "\n", "\n", " Total volume of mixture is 1.79272874459 m**3\n", "\n", " Density of mixture is 4.46247098126 kg/m**3\n", "\n", "\n", " Cp and Cv of mixture are \n", " 0.920740483948 kJ/kg K and 0.691295678753 kJ/kg K respectively\n", "\n", "\n", " Change in internal energy of the system heated at constant volume is 110.6073086 kJ\n", "\n", " Change in enthalpy of the system heated at constant volume is 147.318477432 kJ\n", "\n", " Change in entropy of the system heated at constant volume is 0.36517324538 kJ/kg K\n", "\n", "\n", " Change in entropy of the system heated at constant Pressure is 0.486376236695 kJ/kgK\n" ] } ], "source": [ "import math\n", "mn = 3.0 # Mass of nitrogen in kg\n", "mc = 5.0 # mass of CO2 in kg\n", "an = 28.0 # Atomic weight of nitrogen\n", "ac = 44.0 # Atomic weight of CO2\n", "# Part (a)\n", "xn = (mn/an)/((mn/an)+(mc/ac)) # mole fraction of nitrogen\n", "xc = (mc/ac)/((mn/an)+(mc/ac)) # mole fraction of carbon\n", "\n", "print \"\\n Example 10.8\"\n", "print \"\\n\\n Mole fraction of N2 is \",xn \n", "print \"\\n Mole fraction of CO2 is \",xc\n", "#The answers vary due to round off error\n", "\n", "# Part (b)\n", "M = xn*an+xc*ac # Equivalent molecular weight\n", "print \"\\n Equivalent molecular weight of mixture is \",M ,\"kg/kg mol\" \n", "\n", "# Part (c)\n", "R = 8.314 # Gas constant\n", "Req = ((mn*R/an)+(mc*R/ac))/(mn+mc)\n", "print \"\\n\\n The equivalent gas constant of the mixture is \",Req ,\" kJ/kg K\" \n", "\n", "# Part (d)\n", "P = 300.0 # Initial pressure in kPa\n", "T = 20.0 # Initial temperature in degree Celsius\n", "Pn = xn*P # Partial pressure of Nitrogen\n", "Pc = xc*P # Partial pressure of CO2 \n", "Vn = (mn*R*(T+273))/(P*an) # Volume of nitrogen\n", "Vc = (mc*R*(T+273))/(P*ac) # Volume of CO2\n", "print \"\\n\\n Partial pressures of nitrogen and CO2 are \\n \",Pn ,\" kPa and \",Pc ,\" kPa respectively\"\n", "print \"\\n Partial volume of nitrogen and CO2 are \\n \",Vn ,\" kPa and \",Vc ,\" kPa respectively\"\n", "# Part (e)\n", "V = (mn+mc)*Req*(T+273)/P # Total volume\n", "rho = (mn+mc)/V # mass density\n", "print \"\\n\\n Total volume of mixture is \",V ,\" m**3\" \n", "print \"\\n Density of mixture is \",rho ,\" kg/m**3\" \n", "\n", "# Part (f)\n", "gn = 1.4 # Heat capacity ratio for nitrogen\n", "gc = 1.286 # Heat capacity ratio for carbon dioxide \n", "cvn = R/((gn-1)*an) # cp and cv of N2\n", "cpn = gn*cvn # Constant pressure heat capacity of nitrogen\n", "cvc = R/((gc-1)*ac) # cp and cv of CO2\n", "cpc = gc*cvc# COnstant pressure heat capacity of carbon dioxide \n", "cp = (mn*cpn+mc*cpc)/(mn+mc) # Constant pressure heat capacity ratio of mixture\n", "cv = (mn*cvn+mc*cvc)/(mn+mc) # Constant volume Heat capacity ratio of mixture\n", "print \"\\n\\n Cp and Cv of mixture are \\n \",cp ,\"kJ/kg K and \",cv ,\"kJ/kg K respectively\" \n", "T1 = T \n", "T2 = 40 \n", "U21 = (mn+mc)*cv*(T2-T1)\n", "H21 = (mn+mc)*cp*(T2-T1)\n", "S21v = (mn+mc)*cv*math.log((T2+273)/(T1+273)) # If heated at constant volume\n", "S21p = (mn+mc)*cp*math.log((T2+273)/(T1+273)) # If heated at constant Pressure\n", "\n", "print \"\\n\\n Change in internal energy of the system heated at constant volume is \",U21 ,\"kJ\" \n", "print \"\\n Change in enthalpy of the system heated at constant volume is \",H21 ,\"kJ\" \n", "print \"\\n Change in entropy of the system heated at constant volume is \",S21v ,\" kJ/kg K\"\n", "print \"\\n\\n Change in entropy of the system heated at constant Pressure is \",S21p ,\"kJ/kgK\" \n", "\n", "#The answers vary due to round off error\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.9:pg-375" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.9\n", "\n", " Increase in entropy is 1.22920562691 kJ/kg K\n" ] } ], "source": [ "import math\n", "mo = 2.0 # mass of oxygen in kg\n", "mn = 6.0 # mass of nitrogen in kg\n", "muo = 32.0 # molecular mass of oxygen\n", "mun = 28.0 # molecular mass of nitrogen\n", "o = mo/muo # mass fraction of oxygen\n", "n = mn/mun # mass fraction of nitrogen\n", "xo = o/(n+o) # mole fraction of oxygen\n", "xn = n/(n+o) # mole fraction of nitrogen\n", "R = 8.314 # Universal gas constant\n", "Ro = R/muo # Gas constant for oxygen\n", "Rn = R/mun # Gas constant for nitrogen\n", "dS = -mo*Ro*math.log(xo)-mn*Rn*math.log(xn) # Increase in entropy \n", "\n", "print \"\\n Example 10.9\"\n", "print \"\\n Increase in entropy is \",dS ,\" kJ/kg K\"\n", "#The answers vary due to round off error\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ex10.10:pg-376" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Example 10.10\n", "\n", " Specific volume is 3.05515367719 *10**-3 m3/kg\n", "\n", " Specific temperature is 57.85 K\n", "\n", " Specific pressure is 5.46 MPa\n", "\n", " Reduced volume is 1.48226362179 m3/kg\n" ] } ], "source": [ "import math\n", "an = 20.183 # molecular weight of neon\n", "Pc = 2.73 # Critical pressure\n", "Tc = 44.5 # Critical tmperature in Kelvin\n", "Vc = 0.0416 # volume of gas in m**3\n", "Pr = 2 # Reduced Pressure\n", "Tr = 1.3 # Reduced temperature\n", "Z = 0.7 # Compressibility factor\n", "P = Pr*Pc # Corresponding Pressure \n", "T = Tr*Tc # Corresponding temperature\n", "R = 8.314 # Gas constant\n", "v = (Z*R*T)/(P*an) # Corresponding volume\n", "vr = (v*an)/(Vc*1e3) # reduced volume\n", "\n", "print \"\\n Example 10.10\"\n", "print \"\\n Specific volume is \",v ,\" *10**-3 m3/kg\"\n", "print \"\\n Specific temperature is \",T ,\" K\"\n", "print \"\\n Specific pressure is \",P ,\" MPa\"\n", "print \"\\n Reduced volume is \",vr ,\" m3/kg\"\n", "#The answers vary due to round off error\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }