In [1]:

```
import math
#Input data
n = 4. #Four cylinder engine
N = 1200. #Speed in r.p.m
BHP1 = 26.3 #Brake horse power in B.H.P
T = 11.3 #Average torque in kg
CV = 10000. #Calorific value of the fuel in kcal/kg
m = 270. #Flow rate in gm of petrol per B.H.P hour
#Calculations
BHP2 = (T*2*3.14*N)/4500 #Average B.H.P on 3 cylinders
IHP = BHP1-BHP2 #Average I.H.P of one cylinder
TIHP = (n*IHP) #Total I.H.P
p = ((m/1000)*BHP1)/TIHP #Petrol used in kg/I.H.P hr
nth = ((4500*60)/(427*p*CV))*100 #Indicated Thermal efficiency in percent
#Output
print 'Thermal efficiency is %3.1f percent'%(nth)
```

In [2]:

```
import math
n = 4 #Four cylinder engine
d = 0.1 #Diameter of piston in m
l = 0.15 #Stroke in m
RPM = 1600 #Speed in r.p.m
ap = (5.76*10**-4) #Area of positive loop of indicator diagram in sq.m
an = (0.26*10**-4) #Area of negative loop of indicator diagram in sq.m
L = 0.055 #Length of the indicator diagram in m
k = (3.5/10**-6) #Spring constant in kg/m**2 per m
#Calculations
NA = (ap-an) #Net area of the indicator diagram in sq.m
h = (NA/L) #Average height of diagram in m
Pm = (h*k) #Mean effective pressure in kg/m**2
IHP = (Pm*l*(3.14/4)*d**2*RPM*n)/4500 #Indicated Horse Power
#Output
print 'Indicated horse power of a four cylinder two stroke petrol engine is %3.1f'%(IHP)
```

In [3]:

```
import math
#Input data
n = 6 #Number of cylinders
d = 0.089 #Bore in m
l = 0.1016 #Stroke in m
vc = 3.183 #Compression ratio
rn = 55 #Relative efficiency in percent
m = 0.218 #Petrol consumption in kg/hp.hr
Pm = (8.4/10**-4) #Indicated mean effective pressure in kg/m**2
N = 2500 #Speed in r.p.m
#Calculations
an = (1-(1/(vc-1)))*100 #Air standard efficiency in percent
nth = (rn*an)/100 #Thermal efficiency in percent
CV = ((4500*60)/(m*(nth/100)*427)) #Calorific value in kcal/kg
IHP = ((Pm*(3.14/4)*d**2*l*N*n)/(4500*2)) #Indicated horse power
p = (m*IHP) #Petrol consumption in kg/hour
#Output
print '1) The calorific value of petrol is %i kcal/kg \
\n2) Corresponding petrol consumption is %3.1f kg/hour'%(CV,p)
```

In [5]:

```
import math
#Input data
n = 4. #Number of cylinders
d = 0.2 #Bore in m
l = 0.3 #Stroke in m
N = 300. #Speed in r.p.m
af = 5. #Air to fuel ratio by volume. In textbook it is given as 4 which is wrong
nv = 78. #Volumetric efficiency in percent
CV = 2200. #Calorific value in kcal/cu.m at N.T.P
bth = 23. #Brake thermal efficiency in percent
#Calculations
Vs = ((3.14/4)*d**2*l) #Swept volume in cu.m
c = ((nv/100)*Vs) #Total charge per stroke in cu.m
Vg = ((c/af)*N) #Volume of gas used per min in cu.m at N.T.P
q = (CV*Vg) #Heat supplied in kcal/min
BHP = ((bth/100)*q)/(4500./427) #Brake horse power
#Output
print 'The volume of gas used per min is %3.3f cu.m at N.T.P \
\nB.H.P of engine is %3.1f'%(Vg,BHP)
```

In [7]:

```
import math
#Input data
d = 20. #Bore in cm
l = 37.5 #Stroke in cm
r = 6. #Compression ratio
IPm = 5. #Indicated Mean effective pressure in kg/cm**2
ag = 6. #Air to gas ratio
CV = 3070. #Calorific value of gas in kcal/cu.m
T = 75.+273 #Temperature in K
p = 0.975 #Pressure in kg/cm**2
RPM = 240. #Speed in r.p.m
g = 1.4 #Ratio of specific heats
#Calculations
Vs = (3.14/4)*d**2*l #Stroke Volume in cu.m
Vg = (1/(r+1))*Vs #Volume of gas in cylinder in cu.m per cycle
x = (Vg*(p/1.03)*(273/T)) #Volume at 'Vg' cu.m at 'p' kg/cm**2 and 'T' K are equivalent in cu.m
q = (CV*x)/10**6 #Heat added in kcal per cycle
IHP = (IPm*(Vs/100)*(RPM/2))/4500 #Indicated horse power
nth = ((IHP*4500)/(427*q*(RPM/2)))*100 #Thermal efficiency in percent
na = (1-(1/r**(g-1)))*100 #Air standard efficiency in percent
rn = (nth/na)*100 #Relative effeciency in percent
#Output
print 'The thermal efficiency is %3.1f percent \
\nThe relative efficiency is %3.1f percent \
\nIndicated horese power is %3.1f H.P'%(nth,rn,IHP)
```

In [8]:

```
import math
#Input data
n = 4 #Number of cylinders
d = 6.25 #Diametre in cm
l = 9.5 #Stroke in cm
t = 678 #Torque in kg.m
N = 3000 #Speed in r.p.m
Vc = 60 #Clearance volume in c.c
be = 0.5 #Brake efficiency ratio based on the air standard cycle
CV = 10000 #Calorific value in kcal/kg
g = 1.4 #Ratio of specific heats
#Calculations
Vs = (3.14/4)*d**2*l #Stroke volume in c.c per cylinder
r = ((Vs+Vc)/Vc) #Compression ratio
na = (1-(1/r**(g-1))) #Air standard efficiency
bth = (be*na)*100 #Brake thermal efficiency in percent
bhp = ((t/100)*2*3.14*N)/4500 #B.H.P in H.P
q = (bhp*(4500/427))/(bth/100) #Heat supplied in kcal/min
F = (q*60)/CV #Fuel consumption in kg/hour
P = (bhp*4500*2*100)/(n*Vs*N) #pressure in kg/cm**2
#Output
print 'The fuel consumption is %3.2f kg/hour \
\nThe brake mean effective pressure is %3.2f kg/cm**2'%(F,P)
```

In [11]:

```
import math
#Input data
n = 1. #Number of cylinders
t = 30. #Trail time in min
m = 5.6 #Oil consumption in l
CV = 9980. #Calorific value of oil in kcal/kg
g = 0.8 #Specific gravity of oil
a = 8.35 #Average area of indicator diagram in sq.cm
l = 8.4 #Length of the indicator diagram in cm
is1 = 5.5 #Indicator spring scale
L = 147.5 #Brake load in kg
sp = 20. #Spring balance reading in kg
d = 1.5 #Effective brake wheel diameter in m
N = 200. #Speed in r.p.m
cyd = 30. #Cylinder diameter in cm
l1 = 45. #Stroke in cm
mw = 11. #Jacket cooling water in kg/min
Tc = 35.+273 #Temperature rise of cooling water in K
#Calculations
mp = (a/l)*is1 #Mean effective pressure
ihp = ((mp*(l1/100)*(3.14/4)*cyd**2*(N/2))/4500) #Indicated horse power in h.p
bhp = (L*3.14*d*N)/4500 #Brake horse power in h.p
nm = (bhp/ihp)*100 #Mechanical efficiency in percent
F = (m*(60/t)*g) #Fuel consumption in kg/hour
Fc = (F/bhp) #Specific fuel consumption in kg/B.H.P/hour
ith = ((ihp*(4500./427))/((F/60)*CV))*100 #Indicated thermal efficiency in percent
#Output
print 'a) I.H.P is %3.1f \
\nb) B.H.P is %3.1f \
\nc) Mechanical efficiency is %3.1f percent \
\nd) Specific fuel consumption is %3.2f kg/B.H.P/hour \
\ne) Indicated thermal efficiency is %3.1f percent'%(ihp,bhp,nm,Fc,ith)
```

In [12]:

```
import math
#Input data
d = 15. #Diameter in cm. In textbook it is given wrong as 39
l = 45. #Stroke in cm
f = 9.5 #Total fuel used in litres
CV = 10500. #Calorific value in kcal/kg
n = 12624. #Total no. of revolutions
imep = 7.24 #Gross i.m.e.p in kg/cm**2
pimep = 0.34 #Pumping i.m.e.p in kg/cm**2
L = 150. #Net load on brake in kg
db = 1.78 #Diameter of the brake wheel drum in m
dr = 4. #Diameter of rope in cm
cw = 545. #Cooling water circulated in litres
Tc = 45. #Cooling water temperature rise in degree C
g = 0.8 #Specific gravity of oil
#Calculations
ihp = ((imep-pimep)*(l/100)*3.14*d**2*n)/(4500*60) #I.H.P in h.p
q = (f*g*CV)/60 #Heat supplied in kcal/min
bhp = (L*3.14*(db+(dr/100))*n)/(4500*60) #B.H.P in h.p
qbhp = (bhp*4500)/427 #Heat equivalent of B.H.P in kcal/min
qw = (cw*Tc)/60 #Heat lost to jacket cooling water in kcal/min
dq = (q-(qbhp+qw)) #Heat unaccounted in kcal/min
#Output
print 'Heat supplied is %3.0f kcal/min \
\nHeat equivalent of B.H.P is %3.0f kcal/min \
\nHeat lost to jacket cooling water is %3.0f kcal/min \
\nHeat unaccounted is %3.0f kcal/min'%(q,qbhp,qw,dq)
```

In [14]:

```
import math
#Input data
d = 27. #Diameter in cm
l = 45. #Stroke in cm
db = 1.62 #Effective diameter of the brake in m
t = (38.*60+30) #Test duration in sec
CV = 4650. #Calorific value in kcal/m**3 at N.T.P
n = 8080. #Total no. of revolutions
en = 3230. #Total number of explosions
p = 5.75 #Mean effective pressure in kg/cm**2
V = 7.7 #Gas used in m**3
T = 15.+273 #Atmospheric temperature in K
pg = 135. #pressure of gas in mm of water above atmospheric pressure
hb = 750. #Height of barometer in mm of Hg
L = 92. #Net load on brake in kg
w = 183. #Weigh of jacket cooling water in kg
Tc = 47. #Cooling water temperature rise in degree C
#Calculations
ihp = (p*(l/100)*(3.14/4)*d**2*en)/(4500*(t/60)) #I.H.P in h.p
bhp = (L*3.14*db*n)/(4500*(t/60)) #B.H.P in h.p
pa = (hb+(pg/13)) #Pressure of gas supplied in mm of Hg
Vg = (V*(273/T)*(pa/760)) #Volume of gas used at N.T.P in m**3
q = (Vg*CV)/(t/60) #Heat supplied per minute in kcal
qbhp = (bhp*4500)/427 #Heat equivalent of B.H.P in kcal/min
qc = (w/(t/60))*Tc #Heat lost to jacket cooling water in kcal/min
qra = (q-(qbhp+qc)) #Heat lost to exhaust, etc in kcal/min
#Output
print 'Heat supplied is %3.1f kcal/min \
\nHeat equivalent of B.H.P is %3.0f kcal/min \
\nHeat lost to jacket cooling water is %3.1f kcal/min \
\nHeat lost to exhaust radiation etc. is %3.1f kcal/min'%(q,qbhp,qc,qra)
```

In [15]:

```
import math
#Input data
d = 25. #Bore in cm
l = 50. #Stroke in cm
N = 240. #Speed in r.p.m
n = 100. #Number of times fires per minute
qc = 0.3 #Quantity of coal gas used in cu.m per minute
h = 100. #Head in mm of water
bp = 1.03 #Barometric pressure in kg/cm**2
T = 15.+273 #Temperature in K
ma = 2.82 #Mass of air used in kg per minute
R = 29.45 #Characteristic gas constant in kg.m/kg.K
#Calculations
gp = (bp+(100/13.6)*(bp/76)) #Gas pressure in kg/cm**2
Vc = (qc*(gp/bp)*(273/T)) #Volume of coal gas at N.T.P in cu.m per minute
Vce = (Vc/n) #Volume of coal gas per explosion in cu.m at N.T.P
va = (ma*R*273)/(bp*10**4) #Volume of air taken in at N.T.P in cu.m per min
V = ((va-(((N/2)-n)*Vce))/(N/2)) #Volume in cu.m
tV = (V+Vce) #Total volume of charge in cu.m at N.T.P
Vs = ((3.14/4)*(d**2*l)*10**-6) #Swept volume in cu.m
nv = (tV/Vs)*100 #Volumetric efficiency in percent
#Output
print 'a) the charge of air per working cycle as measured at N.T.P is %3.5f cu.m \
\nb) the volumetric efficiency is %3.1f percent'%(tV,nv)
```

In [16]:

```
import math
#Input data
d = 18. #Diameter in cm
l = 24. #Stroke in cm
t = 30. #Duration of trail in min
r = 9000. #Total number of revolutins
e = 4445. #Total number of explosions
mep = 5.85 #Mean effective pressure in kg/cm**2
Nl = 40. #Net load on brake wheel in kg
ed = 1. #Effective diameter of brake wheel in meter
tg = 2.3 #Total gas used at N.T.P in m**3
CV = 4600. #Calorific value of gas in kcal/m**3 at N.T.P
ta = 36. #Total air used in m**3
pa = 720. #Pressure of air in mm of Hg
Ta = 18.+273 #Temperature of air in K
da = 1.293 #Density of air at N.T.P in kg/m**3
Te = 350.+273 #Temperature of exhaust gases in K
Tr = 18.+273 #Room temperature in K
Cp = 0.24 #Specific heat of exhaust gases in kJ/kg.K
twc = 81.5 #Total weight of cylinder jacket cooling water in kg
dT = 33. #Rise in temperature of jacket cooling water in degree C
R = 29.45 #Characteristic gas constant in kg.m/kg.degree C
#Calculations
ihp = (mep*(l/100)*(3.14/4)*d**2*(e/t))/4500 #Indicated horse power in h.p
bhp = (Nl*3.14*r*ed)/(4500*t) #Brake horse power in h.p
qs = (tg/t)*CV #Heat supplied at N.T.P in kcal
qbhp = (bhp*4500)/427 #Heat equivalent of B.H.P in kcal/min
ql = (twc/t)*dT #Heat lost to cylinder jacket cooling water in kcal/min
VA = (ta*(273/Ta)*(pa/760)) #Volume of air used at N.T.P in m**3
WA = (VA*da)/t #Weight of air used per min in kg
WG = (1.03*tg*10**4)/(R*273) #Weight of gas in kg
Wg = (WG/t) #Weight of gas per minute in kg
We = (WA+Wg) #Total weight of exhaust gases in kg
qle = (We*(Te-Tr)*Cp) #Heat lost of exhaust gases in kcal/min
qra = (qs-(qbhp+ql+qle)) #Heat lost by radiation in kcal/min
nm = (bhp/ihp)*100 #Mechanical efficiency in percent
ith = ((ihp*4500)/(427*qs))*100 #Indicated thermal efficiency in percent
#Output
print ' HEAT BALANCE SHEET ------------------ \
\nHeat supplied per minute is %3.1f kcal/min \
\nHeat expenditure kcal per minute \
\n1.Heat equivalent of B.H.P is %3.1f \
\n2.Heat lost to jacket cooling water is %3.1f \
\n3.Heat lost in exhaust gases is %3.1f \
\n4.Heat lost by radiation, etc, is %3.1f \
\n-------- %3.1f --------'%(qs,qbhp,ql,qle,qra,qs)
```

In [17]:

```
import math
#Input data
gu = 0.135 #Gas used in m**3/min at N.T.P
CV = 3990 #Calorific value of gas in kcal/m**3 at N.T.P
dg = 0.64 #Density of gas in kg/m**3 at N.T.P
au = 1.52 #Air used in kg/min
C = 0.24 #Specific heat of exhaust gases in kJ/kg.K
Te = 397+273 #Temperature of exhaust gases in K
Tr = 17+273 #Room temperature in K
cw = 6 #Cooling water per minute in kg
rT = 27.5 #Rise in temperature in degree C
ihp = 12.3 #Indicated horse power in h.p
bhp = 10.2 #Brake horse power in h.p
#Calculations
qs = (gu*CV*60) #Heat supplied in kcal/hour
qbhp = ((bhp*4500*60)/427) #Heat equivalent of B.H.P in kcal/hr
ql = (cw*60*rT) #Heat lost in jacket cooling water in kcal/hr
mg = (gu*dg) #Mass of gas used per minute in kg
me = (mg+au) #Mass of exhaust gases per minute in kg
qe = (me*C*(Te-Tr)*60) #Heat carried away by exhaust gases in kcal/hour
qun = (qs-(qbhp+ql+qe)) #Heat unaccounted in kcal/hour
#Output
print 'Heat supplied is %3.0f kcal/hour \
\nHeat equivalent of B.H.P is %3.0f kcal/hr \
\nHeat lost in jacket cooling water is %3.0f kcal/hr \
\nHeat carried away by exhaust gases is %3.0f kcal/hour \
\nHeat unaccounted is %3.0f kcal/hour'%(qs,qbhp,ql,qe,qun)
```

In [20]:

```
import math
#Input data
n = 4. #Number of cylinders
r = 1. #Radius in metre
N = 1400. #Speed in r.p.m
bl = 14.5 #Net brake load in kg
P = [9.8,10.1,10.3,10] #Loads on the brake in kg
d = 9. #Bore in cm
l = 12. #Stroke in cm
#Calculations
bhp = (bl*2*3.14*r*N)/4500 #Brake horse power in h.p
bhp1 = (P[0]*2*3.14*r*N)/4500 #Brake horse power in h.p
bhp2 = (P[1]*2*3.14*r*N)/4500 #Brake horse power in h.p
bhp3 = (P[2]*2*3.14*r*N)/4500 #Brake horse power in h.p
bhp4 = (P[3]*2*3.14*r*N)/4500 #Brake horse power in h.p
ihp1 = bhp-bhp1 #Indicated horse power in h.p
ihp2 = bhp-bhp2 #Indicated horse power in h.p
ihp3 = bhp-bhp3 #Indicated horse power in h.p
ihp4 = bhp-bhp4 #Indicated horse power in h.p
ihp = (ihp1+ihp2+ihp3+ihp4) #Indicated horse power in h.p
nm = (bhp/ihp)*100 #Mechanical efficiency in percent
pm = ((4500*bhp)/((l/100)*(3.14/4)*d**2*(N/2))) #Brake mean effective pressure in kg/cm**2
#Output
print 'I.H.P is %3.1f h.p \
\nMechanical efficiency is %3.1f percent \
\nBrake mean effective pressure is %3.0f kg/cm**2'%(ihp,nm,pm)
```

In [23]:

```
import math
#Input data
N = 350 #Speed in r.p.m
L = 60 #Net brake load in kg
mep = 2.75 #Mean effective pressure in kg/cm**2
oc = 4.25 #Oil consumption in kg/hour
jcw = 490 #Jacket cooling water in kg/hour
Tw = [20+273,45+273] #Temperature of jacket water at inlet and outlet in K
au = 31.5 #Air used per kg of oil in kg
Ta = 20+273 #Temperature of air in the test room in K
Te = 390+273 #Temperature of exhaust gases in K
d = 22 #Cylinder diameter in cm
l = 28 #Stroke in cm
bd = 1 #Effective brake diameter in m
CV = 10500 #Calorific value of oil in kcal/kg
pH2 = 15 #Proportion of hydrogen in fuel oil in percent
C = 0.24 #Mean specific heat of dry exhaust gases
Cs = 9.5 #Specific heat of steam in kJ/kg.K
#Calculations
ibp = (mep*(l/100)*(3.14/4)*d**2*N)/4500 #Indicated brake power in h.p
bhp = (L*3.14*N*bd)/4500 #Brake horse power in h.p
qs = (oc*CV)/60 #Heat supplied per minute in kcal
qbhp = (bhp*4500)/427 #Heat equivalent of B.H.P in kcal/min
pqbhp = (qbhp/qs)*100 #Percenatge of heat
ql = (jcw/60)*(Tw[1]-Tw[0]) #Heat lost to cooling water in kcal/min
pql = (ql/qs)*100 #Percenatge of heat
wH2O = (9*(pH2/100)*(oc/60)) #Weight of H2O produced per kg of fuel burnt in kg/min
twe = (oc*(au+1))/60 #Total weight of wet exhaust gases per minute in kg
twd = (twe-wH2O) #Weight of dry exhaust gases per minute in kg
qle = (twd*C*(Te-Ta)) #Heat lost to dry exhaust gases/min in kcal
pqle = (qle/qs)*100 #Percenatge of heat
qx = (100+538.9+0.5*(Te-373)) #Heat in kcal/kg
qst = (wH2O*qx) #Heat to steam in kcal/min
pqst = (qst/qs)*100 #Percenatge of heat
qra = (qs-(qbhp+ql+qle+qst)) #Heat lost by radiation in kcal/min
pqra = (qra/qs)*100 #Percenatge of heat
#Output
print ' HEAT BALANCE SHEET ------------------ \
\nHeat supplied per minute is %3.0f kcal/min 100 percent \
\nHeat expenditure kcal per minute percent \
\n1.Heat equivalent of B.H.P is %3.1f %3.1f \
\n2.Heat lost to cooling water is %3.0f %3.1f \
\n3.Heat lost to dry exhaust gases is %3.1f %3.1f \
\n4.Heat lost of steam in exhaust gases is %3.0f %3.1f \
\n5.Heat lost by radiation, etc., is %3.0f %3.1f \
\n ---------- Total %3.0f %3.0f ------------------'\
%(qs,qbhp,pqbhp,ql,pql,qle,pqle,qst,pqst,qra,pqra,qs,(pqbhp+pql+pqle+pqst+pqra))
```

In [24]:

```
import math
#Input data
d = 20 #Diameter in cm
l = 40 #Stroke in cm
mep = 5.95 #Mean effective pressure in kg/cm**2
bt = 41.5 #Brake torque in kg.m
N = 250 #Speed in r.p.m
oc = 4.2 #Oil consumption in kg per hour
CV = 11300 #Calorific value of fuel in kcal/kg
jcw = 4.5 #Jacket cooling water in kg/min
rT = 45 #Rise in temperature in degree C
au = 31 #Air used in kg
Te = 420 #Temperature of exhaust gases in degree C
Tr = 20 #Room temperature in degree C
Cm = 0.24 #Mean specific heat of exhaust gases in kJ/kg.K
#Calculations
ihp = (mep*(l/100)*(3.14/4)*d**2*(N/2))/4500 #Indicated horse power in h.p
bhp = (bt*2*3.14*N)/4500 #Brake horse power in h.p
q = (oc*CV) #Heat supplied in kcal/hour
qbhp = (bhp*4500*60)/427 #Heat equivalent of B.H.P in kcal/hour
qfhp = ((ihp-bhp)*4500*60)/427 #Heat equivalent F.H.P in kcal/hour
qc = (jcw*rT*60) #Heat lost in cooling water in kcal/hour
qe = (oc*32*Cm*(Te-Tr)) #Heat lost in exhaust gases in kcal/hour
hu = (q-(qbhp+qfhp+qc+qe)) #Heat unaccounted in kcal/hour
#Output
print 'Indicated horse power is %3.1f h.p \
\nBrake horse power is %3.2f h.p \
\nHeat supplied is %3.0f kcal/hour \
\nHeat equivalent of B.H.P is %3.0f kcal/hour \
\nHeat equivalent of F.H.P is %3.0f kcal/hour \
\nHeat lost in cooling water is %3.0f kcal/hour \
\nHeat lost in exhaust gases is %3.0f kcal/hour \
\nHeat unaccounted is %3.0f kcal/hour'%(ihp,bhp,q,qbhp,qfhp,qc,qe,hu)
```

In [26]:

```
import math
#Input data
ihp = 45. #Indicated horse power in h.p
bhp = 37. #Brake horse power in h.p
fu = 8.4 #Fuel used in kg/hour
CV = 10000. #Calorific value in kcal/kg
Tc = [15.,70.] #Inlet and outlet temperatures of cylinders in degree C
cj = 7. #Rate of flow of cylinder jacket in kg/min
Tw = [15.,55.] #Inlet and outlet temperatures of water in degree C
rw = 12.5 #Rate of water flow in kg per minute
Te = 82. #Final temperature of exhaust gases in degree C
Tr = 17. #Room temperature in degree C
af = 20. #Air fuel ratio
Cm = 0.24 #Mean specific heat of exhaust gases in kJ/kg.K
#Calculations
q = (fu/60)*CV #Heat supplied in kcal/min
qbhp = (bhp*4500)/427 #Heat equivalent of B.H.P in kcal/min
ql = (cj*(Tc[1]-Tc[0])) #Heat lost to cylinder jacket cooling water in kcal/min
qe = (rw*(Tw[1]-Tw[0])) #Heat lost by exhaust gases in kcal/min
qee = (Te-Tr)*Cm*(af+1)*fu/60 #Heat of exhaust gas in kcal/min
te = (qe+qee) #Total heat lost to exhaust gases in kcal/min
hra = (q-(qbhp+ql+te)) #Heat lost to radiation in kcal/min
ith = ((ihp*4500)/(427*q))*100 #Indicated thermal efficiency in percent
bth = ((bhp*4500)/(427*q))*100 #Brake thermal efficiency in percent
nm = (bhp/ihp)*100 #Mechanical efficiency in percent
#Output
print 'Heat supplied is %3.0f kcal/min \
\nHeat equivalent of B.H.P is %3.0f kcal/min \
\nHeat lost to cylinder jacket cooling water is %3.0f kcal/min \
\nTotal heat lost to exhaust gases is %3.1f kcal/min \
\nHeat lost to radiation is %3.1f kcal/min \
\nIndicated thermal efficiency is %3.1f percent \
\nBrake thermal efficiency is %3.1f percent \
\nMechanical efficiency is %3.1f percent'%(q,qbhp,ql,te,hra,ith,bth,nm)
```

In [28]:

```
import math
#Input data
Vs = 0.0015 #Stroke volume in cu.m
rc = 5.5 #Volume compression ratio
p2 = 8. #Pressure at the end of compression stroke in kg/cm**2
T2 = 350.+273 #Temperature at the end of compression stroke in K
p3 = 25. #Pressure in kg/cm**2
x = (1./30) #Fraction of dismath.tance travelled by piston
pa = 1./16 #Petrol air mixture ratio
R = 29.45 #Characteristic gas constant in kg.m/kg degree C
CV = 10000. #Calorific value of fuel in kcal per kg
Cv = 0.23 #Specific heat in kJ/kg.K
#Calculations
V2 = (Vs*10**6)/(rc-1) #Volume in c.c
V3 = (Vs*10**6)*x+V2 #Volume in c.c
T3 = (T2*p3*V3)/(p2*V2) #Temperature in K
W = ((p3+p2)/2)*(V3-V2) #Workdone in kg.cm
mM = ((p2*V2)/(T2*R*100)) #Mass of mixture present in kg
dE = (mM*Cv*(T3-T2)) #Change in energy in kcal
q = (dE+(W/(427*100))) #Heat in kcal
qc = (1/(1+(1/pa)))*mM*CV #Heat in kcal
ql = (qc-q)/mM #Heat lost in kcal per kg of charge
#Output
print 'Heat lost per kg of charge during explosion is %3.0f kcal'%(ql)
```