"A diesel engine has a compression ratio of 22:1.  The conditions in the cylinder 
  at the start of compression are p = 101.2 kPa and T = 325 K.  Calculate the
  pressure and temperature at the end of compression, assuming that the process
  is isentropic."

r_c = 22

"Composition"

y_O2 = 0.2095
y_N2 = 0.7905

"Starting Point - 1"

P_1 = 101.3														"[kPa]"
T_1 = 325														"[kPa]"

v_1 = y_O2 * VOLUME(O2,T=T_1,P=P_1)+y_N2 * VOLUME(N2,T=T_1,P=P_1)


cp_1 = y_O2 * CP(O2,T=T_1)+y_N2 * CP(N2,T=T_1)
cp_1 - cv_1 = R#
gamma_1 = cp_1/cv_1

u_1 = y_O2 * INTENERGY(O2,T=T_1)+y_N2 * INTENERGY(N2,T=T_1)
s_1 = y_O2 * ENTROPY(O2,T=T_1,P=y_O2*P_1)+y_N2 * ENTROPY(N2,T=T_1,P=y_N2*P_1)

"End Point - 2"

v_2 = y_O2 * VOLUME(O2,T=T_2,P=P_2)+y_N2 * VOLUME(N2,T=T_2,P=P_2)
v_2 = v_1 / r_c

cp_2 = y_O2 * CP(O2,T=T_2)+y_N2 * CP(N2,T=T_2)
cp_2 - cv_2 = R#
gamma_2 = cp_2/cv_2

u_2 = y_O2 * INTENERGY(O2,T=T_2)+y_N2 * INTENERGY(N2,T=T_2)
s_2 = y_O2 * ENTROPY(O2,T=T_2,P=y_O2*P_2)+y_N2 * ENTROPY(N2,T=T_2,P=y_N2*P_2)
s_2=s_1

"Work done per kg"

w_12 = (u_2 - u_1)/molarmass(air)

"Compare with polytropic process"

{gamma=(gamma_1+gamma_2)/2}					"Exercise value"

gamma=1.4												"Check against text"

(T_2a/T_1)=(P_2a/P_1)^((gamma-1)/gamma)

(T_1*P_2a)/(T_2a*P_1)=r_c