From 238d7e632aecde748a97437c2b5774e136a3b4da Mon Sep 17 00:00:00 2001 From: nice Date: Wed, 27 Aug 2014 16:12:51 +0530 Subject: adding book --- Thermodynamics/ch4.ipynb | 863 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 863 insertions(+) create mode 100755 Thermodynamics/ch4.ipynb (limited to 'Thermodynamics/ch4.ipynb') diff --git a/Thermodynamics/ch4.ipynb b/Thermodynamics/ch4.ipynb new file mode 100755 index 00000000..6ceae71d --- /dev/null +++ b/Thermodynamics/ch4.ipynb @@ -0,0 +1,863 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:ea35efcfa8b2b76b1ca1456260b722b88d999ecbb9e7a41ed6195c31bb1ca2a1" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 4 : Entropy" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.1 Page No : 6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables :\n", + "T1 = 400.;\t\t\t#Kelvin\n", + "T2 = 300.;\t\t\t#Kelvin\n", + "Q1 = 4800.;\t\t\t#KJ\n", + "Q2 = -4800.;\t\t\t#KJ\n", + "\n", + "# Calculations\n", + "#Q1/T1+Q2/T2< = 0\n", + "LHS = Q1/T1+Q2/T2;\t\t\t#\n", + "\n", + "# Results\n", + "print \"/T1+Q2/T2 = \",LHS\n", + "print (\"It is less than zero. Process is irreversible\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "/T1+Q2/T2 = -4.0\n", + "It is less than zero. Process is irreversible\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.2 Page No : 6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables :\n", + "T1 = 290.+273;\t\t\t#Kelvin\n", + "T2 = 8.5+273;\t\t\t#Kelvin\n", + "Q1 = 300.;\t\t\t#KJ\n", + "#Case 1 :\n", + "Q2 = -215.;\t\t\t#KJ\n", + "\n", + "# Calculations and Results\n", + "sigmaQbyT = Q1/T1+Q2/T2\n", + "print \"(i) Q1/T1+Q2/T2 = %.4f\"%sigmaQbyT\n", + "print (\"It is less than zero. Cycle is irreversible\")\n", + "\n", + "#Case 2 :\n", + "Q2 = -150.;\t\t\t#KJ\n", + "sigmaQbyT = Q1/T1+Q2/T2\n", + "print \"(ii) Q1/T1+Q2/T2 = %.0f\"%sigmaQbyT\n", + "print (\"It is equal to zero. Cycle is reversible\");\n", + "#Case 3 :\n", + "Q2 = -75.;\t\t\t#KJ\n", + "sigmaQbyT = Q1/T1+Q2/T2\n", + "print \"(iii) Q1/T1+Q2/T2 = %.4f\"%sigmaQbyT\n", + "print (\"It is greater than zero. Cycle is impossible.\");\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Q1/T1+Q2/T2 = -0.2309\n", + "It is less than zero. Cycle is irreversible\n", + "(ii) Q1/T1+Q2/T2 = 0\n", + "It is equal to zero. Cycle is reversible\n", + "(iii) Q1/T1+Q2/T2 = 0.2664\n", + "It is greater than zero. Cycle is impossible.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.3 Page No : 18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables :\n", + "V1 = 10.;\t\t\t#m**3\n", + "T1 = 175.+273;\t\t\t#Kelvin\n", + "T2 = 36.+273;\t\t\t#Kelvin\n", + "p1 = 5.;\t\t\t#bar\n", + "p2 = 1.;\t\t\t#bar\n", + "R = 287.;\t\t\t#KJ/KgK\n", + "Cp = 1.005;\t\t\t#KJ/KgK\n", + "\n", + "# Calculations\n", + "#p*V = m*R*T\n", + "m = p1*10**5*V1/R/T1;\t\t\t#Kg\n", + "deltaS = m*Cp*math.log(T2/T1)+m*R/1000*math.log(p1/p2);\t\t\t#KJ/K\n", + "\n", + "# Results\n", + "print \"Entropy change in KJ/K : %.3f\"%deltaS\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy change in KJ/K : 3.445\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.4 Page No : 18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "# Variables :\n", + "deltaS = 5.;\t\t\t#KJ/KgK\n", + "W = 2000.;\t\t\t#KJ/Kg\n", + "T1 = 327.+273;\t\t\t#Kelvin\n", + "\n", + "# Calculations and Results\n", + "Q1 = deltaS*T1;\t\t\t#KJ/Kg\n", + "Q2 = Q1-W;\t\t\t#KJ/Kg\n", + "Eta = W/Q1*100;\t\t\t#%\n", + "print \"Efficiency in %% : %.1f\"%Eta\n", + "\n", + "T2 = Q2/Q1*T1;\t\t\t#K\n", + "print \"Lowest temperature in Kelvin : \",T2\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Efficiency in % : 66.7\n", + "Lowest temperature in Kelvin : 200.0\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.5 Page No : 19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import scipy\n", + "from scipy.integrate import quad \n", + "\t\t\t\n", + "# Variables :\n", + "mc = 0.5;\t\t\t#Kg\n", + "Tc = 100.+273;\t\t\t#K\n", + "Cpc = 0.393;\t\t\t#KJ/KgK\n", + "Tw = 10.+273;\t\t\t#K\n", + "Cpw = 4.2;\t\t\t#KJ/KgK\n", + "\n", + "# Calculations and Results\n", + "def f0(T): \n", + "\t return mc*Cpc\n", + "\n", + "Q = quad(f0,Tc,Tw)[0]\n", + "\n", + "def f1(T): \n", + "\t return mc*Cpc/T\n", + "\n", + "deltaSc = quad(f1,Tc,Tw)[0]\n", + "\n", + "deltaSw = abs(Q)/Tw;\t\t\t#KJ/K\n", + "deltaSuniverse = deltaSc+deltaSw;\t\t\t#Kj/K\n", + "print \"Part (i) Chane in entropy in KJ/K : %.4f\"%deltaSuniverse\n", + "\n", + "T1 = 383.;\t\t\t#K\n", + "T2 = 283.;\t\t\t#K\n", + "T = (T1+T2)/2;\t\t\t#K\n", + "\n", + "def f2(T): \n", + "\t return 1/T\n", + "a = quad(f2,T1,T)[0]\n", + "deltaSuniverse = mc*Cpc*( a + 0.1627)\n", + "print \"Part (ii) Chane in entropy in KJ/K : %.5f\"%deltaSuniverse\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (i) Chane in entropy in KJ/K : 0.0082\n", + "Part (ii) Chane in entropy in KJ/K : 0.00448\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.6 Page No : 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables :\n", + "Tc = 35.+273;\t\t\t#K\n", + "W = 500.;\t\t\t#KJ\n", + "T1 = 308.;\t\t\t#K\n", + "T2 = 308.;\t\t\t#K\n", + "T0 = 15.+273;\t\t\t#K\n", + "Q = W;\t \t\t#KJ\n", + "deltaS1 = 0;\t\t\t#as heat supplied is zero\n", + "\n", + "# Calculations\n", + "deltaS2 = Q/T0;\t\t\t#KJ/K\n", + "\n", + "# Results\n", + "print \"Change in entropy in KJ/K : %.4f\"%deltaS2\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in entropy in KJ/K : 1.7361\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.7 Page No : 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "# Variables :\n", + "mi = 0.5;\t\t\t#Kg\n", + "Ti = -10.+273;\t\t\t#K\n", + "Cpi = 2.;\t\t\t#KJ/KgK\n", + "Cpw = 4.2;\t\t\t#KJ/KgK\n", + "Li = 334.;\t\t\t#KJ/Kg\n", + "mc = 5.;\t\t\t#Kg\n", + "Tc = 80.+273;\t\t\t#K\n", + "Cpc = 0.5;\t\t\t#KJ/KgK\n", + "T0 = 0.+273;\t\t\t#K\n", + "\n", + "# Calculations and Results\n", + "#mi*[Cpi*(T0-Ti)+Li+Cpw*(T-T0)] = mc*Cpc*(Tc-T)\n", + "T = (mc*Cpc*Tc-mi*Cpi*(T0-Ti)-mi*Li+mi*Cpw*T0)/(mi*Cpw+mc*Cpc);\t\t\t#K\n", + "deltaSi = mi*Cpi*math.log(T0/Ti)+Li/T0+mi*Cpw*math.log(T/T0);\t\t\t#KJ/K\n", + "print \"Entropy chane of Ice in KJ/K : %.4f\"%deltaSi\n", + "\n", + "deltaSc = mc*Cpc*math.log(T/Tc);\t\t\t#KJ/K\n", + "print \"Entropy chane of Copper in KJ/K : %.4f\"%deltaSc\n", + "\n", + "deltaSsurr = 0;\t\t\t#No heat transfer between system & Surrounding\n", + "deltaSuniverse = deltaSi+deltaSc+deltaSsurr;\t\t\t#KJ/K\n", + "print \"Entropy chane of universe in KJ/K : %.4f\"%deltaSuniverse\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy chane of Ice in KJ/K : 1.2989\n", + "Entropy chane of Copper in KJ/K : -0.5971\n", + "Entropy chane of universe in KJ/K : 0.7018\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.8 Page No : 21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import scipy\n", + "from scipy.integrate import quad \n", + "\t\t\t\n", + "# Variables :\n", + "m1 = 5.;\t\t\t#Kg\n", + "T1 = 200.+273;\t\t\t#K\n", + "Cp1 = 0.4;\t\t\t#KJ/KgK\n", + "m2 = 100.;\t\t\t#Kg\n", + "T2 = 30.+273;\t\t\t#K\n", + "Cp2 = 2.1;\t\t\t#KJ/KgK\n", + "\n", + "# Calculations\n", + "#m1*Cp1*(T1-T) = m2*Cp2*(T-T2)\n", + "T = (m1*Cp1*T1+T2*m2*Cp2)/(m2*Cp2+m1*Cp1);\t\t\t#K\n", + "\n", + "def f8(T): \n", + "\t return m1*Cp1/T\n", + "\n", + "deltaS1 = quad(f8,T1,T)[0]\n", + "\n", + "def f9(T): \n", + "\t return m2*Cp2/T\n", + "\n", + "deltaS2 = quad(f9,T2,T)[0]\n", + "deltaSsurr = 0;\t\t\t#No heat transfer neglected\n", + "deltaSuniverse = deltaS1+deltaS2+deltaSsurr;\t\t\t#KJ/K\n", + "\n", + "# Results\n", + "print \"Increase in Entropy of universe in KJ/K : %.4f\"%deltaSuniverse\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Increase in Entropy of universe in KJ/K : 0.2284\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.9 Page No : 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import scipy\n", + "from scipy.integrate import quad \n", + "\n", + "# Variables :\n", + "HeatTransfer = 2;\t\t\t#KJ/degreeCentigrade(it is d'Q/dT)\n", + "T1 = 27+273;\t\t\t#K\n", + "T2 = 127+273;\t\t\t#K\n", + "\n", + "# Calculations\n", + "def f22(T): \n", + "\t return HeatTransfer/T\n", + "\n", + "deltaS = quad(f22,T1,T2)[0]\n", + "\n", + "# Results\n", + "print \"Entropy change when heat is transfered to system in KJ/K : %.4f\"%deltaS\n", + "print \"change when end states are achieved by stirring action in KJ/K : %.4f\"%deltaS\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy change when heat is transfered to system in KJ/K : 0.5754\n", + "change when end states are achieved by stirring action in KJ/K : 0.5754\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.11 Page No : 23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import scipy\n", + "from scipy.integrate import quad \n", + "\t\t\t\n", + "# Variables :\n", + "m1 = 2.;\t\t\t#Kg\n", + "T1 = 80.+273;\t\t\t#K\n", + "m2 = 3.;\t\t\t#Kg\n", + "T2 = 30.+273;\t\t\t#K\n", + "Cp = 4.187;\t\t\t#KJ/KgK\n", + "\n", + "# Calculations\n", + "#m1*Cp1*(T1-T) = m2*Cp2*(T-T2)\n", + "T = (m1*Cp*T1+T2*m2*Cp)/(m2*Cp+m1*Cp);\t\t\t#K\n", + "\n", + "def f26(T): \n", + "\t return m1*Cp/T\n", + "\n", + "deltaS = quad(f26,T1,T)[0] + 0.8029\n", + "\n", + "print \"Total Entropy change due to mixing process in KJ/K : %.4f\"%deltaS\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total Entropy change due to mixing process in KJ/K : 0.0592\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.14 Page No : 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from scipy.integrate import quad \n", + "\t\t\t\n", + "# Variables :\n", + "V1 = 4.;\t\t\t#m**3\n", + "V2 = 4.;\t\t\t#m**3\n", + "m = 20.;\t\t\t#Kg\n", + "p1 = 4.*100;\t\t\t#KPa\n", + "p2 = 8.*100;\t\t\t#KPa\n", + "Cp = 1.005;\t\t\t#KJ/KgK\n", + "Cv = 0.718;\t\t\t#KJ/KgK\n", + "\n", + "# Calculations and Results\n", + "R = Cp-Cv;\t\t\t#KJ/KgK\n", + "T1 = p1*V1/m/R;\t\t\t#K\n", + "T2 = p2*V2/m/R;\t\t\t#K\n", + "deltaU = m*Cv*(T2-T1);\t\t\t#KJ\n", + "print \"Change in internal energy in KJ : %.2f\"%deltaU\n", + "W = 0;\t\t\t#KJ\n", + "print \"no movement, Work done in KJ : \",W\n", + "\n", + "Q = W+deltaU;\t\t\t#KJ\n", + "print \"Heat transfered in KJ : %.2f\"%Q\n", + "\n", + "def f19(T): \n", + "\t return m*Cv/T\n", + "\n", + "deltaS = quad(f19,T1,T2)[0]\n", + "\n", + "print \"Entropy change in KJ/K : %.4f\"%deltaS\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in internal energy in KJ : 4002.79\n", + "no movement, Work done in KJ : 0\n", + "Heat transfered in KJ : 4002.79\n", + "Entropy change in KJ/K : 9.9536\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.15 Page No : 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import scipy\n", + "from scipy.integrate import quad \n", + "\t\t\t\n", + "# Variables :\n", + "V1 = 4.;\t\t\t#m**3\n", + "V2 = 4.;\t\t\t#m**3\n", + "m = 600./1000;\t\t\t#Kg\n", + "C = 150.;\t\t\t#J/K\n", + "T1 = 100.+273;\t\t\t#K\n", + "T0 = 8.+273;\t\t\t#K\n", + "Cp = C/1000;\t\t\t#KJ/K\n", + "\n", + "# Calculations and Results\n", + "def f10(T): \n", + "\t return Cp/T\n", + "\n", + "deltaSblock = quad(f10,T1,T0)[0]\n", + "\n", + "Q = Cp*(T1-T0);\t\t\t#KJ\n", + "deltaSlake = Q/T0;\t\t\t#KJ/K\n", + "deltaSuniverse = deltaSblock+deltaSlake;\t\t\t#KJ/K\n", + "print \"Part (i) Entropy change of universe in KJ/K : %.4f\"%deltaSuniverse\n", + "\n", + "T1 = 8.+273;\t\t\t#K\n", + "Z = 100.;\t\t \t#meter\n", + "g = 9.81;\t\t\t #gravity constant\n", + "PE = m*g*Z/1000.;\t\t#KJ\n", + "deltaT = PE/Cp;\t\t\t#degree centigrade\n", + "T2 = T1+deltaT;\t\t\t#K\n", + "\n", + "def f11(T): \n", + "\t return Cp/T\n", + "\n", + "deltaSblock = - quad(f11,T1,T2)[0]\n", + "\n", + "deltaSlake = PE/T0;\t\t\t#KJ/K\n", + "deltaSuniverse = deltaSblock+deltaSlake;\t\t\t#KJ/K\n", + "print \"Part (ii) Entropy change of universe in %f KJ/K : \"%deltaSuniverse\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (i) Entropy change of universe in KJ/K : 0.0066\n", + "Part (ii) Entropy change of universe in 0.000014 KJ/K : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.17 Page No : 29" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "\n", + "# Variables :\n", + "m = 1.;\t\t\t#Kg\n", + "p1 = 1.;\t\t\t#bar\n", + "T1 = 290.;\t\t\t#K\n", + "p2 = 30.;\t\t\t#bar\n", + "T2 = 290.;\t\t\t#K\n", + "n = 1.3;\t\t\t#consmath.tant\n", + "R = 300.;\t\t\t#Nm/KgK\n", + "Cv = 0.72;\t\t\t#KJ/KgK\n", + "\n", + "# Calculations and Results\n", + "print (\"part (a) Isothermally\")\n", + "V1 = R*T1/p1/10**5;\t\t\t#m**3/Kg\n", + "V2 = p1*V1/p2;\t\t\t#m**3/Kg\n", + "w = p1*10**5*V1*math.log(V2/V1)/1000;\t\t\t#KJ/Kg\n", + "print \"Workdone in KJ/Kg : %.1f\"%w\n", + "\n", + "deltaU = m*Cv*(T2-T1);\t\t\t#KJ(as T1 = T2)\n", + "print \"Change in internal energy in KJ : \",deltaU\n", + "\n", + "q = w+deltaU;\t\t\t#KJ/Kg\n", + "print \"Heat transfer in KJ/Kg : %.1f\"%q\n", + "\n", + "S2subS1 = m*R/1000*math.log(V2/V1)+m*Cv*math.log(T2/T1);\t\t\t#KJ/KgK\n", + "print \"Change in entropy in KJ/KgK : %.4f\"%S2subS1\n", + "\n", + "print (\"\\npart (b) Polytropically\")\n", + "T2 = T1*(p2/p1)**((n-1)/n);\t\t\t#K\n", + "print \"Temperature T2 in K : %.1f\"%T2\n", + "\n", + "V1 = R*T1/p1/10**5;\t\t\t#m**3/Kg\n", + "V2 = (p1/p2)**(1/n)*V1;\t\t\t#m**3/Kg\n", + "w = m*R/1000*(T1-T2)/(n-1);\t\t\t#KJ/Kg\n", + "print \"Workdone in KJ/Kg : %.1f\"%w\n", + "\n", + "deltaU = m*Cv*(T2-T1);\t\t\t#KJ(as T1 = T2)\n", + "q = w+deltaU;\t\t\t#KJ/Kg\n", + "print \"Heat transfer in KJ/Kg : %.1f\"%q\n", + "\n", + "S2subS1 = m*R/1000*math.log(V2/V1)+m*Cv*math.log(T2/T1);\t\t\t#KJ/KgK\n", + "print \"Change in entropy in KJ/KgK : %.4f\"%S2subS1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "part (a) Isothermally\n", + "Workdone in KJ/Kg : -295.9\n", + "Change in internal energy in KJ : 0.0\n", + "Heat transfer in KJ/Kg : -295.9\n", + "Change in entropy in KJ/KgK : -1.0204\n", + "\n", + "part (b) Polytropically\n", + "Temperature T2 in K : 635.7\n", + "Workdone in KJ/Kg : -345.7\n", + "Heat transfer in KJ/Kg : -96.8\n", + "Change in entropy in KJ/KgK : -0.2198\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.18 Page No : 30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables :\n", + "P1 = 480.;\t\t\t#kPa\n", + "T1 = 190.+273;\t\t\t#K\n", + "T3 = 190.+273;\t\t\t#K\n", + "P2 = 94.;\t\t\t#kPa\n", + "P3 = 150.;\t\t\t#kPa\n", + "T2 = T3*P2/P3;\t\t\t#K\n", + "R = 0.29;\t\t\t#KJ/KgK\n", + "m = 1.;\t\t\t#Kg\n", + "Cp = 1.011;\t\t\t#KJ/KgK\n", + "\n", + "#T2/T1 = (P2/P1)**((Gamma-1)/Gamma)\n", + "#((Gamma-1)/Gamma) = math.log(T2/T1)/math.log(P2/P1);\t\t\t#\n", + "Gamma = 1.402;\t\t\t#by trial method\n", + "print \"Index of adiabatic expansion : %.2f\"%Gamma\n", + "\n", + "Cv = R/(Gamma-1);\t\t\t#KJ/KgK\n", + "W1_2 = m*R*(T1-T2)/(Gamma-1);\t\t\t#KJ/Kg\n", + "print \"Work done, W1-2 per Kg of air in KJ/Kg : %.2f\"%W1_2\n", + "\n", + "W2_3 = 0;\t\t\t#Consmath.tant volume process\n", + "print \"Work done, W2-3 per Kg of air in KJ/Kg : %.0f\"%W2_3\n", + "\n", + "W3_1 = m*R*T2*math.log(P3/P1);\t\t\t#KJ/Kg\n", + "print \"Work done, W1-2 per Kg of air in KJ/Kg : %.2f\"%W3_1\n", + "\n", + "W = W1_2+W2_3+W3_1;\t\t\t#KJ/Kg\n", + "print \"Total Work done in KJ/Kg : %.2f\"%W\n", + "\n", + "S2subS1 = 0;\t\t\t#adiabatic process\n", + "S3subS2 = m*R*math.log(P2/P3)+m*Cp*math.log(T3/T2);\t\t\t#KJ/KgK\n", + "print \"Change in specific entropy, S1-2 in KJ/KgK ; %.3f\"%S3subS2\n", + "\n", + "S1subS3 = -S2subS1-S3subS2;\t\t\t#KJ/KgK\n", + "print \"Change in specific entropy, S3-1 in KJ/KgK ; %.3f\"%S1subS3\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Index of adiabatic expansion : 1.40\n", + "Work done, W1-2 per Kg of air in KJ/Kg : 124.70\n", + "Work done, W2-3 per Kg of air in KJ/Kg : 0\n", + "Work done, W1-2 per Kg of air in KJ/Kg : -97.87\n", + "Total Work done in KJ/Kg : 26.82\n", + "Change in specific entropy, S1-2 in KJ/KgK ; 0.337\n", + "Change in specific entropy, S3-1 in KJ/KgK ; -0.337\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.21 Page No : 33" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\t\t\n", + "# Variables :\n", + "p1 = 5.;\t\t\t#bar\n", + "T1 = 30.+273;\t\t\t#K\n", + "p2 = 4.;\t\t\t#bar\n", + "m = 1.; \t\t\t#Kg\n", + "R = 0.287;\t\t\t#KJ/KgK\n", + "\n", + "# Calculations\n", + "#deltaS = m*R*math.log(p1/p2)+m*Cp*math.log(T2/T1);\t\t\t#KJ/kgK\n", + "deltaS = m*R*math.log(p1/p2);\t\t\t#KJ/kgK(T2/T1 leads to 2nd term zero)\n", + "\n", + "# Results\n", + "print \"Entropy Change in KJ/KgK : %.5f\"%deltaS\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entropy Change in KJ/KgK : 0.06404\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.22 Page No : 34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import scipy\n", + "from scipy.integrate import quad \n", + "\t\t\t\n", + "# Variables :\n", + "Cpg = 1.05;\t\t\t#KJ/KgK\n", + "t1 = 400.;\t\t\t#degree centigrade\n", + "t2 = 360.;\t\t\t#degree centigrade\n", + "T = 30.+273;\t\t\t#K\n", + "\n", + "# Calculations\n", + "Q = Cpg*(t1-t2);\t\t\t#KJ/Kg\n", + "deltaSsurr = Q/T;\t\t\t#KJ/KgK\n", + "\n", + "def f25(T): \n", + "\t return Cpg/T\n", + "\n", + "deltaSsystem = quad(f25,t1+273,t2+273)[0]\n", + "deltaSuniverse = deltaSsystem+deltaSsurr;\t\t\t#KJ/KgK\n", + "\n", + "# Results\n", + "print \"Change in entropy of the universe in KJ/KgK : %.4f\"%deltaSuniverse\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in entropy of the universe in KJ/KgK : 0.0743\n" + ] + } + ], + "prompt_number": 18 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file -- cgit