#pg 98
#calculate the new pressure and difference in two levels
print('Example 5.1');
# aim : To determine
# new pressure exerted on the air and the difference in two mercury column level
# Given values
P1 = 765.;# atmospheric pressure, [mmHg]
V1 = 20000.;# [mm^3]
V2 = 17000.;# [mm^3]
# solution
# using boyle's law P*V=constant
# hence
P2 = P1*V1/V2;# [mmHg]
del_h = P2-P1;# difference in Height of mercury column level
#results
print ' The new pressure exerted on the air (mmHg) = ',P2
print ' The difference in the two mercury column level (mm) = ',del_h
# End
#pg 99
#calculate the new volume
print('Example 5.2');
# aim : To determine
# the new volume
# Given values
P1 = 300;# original pressure,[kN/m^2]
V1 = .14;# original volume,[m^3]
P2 = 60.;# new pressure after expansion,[kn/m^2]
# solution
# since temperature is constant so using boyle's law P*V=constant
V2 = V1*P1/P2;# [m^3]
#results
print ' The new volume after expansion (m^3) = ',V2
# End
#pg 101
#calculate the new volume
print('Example 5.3');
# aim : To determine
# the new volume of the gas
# Given values
V1 = 10000;# [mm^3]
T1 = 273.+18;# [K]
T2 = 273.+85;# [K]
# solution
# since pressure exerted on the apparatus is constant so using charle's law V/T=constant
# hence
V2 = V1*T2/T1;# [mm^3]
#results
print ' The new volume of the gas trapped in the apparatus (mm^3) = ',round(V2)
# End
#pg 102
#calculate the final temperature
print('Example 5.4');
# aim : To determine
# the final temperature
# Given values
V1 = .2;# original volume,[m^3]
T1 = 273+303;# original temperature, [K]
V2 = .1;# final volume, [m^3]
# solution
# since pressure is constant, so using charle's law V/T=constant
# hence
T2 = T1*V2/V1;# [K]
t2 = T2-273;# [C]
#results
print ' The final temperature of the gas (C) = ',t2
# End
#pg 106
#calculate the new volume
print('Example 5.5');
# aim : To determine
# the new volume of the gas
# Given values
# initial codition
P1 = 140;# [kN/m^2]
V1 = .1;# [m^3]
T1 = 273+25;# [K]
# final condition
P2 = 700.;# [kN/m^2]
T2 = 273.+60;# [K]
# by charasteristic equation, P1*V1/T1=P2*V2/T2
V2=P1*V1*T2/(T1*P2);# final volume, [m^3]
#results
print 'The new volume of the gas (m^3) = ',round(V2,4)
# End
#pg 106
#calculate the new temperature and mass of gas
print('Example 5.6');
# aim : To determine
# the mas of the gas and new temperature
# Given values
P1 = 350;# [kN/m^2]
V1 = .03;# [m^3]
T1 = 273+35;# [K]
R = .29;# Gas constant,[kJ/kg K]
# solution
# using charasteristic equation, P*V=m*R*T
m = P1*V1/(R*T1);# [Kg]
# Now the gas is compressed
P2 = 1050;# [kN/m^2]
V2 = V1;
# since mass of the gas is constant so using, P*V/T=constant
# hence
T2 = T1*P2/P1# [K]
t2 = T2-273;# [C]
#results
print ' The mass of the gas present (kg) = ',round(m,3)
print ' The new temperature of the gas (C) = ',t2
# End
#pg 111
#calculate the final pressure and heat transferred
print('Example 5.7');
# aim : To determine
# the heat transferred to the gas and its final pressure
# Given values
m = 2;# masss of the gas, [kg]
V1 = .7;# volume,[m^3]
T1 = 273+15;# original temperature,[K]
T2 = 273+135;# final temperature,[K]
cv = .72;# specific heat capacity at constant volume,[kJ/kg K]
R = .29;# gas law constant,[kJ/kg K]
# solution
Q = m*cv*(T2-T1);# Heat transferred at constant volume,[kJ]
# Now,using P1*V1=m*R*T1
P1 = m*R*T1/V1;# [kN/m^2]
# since volume of the system is constant, so P1/T1=P2/T2
# hence
P2 = P1*T2/T1;# final pressure,[kN/m^2]
#results
print ' The heat transferred to the gas (kJ) = ',Q
print ' The final pressure of the gas (kN/m^2) = ',round(P2,2)
# End
#pg 114
#calculate the heat transferred and work done
print('Example 5.8');
# aim : To determine
# the heat transferred from the gas and the work done on the gas
# Given values
P1 = 275;# pressure, [kN/m^2]
V1 = .09;# volume,[m^3]
T1 = 273+185;# initial temperature,[K]
T2 = 273+15;# final temperature,[K]
cp = 1.005;# specific heat capacity at constant pressure,[kJ/kg K]
R = .29;# gas law constant,[kJ/kg K]
# solution
# using P1*V1=m*R*T1
m = P1*V1/(R*T1);# mass of the gas
# calculation of heat transfer
Q = m*cp*(T2-T1);# Heat transferred at constant pressure,[kJ]
# calculation of work done
# Now,since pressure is constant so, V/T=constant
# hence
V2 = V1*T2/T1;# [m^3]
W = P1*(V2-V1);# formula for work done at constant pressure,[kJ]
#results
print ' The heat transferred to the gas (kJ) = ',round(Q,2)
print ' Work done on the gas during the process (kJ) = ',round(W,2)
# End
#pg 117
#calculate the new pressure
print('Example 5.9');
# aim : To determine
# the new pressure of the gas
# Given values
P1 = 300.;# original pressure,[kN/m**2]
T1 = 273.+25;# original temperature,[K]
T2 = 273.+180;# final temperature,[K]
# solution
# since gas compressing according to the law,P*V**1.4=constant
# so,for polytropic process,T1/T2=(P1/P2)**((n-1)/n),here n=1.4
# hence
P2 = P1*(T2/T1)**((1.4)/(1.4-1));# [kN/m**2]
#results
print ' The new pressure of the gas (kN/m^2) = ',round(P2)
# End
#pg 118
#calculate the new temperature
print('Example 5.10');
# aim : To determine
# the new temperature of the gas
# Given values
V1 = .015;# original volume,[m**3]
T1 = 273.+285;# original temperature,[K]
V2 = .09;# final volume,[m**3]
# solution
# Given gas is following the law,P*V**1.35=constant
# so process is polytropic with
n = 1.35; # polytropic index
# hence
T2 = T1*(V1/V2)**(n-1);# final temperature, [K]
t2 = T2-273;# [C]
#results
print ' The new temperature of the gas (C) = ',round(t2,1)
print ' there is minor error in book answer due to rounding off error'
# End
#pg 119
#calculate the final pressure, temperature and volume of gas
print('Example 5.11');
# aim : To determine the
# (a) original and final volume of the gas
# (b) final pressure of the gas
# (c) final temperature of the gas
# Given values
m = .675;# mass of the gas,[kg]
P1 = 1.4;# original pressure,[MN/m**2]
T1 = 273+280;# original temperature,[K]
R = .287;#gas constant,[kJ/kg K]
# solution and results
# (a)
# using characteristic equation, P1*V1=m*R*T1
V1 = m*R*T1*10**-3/P1;# [m**3]
# also Given
V2 = 4*V1;# [m**3]
print ' (a) The original volume of the gas (m^3) = ',round(V1,4)
print ' and The final volume of the gas (m^3) = ',round(V2,3)
# (b)
# Given that gas is following the law P*V**1.3=constant
# hence process is polytropic with
n = 1.3; # polytropic index
P2 = P1*(V1/V2)**n;# formula for polytropic process,[MN/m**2]
print ' (b) The final pressure of the gas (kN/m^2) = ',round(P2*10**3)
# (c)
# since mass is constant so,using P*V/T=constant
# hence
T2 = P2*V2*T1/(P1*V1);# [K]
t2 = T2-273;# [C]
print ' (c) The final temperature of the gas (C) = ',round(t2)
# End
#pg 120
#calculate the change in internal energy, work done and heat transfer
print('Example 5.12');
# aim : T0 determine
# (a) change in internal energy of the air
# (b) work done
# (c) heat transfer
# Given values
m = .25;# mass, [kg]
P1 = 140;# initial pressure, [kN/m**2]
V1 = .15;# initial volume, [m**3]
P2 = 1400;# final volume, [m**3]
cp = 1.005;# [kJ/kg K]
cv = .718;# [kJ/kg K]
# solution
# (a)
# assuming ideal gas
R = cp-cv;# [kJ/kg K]
# also, P1*V1=m*R*T1,hence
T1 = P1*V1/(m*R);# [K]
# given that process is polytropic with
n = 1.25; # polytropic index
T2 = T1*(P2/P1)**((n-1)/n);# [K]
# Hence, change in internal energy is,
del_U = m*cv*(T2-T1);# [kJ]
print ' (a) The change in internal energy of the air is del_U (kJ) = ',round(del_U,2)
if(del_U>0):
print('since del_U>0, so it is gain of internal energy to the air')
else:
print('since del_U<0, so it is gain of internal energy to the surrounding')
# (b)
W = m*R*(T1-T2)/(n-1);# formula of work done for polytropic process,[kJ]
print ' (b) The work done is (kJ) = ',round(W,1)
if(W>0):
print('since W>0, so the work is done by the air')
else:
print('since W<0, so the work is done on the air')
# (c)
Q = del_U+W;# using 1st law of thermodynamics,[kJ]
print ' (c) The heat transfer is Q (kJ) = ',round(Q,2)
if(Q>0):
print('since Q>0, so the heat is received by the air')
else:
print('since Q<0, so the heat is rejected by the air')
print 'The answer is a bit different from textbook due to rounding off error'
# End
#pg 123
#calculate the final volume, work done and the change in internal energy
print('Example 5.13');
# aim : To determine the
# final volume, work done and the change in internal energy
# Given values
P1 = 700.;# initial pressure,[kN/m^2]
V1 = .015;# initial volume, [m^3]
P2 = 140.;# final pressure, [kN/m^2]
cp = 1.046;# [kJ/kg K]
cv = .752; # [kJ/kg K]
# solution
Gamma = cp/cv;
# for adiabatic expansion, P*V^gamma=constant, so
V2 = V1*(P1/P2)**(1/Gamma);# final volume, [m^3]
print '\n The final volume of the gas is V2 (m^3) = ',round(V2,3)
# work done
W = (P1*V1-P2*V2)/(Gamma-1);# [kJ]
print '\n The work done by the gas is (kJ) = ',round(W,2)
# for adiabatic process
del_U = -W;# [kJ]
print '\n The change of internal energy is (kJ) = ',round(del_U,2)
if(del_U>0):
print 'since del_U>0, so the the gain in internal energy of the gas '
else:
print 'since del_U<0, so this is a loss of internal energy from the gas'
print 'The answer is a bit different from textbook due to rounding off error'
# End
#pg 125
#calculate the heat transfer, change of internal energy and mass of gas
print('Example 5.14');
import math
# aim : To determine the
# (a)heat transfer
# (b)change of internal energy
# (c)mass of gas
# Given values
V1 = .4;# initial volume, [m^3]
P1 = 100.;# initial pressure, [kN/m^2]
T1 = 273.+20;# temperature, [K]
P2 = 450.;# final pressure,[kN/m^2]
cp = 1.0;# [kJ/kg K]
Gamma = 1.4; # heat capacity ratio
# solution
# (a)
# for the isothermal compression,P*V=constant,so
V2 = V1*P1/P2;# [m^3]
W = P1*V1*math.log(P1/P2);# formula of workdone for isothermal process,[kJ]
# for isothermal process, del_U=0;so
Q = W;
print '\n (a) The heat transferred during compression is Q (kJ) = ',round(Q)
# (b)
V3 = V1;
# for adiabatic expansion
# also
P3 = P2*(V2/V3)**Gamma;# [kN/m^2]
W = -(P3*V3-P2*V2)/(Gamma-1);# work done formula for adiabatic process,[kJ]
# also, Q=0,so using Q=del_U+W
del_U = -W;# [kJ]
print '\n (b) The change of the internal energy during the expansion is,del_U (kJ) = ',round(del_U,1)
# (c)
# for ideal gas
# cp-cv=R, and cp/cv=gamma, hence
R = cp*(1-1/Gamma);# [kj/kg K]
# now using ideal gas equation
m = P1*V1/(R*T1);# mass of the gas,[kg]
print '\n (c) The mass of the gas is,m (kg) = ',round(m,3)
print' There is calculation mistake in the book'
# End
#pg 128
#calculate the the heat transferred and polytropic specific heat capacity
print('Example 5.15');
# aim : To determine
# the heat transferred and polytropic specific heat capacity
# Given values
P1 = 1;# initial pressure, [MN/m^2]
V1 = .003;# initial volume, [m^3]
P2 = .1;# final pressure,[MN/m^2]
cv = .718;# [kJ/kg*K]
Gamma=1.4;# heat capacity ratio
# solution
# Given process is polytropic with
n = 1.3;# polytropic index
# hence
V2 = V1*(P1/P2)**(1/n);# final volume,[m^3]
W = (P1*V1-P2*V2)*10**3/(n-1);# work done,[kJ]
# so
Q = (Gamma-n)*W/(Gamma-1);# heat transferred,[kJ]
print ' The heat received or rejected by the gas during this process is Q (kJ) = ',round(Q,2)
if(Q>0):
print 'since Q>0, so heat is received by the gas'
else:
print 'since Q<0, so heat is rejected by the gas'
# now
cn = cv*(Gamma-n)/(n-1);# polytropic specific heat capacity,[kJ/kg K]
print '\n The polytropic specific heat capacity is cn (kJ/kg K) = ',round(cn,3)
# End
#pg 129
print('Example 5.16');
# To determine the
# (a) initial partial pressure of the steam and air
# (b) final partial pressure of the steam and air
# (c) total pressure in the container after heating
# Given values
T1 = 273.+39;# initial temperature,[K]
P1 = 100.;# pressure, [MN/m^2]
T2 = 273.+120.2;# final temperature,[K]
# solution
# (a)
# from the steam tables, the pressure of wet steam at 39 C is
Pw1 = 7;# partial pressure of wet steam,[kN/m^2]
# and by Dalton's law
Pa1 = P1-Pw1;# initial pressure of air, [kN/m^2]
print '\n (a) The initial partial pressure of the steam is (kN/m^2) = ',Pw1
print '\n The initial partial pressure of the air is (kN/m^2) = ',Pa1
# (b)
# again from steam table, at 120.2 C the pressure of wet steam is
Pw2 = 200.;# [kN/m^2]
# now since volume is constant so assuming air to be ideal gas so for air P/T=contant, hence
Pa2 = Pa1*T2/T1 ;# [kN/m^2]
print ' \n(b) The final partial pressure of the steam is (kN/m^2) = ',Pw2
print '\n The final partial pressure of the air is (kN/m^2) = ',round(Pa2,2)
# (c)
Pt = Pa2+Pw2;# using dalton's law, total pressure,[kN/m^2]
print '\n (c) The total pressure after heating is (kN/m^2) = ',round(Pt,2)
# End
#pg 130
print('Example 5.17');
# aim : To determine
# the partial pressure of the air and steam, and the mass of the air
# Given values
P1 = 660.;# vaccum gauge pressure on condenser [mmHg]
P = 765.;# atmospheric pressure, [mmHg]
x = .8;# dryness fraction
T = 273.+41.5;# temperature,[K]
ms_dot = 1500.;# condense rate of steam,[kg/h]
R = .29;# [kJ/kg]
# solution
Pa = (P-P1)*.1334;# absolute pressure,[kN/m^2]
# from steam table, at 41.5 C partial pressure of steam is
Ps = 8;# [kN/m^2]
# by dalton's law, partial pressure of air is
Pg = Pa-Ps;# [kN/m^2]
print '\n The partial pressure of the air in the condenser is (kN/m^2) = ',round(Pg)
print '\n The partial pressure of the steam in the condenser is (kN/m^2) = ',Ps
# also
vg = 18.1;# [m^3/kg]
# so
V = x*vg;# [m^3/kg]
# The air associated with 1 kg of the steam will occupiy this same volume
# for air, Pg*V=m*R*T,so
m = Pg*V/(R*T);# [kg/kg steam]
# hence
ma = m*ms_dot;# [kg/h]
print '\n The mass of air which will associated with this steam is (kg) = ',round(ma,1)
print' There is misprint in book'
# End
#pg 130
print('Example 5.18');
# aim : To determine the
# (a) final pressure
# (b) final dryness fraction of the steam
# Given values
P1 = 130.;# initial pressure, [kN/m^2]
T1 = 273.+75.9;# initial temperature, [K]
x1 = .92;# initial dryness fraction
T2 = 273.+120.2;# final temperature, [K]
# solution
# (a)
# from steam table, at 75.9 C
Pws = 40.;# partial pressure of wet steam[kN/m^2]
Pa = P1-Pws;# partial pressure of air, [kN/m^2]
vg = 3.99# specific volume of the wet steam, [m^3/kg]
# hence
V1 = x1*vg;# [m^3/kg]
V2 = V1/5;# [m^3/kg]
# for air, mass is constant so, Pa*V1/T1=P2*V2/T2,also given ,V1/V2=5,so
P2 = Pa*V1*T2/(V2*T1);# final pressure,[kN/m^2]
# now for steam at 120.2 C
Ps = 200.;# final partial pressure of steam,[kN/m^2]
# so by dalton's law total pressure in cylindert is
Pt = P2+Ps;# [kN/m^2]
print ' (a) The final pressure in the cylinder is (kN/m^2) = ',round(Pt,1)
# (b)
# from steam table at 200 kN/m^2
vg = .885;# [m^3/kg]
# hence
x2 = V2/vg;# final dryness fraction of the steam
print ' (b) The final dryness fraction of the steam is = ',round(x2,2)
# End
#pg 131
print('Example 5.19')
# aim : To determine the
# (a) Gamma,
# (b) del_U
import math
# Given Values
P1 = 1400.;# [kN/m^2]
P2 = 100.;# [kN/m^2]
P3 = 220.;# [kN/m^2]
T1 = 273.+360;# [K]
m = .23;# [kg]
cp = 1.005;# [kJ/kg*K]
# Solution
T3 = T1;# since process 1-3 is isothermal
# (a)
# for process 1-3, P1*V1=P3*V3,so
V3_by_V1 = P1/P3;
# also process 1-2 is adiabatic,so P1*V1^(Gamma)=P2*V2^(Gamma),hence
# and process process 2-3 is iso-choric so,V3=V2 and
V2_by_V1 = V3_by_V1;
# hence,
Gamma = math.log(P1/P2)/math.log(P1/P3); # heat capacity ratio
print ' (a) The value of adiabatic index Gamma is = ',round(Gamma,3)
# (b)
cv = cp/Gamma;# [kJ/kg K]
# for process 2-3,P3/T3=P2/T2,so
T2 = P2*T3/P3;# [K]
# now
del_U = m*cv*(T2-T1);# [kJ]
print ' (b) The change in internal energy during the adiabatic expansion is U2-U1 (This is loss of internal energy) (kJ) = ',round(del_U,2)
# End
#pg 133
print('Example 5.20');
# aim : To determine
# the mass of oxygen and heat transferred
# Given values
V1 = 300.;# [L]
P1 = 3.1;# [MN/m^2]
T1 = 273.+18;# [K]
P2 = 1.7;# [MN/m^2]
T2 = 273.+15;# [K]
Gamma = 1.4; # heat capacity ratio
# density condition
P = .101325;# [MN/m^2]
T = 273.;# [K]
V = 1.;# [m^3]
m = 1.429;# [kg]
# hence
R = P*V*10**3/(m*T);# [kJ/kg*K]
# since volume is constant
V2 = V1;# [L]
# for the initial conditions in the cylinder,P1*V1=m1*R*T1
m1 = P1*V1/(R*T1);# [kg]
# after some of the gas is used
m2 = P2*V2/(R*T2);# [kg]
# The mass of oxygen remaining in cylinder is m2 kg,so
# Mass of oxygen used is
m_used = m1-m2;# [kg]
print ' The mass of oxygen used (kg) = ',round(m_used,1)
# for non-flow process,Q=del_U+W
# volume is constant so no external work is done so,Q=del_U
cv = R/(Gamma-1);# [kJ/kg*K]
# heat transfer is
Q = m2*cv*(T1-T2);# (kJ)
print ' The amount of heat transferred through the cylinder wall is (kJ) = ',round(Q,2)
# End
#pg 134
print('Example 5.21');
# aim : To determine the
# (a) work transferred during the compression
# (b) change in internal energy
# (c) heat transferred during the compression
# Given values
V1 = .1;# initial volume, [m^3]
P1 = 120.;# initial pressure, [kN/m^2]
P2 = 1200.; # final pressure, [kN/m^2]
T1 = 273.+25;# initial temperature, [K]
cv = .72;# [kJ/kg*K]
R = .285;# [kJ/kg*K]
# solution
# (a)
# given process is polytropic with
n = 1.2; # polytropic index
# hence
V2 = V1*(P1/P2)**(1/n);# [m^3]
W = (P1*V1-P2*V2)/(n-1);# workdone formula, [kJ]
print ' (a) The work transferred during the compression is (kJ) = ',round(W,1)
# (b)
# now mass is constant so,
T2 = P2*V2*T1/(P1*V1);# [K]
# using, P*V=m*R*T
m = P1*V1/(R*T1);# [kg]
# change in internal energy is
del_U = m*cv*(T2-T1);# [kJ]
print ' (b) The change in internal energy is (kJ) = ',round(del_U,1)
# (c)
Q = del_U+W;# [kJ]
print ' (c) The heat transferred during the compression is (kJ) = ',round(Q,0)
# End
#pg 135
print('Example 5.22');
# aim : To determine the
# (a) new pressure of the air in the receiver
# (b) specific enthalpy of air at 15 C
# Given values
V1 = .85;# [m^3]
T1 = 15.+273;# [K]
P1 = 275.;# pressure,[kN/m^2]
m = 1.7;# [kg]
cp = 1.005;# [kJ/kg*K]
cv = .715;# [kJ/kg*K]
# solution
# (a)
R = cp-cv;# [kJ/kg*K]
# assuming m1 is original mass of the air, using P*V=m*R*T
m1 = P1*V1/(R*T1);# [kg]
m2 = m1+m;# [kg]
# again using P*V=m*R*T
# P2/P1=(m2*R*T2/V2)/(m1*R*T1/V1); and T1=T2,V1=V2,so
P2 = P1*m2/m1;# [kN/m^2]
print ' (a) The new pressure of the air in the receiver is (kN/m^2) = ',round(P2)
# (b)
# for 1 kg of air, h2-h1=cp*(T1-T0)
# and if 0 is chosen as the zero enthalpy, then
h = cp*(T1-273);# [kJ/kg]
print ' (b) The specific enthalpy of the air at 15 C is (kJ/kg) = ',h
# End
#pg 136
print('Example 5.23');
# aim : T determine the
# (a) characteristic gas constant of the gas
# (b) cp,
# (c) cv,
# (d) del_u
# (e) work transfer
# Given values
P = 1.;# [bar]
T1 = 273.+15;# [K]
m = .9;# [kg]
T2 = 273.+250;# [K]
Q = 175.;# heat transfer,[kJ]
# solution
# (a)
# using, P*V=m*R*T, given,
m_by_V = 1.875;
# hence
R = P*100/(T1*m_by_V);# [kJ/kg*K]
print ' (a) The characteristic gas constant of the gas is R (kJ/kg K) = ',round(R,3)
# (b)
# using, Q=m*cp*(T2-T1)
cp = Q/(m*(T2-T1));# [kJ/kg K]
print ' (b) The specific heat capacity of the gas at constant pressure cp (kJ/kg K) = ',round(cp,3)
# (c)
# we have, cp-cv=R,so
cv = cp-R;# [kJ/kg*K]
print ' (c) The specific heat capacity of the gas at constant volume cv (kJ/kg K) = ',round(cv,3)
# (d)
del_U = m*cv*(T2-T1);# [kJ]
print ' (d) The change in internal energy is (kJ) = ',round(del_U)
# (e)
# using, Q=del_U+W
W = Q-del_U;# [kJ]
print ' (e) The work transfer is W (kJ) = ',round(W)
# End
#pg 136
print('Example 5.24');
# aim : To determine the
# (a) work transfer,
# (b)del_U and,
# (c)heat transfer
# Given values
V1 = .15;# [m^3]
P1 = 1200.;# [kN/m^2]
T1 = 273.+120;# [K]
P2 = 200.;# [kN/m^2]
cp = 1.006;#[kJ/kg K]
cv = .717;# [kJ/kg K]
# solution
# (a)
# Given, PV^1.32=constant, so it is polytropic process with
n = 1.32;# polytropic index
# hence
V2 = V1*(P1/P2)**(1./n);# [m^3]
# now, W
W = (P1*V1-P2*V2)/(n-1);# [kJ]
print ' (a) The work transfer is W (kJ) = ',round(W,1)
# (b)
R = cp-cv;# [kJ/kg K]
m = P1*V1/(R*T1);# gas law,[kg]
# also for polytropic process
T2 = T1*(P2/P1)**((n-1)/n);# [K]
# now for gas,
del_U = m*cv*(T2-T1);# [kJ]
print ' (b) The change of internal energy is del_U (kJ) = ',round(del_U,1)
# (c)
Q = del_U+W;# first law of thermodynamics,[kJ]
print ' (c) The heat transfer Q (kJ) = ',round(Q,1)
print 'The answer is a bit different due to rounding off error in textbook'
# End
#pg 141
print('Example 5.26');
# aim : To determine
# the volume of the pressure vessel and the volume of the gas before transfer
# Given values
P1 = 1400.;# initial pressure,[kN/m^2]
T1 = 273.+85;# initial temperature,[K]
P2 = 700.;# final pressure,[kN/m^2]
T2 = 273.+60;# final temperature,[K]
m = 2.7;# mass of the gas passes,[kg]
cp = .88;# [kJ/kg]
cv = .67;# [kJ/kg]
# solution
# steady flow equation is, u1+P1*V1+C1^2/2+Q=u2+P2*V2+C2^2/2+W [1],
# given, there is no kinetic energy change and neglecting potential energy term
W = 0;# no external work done
# so final equation is,u1+P1*v1+Q=u2 [2]
# also u2-u1=cv*(T2-T1)
# hence Q=cv*(T2-T1)-P1*v1 [3]
# and for unit mass P1*v1=R*T1=(cp-cv)*T1 [4]
# so finally
Q = cv*(T2-T1)-(cp-cv)*T1;# [kJ/kg]
# so total heat transferred is
Q2 = m*Q;# [kJ]
# using eqn [4]
v1 = (cp-cv)*T1/P1;# [m^3/kg]
# Total volume is
V1 = m*v1;# [m^3]
# using ideal gas equation P1*V1/T1=P2*V2/T2
V2 = P1*T2*V1/(P2*T1);# final volume,[m^3]
print 'heat transfer from the gas (kJ) = ',round(Q2,1)
print ' The volume of gas before transfer is (m^3) = ',round(V1,3)
print ' The volume of pressure vessel is (m^3) = ',round(V2,2)
# End