#from Table A-17
#cp value approximately by replacing the differentials
h1=305.22;#in kJ/kg
T1=305;#in K
h2=295.17;#in kJ/kg
T2=295;#in K
#calculations
#from the given equation we can calculate
cp=(h1-h2)/(T1-T2);
print'the cp of air at 300 K %f kJ/ kg - K'%round(cp,3)
#given data
dT=302-300;#differnce in final and intial temperatures of air in K
dv=0.87-0.86;#differnce in final and intial volumnes of air in m^3/kg
T=(302+300)/2;#average temp in K
v=(0.87+0.86)/2;#average volumne in m^3/kg
#constants used
R=0.287;#in kJ/kg-K
#calculations
#using eq 12-3 by diffrentiating P= R*T/v
dP= R*dT/v - R*T*dv/v**2;
print'the change in the pressure of air %f kPa'%round(dP,3)
#given data
T=20+273.15;#temperature of refrigerant in K
#from Table A–11
vf=0.0008161;#in m^3/kg
vg=0.035969;#in m^3/kg
#calculations
#using Eq 12-22
# hfg= T*vfg*(dP/dT)sat
#(dP/dT)sat b/w 24 C - 16 C
dPT=(646.18-504.58)/(24-16);#dP/dT ; values from Table A–11
vfg=vg-vf;
hfg=T*vfg*dPT;
print'the value of the enthalpy of vaporization of refrigerant-134a %f kJ/kg'%round(hfg,2)
from math import exp
#given data
T2=-50+460.0;#temperature of refrigerant-134a on R
#constants
R=0.01946;#in Btu/lbm
#from Table A-11E
T1=-40+460.0;#converted into R from F
P1=7.432;
hfg=97.100;
#calcualation\
#using Equation 12–24
#ln(P2/P1)= hfg/R *(1/T1 - 1/T2)
P2=P1*exp(hfg/R *(1/T1 - 1/T2));
print'the saturation pressure of refrigerant-134a %f psia'%round(P2,2)
from math import log
#given data
T1=220;#intial temperature in K
P1=5;#intial pressure in MPa
T2=300;#final temperature in K
P2=10;#final pressure in MPa
#constants used
Ru=8.314;#on kJ/kmol- K
#from Table A–1
Tcr=154.8;
Pcr=5.08;
#calculations
#part - a
print('part - a');
#by assuming ideal-gas behavior
#from Table A–19
h1=6404;
h2=8736;
s2=205.213;
s1=196.171;
h21i=h2-h1;#h2 - h1 ideal
s21i=(s2-s1)-Ru*log(P2/P1);#s2 - s1 ideal
print'the enthalpy change %i kJ/kmol'%round(h21i);
print'the entropy change %f kJ/kmol-K'%round(s21i,2);
#part - b
print('part - b');
#by accounting for the deviation from ideal-gas behavior
TR1=T1/Tcr;
Pr1=P1/Pcr;
#from the generalized charts at each state
Zh1=0.53;
Zs1=0.25;
TR2=T2/Tcr;
Pr2=P2/Pcr;
#from the generalized charts at each state
Zh2=0.48;
Zs2=0.20;
h21=h21i-Ru*Tcr*(Zh2-Zh1);
s21=s21i-Ru*(Zs2-Zs1);
print'the enthalpy change %i in kJ/kmol'%round(h21);
print'the entropy change %f kJ/kmol-K'%round(s21,2);