{ "metadata": { "name": "", "signature": "sha256:c0f28306b8717687dd43e0cba515058fc2c63cfc2e10a436e8c618a282c7ae33" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 5: Entropy" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 1, page no. 146" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "p1 = 5 #Initial pressure(in bar):\n", "T1 = 300 #Initial temperature(in K):\n", "p2 = 2 #Final pressure(in bar):\n", "Cp = 1.004 #Cp for air(in kJ/kg.K):\n", "R = 0.287 #Gas constant for air(in kJ/kg.K):\n", "\n", "#Calculation:\n", "T2 = T1 #As it is a throttling process:\n", "dS = Cp*log(T2/T1)-R*log(p2/p1)\t#Change in entropy(in kJ/kg.K):\n", "\n", "#Results:\n", "print \"Change in entropy: \",round(dS,3),\"KJ/Kg.K\" " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Change in entropy: 0.263 KJ/Kg.K\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 2, page no. 146" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from sympy import *\n", "\n", "#Variable Declaration: \n", "m = 5 #Mass of water(in kg):\n", "T1 = 27+273.16 #Atmospheric temperature(in K):\n", "T2 = 100+273.16 #Temperature of evaporation(in K):\n", "T3 = 400+273.16 #Temperature at which steam is generated(in K):\n", "Cp = 4.2 #Specific heat of water(in kJ/kg.K):\n", "q2 = 2260 #Heat of vaporisation(in kJ/kg):\n", "T = symbols('T') #Symbolic variable for Temperature:\n", "R = 8.314 #Universal gas constant:\n", "ms = 18 #Molar mass of steam (in g):\n", "\n", "#Calculation:\n", "Q1 = m*Cp*(T2-T1) #Heat added for increasing water temperature from 27C to 100C(in kJ):\t\t\t\t\n", "dS1 = Q1/T1 #Entropy change during water temperature rise(in kJ/K):\n", "Q2 = m*q2 #Heat of vaporization(in kJ):\n", "dS2 = Q2/T2 #Entropy change during water to steam change(in kJ/K):\n", "Rs = round(R/ms,3) #Value of R for steam (KJ/Kg.K)\n", "CP = Rs*(3.5+1.2*T+0.14*T**2) #Molar heat capacity at constant pressure for steam(J/Kg.K)\n", "dQ = m*10**-3*CP\n", "dS3 = round(integrate(apart(dQ/T),(T,T2,T3)),2)\n", "dS = dS1+dS2+dS3 #Total entropy change(in kJ/K):\n", "\n", "#Results:\n", "print \"!--- Small differences in error is due to integration approximation in coding ---!\"\n", "print \"Total change in entropy of universe: \",round(dS,2),\"KJ/K\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "!--- Small differences in error is due to integration approximation in coding ---!\n", "Total change in entropy of universe: 86.98 KJ/K\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3, page no. 147" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from math import log\n", "\n", "#Variable Declaration: \n", "p1 = 125 #Initial pressure(in kPa):\n", "p2 = 375 #Final pressure(in kPa):\n", "T1 = 27+273 #Intial temperature(in K):\n", "R = 8.314/32 #Gas constant for oxygen(in kJ/kg.K):\n", "\n", "#Calculation:\n", "dS = -R*log(p2/p1) #Change in entropy(in kJ/kg.K):\n", "\n", "#Results:\n", "print \"Change in entropy: \",round(dS,3),\"KJ/Kg.K\" " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Change in entropy: -0.285 KJ/Kg.K\n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 4, page no. 147" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "m = 1 #Mass of the block(in kg):\n", "T1 = 150+273.15 #Temperature of the block(in K):\n", "T2 = 25+273.15 #Temperature of the sea(in K):\n", "C = 0.393 #Heat capacity of copper(in kJ/kg.K):\n", "\n", "#Calculation:\n", "dSb = m*C*log(T2/T1) #Change in entropy of block(in kJ/K):\n", "Q = m*C*(T1-T2) #Heat lost by water(in kJ): #Heat lost by the block will be equal to heat gained by the water\n", "dSw = round(Q/T2,3) #Change in entropy of water(in kJ/K):\n", "dSu = dSb+dSw #Entropy change of universe(in kJ/K):\n", "\n", "#Results:\n", "print \"Change in entropy of universe: \",round(dSu*10**3,1),\"J/K\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Change in entropy of universe: 27.4 J/K\n" ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 5, page no. 148" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "\n", "#Variable Declaration: \n", "m = 1 #Mass of the block(in kg):\n", "T = 27+273 #Temperature of the block(in K):\n", "h = 200 #Height(in m):\n", "s = 0.393 #Heat capacity for copper(in kJ/kg.K):\n", "g = 9.81 #Acceleration due to gravity(in m/s**2):\n", "\n", "#Calculation:\n", "PE = m*g*h #Change in potential energy(in J):\n", "Q = PE #In this case:\n", "dSu = Q/T #Change in entropy of universe(in J/kg.K):\n", "\n", "#Results:\n", "print \"Change in entropy of universe: \" ,round(dSu,2),\"J/kg.K\" \n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Change in entropy of universe: 6.54 J/kg.K\n" ] } ], "prompt_number": 5 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 6, page no. 148" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "m1 = 1 #Mass(in kg) of Block 1:\n", "T1 = 150+273 #Temperature(in K):\n", "C1 = 0.393 #Specific heat(in kJ/kg.K):\n", "m2 = 0.5 #Mass(in kg) of Block 2:\n", "T2 = 0+273 #Temperature(in K):\n", "C2 = 0.381 #Specific heat(in kJ/kg.K):\n", "\n", "#Calculation:\n", "Tf = (m1*C1*T1+m2*C2*T2)/(m1*C1+m2*C2) #Final temperature(in K):\n", "dS1 = m1*C1*log(Tf/T1) #Entropy change in block 1(in kJ/K):\n", "dS2 = m2*C2*log(Tf/T2) #Entropy change in block 2(in kJ/K):\n", "dS = dS1+dS2 #Total entropy change(in kJ/K):\n", "\n", "#Results:\n", "print \"Change in entropy of universe: \",round(dS,4),\"J/K\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Change in entropy of universe: 0.0116 J/K\n" ] } ], "prompt_number": 6 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 8, page no. 149" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "\n", "#Variable Declaration: \n", "T1 = 1800 #Maximum temperature(in K):\n", "T2 = 300 #Minimum temperature(in K):\n", "Q1 = 5 #Rate at which heat is added(in MW):\n", "W = 2 #Work output(in MW):\n", "\n", "#Calculation:\n", "Q2 = Q1-W #Heat rejected(in MW):\n", "dSg = (-Q1/T1+Q2/T2) #Entropy generated(in MW/K):\n", "w = T2*dSg #Work lost(in MW):\n", "\n", "#Results:\n", "print \"Work lost: \",round(w,2),\"MW\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Work lost: 2.17 MW\n" ] } ], "prompt_number": 8 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 9, page no. 150" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "from sympy import *\n", "\n", "#Variable Declaration: \n", "T1 = 500 #Temperature of the system(in K):\n", "T2 = 300 #Temperature of the reservoir(in K):\n", "T = symbols('T') #Symbolic representation of tempreture:\n", "\n", "#Calculation:\n", "C = 0.05*T**2 + 0.10*T + 0.085 #Heat Capacity:\n", "Q1 = integrate(C,(T,T2,T1)) #Maximum heat(in J):\n", "dSs =integrate(apart(C/T),(T,T1,T2)) #Entropy change of the system(in J/K):\n", "W = (Q1/T2+dSs)*T2 #Maximum work available(in kJ):\n", "\n", "#Results:\n", "print \"Maximum work: \",round(W/(10**3),2),\"KJ\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Maximum work: 435.34 KJ\n" ] } ], "prompt_number": 9 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10, page no. 151" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "from sympy import *\n", "\n", "#Variable Declaration: \n", "p1 = 3000 #Initial pressure(in kPa):\n", "v1 = 0.05 #Initial volume(in m**3):\n", "v2 = 0.3 #Final volume(in m**3):\n", "n = 1.4 #Value of n:\n", "dS = 0 #Entropy change:\n", "T,P = symbols('T,P') #Symbolic expressions for T and P respectively\n", "\n", "#Calculation:\n", "p2 = round(p1*((v1/v2)**n)) #Final pressure(in MPa):\n", "V = (p1*v1**n/P)**(1/n)\n", "dH = integrate(V,(P,p2,p1)) #Change in enthalpy(in kJ):\n", "\n", "#Results:\n", "print \"Enthalpy change: \",round(dH,1),\"KJ\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Enthalpy change: 268.7 KJ\n" ] } ], "prompt_number": 10 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 11, page no. 152" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "m = 2 #Mass of air(in kg):\n", "v1 = 1 #Initial volume(in m**3):\n", "v2 = 10 #Final volume(in m**3):\n", "R = 287 #Gas const(in J/kg.K):\n", "\n", "#Calculation:\n", "dSa = m*R*log(v2/v1) #Change in entropy of air(in J/K):\n", "dSs = 0 #During free expansion, entropy change of surroundings(in J/K):\n", "dSu = dSa+dSs #Entropy change of universe(in J/K):\n", "\n", "#Results:\n", "print \"Entropy change of air: \",round(dSa,2),\"J/K\" \n", "print \"Entropy change of surroundings: \",round(dSs),\"J/K\"\n", "print \"Entropy change of universe: \",round(dSu,2),\"J/K\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Entropy change of air: 1321.68 J/K\n", "Entropy change of surroundings: 0.0 J/K\n", "Entropy change of universe: 1321.68 J/K\n" ] } ], "prompt_number": 11 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12, page no. 152" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "m = 0.5 #Mass of air(in kg):\n", "p1 = 1.013*10**5 #Initial pressure(in Pa):\n", "p2 = 0.8*10**6 #Final pressure(in Pa):\n", "T1 = 800 #Initial temperature(in K):\n", "n = 1.2 #Index of compression:\n", "r = 1.4 #Adiabatic index of compression:\n", "Cv = 0.71*10**3 #Value of Cv(in J/kg.K):\n", "\n", "#Calculation:\n", "T2 = T1*((p2/p1)**((n-1)/n)) #Final temperature(in K):\n", "dS = m*Cv*((n-r)/(n-1))*log(T2/T1) #Total entropy change(in J/K):\n", "\n", "#Results:\n", "print \"Entropy change: \",abs(round(dS,2)),\"J/K\"\t" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Entropy change: 122.27 J/K\n" ] } ], "prompt_number": 12 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 14, page no. 154" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "\n", "#Variable Declaration:\n", "Q1 = 500 #Heat supplied by source (Kcal/s)\n", "T1 = 600 #Temperature of source(K):\n", "T2 = 300 #Temperature of sink(K):\n", "def feasibility(Q2):\n", " Y = Q1/T1 - Q2/T2\n", " if(Y>0):\n", " return \"Under this condition engine is not possible\"\n", " elif (Y<0):\n", " return \"Engine is feasible and cycle is irreversible\"\n", " elif (Y==0):\n", " return \"Engine is feasible and cycle is reversible\"\n", "\n", "#Results:\n", "print \"(i) If heat rejected at 200 Kcal/s then \",feasibility(200)\n", "print \"(ii) If heat rejected at 400 Kcal/s then \",feasibility(400)\n", "print \"(iii) If heat rejected at 250 Kcal/s then \",feasibility(250) " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "(i) If heat rejected at 200 Kcal/s then Under this condition engine is not possible\n", "(ii) If heat rejected at 400 Kcal/s then Engine is feasible and cycle is irreversible\n", "(iii) If heat rejected at 250 Kcal/s then Engine is feasible and cycle is reversible\n" ] } ], "prompt_number": 16 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 15, page no. 154" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "p1 = 0.5 #Pressure at point 1(in MPa):\n", "T1 = 400 #Temperature at point 1(in K):\n", "p2 = 0.3 #Pressure at point 2(in MPa):\n", "T2 = 350 #Temperature at point 2(in K):\n", "R = 0.287 #Gas constant(in kJ/kg.K):\n", "Cp = 1.004 #Value of Cp(in kJ/kg.K):\n", "\n", "#Calculation:\n", "ds = Cp*log(T1/T2)-R*log(p1/p2) #Entropy change(in kJ/kg.K):\n", "\n", "#Results:\n", "print \"Change in entropy: \",round(ds,5),\"KJ/Kg.K\"\n", "print \"Hence flow occurs from 1 to 2 i.e. from 0.5 MPa, 400 K to 0.3 MPa & 350 K\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Change in entropy: -0.01254 KJ/Kg.K\n", "Hence flow occurs from 1 to 2 i.e. from 0.5 MPa, 400 K to 0.3 MPa & 350 K\n" ] } ], "prompt_number": 17 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 17, page no. 155" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "\n", "#Variable Declaration: \n", "Q12 = 1000 #Heat added in process 1-2(in kJ):\n", "Q34 = 800 #Heat added in process 3-4(in kJ):\n", "T1 = 500 #Temperature at point 1(in K):\n", "T3 = 400 #Temperature at point 3(in K):\n", "T5 = 300 #Temperature at point 5(in K):\n", "\n", "#Calculation:\n", "Qt = Q12+Q34 #Total heat added(in kJ):\n", "S12 = Q12/T1 #Entropy change from state 1-2(in kJ/K):\n", "S34 = Q34/T3 #Entropy change from state 3-4(in kJ/K):\n", "S56 = S12+S34 #Entropy change from state 5-6(in kJ/K):\n", "Q56 = T5*S56 #Heat rejected in process 5-6(in kJ):\n", "W = Q12+Q34-Q56 #Net work done(in kJ):\n", "n = W/Qt #Thermal efficiency of the cycle:\n", "\n", "#Results:\n", "print \"Work done: \",round(W),\"KJ\" \n", "print \"Thermal efficiency: \",round(n*100,2),\"%\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Work done: 600.0 KJ\n", "Thermal efficiency: 33.33 %\n" ] } ], "prompt_number": 19 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 18, page no. 156" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "from sympy import *\n", "#Variable Declaration: \n", "T1 = 800 #Temperature of the reservoirs(in K):\n", "T2 = 700\n", "T3 = 600\n", "T4 = 320 #Temperature of the sink(in K):\n", "Q2 = 10 #Total heat rejected to the heat sink(in kJ/s):\n", "W = 20 #Work done(in kW):\n", "Q11,Q12,Q13 = symbols('Q11,Q12,Q13')\n", "\n", "#Calculation:\n", "Q1 = Q2+W #Total heat added(in kJ/s):\n", "EQ1 = 0.7*Q12 - Q11 #Heat from reservoir 1(in kJ/s) formed as equation:\n", "EQ2 = Q1-1.7*Q12 - Q13 #Heat from reservoir 3(in kJ/s) formed as equation:\n", "EQ3 = Q11/T1 + Q12/T2 +Q13/T3 - Q2/T4 #For reversible engine\n", "result = solve([EQ1,EQ2,EQ3],[Q11,Q12,Q13])\n", "\n", "#Results:\n", "print \"!!!--There are some error in calculations in the book --!\"\n", "print \"Heat supplied by reservoir at 800 K: \",round(result[Q11],2),\"KJ/s\" \n", "print \"Heat supplied by reservoir at 700 K: \",round(result[Q12],2),\"KJ/s\"\n", "print \"Heat supplied by reservoir at 600 K: \",round(result[Q13],2),\"KJ/s\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "!!!--There are some error in calculations in the book --!\n", "Heat supplied by reservoir at 800 K: 24.78 KJ/s\n", "Heat supplied by reservoir at 700 K: 35.39 KJ/s\n", "Heat supplied by reservoir at 600 K: -30.17 KJ/s\n" ] } ], "prompt_number": 21 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 19, page no. 157" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from math import log\n", "#Variable Declaration: \n", "v1 = 0.04 #Volume of the chamber(in m**3):\n", "p1 = 10 #Initial pressure(in bar):\n", "T1 = 25+273 #Initial temperature(in K):\n", "R = 0.287 #Gas constant(in kJ/kg.K):\n", "Cv = 0.71 #Value of Cv(in kJ/kg.K):\n", "\n", "#Calculation:\n", "T2 = T1 #Final temperature(in K):\n", "v2 = 2*v1 #Final volume(in m**3):\n", "p2 = p1*v1/v2 #Final pressure(in bar):\n", "m = p1*10**2*v1/(R*T1) #Initial mass(in kg):\n", "dS = m*R*log(v2/v1)+m*Cv*log(T2/T1)\t#Change in entropy(in kJ/K):\n", "\n", "#Results:\n", "print \"Entropy change: \",round(dS,5), \"KJ/K\" \n", "print \"The process is irreversible\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Entropy change: 0.09304 KJ/K\n", "The process is irreversible\n" ] } ], "prompt_number": 22 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 20, page no. 158" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "ma = 0.6 #Mass in tank A(in kg):\n", "mb = 1 #Mass in tank B(in kg):\n", "Ta = 90+273 #Temperature in tank A(in K):\n", "Tb = 45+273 #Temperature in tank B(in K):\n", "pa = 1 #Pressure in tank A(in bar):\n", "pb = 2 #Pressure in tank B(in bar):\n", "R = 0.287 #Gas constant(in kJ/kg.K):\n", "Cp = 1.005 #Value of Cp(in kJ/kg.K):\n", "\n", "#Calculation:\n", "Tf = (ma*Ta+mb*Tb)/(ma+mb) #Final temperature(in K):\n", "va = ma*R*Ta/pa #Volume of tank A(in m**3):\n", "vb = mb*R*Tb/pb #Volume of tank B(in m**3):\n", "pf = (ma+mb)*R*Tf/(va+vb) #Final pressure(in kPa):\n", "dS = ma*(Cp*log(Tf/Ta)-R*log(pf/pa))+mb*(Cp*log(Tf/Tb)-R*log(pf/pb)) #Entropy change(in kJ/K):\n", "\n", "#Results:\n", "print \"Final Pressure: \",round(pf,2),\"KPa\"\n", "print \"Entropy produced: \",round(dS,5),\"KJ/K\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Final Pressure: 1.42 KPa\n", "Entropy produced: 0.04061 KJ/K\n" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 21, page no. 159" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from __future__ import division\n", "from math import log\n", "\n", "#Variable Declaration: \n", "va = 4 #Volume of the tanks(in m**3):\n", "vb = 4\n", "vc = 4\n", "pa = 6 #Pressure in tank A(in bar):\n", "Ta = 90+273 #Temperature in tank A(in K):\n", "pb = 3 #Pressure in tank B(in bar):\n", "Tb = 300+273 #Temperature in tank B(in K):\n", "pc = 12 #Pressure in tank C(in bar):\n", "Tc = 50+273 #Temperature in tank C(in K):\n", "Ra = 0.287 #Gas constant for air(in kJ/kg.K):\n", "Rn = 0.297 #Gas constant for nitrogen(in kJ/kg.K):\n", "ra = 1.4 #Adiabatic index of compression for air:\n", "rn = 1.4 #Adiabatic index of compression for nitrogen:\n", "Cp = 1.005 #Value of Cp(in kJ/kg.K):\n", "Cv = 0.718 #Value of Cv(in kJ/kg.K):\n", "\n", "#Calculations:\n", "ma = pa*10**2*va/(Ra*Ta) #Mass in tank A(in kg): #Part (i)\n", "mb = pb*10**2*vb/(Ra*Tb) #Mass in tank B(in kg):\n", "Td = (ma*Ta+mb*Tb)/(ma+mb) #Final temperature(in K):\n", "pd = Ra*Td*(ma+mb)/((va+vb)*10**2) #Final pressure(in bar):\n", "dS1 = ma*Cp*log(Td/Ta)-ma*Ra*log(pd/pa)+mb*Cp*log(Td/Tb)-mb*Ra*log(pd/pb) #Entropy change(in kJ/K):\n", "mc = pc*10**2*vc/(Rn*Tc) #Mass in tank C(in kg): #Part (ii)\n", "md = ma+mb #Mass in tank D(in kg):\n", "Cvn = Rn/(rn-1) #Value of Cv for nitrogen(in kJ/kg.K):\n", "Cpn = rn*Cvn #Value of Cp for nitrogen(in kJ/kg.K):\n", "mf = md+mc #Total mass(in kg):\n", "CvF = (md*Cv+mc*Cvn)/mf #Final Cv(in kJ/kg.K):\n", "RF = (md*Ra+mc*Rn)/mf #Final gas constant(in kJ/kg.K):\n", "TF = (md*Cv*Td+mc*Cvn*Tc)/(mf*CvF) #Final temperature(in K):\n", "VF = va+vb+vc #Final volume(in m**3):\n", "pF = mf*RF*TF/VF #Final pressure(in kPa):\n", "dS2 = md*(Cp*log(TF/Td)-Ra*log(pF/(pd*10**2)))+mc*(Cpn*log(TF/Tc)-Rn*log(pF/(pc*10**2))) #Change in entropy(in kJ/K):\n", "\n", "#Results:\n", "print \"Entropy change in case 1: \",round(dS1,3),\"KJ/K\"\n", "print \"Entropy change in case 2: \",round(dS2,3),\"KJ/K\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Entropy change in case 1: 1.677 KJ/K\n", "Entropy change in case 2: 4.761 KJ/K\n" ] } ], "prompt_number": 24 } ], "metadata": {} } ] }