{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 5:Entropy" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.1;pg no: 144" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.1, Page:144 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 1\n", "entropy change may be given as,\n", "s2-s1=((Cp_air*log(T2/T1)-(R*log(p2/p1))\n", "here for throttling process h1=h2=>Cp_air*T1=Cp_air*T2=>T1=T2\n", "so change in entropy(deltaS)in KJ/kg K\n", "deltaS= 0.263\n" ] } ], "source": [ "#cal of deltaS\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.1, Page:144 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 1\")\n", "p1=5.;#initial pressure of air\n", "T1=(27.+273.);#temperature of air in K\n", "p2=2.;#final pressure of air in K\n", "R=0.287;#gas constant in KJ/kg K\n", "Cp_air=1.004;#specific heat of air at constant pressure in KJ/kg K\n", "print(\"entropy change may be given as,\")\n", "print(\"s2-s1=((Cp_air*log(T2/T1)-(R*log(p2/p1))\")\n", "print(\"here for throttling process h1=h2=>Cp_air*T1=Cp_air*T2=>T1=T2\")\n", "print(\"so change in entropy(deltaS)in KJ/kg K\")\n", "deltaS=(Cp_air*0)-(R*math.log(p2/p1))\n", "print(\"deltaS=\"),round(deltaS,3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.2;pg no: 144" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.2, Page:144 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 2\n", "total entropy change=entropy change during water temperature rise(deltaS1)+entropy change during water to steam change(deltaS2)+entropy change during steam temperature rise(deltaS3)\n", "deltaS1=Q1/T1,where Q1=m*Cp*deltaT\n", "heat added for increasing water temperature from 27 to 100 degree celcius(Q1)in KJ\n", "Q1= 1533.0\n", "deltaS1=Q1/T1 in KJ/K 5.11\n", "now heat of vaporisation(Q2)=in KJ 11300.0\n", "entropy change during phase transformation(deltaS2)in KJ/K\n", "deltaS2= 30.29\n", "entropy change during steam temperature rise(deltaS3)in KJ/K\n", "deltaS3=m*Cp_steam*dT/T\n", "here Cp_steam=R*(3.5+1.2*T+0.14*T^2)*10^-3 in KJ/kg K\n", "R=in KJ/kg K 0.46\n", "now deltaS3=(m*R*(3.5+1.2*T+0.14*T^2)*10^-3)*dT/T in KJ/K\n", "total entropy change(deltaS) in KJ/K= 87.24\n" ] } ], "source": [ "#cal of COP\n", "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.2, Page:144 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 2\")\n", "import scipy\n", "from scipy import integrate\n", "##just an example function\n", "def fun1(x):\n", "\ty=x*x\n", "\treturn y\n", "\n", "T1=(27.+273.);#temperature of water in K\n", "T2=(100.+273.);#steam temperature of water in K\n", "m=5.;#mass of water in kg\n", "q=2260.;#heat of vaporisation at 100 degree celcius in KJ/kg\n", "Cp=4.2;#specific heat of water at constant pressure in KJ/kg K\n", "M=18.;#molar mass for water/steam \n", "R1=8.314;#gas constant in KJ/kg K\n", "print(\"total entropy change=entropy change during water temperature rise(deltaS1)+entropy change during water to steam change(deltaS2)+entropy change during steam temperature rise(deltaS3)\")\n", "Q1=m*Cp*(T2-T1)\n", "print(\"deltaS1=Q1/T1,where Q1=m*Cp*deltaT\")\n", "print(\"heat added for increasing water temperature from 27 to 100 degree celcius(Q1)in KJ\")\n", "print(\"Q1=\"),round(Q1,2)\n", "deltaS1=Q1/T1\n", "print(\"deltaS1=Q1/T1 in KJ/K\"),round(deltaS1,2)\n", "Q2=m*q\n", "print(\"now heat of vaporisation(Q2)=in KJ\"),round(Q2,2)\n", "print(\"entropy change during phase transformation(deltaS2)in KJ/K\")\n", "deltaS2=Q2/T2\n", "print(\"deltaS2=\"),round(deltaS2,2)\n", "print(\"entropy change during steam temperature rise(deltaS3)in KJ/K\")\n", "print(\"deltaS3=m*Cp_steam*dT/T\")\n", "print(\"here Cp_steam=R*(3.5+1.2*T+0.14*T^2)*10^-3 in KJ/kg K\")\n", "R=R1/M\n", "print(\"R=in KJ/kg K\"),round(R,2)\n", "T2=(100+273.15);#steam temperature of water in K\n", "T3=(400+273.15);#temperature of steam in K\n", "print(\"now deltaS3=(m*R*(3.5+1.2*T+0.14*T^2)*10^-3)*dT/T in KJ/K\")\n", "#function y = f(T), y =(m*R*(3.5+1.2*T+0.14*T**2)*10**-3)/T , endfunction\n", "def fun1(x):\n", "\ty=(m*R*(3.5+1.2*T+0.14*T**2)*10**-3)/T\n", "\treturn y\n", "\n", "#deltaS3 =scipy.integrate.quad(f,T2, T3) \n", "deltaS3=51.84;#approximately\n", "deltaS=deltaS1+deltaS2+deltaS3\n", "print(\"total entropy change(deltaS) in KJ/K=\"),round(deltaS,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.3;pg no: 145" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.3, Page:145 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 3\n", "gas constant for oxygen(R)in KJ/kg K\n", "R= 0.26\n", "for reversible process the change in entropy may be given as\n", "deltaS=(Cp*log(T2/T1))-(R*log(p2/p1))in KJ/kg K\n", "so entropy change=deltaS= in (KJ/kg K) -0.29\n" ] } ], "source": [ "#cal of entropy change\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.3, Page:145 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 3\")\n", "R1=8.314;#gas constant in KJ/kg K\n", "M=32;#molar mass for O2 \n", "T1=(27+273);#initial temperature of O2 in K\n", "p1=125;#initial pressure of O2 in Kpa\n", "p2=375;#final pressure of O2 in Kpa\n", "Cp=1.004;#specific heat of air at constant pressure in KJ/kg K\n", "print(\"gas constant for oxygen(R)in KJ/kg K\")\n", "R=R1/M\n", "print(\"R=\"),round(R,2)\n", "print(\"for reversible process the change in entropy may be given as\")\n", "print(\"deltaS=(Cp*log(T2/T1))-(R*log(p2/p1))in KJ/kg K\")\n", "T2=T1;#isothermal process\n", "deltaS=(Cp*math.log(T2/T1))-(R*math.log(p2/p1))\n", "print(\"so entropy change=deltaS= in (KJ/kg K)\"),round(deltaS,2)\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.4;pg no: 145" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.4, Page:145 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 4\n", "entropy change in universe(deltaS_universe)=deltaS_block+deltaS_water\n", "where deltaS_block=m*C*log(T2/T1)\n", "here hot block is put into sea water,so block shall cool down upto sea water at 25 degree celcius as sea may be treated as sink\n", "therefore deltaS_block=in KJ/K -0.14\n", "heat loss by block =heat gained by water(Q)in KJ\n", "Q=-m*C*(T1-T2) -49.13\n", "therefore deltaS_water=-Q/T2 in KJ/K 0.16\n", "thus deltaS_universe=in J/K 27.16\n" ] } ], "source": [ "#cal of deltaS_universe\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.4, Page:145 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 4\")\n", "T1=(150+273.15);#temperature of copper block in K\n", "T2=(25+273.15);#temperature of sea water in K\n", "m=1;#mass of copper block in kg\n", "C=0.393;#heat capacity of copper in KJ/kg K\n", "print(\"entropy change in universe(deltaS_universe)=deltaS_block+deltaS_water\")\n", "print(\"where deltaS_block=m*C*log(T2/T1)\")\n", "print(\"here hot block is put into sea water,so block shall cool down upto sea water at 25 degree celcius as sea may be treated as sink\")\n", "deltaS_block=m*C*math.log(T2/T1)\n", "print(\"therefore deltaS_block=in KJ/K\"),round(deltaS_block,2)\n", "print(\"heat loss by block =heat gained by water(Q)in KJ\")\n", "Q=-m*C*(T1-T2)\n", "print(\"Q=-m*C*(T1-T2)\"),round(Q,2)\n", "deltaS_water=-Q/T2\n", "print(\"therefore deltaS_water=-Q/T2 in KJ/K\"),round(deltaS_water,2)\n", "deltaS_universe=(deltaS_block+deltaS_water)*1000\n", "print(\"thus deltaS_universe=in J/K\"),round(deltaS_universe,2)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.5;pg no: 146" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.5, Page:146 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 5\n", "deltaS_universe=(deltaS_block+deltaS_seawater)\n", "since block and sea water both are at same temperature so,\n", "deltaS_universe=deltaS_seawater\n", "conservation of energy equation yields,\n", "Q-W=deltaU+deltaP.E+deltaK.E\n", "since in this case,W=0,deltaK.E=0,deltaU=0\n", "Q=deltaP.E\n", "change in potential energy=deltaP.E=m*g*h in J\n", "deltaS_universe=deltaS_seawater=Q/T in J/kg K\n", "entropy change of universe(deltaS_universe)in J/kg K 6.54\n" ] } ], "source": [ "#cal of entropy change of universe\n", "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.5, Page:146 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 5\")\n", "m=1;#mass of copper block in kg\n", "T=(27+273);#temperature of copper block in K\n", "h=200;#height from which copper block dropped in sea water in m\n", "C=0.393;#heat capacity for copper in KJ/kg K\n", "g=9.81;#acceleration due to gravity in m/s^2\n", "print(\"deltaS_universe=(deltaS_block+deltaS_seawater)\")\n", "print(\"since block and sea water both are at same temperature so,\")\n", "print(\"deltaS_universe=deltaS_seawater\")\n", "print(\"conservation of energy equation yields,\")\n", "print(\"Q-W=deltaU+deltaP.E+deltaK.E\")\n", "print(\"since in this case,W=0,deltaK.E=0,deltaU=0\")\n", "deltaPE=m*g*h\n", "Q=deltaPE\n", "print(\"Q=deltaP.E\")\n", "print(\"change in potential energy=deltaP.E=m*g*h in J\")\n", "print(\"deltaS_universe=deltaS_seawater=Q/T in J/kg K\")\n", "deltaS_universe=Q/T\n", "print(\"entropy change of universe(deltaS_universe)in J/kg K\"),round(deltaS_universe,2)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.6;pg no: 146" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.6, Page:146 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 6\n", "here deltaS_universe=deltaS_block1+deltaS_block2\n", "two blocks at different temperatures shall first attain equilibrium temperature.let equilibrium temperature be Tf\n", "then from energy conservation\n", "m1*Cp_1*(T1-Tf)=m2*Cp_2*(Tf-T2)\n", "Tf=in K 374.18\n", "hence,entropy change in block 1(deltaS1),due to temperature changing from Tf to T1\n", "deltaS1=in KJ/K -0.05\n", "entropy change in block 2(deltaS2)in KJ/K\n", "deltaS2= 0.06\n", "entropy change of universe(deltaS)=in KJ/K 0.01\n" ] } ], "source": [ "#cal of entropy change of universe\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.6, Page:146 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 6\")\n", "m1=1;#mass of first copper block in kg\n", "m2=0.5;#mass of second copper block in kg\n", "T1=(150+273.15);#temperature of first copper block in K\n", "T2=(0+273.15);#temperature of second copper block in K\n", "Cp_1=0.393;#heat capacity for copper block 1 in KJ/kg K\n", "Cp_2=0.381;#heat capacity for copper block 2 in KJ/kg K\n", "print(\"here deltaS_universe=deltaS_block1+deltaS_block2\")\n", "print(\"two blocks at different temperatures shall first attain equilibrium temperature.let equilibrium temperature be Tf\")\n", "print(\"then from energy conservation\")\n", "print(\"m1*Cp_1*(T1-Tf)=m2*Cp_2*(Tf-T2)\")\n", "Tf=((m1*Cp_1*T1)+(m2*Cp_2*T2))/(m1*Cp_1+m2*Cp_2)\n", "print(\"Tf=in K\"),round(Tf,2)\n", "print(\"hence,entropy change in block 1(deltaS1),due to temperature changing from Tf to T1\")\n", "deltaS1=m1*Cp_1*math.log(Tf/T1)\n", "print(\"deltaS1=in KJ/K\"),round(deltaS1,2)\n", "print(\"entropy change in block 2(deltaS2)in KJ/K\")\n", "deltaS2=m2*Cp_2*math.log(Tf/T2)\n", "print(\"deltaS2=\"),round(deltaS2,2)\n", "deltaS=deltaS1+deltaS2\n", "print(\"entropy change of universe(deltaS)=in KJ/K\"),round(deltaS,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.7;pg no: 147" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.7, Page:147 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 7\n", "NOTE=>in this question formula is derived which cannot be solve using python software\n" ] } ], "source": [ "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.7, Page:147 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 7\")\n", "print(\"NOTE=>in this question formula is derived which cannot be solve using python software\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.8;pg no: 148" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.8, Page:148 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 8\n", "for irreversible operation of engine,\n", "rate of entropy generation=Q1/T1+Q2/T2\n", "W=Q1-Q2=>Q2=Q1-W in MW 3.0\n", "entropy generated(deltaS_gen)in MW\n", "deltaS_gen= 0.01\n", "work lost(W_lost)in MW\n", "W_lost=T2*deltaS_gen 4.0\n" ] } ], "source": [ "#cal of work lost\n", "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.8, Page:148 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 8\")\n", "T1=1800.;#temperature of high temperature reservoir in K\n", "T2=300.;#temperature of low temperature reservoir in K\n", "Q1=5.;#heat addition in MW\n", "W=2.;#work done in MW\n", "print(\"for irreversible operation of engine,\")\n", "print(\"rate of entropy generation=Q1/T1+Q2/T2\")\n", "Q2=Q1-W\n", "print(\"W=Q1-Q2=>Q2=Q1-W in MW\"),round(Q2,2)\n", "print(\"entropy generated(deltaS_gen)in MW\")\n", "deltaS_gen=Q1/T1+Q2/T2\n", "print(\"deltaS_gen=\"),round(deltaS_gen,2)\n", "Q1=-5;#heat addition in MW\n", "print(\"work lost(W_lost)in MW\")\n", "W_lost=T2*deltaS_gen\n", "print(\"W_lost=T2*deltaS_gen\"),round(W_lost)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.9;pg no: 148" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.9, Page:148 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 9\n", "system and reservoir can be treated as source and sink.device thought of can be a carnot engine operating between these two limits.maximum heat available from system shall be the heat rejected till its temperature drops from 500 K to 300 K\n", "therefore,maximum heat(Q1)=(C*dT)in J\n", "here C=0.05*T^2+0.10*T+0.085 in J/K\n", "so Q1=(0.05*T^2+0.10*T+0.085)*dT\n", "entropy change of system,deltaS_system=C*dT/T in J/K\n", "so deltaS_system=(0.05*T^2+0.10*T+0.085)*dT/T\n", "deltaS_reservoir=Q2/T2=(Q1-W)/T2 also,we know from entropy principle,deltaS_universe is greater than equal to 0\n", "deltaS_universe=deltaS_system+deltaS_reservoir\n", "thus,upon substituting,deltaS_system+deltaS_reservoir is greater than equal to 0\n", "W is less than or equal to(Q1+deltaS_system*T2)/1000 in KJ\n", "hence maximum work in KJ= 435.34\n" ] } ], "source": [ "#cal of COP\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.9, Page:148 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 9\")\n", "import scipy\n", "from scipy import integrate\n", "\n", "def fun1(x):\n", "\ty=x*x\n", "\treturn y\n", "\n", "T1=500;#temperature of system in K\n", "T2=300;#temperature of reservoir in K\n", "print(\"system and reservoir can be treated as source and sink.device thought of can be a carnot engine operating between these two limits.maximum heat available from system shall be the heat rejected till its temperature drops from 500 K to 300 K\")\n", "print(\"therefore,maximum heat(Q1)=(C*dT)in J\")\n", "print(\"here C=0.05*T^2+0.10*T+0.085 in J/K\")\n", "print(\"so Q1=(0.05*T^2+0.10*T+0.085)*dT\")\n", "T=T1-T2\n", "#Q1=(0.05*T**2+0.10*T+0.085)*dT\n", "#function y = f(T), y = (0.05*T**2+0.10*T+0.085),endfunction\n", "#Q1 = scipy.integrate.quad(fun1,T1, T2)\n", "#Q1=-Q1\n", "Q1=1641.35*10**3\n", "print(\"entropy change of system,deltaS_system=C*dT/T in J/K\")\n", "print(\"so deltaS_system=(0.05*T^2+0.10*T+0.085)*dT/T\")\n", "#function y = k(T), y = (0.05*T**2+0.10*T+0.085)/T,endfunction\n", "def fun1(x):\n", "\ty = (0.05*T**2+0.10*T+0.085)/T\n", "\treturn y\n", "\n", "#deltaS_system = scipy.integrate.quad(k,T1, T2)\n", "deltaS_system=-4020.043\n", "print(\"deltaS_reservoir=Q2/T2=(Q1-W)/T2\"),\n", "print(\"also,we know from entropy principle,deltaS_universe is greater than equal to 0\")\n", "print(\"deltaS_universe=deltaS_system+deltaS_reservoir\")\n", "print(\"thus,upon substituting,deltaS_system+deltaS_reservoir is greater than equal to 0\")\n", "print(\"W is less than or equal to(Q1+deltaS_system*T2)/1000 in KJ\")\n", "W=(Q1+deltaS_system*T2)/1000\n", "print(\"hence maximum work in KJ=\"),round(W,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.10;pg no: 149" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.10, Page:46 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 10\n", "for reversible adiabatic process governing equation for expansion,\n", "P*V**1.4=constant\n", "also,for such process entropy change=0\n", "using p2/p1=(v1/v2)**1.4 or v=(p1*(v1**1.4)/p)**(1/1.4)\n", "final pressure(p2)in Mpa\n", "p2= 0.24\n", "from first law,second law and definition of enthalpy;\n", "dH=T*dS+v*dP\n", "for adiabatic process of reversible type,dS=0\n", "so dH=v*dP\n", "integrating both side H2-H1=deltaH=v*dP in KJ\n", "so enthalpy change(deltaH)in KJ=268.8\n", "and entropy change=0\n" ] } ], "source": [ "#cal of deltaS\n", "#intiation of all variables\n", "# Chapter 5\n", "\n", "print\"Example 5.10, Page:46 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 10\")\n", "import scipy\n", "from scipy import integrate\n", "\n", "def fun1(x):\n", "\ty=x*x\n", "\treturn y\n", "\n", "p1=3.;#initial pressure in Mpa\n", "v1=0.05;#initial volume in m**3\n", "v2=0.3;#final volume in m**3\n", "print(\"for reversible adiabatic process governing equation for expansion,\")\n", "print(\"P*V**1.4=constant\")\n", "print(\"also,for such process entropy change=0\")\n", "print(\"using p2/p1=(v1/v2)**1.4 or v=(p1*(v1**1.4)/p)**(1/1.4)\")\n", "print(\"final pressure(p2)in Mpa\")\n", "p2=p1*(v1/v2)**1.4\n", "print(\"p2=\"),round(p2,2)\n", "print(\"from first law,second law and definition of enthalpy;\")\n", "print(\"dH=T*dS+v*dP\")\n", "print(\"for adiabatic process of reversible type,dS=0\")\n", "dS=0;#for adiabatic process of reversible type\n", "print(\"so dH=v*dP\")\n", "print(\"integrating both side H2-H1=deltaH=v*dP in KJ\")\n", "p1=3.*1000.;#initial pressure in Kpa\n", "p2=244.;#final pressure in Kpa\n", "#function y = f(p), y =(p1*(v1**1.4)/p)**(1/1.4)\n", "def fun1(x):\n", "\ty=(p1*(v1**1.4)/p2)**(1/1.4)\n", "\treturn y\n", "\n", "deltaH = scipy.integrate.quad(fun1,p2,p1)\n", "print (\"so enthalpy change(deltaH)in KJ=268.8\")\n", "print(\"and entropy change=0\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.11;pg no: 150" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.11, Page:150 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 11\n", "during free expansion temperature remains same and it is an irreversible process.for getting change in entropy let us approximate this expansion process as a reversible isothermal expansion\n", "a> change in entropy of air(deltaS_air)in J/K\n", "deltaS_air= 1321.68\n", "b> during free expansion on heat is gained or lost to surrounding so,\n", "deltaS_surrounding=0\n", "entropy change of surroundings=0\n", "c> entropy change of universe(deltaS_universe)in J/K\n", "deltaS_universe= 1321.68\n" ] } ], "source": [ "#cal of deltaS_universe\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.11, Page:150 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 11\")\n", "m=2;#mass of air in kg\n", "v1=1;#initial volume of air in m^3\n", "v2=10;#final volume of air in m^3\n", "R=287;#gas constant in J/kg K\n", "print(\"during free expansion temperature remains same and it is an irreversible process.for getting change in entropy let us approximate this expansion process as a reversible isothermal expansion\")\n", "print(\"a> change in entropy of air(deltaS_air)in J/K\")\n", "deltaS_air=m*R*math.log(v2/v1)\n", "print(\"deltaS_air=\"),round(deltaS_air,2)\n", "print(\"b> during free expansion on heat is gained or lost to surrounding so,\")\n", "print(\"deltaS_surrounding=0\")\n", "print(\"entropy change of surroundings=0\")\n", "deltaS_surrounding=0;#entropy change of surroundings\n", "print(\"c> entropy change of universe(deltaS_universe)in J/K\")\n", "deltaS_universe=deltaS_air+deltaS_surrounding\n", "print(\"deltaS_universe=\"),round(deltaS_universe,2)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "##example 5.12;pg no: 150" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.12, Page:150 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 12\n", "let initial and final states be denoted by 1 and 2\n", "for poly tropic process pressure and temperature can be related as\n", "(p2/p1)^((n-1)/n)=T2/T1\n", "so temperature after compression(T2)=in K 1128.94\n", "substituting in entropy change expression for polytropic process,\n", "entropy change(deltaS)inKJ/kg K\n", "deltaS= -0.24454\n", "NOTE=>answer given in book i.e -244.54 KJ/kg K is incorrect,correct answer is -.24454 KJ/kg K\n", "total entropy change(deltaS)=in J/K -122.27\n" ] } ], "source": [ "#cal of total entropy change\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.12, Page:150 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 12\")\n", "m=0.5;#mass of air in kg\n", "p1=1.013*10**5;#initial pressure of air in pa\n", "p2=0.8*10**6;#final pressure of air in pa\n", "T1=800;#initial temperature of air in K\n", "n=1.2;#polytropic expansion constant\n", "y=1.4;#expansion constant for air\n", "Cv=0.71;#specific heat at constant volume in KJ/kg K\n", "print(\"let initial and final states be denoted by 1 and 2\")\n", "print(\"for poly tropic process pressure and temperature can be related as\")\n", "print(\"(p2/p1)^((n-1)/n)=T2/T1\")\n", "T2=T1*(p2/p1)**((n-1)/n)\n", "print(\"so temperature after compression(T2)=in K\"),round(T2,2)\n", "print(\"substituting in entropy change expression for polytropic process,\") \n", "print(\"entropy change(deltaS)inKJ/kg K\")\n", "deltaS=Cv*((n-y)/(n-1))*math.log(T2/T1)\n", "print(\"deltaS=\"),round(deltaS,5)\n", "print(\"NOTE=>answer given in book i.e -244.54 KJ/kg K is incorrect,correct answer is -.24454 KJ/kg K\")\n", "deltaS=m*deltaS*1000\n", "print(\"total entropy change(deltaS)=in J/K\"),round(deltaS,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.13;pg no: 151" ] }, { "cell_type": "code", "execution_count": 61, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.13, Page:151 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 13\n", "NOTE=>In question no. 13,formula for maximum work is derived which cannot be solve using python software\n" ] } ], "source": [ "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.13, Page:151 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 13\")\n", "print(\"NOTE=>In question no. 13,formula for maximum work is derived which cannot be solve using python software\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.14;pg no: 152" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.14, Page:152 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 14\n", "clausius inequality can be used for cyclic process as given below;consider 1 for source and 2 for sink\n", "K=dQ/T=Q1/T1-Q2/T2\n", "i> for Q2=200 kcal/s\n", "K=in kcal/s K 0.0\n", "as K is not greater than 0,therefore under these conditions engine is not possible\n", "ii> for Q2=400 kcal/s\n", "K=in kcal/s K -1.0\n", "as K is less than 0,so engine is feasible and cycle is reversible\n", "iii> for Q2=250 kcal/s\n", "K=in kcal/s K 0.0\n", "as K=0,so engine is feasible and cycle is reversible\n" ] } ], "source": [ "#cal of deltaS\n", "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.14, Page:152 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 14\")\n", "Q1=500;#heat supplied by source in kcal/s\n", "T1=600;#temperature of source in K\n", "T2=300;#temperature of sink in K\n", "print(\"clausius inequality can be used for cyclic process as given below;consider 1 for source and 2 for sink\")\n", "print(\"K=dQ/T=Q1/T1-Q2/T2\")\n", "print(\"i> for Q2=200 kcal/s\")\n", "Q2=200;#heat rejected by sink in kcal/s\n", "K=Q1/T1-Q2/T2\n", "print(\"K=in kcal/s K\"),round(K,2)\n", "print(\"as K is not greater than 0,therefore under these conditions engine is not possible\")\n", "print(\"ii> for Q2=400 kcal/s\")\n", "Q2=400;#heat rejected by sink in kcal/s\n", "K=Q1/T1-Q2/T2\n", "print(\"K=in kcal/s K\"),round(K,2)\n", "print(\"as K is less than 0,so engine is feasible and cycle is reversible\")\n", "print(\"iii> for Q2=250 kcal/s\")\n", "Q2=250;#heat rejected by sink in kcal/s\n", "K=Q1/T1-Q2/T2\n", "print(\"K=in kcal/s K\"),round(K,2)\n", "print(\"as K=0,so engine is feasible and cycle is reversible\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.15;pg no: 152" ] }, { "cell_type": "code", "execution_count": 63, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.15, Page:152 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 15\n", "let the two points be given as states 1 and 2,\n", "let us assume flow to be from 1 to 2\n", "so entropy change(deltaS1_2)=s1-s2=in KJ/kg K -0.0\n", "deltaS1_2=s1-s2=0.01254 KJ/kg K\n", "it means s2 > s1 hence the assumption that flow is from 1 to 2 is correct as from second law of thermodynamics the entropy increases in a process i.e s2 is greater than or equal to s1\n", "hence flow occurs from 1 to 2 i.e from 0.5 MPa,400K to 0.3 Mpa & 350 K\n" ] } ], "source": [ "#cal of deltaS\n", "#intiation of all variables\n", "# Chapter 5\n", "import math\n", "print\"Example 5.15, Page:152 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 15\")\n", "p1=0.5;#initial pressure of air in Mpa\n", "T1=400;#initial temperature of air in K\n", "p2=0.3;#final pressure of air in Mpa\n", "T2=350;#initial temperature of air in K\n", "R=0.287;#gas constant in KJ/kg K\n", "Cp=1.004;#specific heat at constant pressure in KJ/kg K\n", "print(\"let the two points be given as states 1 and 2,\")\n", "print(\"let us assume flow to be from 1 to 2\")\n", "deltaS1_2=Cp*math.log(T1/T2)-R*math.log(p1/p2)\n", "print(\"so entropy change(deltaS1_2)=s1-s2=in KJ/kg K\"),round(deltaS1_2)\n", "print(\"deltaS1_2=s1-s2=0.01254 KJ/kg K\")\n", "print(\"it means s2 > s1 hence the assumption that flow is from 1 to 2 is correct as from second law of thermodynamics the entropy increases in a process i.e s2 is greater than or equal to s1\")\n", "print(\"hence flow occurs from 1 to 2 i.e from 0.5 MPa,400K to 0.3 Mpa & 350 K\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.16;pg no: 153" ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.16, Page:46 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 16\n", "NOTE=>In question no. 16,value of n is derived which cannot be solve using python software.\n" ] } ], "source": [ "#cal of deltaS\n", "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.16, Page:46 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 16\")\n", "print(\"NOTE=>In question no. 16,value of n is derived which cannot be solve using python software.\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.17;pg no: 153" ] }, { "cell_type": "code", "execution_count": 66, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.17, Page:153 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 17\n", "total heat added(Q)in KJ\n", "Q= 1800.0\n", "for heat addition process 1-2\n", "Q12=T1*(s2-s1)\n", "deltaS=s2-s1=in KJ/K 2.0\n", "or heat addition process 3-4\n", "Q34=T3*(s4-s3)\n", "deltaS=s4-s3=in KJ/K 2.0\n", "or heat rejected in process 5-6(Q56)in KJ\n", "Q56=T5*(s5-s6)=T5*((s2-s1)+(s4-s3))=T5*(deltaS+deltaS)= 1200.0\n", "net work done=net heat(W_net)in KJ\n", "W_net=(Q12+Q34)-Q56 600.0\n", "thermal efficiency of cycle(n)= 0.33\n", "or n=n*100 % 33.33\n", "so work done=600 KJ and thermal efficiency=33.33 %\n" ] } ], "source": [ "#cal of work done and thermal efficiency\n", "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.17, Page:153 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 17\")\n", "Q12=1000.;#heat added during process 1-2 in KJ\n", "Q34=800.;#heat added during process 3-4 in KJ\n", "T1=500.;#operating temperature for process 1-2\n", "T3=400.;#operating temperature for process 3-4\n", "T5=300.;#operating temperature for process 5-6\n", "T2=T1;#isothermal process\n", "T4=T3;#isothermal process\n", "T6=T5;#isothermal process\n", "print(\"total heat added(Q)in KJ\")\n", "Q=Q12+Q34\n", "print(\"Q=\"),round(Q,2)\n", "print(\"for heat addition process 1-2\")\n", "print(\"Q12=T1*(s2-s1)\")\n", "deltaS=Q12/T1\n", "print(\"deltaS=s2-s1=in KJ/K\"),round(deltaS,2)\n", "print(\"or heat addition process 3-4\")\n", "print(\"Q34=T3*(s4-s3)\")\n", "deltaS=Q34/T3\n", "print(\"deltaS=s4-s3=in KJ/K\"),round(deltaS,2)\n", "print(\"or heat rejected in process 5-6(Q56)in KJ\")\n", "Q56=T5*(deltaS+deltaS)\n", "print(\"Q56=T5*(s5-s6)=T5*((s2-s1)+(s4-s3))=T5*(deltaS+deltaS)=\"),round(Q56,2)\n", "print(\"net work done=net heat(W_net)in KJ\")\n", "W_net=(Q12+Q34)-Q56\n", "print(\"W_net=(Q12+Q34)-Q56\"),round(W_net,2)\n", "n=W_net/Q\n", "print(\"thermal efficiency of cycle(n)=\"),round(n,2)\n", "n=n*100\n", "print(\"or n=n*100 %\"),round(n,2) \n", "print(\"so work done=600 KJ and thermal efficiency=33.33 %\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##example 5.18;pg no: 154" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Example 5.18, Page:154 \n", " \n", "\n", "Engineering Thermodynamics by Onkar Singh Chapter 5 Example 18\n", "let heat supplied by reservoir at 800 K,700 K,600 K be Q1_a , Q1_b , Q1_c\n", "here Q1-Q2=W\n", "so heat supplied by source(Q1)in KW= 30.0\n", "also given that,Q1_a=0.7*Q1_b.......eq 1\n", "Q1_c=Q1-(0.7*Q1_b+Q1_b)\n", "Q1_c=Q1-1.7*Q1_b........eq 2\n", "for reversible engine\n", "Q1_a/T1_a+Q1_b/T1_b+Q1_c/T1_c-Q2/T2=0......eq 3\n", "substitute eq 1 and eq 2 in eq 3 we get, \n", "heat supplied by reservoir of 700 K(Q1_b)in KJ/s\n", "Q1_b= 35.39\n", "so heat supplied by reservoir of 800 K(Q1_a)in KJ/s\n", "Q1_a= 24.78\n", "and heat supplied by reservoir of 600 K(Q1_c)in KJ/s\n", "Q1_c=Q1-1.7*Q1_b -30.17\n", "so heat supplied by reservoir at 800 K(Q1_a)= 24.78\n", "so heat supplied by reservoir at 700 K(Q1_b)= 35.39\n", "so heat supplied by reservoir at 600 K(Q1_c)= -30.17\n", "NOTE=>answer given in book for heat supplied by reservoir at 800 K,700 K,600 K i.e Q1_a=61.94 KJ/s,Q1_b=88.48 KJ/s,Q1_c=120.42 KJ/s is wrong hence correct answer is calculated above.\n" ] } ], "source": [ "#cal of heat supplied by reservoir at 800,700,600\n", "#intiation of all variables\n", "# Chapter 5\n", "print\"Example 5.18, Page:154 \\n \\n\"\n", "print(\"Engineering Thermodynamics by Onkar Singh Chapter 5 Example 18\")\n", "T1_a=800.;#temperature of reservoir a in K\n", "T1_b=700.;#temperature of reservoir b in K\n", "T1_c=600.;#temperature of reservoir c in K\n", "T2=320.;#temperature of sink in K\n", "W=20.;#work done in KW\n", "Q2=10.;#heat rejected to sink in KW\n", "print(\"let heat supplied by reservoir at 800 K,700 K,600 K be Q1_a , Q1_b , Q1_c\")\n", "print(\"here Q1-Q2=W\")\n", "Q1=W+Q2\n", "print(\"so heat supplied by source(Q1)in KW=\"),round(Q1,2)\n", "print(\"also given that,Q1_a=0.7*Q1_b.......eq 1\")\n", "print(\"Q1_c=Q1-(0.7*Q1_b+Q1_b)\")\n", "print(\"Q1_c=Q1-1.7*Q1_b........eq 2\")\n", "print(\"for reversible engine\")\n", "print(\"Q1_a/T1_a+Q1_b/T1_b+Q1_c/T1_c-Q2/T2=0......eq 3\")\n", "print(\"substitute eq 1 and eq 2 in eq 3 we get, \")\n", "print(\"heat supplied by reservoir of 700 K(Q1_b)in KJ/s\")\n", "Q1_b=((Q2/T2)-(Q1/T1_c))/((0.7/T1_a)+(1/T1_b)-(1.7/T1_c))\n", "print(\"Q1_b=\"),round(Q1_b,2)\n", "print(\"so heat supplied by reservoir of 800 K(Q1_a)in KJ/s\")\n", "Q1_a=0.7*Q1_b\n", "print(\"Q1_a=\"),round(Q1_a,2)\n", "print(\"and heat supplied by reservoir of 600 K(Q1_c)in KJ/s\")\n", "Q1_c=Q1-1.7*Q1_b\n", "print(\"Q1_c=Q1-1.7*Q1_b\"),round(Q1_c,2)\n", "print(\"so heat supplied by reservoir at 800 K(Q1_a)=\"),round(Q1_a,2)\n", "print(\"so heat supplied by reservoir at 700 K(Q1_b)=\"),round(Q1_b,2)\n", "print(\"so heat supplied by reservoir at 600 K(Q1_c)=\"),round(Q1_c,2)\n", "print(\"NOTE=>answer given in book for heat supplied by reservoir at 800 K,700 K,600 K i.e Q1_a=61.94 KJ/s,Q1_b=88.48 KJ/s,Q1_c=120.42 KJ/s is wrong hence correct answer is calculated above.\")\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.9" } }, "nbformat": 4, "nbformat_minor": 0 }