import math
#Input data
r = 14.3 #Compression ratio
c = 5 #Fuel cutoff in percent of stroke
w = 0.006 #Weight of charge in kg
T4 = 912 #Final temperature in degree C abs
q = 8300 #Heat in kcal
x = [0.258,0.000048] #Temperature expression is 0.258T+0.000048T**2, where T is in degree C abs
#Calculations
v4 = 1. #Assuming clearance volume as unity
v1 = 1.665 #v1 from fig. 14.2 on page no. 352
T1 = (T4*v1)/v4 #Temperature in degree C abs
qp1 = (x[0]*T1+x[1]*T1**2) #constant pressure heat of mixture at temperature T1 in kcal/kg
qp4 = (x[0]*T4+x[1]*T4**2) #constant pressure heat of mixture at temperature T4 in kcal/kg
qre = (qp1-qp4) #Heat required by the mixture in kcal/kg
wf = (w*qre)/q #Weight of oil in kg
#Output
print 'The weight of oil that must be injected is %3.6f kg'%(wf)
import math
#Input data
r = 14 #Compression ratio
p = 1.2 #Induction pipe pressure in kg/cm**2
bp = 0.65 #Exhaust back pressure in kg/cm**2
Tc = 87+273 #Charge temperature in K
Te = 850+273 #Exhaust temperature in K
T1 = 111+273 #Temperature at the beginning of compression in K
g = 1.2 #Ratio of specific heats
#Calculations
Cw1 = ((bp*10**4)/Te) #specific heat in kJ/kg.K
Cw2 = ((p*10**4*(r-1))/Tc) #specific heat in kJ/kg.K
T3 = ((g*Te*Cw1+Cw2*Tc)/(Cw1*g+Cw2)) #Temperature in K
t3 = T3-273 #Temperature in degree C
rw = (Cw1/Cw2) #Ratio of specific heats
#Output
print 'The ratio of the mass residuals to fresh charge is %3.4f'%(rw)