6.10: Air in rigid tank: two compartments#

A rigid tank contains air in two compartments. Compartment A containg \(1\:kg\) of air at \(P_A=200\:kPa\) and compartment B contains \(3\:kg\) of air at \(P_B=50\:kPa\). The tank is in thermal equilibrium with the surrounding at \(T=25^{\circ} C\). The middle divider is then removed redulting in air in two compartments being mixed and filling the whole tank. Assuming the temperature remains constant calculate:

a) final pressure assuming ideal gas

b) entropy generation assuming ideal gas

c) final pressure using CoolProp module

d) entropy generation using CoolProp module

e) error of entropy generation for ideal gas assumption

CH6-Q9.jpg

Solution Approach for a)#

from ideal gas law

\(V_{A,B}=m_{A,B}RT/P_{A,B}\)

for the tank

\(V=V_A+V_B\)

\(m=m_A+m_B\)

\(T=25^{\circ} C\)

to calculate final pressre from ideal gas assumption

\(P=mRT/V\)

#define variables
R = 0.287   #air gas constant in kJ/kg.K
C_v = 0.718   #air specific heat in constant colume kJ/kg.K
C_p = 1.005   #air specific heat in constant pressure kJ/kg.K

m_A = 1   #air mass at compartment A in kg
m_B = 3   #air mass at compartment B in kg

P_A = 200   #air pressure in compartment A in kPa
P_B = 50   #air pressure in compartment A in kPa

T = 25 + 273.15   #ambient and system temperature in K

V_A = m_A * R  * T / P_A   #volume of compartment A in m3
V_B = m_B * R  * T / P_B   #volume of compartment B in m3

V = V_A + V_B              #total volume in m3
m = m_A + m_B              #total mass in kg

P = m * R * T / V   #final pressure of mixture in kPa

print('The final pressure of the mixture assuming ideal gas is:', f"{P:.1f}", 'kPa')
The final pressure of the mixture assuming ideal gas is: 61.5 kPa

Solution Approach for b)#

\(\Delta s=q/T+s_{gen}\)

from first law

\(q=\Delta u+w\)

since the boundaries of the system are fixed (\(w\)) and also the temperature remains constant (\(\Delta u\)), heat transfer for the process is negligible

\(q=0\)

and

\(s_{gen}=\Delta s\)

for an ideal gas

\(s_2-s_1=C_pln(T_2/T_1)-Rln(P_2/P_1)\)

since \(T_2=T_1\)

\(s_2-s_1=-Rln(P_2/P_1)\)

# import the libraries we'll need
import numpy as np

ds_A = -1 * R * np.log(P/P_A)
ds_B = -1 * R * np.log(P/P_B)
ds_total = m_A * ds_A + m_B * ds_B   #changes in entropy calculated and summed up seperately for A and B
S_gen_ideal = ds_total

print('The entropy generation based on ideal gas assumption is:', f"{S_gen_ideal:.3f}", 'kJ/K')
The entropy generation based on ideal gas assumption is: 0.159 kJ/K

Solution Approach for c)#

same rules for the tank applies except ideal gas equation. Therefore, air properties obtained from CoolProp are used to obtain final pressure

import CoolProp.CoolProp as CP
fluid = "air"  # define the fluid or material of interest

D_A = CP.PropsSI("D", "T", T, "P", P_A * 1000 , fluid)   #fluid density at compartment A in kg/m3
D_B = CP.PropsSI("D", "T", T, "P", P_B * 1000 , fluid)   #fluid density at compartment B in kg/m3

V_A = m_A / D_A   #fluid volume at compartment A in m3
V_B = m_B / D_B   #fluid volume at compartment A in m3

V = V_A + V_B              #total volume in m3
m = m_A + m_B              #total mass in kg
D = m / V                  #final density in kg/m3

P_clp = CP.PropsSI("P", "T", T, "D", D, fluid)   #fluid pressure after mixture in Pa
print('The final pressure of the mixture using CoolProp is:', f"{P_clp/1000:.1f}", 'kPa')
The final pressure of the mixture using CoolProp is: 61.5 kPa

Solution Approach for d)#

Fluid properties obtained from CoolProp are to be used instead of equations based on ideal gas assumption to calculate changes in entropy

s_A = CP.PropsSI("S", "T", T, "P", P_A * 1000 , fluid)   #fluid entropy at compartment A in J/kg.K
s_B = CP.PropsSI("S", "T", T, "P", P_B * 1000 , fluid)   #fluid entropy at compartment B in J/kg.K
s_mix = CP.PropsSI("S", "T", T, "P", P_clp, fluid)   #fluid entropy after mixture in J/kg.K

ds_total = m_A * (s_mix - s_A) + m_B * (s_mix - s_B)   #changes in entropy calculated and summed up seperately for A and B in J/K
S_gen_clp = ds_total   #entropy generation in J/K

print('The entropy generation using CoolProp is:', f"{S_gen_clp/1000:.3f}", 'kJ/K')
The entropy generation using CoolProp is: 0.160 kJ/K

Solution Approach for e)#

E = np.absolute((S_gen_clp/1000 - S_gen_ideal)/(S_gen_clp/1000)) * 100

print('The error percentage for ideal gas assumption in calculating entropy generation is:', f"{E:.2f}", '%')
The error percentage for ideal gas assumption in calculating entropy generation is: 0.46 %