diff options
author | hardythe1 | 2015-04-07 15:58:05 +0530 |
---|---|---|
committer | hardythe1 | 2015-04-07 15:58:05 +0530 |
commit | 92cca121f959c6616e3da431c1e2d23c4fa5e886 (patch) | |
tree | 205e68d0ce598ac5caca7de839a2934d746cce86 /Thermodynamics_An_Engineering_Approach/Chapter7.ipynb | |
parent | b14c13fcc6bb6d01c468805d612acb353ec168ac (diff) | |
download | Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.gz Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.bz2 Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.zip |
added books
Diffstat (limited to 'Thermodynamics_An_Engineering_Approach/Chapter7.ipynb')
-rwxr-xr-x | Thermodynamics_An_Engineering_Approach/Chapter7.ipynb | 1049 |
1 files changed, 1049 insertions, 0 deletions
diff --git a/Thermodynamics_An_Engineering_Approach/Chapter7.ipynb b/Thermodynamics_An_Engineering_Approach/Chapter7.ipynb new file mode 100755 index 00000000..d5ab12d2 --- /dev/null +++ b/Thermodynamics_An_Engineering_Approach/Chapter7.ipynb @@ -0,0 +1,1049 @@ +{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 7: Entropy"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-1 ,Page No.335"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "Q=750;#heat transfered in kJ\n",
+ "Tsys=300.0;#temperature of liquid-water mixture in K\n",
+ "\n",
+ "#calculations\n",
+ "dSsys=Q/Tsys;\n",
+ "print'Entropy change in the process %f kJ/K'%round(dSsys,1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Entropy change in the process 2.500000 kJ/K\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-2 ,Page No.338"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "Qsink=2000.0;#heat lost in kJ\n",
+ "Qsource=-Qsink;\n",
+ "Tsource=800.0;#temp of heat loss in K\n",
+ "\n",
+ "#calculations\n",
+ "#part - a\n",
+ "Tsink=500.0;\n",
+ "dSsource=Qsource/Tsource;\n",
+ "dSsink=Qsink/Tsink;\n",
+ "Sgena=dSsource+dSsink;\n",
+ "print'entropy generated in part a %f kJ/K'%round(Sgena,1);\n",
+ "#part - b\n",
+ "Tsink=750;\n",
+ "dSsource=Qsource/Tsource;\n",
+ "dSsink=Qsink/Tsink;\n",
+ "Sgenb=dSsource+dSsink;\n",
+ "print'entropy generated in part b %f kJ/K'%round(Sgenb,1);\n",
+ "if Sgena>Sgenb :\n",
+ " print('part a is more irreversible');\n",
+ "elif(Sgena == Sgenb) :\n",
+ " print('heat transfer is equally irreversible');\n",
+ "else:\n",
+ " print('part b is more irreversible');\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "entropy generated in part a 1.500000 kJ/K\n",
+ "entropy generated in part b 0.200000 kJ/K\n",
+ "part a is more irreversible\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-3 ,Page No.341"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "m=5.0;#mass of refrigerant 134-a in kg\n",
+ "P1=140.0;#intial pressure in kPa\n",
+ "T1=20.0;#temperature in C\n",
+ "P2=100.0;#final pressure in kPa\n",
+ "\n",
+ "#from refrigerant-134a data\n",
+ "#at P1 and T1\n",
+ "s1=1.0624;\n",
+ "v1=0.16544;\n",
+ "#at P2\n",
+ "v2=v1;\n",
+ "vf=0.0007529;\n",
+ "vg=0.19254;\n",
+ "sf=0.07188;\n",
+ "sfg=0.87995;\n",
+ "\n",
+ "#calculations\n",
+ "# vf < v2 <vg\n",
+ "x2=(v2-vf)/(vg-vf);\n",
+ "s2=sf+x2*sfg;\n",
+ "dS=m*(s2-s1);\n",
+ "print'entropy change in the process %f kJ/k'%round(dS,3)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "entropy change in the process -1.175000 kJ/k\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-4 ,Page No.342"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "m=3;#mass of water in lbm\n",
+ "P1=20;#pressure in psia\n",
+ "T1=70+460;#temperature in R\n",
+ "Qin=3450;#heat added in Btu\n",
+ "\n",
+ "#from Table A-6E\n",
+ "#at P1 and T1\n",
+ "s1=0.07459;\n",
+ "h1=38.08;\n",
+ "\n",
+ "#calculations\n",
+ "#Ein - Eout = dEsystem\n",
+ "#Qin = m*(h2 - h1)\n",
+ "h2=Qin/m+h1;\n",
+ "#from Table A-6E\n",
+ "#At P2 and h2\n",
+ "s2=1.7761;\n",
+ "dS=m*(s2-s1);\n",
+ "print'entropy change %f Btu/R'%round(dS,3);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "entropy change 5.105000 Btu/R\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-5 ,Page No.343"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P1=5.0;#entry pressure in MPa\n",
+ "T1=450.0;#entry temperature in C\n",
+ "P2=1.4;#pressure at exit MPa\n",
+ "\n",
+ "#calculations\n",
+ "#Ein - Eout = dEsystem/dt\n",
+ "#Ein = Eout\n",
+ "#Wout = m*(h1-h2)\n",
+ "#At P1 and T1\n",
+ "h1=3317.2;\n",
+ "s1=6.8210;\n",
+ "s2=s1;\n",
+ "#At P2 and s2\n",
+ "h2=2967.4;\n",
+ "Wout=h1-h2;\n",
+ "print'work output per unit mass %f kJ/kg'%round(Wout,1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "work output per unit mass 349.800000 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-7 ,Page No.352"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from math import log\n",
+ "#given values\n",
+ "P1=1;#pressure at state 1 in kPa\n",
+ "T1=110.0;#temperature at state 1 in K\n",
+ "P2=5;#pressure at state 2 in kPa\n",
+ "T2=120.0;#temperature at state 2 in K\n",
+ "\n",
+ "#from Table \n",
+ "#At P1 and T1\n",
+ "s1=4.875;\n",
+ "cp1=3.471;\n",
+ "#at P2 and T2\n",
+ "s2=5.145;\n",
+ "cp2=3.486;\n",
+ "\n",
+ "#calculations\n",
+ "#part - a\n",
+ "dSa=s2-s1;\n",
+ "print'change in entropy %f kJ/kg K using tabulated properties'%round(dSa,3);\n",
+ "#part - b\n",
+ "cavg=(cp1+cp2)/2.0;\n",
+ "dSb=cavg*log(T2/T1);\n",
+ "print'change in entropy %f kJ/kg K approximating liquid methane as an incompressible substance'%round(dSb,3);\n",
+ "E=(dSb-dSa)/dSa;\n",
+ "print'Error is %f'%round(E,4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "change in entropy 0.270000 kJ/kg K using tabulated properties\n",
+ "change in entropy 0.303000 kJ/kg K approximating liquid methane as an incompressible substance\n",
+ "Error is 0.121000\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-8 ,Page No.353"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Annual power savings has a 0.005% error due to approximation in textbook\n",
+ "\n",
+ "#given data\n",
+ "P1=5;#pressure at state 1 in MPa\n",
+ "V1=0.280;#volimetric flow rate in m^3/s\n",
+ "T1=115;#temperature at state 1 in K\n",
+ "P2=1;#pressure at state 2 in MPa\n",
+ "dt=8760;#time in h/yr\n",
+ "UC=0.075;#unit cost in $\n",
+ "\n",
+ "#from Table\n",
+ "#at P1 and T1\n",
+ "h1=232.3;\n",
+ "s1=4.9945;\n",
+ "p1=422.15;\n",
+ "s2=s1;\n",
+ "#at P2 and s2\n",
+ "h2=222.8;\n",
+ "\n",
+ "#calculations\n",
+ "m=p1*V1;\n",
+ "#Ein - Eout = dEsystem/dt\n",
+ "#Ein = Eout\n",
+ "#Wout = m*(h1-h2)\n",
+ "Wout = m*(h1-h2);\n",
+ "print'maximum amount of power that can be produced %i kW'%round(Wout)\n",
+ "APP=Wout*dt;#annual power production\n",
+ "APS=APP*UC;#annual power savings\n",
+ "print'Annual power savings $%i/yr'%round(APS)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "maximum amount of power that can be produced 1123 kW\n",
+ "Annual power savings $737758/yr\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-9 ,Page No.357"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from math import log\n",
+ "\n",
+ "#given data\n",
+ "P1=100.0;#inlet pressure in kPa\n",
+ "T1=290.0;#inlet temperature in K\n",
+ "P2=600.0;#outlet temperature in kPa\n",
+ "T2=330.0;#outlet temperature in K\n",
+ "\n",
+ "#from Table A-17\n",
+ "s02=1.79783;\n",
+ "s01=1.66802;\n",
+ "#Table A-2b\n",
+ "cpavg=1.006;\n",
+ "\n",
+ "#constants used\n",
+ "R=0.287;#in kJ/kg -K\n",
+ "\n",
+ "#calculations\n",
+ "#part-a\n",
+ "s21=s02-s01-R*log(P2/P1);#stands for s2 - s1\n",
+ "print'entropy change using property values from air table %f kJ/kg-K'%round(s21,4);\n",
+ "s21=cpavg*log(T2/T1)-R*log(P2/P1);#stands for s2 - s1\n",
+ "print'entropy change using average specific heat %f kJ/kg-K'%round(s21,4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "entropy change using property values from air table -0.384400 kJ/kg-K\n",
+ "entropy change using average specific heat -0.384200 kJ/kg-K\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-10 ,Page No.360"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P1=95;#intial pressure in kPa\n",
+ "T1=295;#intial temperature in K\n",
+ "r=8;#ratio of V1/V2\n",
+ "\n",
+ "#calculations\n",
+ "#for closed systems V2/V1 = v2/v1\n",
+ "#At T1\n",
+ "vr1=647.9;\n",
+ "vr2=vr1/r;\n",
+ "#at vr2\n",
+ "T2=662.7;\n",
+ "print'the final temperature %f K'%T2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the final temperature 662.700000 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-11 ,Page No.361"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P1=14.0;#intial pressure in psia\n",
+ "T1=50+460.0;#intial temperature in R\n",
+ "T2=320+460.0;#final temperature in R\n",
+ "\n",
+ "#constants used\n",
+ "k=1.667;\n",
+ "\n",
+ "#calculations\n",
+ "P2=P1*(T2/T1)**(k/(k-1));\n",
+ "print'exit pressure %f psia'%round(P2,1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "exit pressure 40.500000 psia\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-12 ,Page No.364"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P2=1000;#final pressure in MPa\n",
+ "P1=100;#intial pressure in MPa\n",
+ "\n",
+ "#from Table A-5\n",
+ "#At P2\n",
+ "v1=0.001043;\n",
+ "\n",
+ "#calculations\n",
+ "Wrev=v1*(P2-P1);\n",
+ "print'compressor work as saturated liquid at inlet %f kJ/kg'%round(Wrev,2)\n",
+ "#from Table A-5\n",
+ "#at P1 as sat. vapour\n",
+ "h1=2675.0;\n",
+ "s1=7.3589;\n",
+ "s2=s1\n",
+ "#from Table A-6\n",
+ "#at P2 and s2\n",
+ "h2=3194.5;\n",
+ "Wrev=h2-h1;\n",
+ "print'compressor work as saturated vapor at inlet %f kJ/kg'%round(Wrev,1)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "compressor work as saturated liquid at inlet 0.940000 kJ/kg\n",
+ "compressor work as saturated vapor at inlet 519.500000 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-13 ,Page No.368"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from math import sqrt\n",
+ "#given data\n",
+ "P1=100;#intial pressure in kPa\n",
+ "T1=300;#intial temperature in K\n",
+ "P2=900;#final pressure in kPa\n",
+ "\n",
+ "#constants used\n",
+ "R=0.287;#in kJ/kg -K\n",
+ "\n",
+ "#calculations\n",
+ "#part - a\n",
+ "k=1.4;\n",
+ "Wcomp=k*R*T1/(k-1)*((P2/P1)**((k-1)/k)-1);\n",
+ "print'compression work in case of isentropic compression %f kJ/kg'%round(Wcomp,1);\n",
+ "#part - b\n",
+ "n=1.3;\n",
+ "Wcomp=n*R*T1/(n-1)*((P2/P1)**((n-1)/n)-1);\n",
+ "print'compression work in case of polytropic compression %f kJ/kg'%round(Wcomp,1);\n",
+ "#part - c\n",
+ "Wcomp=R*T1*log(P2/P1);\n",
+ "print'compression work in case of isothermal compression %f kJ/kg'%round(Wcomp,1);\n",
+ "#part - d\n",
+ "Ps=sqrt(P1*P2);\n",
+ "Wcomp=2*n*R*T1/(n-1)*((Ps/P1)**((n-1)/n)-1);\n",
+ "print'compression work in case of two-stage compression with intercooling %f kJ/kg'%round(Wcomp,1);\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "compression work in case of isentropic compression 263.200000 kJ/kg\n",
+ "compression work in case of polytropic compression 246.400000 kJ/kg\n",
+ "compression work in case of isothermal compression 189.200000 kJ/kg\n",
+ "compression work in case of two-stage compression with intercooling 215.300000 kJ/kg\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-14 ,Page No.371"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P1=3000;#intial pressure in kPa\n",
+ "T1=400;#intial temperature in C\n",
+ "P2=50;#final pressure in kPa\n",
+ "T2=100;#final temperature in C\n",
+ "Wout=2000;#power output in kW\n",
+ "\n",
+ "#from Table A-6\n",
+ "#at P1\n",
+ "h1=3231.7;\n",
+ "s1=6.9235;\n",
+ "#at 2a\n",
+ "h2a=2682.4;\n",
+ "#from Table A-6\n",
+ "#at 2s\n",
+ "s2s=s1;\n",
+ "sf=1.0912;\n",
+ "sg=7.5937;\n",
+ "hf=340.54;\n",
+ "hfg=2304.7\n",
+ "x2s=(s2s-sf)/(sg-sf);\n",
+ "h2s=hf+x2s*hfg;\n",
+ "nT=(h1-h2a)/(h1-h2s);\n",
+ "print'isentropic efficiency is %f'%round(nT,3)\n",
+ "#Ein = Eout\n",
+ "m=Wout/(h1-h2a);\n",
+ "print'mass flow rate %f kg/s'%round(m,2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "isentropic efficiency is 0.667000\n",
+ "mass flow rate 3.640000 kg/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-15 ,Page No.374"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P1=100;#intial pressure in kPa\n",
+ "T1=285;#intial temperature in K\n",
+ "P2=800;#final pressure in kPa\n",
+ "m=0.2;#mass flow rate in kg/s\n",
+ "nc=0.8;#isentropic efficiency\n",
+ "\n",
+ "#from Table A-17\n",
+ "#at T1\n",
+ "h1=285.14;\n",
+ "Pr1=1.1584;\n",
+ "\n",
+ "#calcualtions\n",
+ "Pr2=Pr1*(P2/P1);\n",
+ "#at Pr2\n",
+ "h2s=517.05;\n",
+ "h2a=(h2s-h1)/nc+h1;\n",
+ "#at h2a\n",
+ "T2a=569.5;\n",
+ "print'exit temperature of air %f K'%T2a;\n",
+ "#Ein = Eout\n",
+ "Wa=m*(h2a-h1);\n",
+ "print'required power input %i kW'%round(Wa)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "exit temperature of air 569.500000 K\n",
+ "required power input 58 kW\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-16 ,Page No.375"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from math import sqrt\n",
+ "\n",
+ "#given data\n",
+ "P1=200.0;#intial pressure in kPa\n",
+ "T1=950.0;#intial temperature in K\n",
+ "P2=80.0;#final pressure in kPa\n",
+ "nN=0.92;#isentropic efficiency\n",
+ "\n",
+ "#from Table A-2b\n",
+ "cp=1.099;\n",
+ "k=1.354;\n",
+ "\n",
+ "#calculations\n",
+ "T2s=T1*(P2/P1)**((k-1)/k);\n",
+ "#ein = eout\n",
+ "V2s=sqrt(2*cp*(T1-T2s)*1000);#factor of 1000 for conversion to m^2/s^2\n",
+ "print'maximum possible exit velocity %i m/s'%(V2s);\n",
+ "T2a=T1-nN*(T1-T2s);\n",
+ "print'exit temperature %i K'%round(T2a);\n",
+ "V2a=sqrt(nN*V2s**2);\n",
+ "print'actual exit velocity %i m/s'%(V2a)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "maximum possible exit velocity 666 m/s\n",
+ "exit temperature 764 K\n",
+ "actual exit velocity 639 m/s\n"
+ ]
+ }
+ ],
+ "prompt_number": 42
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ " Example 7-17 ,Page No.382"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "Qin=1035.0;#rate of heat transfer in W\n",
+ "Tin=20+273.0;#inner temperature in K\n",
+ "Qout=Qin;\n",
+ "Tout=5+273.0;#outer temperature in K\n",
+ "\n",
+ "#calculations\n",
+ "# Sin - Sout + Sgen = dSsystem/dt\n",
+ "Sgen=(Qout/Tout)-(Qin/Tin);\n",
+ "print'entropy generation in the wall %f W/K'%round(Sgen,3);\n",
+ "Ts1=300.0;Ts2=273.0;#Boundary temperatures\n",
+ "Sgen=(Qout/Ts2)-(Qin/Ts1);\n",
+ "print'total entropy generation %f W/K'%round(Sgen,3);"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "entropy generation in the wall 0.191000 W/K\n",
+ "total entropy generation 0.341000 W/K\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-18 ,Page No.383"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P1=7;#intial pressure in MPa\n",
+ "T1=450;#intial temperature in K\n",
+ "P2=3;#final pressure in MPa\n",
+ "\n",
+ "#from steam tables\n",
+ "#at P1 and T1\n",
+ "h1=3288.3;\n",
+ "s1=6.6353;\n",
+ "#at P2\n",
+ "h2=h1;\n",
+ "s2=7.0046;\n",
+ "\n",
+ "#calculations\n",
+ "# Sin - Sout + Sgen = dSsystem/dt\n",
+ "Sgen=s2-s1;\n",
+ "print'the entropy generated %f kJ/kg-K'%round(Sgen,4)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the entropy generated 0.369300 kJ/kg-K\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-19 ,Page No.385"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from math import log\n",
+ "\n",
+ "#given data\n",
+ "m=50;#mass of iron block in kg\n",
+ "T1=500.0;#temperature of iron block in K\n",
+ "T2=285.0;#temperature of lake in K\n",
+ "\n",
+ "#from Table A-3\n",
+ "Cavg=0.45;\n",
+ "\n",
+ "#calculations\n",
+ "dSiron=m*Cavg*log(T2/T1);\n",
+ "print'entropy change of the iron block %f kJ/K'%round(dSiron,2);\n",
+ "# Ein - Eout = dEsystem\n",
+ "Qout=m*Cavg*(T1-T2);\n",
+ "dSlake=Qout/T2;\n",
+ "print'entropy change of the lake %f kJ/K'%round(dSlake,2);\n",
+ "# Sin - Sout + Sgen = dSsystem/dt\n",
+ "Sgen=(Qout/T2)+dSiron;\n",
+ "print'entropy change in the process %f kJ/K'%round(Sgen,2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "entropy change of the iron block -12.650000 kJ/K\n",
+ "entropy change of the lake 16.970000 kJ/K\n",
+ "entropy change in the process 4.330000 kJ/K\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-20 ,Page No.386"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P=20;#pressure of water in psia\n",
+ "T1=50+460.0;#temperature of water in R\n",
+ "T2=240.0;#steam temperature in F\n",
+ "T3=130.0;#leaving temperauture in F\n",
+ "m1=300.0;#mass flow rate in lbm/min\n",
+ "Qout=180.0;#heat losses in Btu/min\n",
+ "\n",
+ "#from steam tables\n",
+ "#at P and T1\n",
+ "h1=18.07;\n",
+ "s1=0.03609;\n",
+ "#at P and T2\n",
+ "h2=1162.3;\n",
+ "s2=1.7406;\n",
+ "#at P and T3\n",
+ "h3=97.99;\n",
+ "s3=0.18174;\n",
+ "\n",
+ "#calculations\n",
+ "# Qout = m1*h1 + m2*h2 - (m1+m2)*h3\n",
+ "m2= (Qout-m1*h1+m1*h3)/(h2-h3);\n",
+ "m3=m1+m2;\n",
+ "# Sin - sout + Sgen = dSsystem/dt\n",
+ "Sgen=m3*s3-m1*s1-m2*s2+Qout/T1;\n",
+ "print'the rate of entropy generation %f Btu/min R'%round(Sgen,2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the rate of entropy generation 8.670000 Btu/min R\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-21 ,Page No.388"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "T=100+273.0;#temperature of water in K\n",
+ "Q=-600.0;#heat transferred in kJ\n",
+ "Tb=25+273.0;#temperature of surroundings in K\n",
+ "\n",
+ "#calculation\n",
+ "dSsys=Q/T;\n",
+ "print'entropy change of water %f kJ/K'%round(dSsys,2);\n",
+ "# Sin - sout + Sgen = dSsystem\n",
+ "Sgen= -Q/Tb + dSsys;\n",
+ "print'total entropy generation %f kJ/K'%round(Sgen,2)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "entropy change of water -1.610000 kJ/K\n",
+ "total entropy generation 0.400000 kJ/K\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-22 ,Page No.394"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from math import pi,sqrt\n",
+ "\n",
+ "#given data\n",
+ "T1=20+273.0;#average temperature of inlet in C\n",
+ "T2=24+273.0;#average temperature of compressed air in C\n",
+ "P1=101.0;#pressure of air inlet in kPa\n",
+ "P2=801.0;#pressure of compressed air in kPa\n",
+ "D=3.0/1000.0;#ihole diameter n m\n",
+ "Cdischarge=0.65;#discharge coefficient\n",
+ "ncomp=0.8;#compressor efficiency\n",
+ "nmotor=0.92;#motor efficiency\n",
+ "UC=0.078;#unit cost in $/kWh\n",
+ "\n",
+ "#constants used\n",
+ "R=0.287;#in kJ/kg K\n",
+ "k=1.4;\n",
+ "n=1.4;\n",
+ "\n",
+ "#calculations\n",
+ "Win=n*R*T1/(ncomp*(n-1))*((P2/P1)**((n-1)/n)-1);\n",
+ "A=pi*D**2/4;\n",
+ "mair=Cdischarge*(2/(k+1))**(1/(k-1))*P2*A/(R*T2)*sqrt(k*R*1000*2/(k+1)*T2);#factor of 1000 to m^2/s^2\n",
+ "PW=mair*Win;#Power wasted\n",
+ "ES=PW*4200/nmotor;#4200 is operating hours ES stands for Energy savings\n",
+ "print'Energy savings %i kWh/yr'%round(ES);\n",
+ "CS=ES*UC;\n",
+ "print'cost savings %i S/yr'%round(CS)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Energy savings 11698 kWh/yr\n",
+ "cost savings 912 S/yr\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7-23 ,Page No.398"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#given data\n",
+ "P1=85.6;#pressure of air inlet in kPa\n",
+ "P2=985.6;#pressure of actual compressed air in kPa\n",
+ "P2r=885.6;#pressure of required compressed air in kPa\n",
+ "CC=12000;#current cost in $/yr\n",
+ "\n",
+ "#constants used\n",
+ "n=1.4;\n",
+ "\n",
+ "#calulation\n",
+ "freduction=1-(((P2r/P1)**((n-1)/n)-1)/((P2/P1)**((n-1)/n)-1));\n",
+ "CS=CC*freduction;\n",
+ "print'cost savings %i Dollar/yr'%(round(CS))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "cost savings 719 Dollar/yr\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |