From 41f1f72e9502f5c3de6ca16b303803dfcf1df594 Mon Sep 17 00:00:00 2001 From: Thomas Stephen Lee Date: Fri, 4 Sep 2015 22:04:10 +0530 Subject: add/remove/update books --- Thermodynamics_Demystified/Chapter4.ipynb | 729 ------------------------------ 1 file changed, 729 deletions(-) delete mode 100755 Thermodynamics_Demystified/Chapter4.ipynb (limited to 'Thermodynamics_Demystified/Chapter4.ipynb') diff --git a/Thermodynamics_Demystified/Chapter4.ipynb b/Thermodynamics_Demystified/Chapter4.ipynb deleted file mode 100755 index 235bb7b4..00000000 --- a/Thermodynamics_Demystified/Chapter4.ipynb +++ /dev/null @@ -1,729 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:c856359b943f772597028d78558909db2e2132e84bca2ae7745f1dba60abb237" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Chapter 4:The First Law of Thermodynamics" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.1:PG-62" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialization of variables\n", - "K=100 # spring constant in kN/m\n", - "d=0.8 # dispacement of spring in m\n", - " # to get total work we integrate from 0 to 0.8 displacement\n", - "x1=0; # lower limit of integration\n", - "x2=0.8; # upper limit of integration\n", - "from scipy.integrate import quad\n", - "\n", - "# we find work\n", - "def integrand(x,K):\n", - " return K*x\n", - "\n", - "W12, err = quad(integrand, x1, x2, K) # integrating to get work\n", - "Q12=W12; # by first law of thermodynamics\n", - "print \"The Heat transfer is \",int(Q12),\" J\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Heat transfer is 32 J\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.2:PG-65" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "P= 5*746 # power of fan converted in watt\n", - "t=1*60*60 # time converted to seconds\n", - "\n", - "# by first law of thermodynamics Q=delU + W\n", - "# Q=0 hence -W=delU\n", - "# first we find work input\n", - "W=-P*t # work in J\n", - "delU=-W # from 1st law\n", - "print \"The internal energy increase is \",float(delU),\" J\"\n", - "# The answer is approximated in textbook\n", - "# our answer is precise\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The internal energy increase is 13428000.0 J\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.3:PG-65" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "P=400 # pressure in kPa\n", - "T1=200 # initial temperature in degree celsius\n", - "V1= 2 # initial volume in m^3\n", - "Q=3500 # heat added in kJ\n", - "v1=0.5342 # specific volume of steam at 200 degree celcius and 0.4 Mpa pressure from table C.3\n", - "u1=2647 # specific internal energy in kJ/kg @ pressure = 0.4 MPa\n", - "m=V1/v1 # mass in kg\n", - "# we have a relation Between u2 and v2 from 1st law of thermodynamics\n", - "v2=1.06 # specific volume at state 2 by trial and error and interpolation\n", - "V2=m*v2 \n", - "u2=((3500-400*(V2-V1))/m)+2647 # specific internal energy for v2=1.06 by trial and error\n", - "\n", - "# on interpolation from steam table at 0.4 MPa we get temperature \n", - "T2=644 # temperature in degree celsius\n", - "print \"The temperature for u2=\",round(u2),\" kJ and v2 =\",round(v2,3),\" kg/m^3 is \\n \",int(T2),\" degree celsius\"\n", - "# this numerical is solved by trial and error thus refer to Appendix C" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The temperature for u2= 3372.0 kJ and v2 = 1.06 kg/m^3 is \n", - " 644 degree celsius\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.4:PG-67" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "# initialization of variables\n", - "P=400 # pressure in kPa\n", - "T1=200 # initial tmperature in degree celsius\n", - "V=2 # initial volume in m^3\n", - "Q=3500 # heat added in kJ\n", - "\n", - "#solution\n", - "h1=2860 # initial enthalpy @ 200*C and 400 kPa from steam table\n", - "v=0.5342 # specific volume from steam table C.3 \n", - "m=V/v;\n", - "h2=(Q/m)+h1; # final enthalpy in kJ/kg from energy equation\n", - "\n", - "# NOW USING THIS ENTHLAPY AND INTERPOlATING FROM STEAM TABLE\n", - "\n", - "T2=600+(92.6/224)*100\n", - "\n", - "print \"The Final temperature is \",int(T2),\" degree Celsius\"\n", - "# result is obtained from interpolation on steam table\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Final temperature is 641 degree Celsius\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.5:PG-71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "T1=300 # initial temperature in degree celsius\n", - "T2=700 # final temperature in degree celsius\n", - "P=150 # pressure in kPa\n", - "m=3 # mass of steam in kg\n", - "\n", - "# solution\n", - "# part (a)\n", - "from scipy.integrate import quad\n", - "\n", - "# now we make function to integrate\n", - "def integrand(T):\n", - " return 2.07+(T-400)/1480\n", - "\n", - "I, err = quad(integrand, T1, T2) # integrating specific heat over temperature range\n", - "delH=m*I #integrate('2.07+(T-400)/1480','T',T1,T2) # expressing as function of temperature and integrating\n", - "\n", - "print\" The change in Enthalpy is \",int(delH),\" kJ \\n\"\n", - " \n", - "# part(b)\n", - "CPavg=delH/(m*(T2-T1)) # avg value of specific heat at constant pressure\n", - "print \" The average value of Cp is \",round(CPavg,2),\" kJ/kg.*C\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The change in Enthalpy is 2565 kJ \n", - "\n", - " The average value of Cp is 2.14 kJ/kg.*C\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.6,PG-72" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "m=1 # mass of nitrogen in kg\n", - "T1=300 # initial temperature in Kelvin\n", - "T2=1200 # final temperature in Kelvin\n", - "M=28.0 # in kg/kmol\n", - "# part(a)\n", - "# the enthalpy change is found from gas table in App.E\n", - "delh=36777-8723 # from gas table\n", - "delH=delh/M \n", - "print \" The entalpy change from gas table is \",round(delH),\" kJ/kg \\n\"\n", - "\n", - "# part (b) \n", - "Cp=1.042 # from table B.2\n", - "delH=Cp*(T2-T1)\n", - "print \" The entalpy change by assuming constant specific heat is \",round(delH),\" kJ/kg\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The entalpy change from gas table is 1002.0 kJ/kg \n", - "\n", - " The entalpy change by assuming constant specific heat is 938.0 kJ/kg\n" - ] - } - ], - "prompt_number": 29 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.7:PG-76" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "x=0.7 # quality of steam\n", - "P1=200 # initial pressure in kPa\n", - "P2=800 # final pressure in kPa\n", - "V=2 # volume in m^3\n", - "# The values are taken from TABLE C.2\n", - "vf1=0.0010 # specific volume of saturated liquid at 200 kPa\n", - "vg1=0.8857 # specific volume of saturated gas at 200 kPa\n", - "uf1=504.5 # specific internal energy of saturated liquid @ state 1\n", - "ug1=2529.5 # speciific internal energy of saturated gas @ state 1\n", - "\n", - "v1=vf1+x*(vg1-vf1); # specific volume of vapour\n", - "m=V/v1\n", - "\n", - "u1=uf1+x*(ug1-uf1) # specific internal energy of vapour @ state 1\n", - "v2=v1 # constant volume process\n", - "u2=((0.6761-0.6203)*(3661-3853)/(0.6761-0.6181))+3853 # from steam table @ 800kPa by interpolating\n", - "Q=m*(u2-u1) # heat transfer\n", - "print \"The heat transfer is \",round(Q,3),\" kJ\"\n", - "# The answer in the textbook is approximated" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The heat transfer is 5630.537 kJ\n" - ] - } - ], - "prompt_number": 34 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.8:PG-76" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "V=0.02 # volume in m^3\n", - "P=400 # pressure in kPa\n", - "T1=50+273 # initial temperature in kelvin\n", - "T2=700+273 # final temperature in kelvin\n", - "Q=50 # heat added in kJ\n", - "R=287 # constant for air\n", - "Cp=1 # constant for specific heat of air\n", - "\n", - "# using the ideal gas equation\n", - "\n", - "m=P*1000*V/(R*T1) # mass of air in kg\n", - "W=Q-(m*Cp*(T2-T1)) # work done from first law\n", - "# result\n", - "print \"The Paddle work is \",round(W,2),\" kJ\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Paddle work is -6.09 kJ\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.9,PG-77" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "V1=2 # initial volume in m^3\n", - "V2=0.2 # final volume in m^3\n", - "T1=20+273 # temperature in kelvin\n", - "P=200 # pressure in kPa\n", - "R=0.287 # constant for air\n", - "gama=1.4 # polytropic index for air\n", - "Cv=0.717 # specific heat at constant volume for air\n", - "\n", - "#solution\n", - "\n", - "#using the ideal gas equation\n", - "m=(P*V1)/(R*T1) # mass in kg\n", - "# process is adiabatic thus\n", - "T2=T1*((V1/V2)**(gama-1)) # final temperature\n", - "\n", - "W=-m*Cv*(T2-T1) # work from first law\n", - "print \"The Work is \",int(W),\" kJ\"\n", - "# solution is approximated in textbook" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Work is -1510 kJ\n" - ] - } - ], - "prompt_number": 41 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.10:PG-79" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "# initialization of variables\n", - "P1=2000.0 # initial pressure in kPa\n", - "T1=600.0 # initial temperature in degree celsius\n", - "p2=600.0 # final pressure in kPa\n", - "T2=200.0 # final temperature in degree celsius\n", - "d1=0.06 # diameter of inlet pipe in metre\n", - "d2=0.120 # diameter of outlet pipe in metre\n", - "V1=20.0 # velocity at inlet in m/s\n", - "\n", - "# solution\n", - "# from superheat table C.3 values are noted\n", - "v1=0.1996 # specific volume of superheated steam @ 600*C and 2000 kPa\n", - "v2=0.3520 # specific volume of superheated steam @ 200*C and 2000 kPa\n", - "rho1=1/v1 # initial density\n", - "rho2=1/v2 # final density\n", - "A1=(math.pi*d1**2)/4 # inlet area\n", - "A2=(math.pi*d2**2)/4 # exit area\n", - "\n", - "V2=(rho1*A1*V1)/(rho2*A2) # from continuity equation\n", - "print \" The Exit velocity is \",round(V2,2),\" m/s \\n\"\n", - "\n", - "mdot=rho1*A1*V1 # mass flow rate\n", - "print\" The mass flow rate is \",round(mdot,3),\" kg/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The Exit velocity is 8.82 m/s \n", - "\n", - " The mass flow rate is 0.283 kg/s\n" - ] - } - ], - "prompt_number": 45 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.11:PG-82" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "P1=8000 # initial pressure in kPa\n", - "T1=300 # temperature in degree celsius\n", - "P2=2000 # final pressure in kPa\n", - "\n", - "# solution\n", - "h1=2785 # specific enthalpy of steam in kJ/kg @ 8000 kPa and 300 degree celsius from steam table\n", - "h2=h1 # throttling process thus enthalpy is constant\n", - "T2=212.4 # from steam table as we know enthalpy and pressure\n", - "hf2=909 # specific enthalpy of saturated liquid @ 2000 kPa and 300 degree celsius\n", - "hg2=2799.5 # specific enthalpy of saturated gas @ 2000 kPa and 300 degree celsius\n", - "x2=(h2-hf2)/(hg2-hf2) # quality of steam\n", - "\n", - "vg2=0.0992 # specific volume of saturated gas @ 2000 kPa and 212.4*c\n", - "vf2=0.0012 # specific volume of saturated liquid @ 2000 kPa and 212.4*c\n", - "v2=vf2+x2*(vg2-vf2) # from properties of pure substance\n", - "\n", - "print \"The Final Temperature and Specific volume is \",round(T2,1),\"*C and \",round(v2,3),\" m^3/kg\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Final Temperature and Specific volume is 212.4 *C and 0.098 m^3/kg\n" - ] - } - ], - "prompt_number": 50 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.12:PG-84" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "# initialization of variables\n", - "P1=4000 # inlet pressure in kPa\n", - "T1=500 # inlet temperature in degree celsius\n", - "V1=200 # inlet steam velocity in m/s\n", - "d1=0.05 # inlet diameter in 'm'\n", - "P2=80 # exit pressure in kPa\n", - "d2=0.250 # exit diameter in 'm'\n", - "\n", - "# solution\n", - "v1=0.08643 # specific volume from steam table @ 4000 kPa and 500*C\n", - "v2=2.087 # specific volume from steam table @ 80 kPa and 500*C\n", - "rho1=1/v1 # density at inlet\n", - "rho2=1/v2 # density at outlet\n", - "A1=(math.pi*d1**2)/4 # inlet area\n", - "A2=(math.pi*d2**2)/4\n", - "mdot=rho1*A1*V1 # mass flow rate\n", - "mdot=round(mdot,3) # rounding to 3 significant digits\n", - "\n", - "#now using table C.3\n", - "h1=3445 # initial specific enthalpy @ 4000 kPa and 500 *C \n", - "h2=2666 # final specific enthalpy @ 80 kPa and 500 *C\n", - "WT=-mdot*(h2-h1) # maximum power from first law\n", - "print \" The power output is \",round(WT),\" kJ/s \\n \"\n", - "\n", - "V2=(A1*V1*rho1)/(A2*rho2) \n", - "V2=round(V2) # rounding of digits\n", - "delKE=mdot*((V2**2)-(V1**2))/2 # the change in kinetic energy\n", - "print \" The change in K.E is \",round(delKE),\" J/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The power output is 3540.0 kJ/s \n", - " \n", - " The change in K.E is -6250.0 J/s\n" - ] - } - ], - "prompt_number": 78 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.13:PG-85" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "# initialization of variables\n", - "Wdot=10 # pump power in hp\n", - "g=9.81 # acceleration due to gravity\n", - "rho=1000 # density of water in kg/m^3\n", - "d1=0.06 # inlet dimeter in 'm'\n", - "d2=0.10 # oulet diamter in 'm'\n", - "V1=10 # velocity of water at inlet in m/s\n", - "\n", - "#solution\n", - "A1=math.pi*(d1**2)/4 # area of inlet\n", - "A2=math.pi*(d2**2)/4 # area of outlet\n", - "V2=A1*V1/A2 # oulet velocity from continuity equation\n", - "\n", - "mdot=rho*A1*V1 # mass flow rate\n", - "delP=((((Wdot*746)/mdot)-((V2**2)-V1**2)/(2*g))*rho)/1000 # change in pressure in kPa\n", - "print \"The rise in pressure is \",round(delP),\" kPa\"\n", - "# The answer is approximated in textbook , our answer is precise \n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The rise in pressure is 268.0 kPa\n" - ] - } - ], - "prompt_number": 80 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.14:PG-85" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# initialization of variables\n", - "P1=7000.0 # inlet pressure in Pa\n", - "T1=420.0 # inlet temperature in degree celsius\n", - "V1=400.0 # inlet velocity in m/s\n", - "d1=0.200 # inlet diameter in 'm'\n", - "V2=700.0 # exit velocity in m/s\n", - "k=1.4 # polytopic index for air\n", - "Cp=1000 # specific heat at constant pressure for air in j/kg.K\n", - "R=287 # specific gas constant for air\n", - "\n", - "#solution\n", - "\n", - "#part (a)\n", - "T2=(((V1**2)-V2**2)/(2*Cp))+T1 # outlet temperature in degree celsius\n", - "print \" The exit temperature is \",round(T2),\" *C \\n\"\n", - "\n", - "#part (b)\n", - "\n", - "rho1=P1/(R*(T1+273)) # density at entrance\n", - "A1=(math.pi*d1**2)/4\n", - "mdot=rho1*A1*V1 # \n", - "print \" The mass flow rate is \",round(mdot,3),\" kg/s \\n\"\n", - "\n", - "# part (c)\n", - "\n", - "rho2=rho1*(((T2+273)/(T1+273))**(1/(k-1))) # density at exit\n", - "# now we find the exit diameter\n", - "d2=math.sqrt((rho1*V1*(d1)**2)/(rho2*V2))\n", - "print \" The outlet diameter is \",round(d2,3),\" m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The exit temperature is 255.0 *C \n", - "\n", - " The mass flow rate is 0.442 kg/s \n", - "\n", - " The outlet diameter is 0.212 m\n" - ] - } - ], - "prompt_number": 87 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4.15:PG-89" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# initialization of variables\n", - "mdots=100 # mass flow rate of sodium in kg/s\n", - "Ts1=450 # inlet temperature of sodium in degree celsius\n", - "Ts2=350 # exit temperature of sodium in degree celsius\n", - "Cp=1.25 # specific heat of sodium in KJ/kg.*C\n", - "Tw1=20 # inlet temperature of water in degree celsius\n", - "Pw=5000 # inlet pressure of water in kPa \n", - "\n", - "# solution\n", - "hw1=88.65 # enthalpy from table C.4\n", - "hw2=2794 # enthalpy from table C.3\n", - "mdotw=(mdots*Cp*(Ts1-Ts2))/(hw2-hw1) # mass flow rate of water\n", - "print \" The mass flow rate of water is \",round(mdotw,2),\" kg/s \\n\"\n", - "Qdot=mdotw*(hw2-hw1) # heat transfer in kW using energy equation\n", - "# result\n", - "print \" The rate of heat transfer is \",round(Qdot),\" kW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The mass flow rate of water is 4.62 kg/s \n", - "\n", - " The rate of heat transfer is 12500.0 kW\n" - ] - } - ], - "prompt_number": 90 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file -- cgit