In [1]:

```
import math
#Input data
d = 0.0625 #Diameter in m
L = 0.09 #Stroke in m
nv = 0.75 #Volumetric efficiency
p = 1.03 #Pressure at N.T.P in kg/cm**2
T = 273 #Temperature at N.T.P in K
R = 29.27 #Characteristic gas constant in kg.m/kg.degree C
#Calculations
Vs = ((3.14/4)*d**2*L) #Swept volume in cu.m
V = (nv*Vs) #Volume of charge at N.T.P in cu.m
w = (p*10**4*V)/(R*T) #Weight of the charge in kg/cycle
#Output
print 'The weight of the charge is %3.6f kg/cycle'%(w)
```

In [3]:

```
import math
#Input data
n = 9. #Number of cylinder
d = 0.145 #Bore in m
l = 0.19 #Stroke in m
r = 5.9 #Compression ratio
bhp = 460. #Brake horse power in B.H.P
N = 2000. #Speed in r.p.m
x = 20. #Percentage rich in mixture
CV = 11200. #Calorific value in kcal/kg
pC = 85.3 #Percentage of carbon
pH2 = 14.7 #Percentage of Hydrogen
nv = 70. #Volumetric efficiency in percent
T = 15.+273 #Temperature in K
nm = 90. #Mechanical efficiency in percent
wO2 = 23.3 #Percentage of oxygen by weight in air
da = 1.29 #Density of air in kg/m**3
mC = 12. #Molecular weight of carbon
mO2 = 32. #Molecular weight of O2
mH2 = 2. #Molecular weight of H2
#Calculations
hihp = ((bhp/(nm/100))*(4500./427)) #Heat equivalent in kcal
Vs = ((3.14/4)*d**2*l*(N/2)*n) #Swept volume in c.m per min
cw = (Vs/da) #Charge weight of air per minute in kg
ma = (100/wO2)*((pC/100)*(mO2/mC)+(pH2/100)*(mO2/(2*mH2))) #Wt. of air required per kg of fuel in kg
mf = (cw/ma) #Minimum fuel inkg
ith = (hihp/(mf*(100+x)/100*CV))*100 #Indicated thermal efficiciency in percent'
#Output
print 'Indicated thermal efficiency of the engine is %3.1f percent'%(ith)
```

In [4]:

```
import math
#Input data
n = 8. #Number of cylinders
d = 8.57 #Bore in cm
l = 8.25 #Stroke in cm
r = 7. #Compression ratio
N = 4000. #Speed in r.p.m
la = 53.35 #Length of the arm in cm
t = 10. #Test duration in min
br = 40.8 #Beam reading in kg
gas = 0.455 #gasoline in kg. In textbook, it is given wrong as 4.55
CV = 11400. #Calorific value in kcal/kg
Ta = 21.+273 #Temperature of air in K
pa = 1.027 #Pressure of air in kg/cm**2
wa = 5.44 #Rate of air in kg/min
J = 427. #Mechanical equivalent of heat in kg.m/kcal
R = 29.27 #Characteristic gas constant in kg.m/kg.K
#Calculations
bhp = (2*3.14*N*br*la)/(4500*100) #Brake horse power in B.H.P
pb = (bhp*4500)/((n/2)*(l/100)*(3.14/4)*d**2*N) #Brake mean effective pressure in kg/cm**2
bsfc = (gas*60)/bhp #Brake specific fuel consumption in kg/b.h.p.hr
bsac = ((wa*60)/bhp) #Brake specific fuel consumption in kg/b.h.p.hr
nb = ((bhp*4500)/(J*gas*CV))*100 #Brake thermal efficiency in percent
Vd = ((3.14/4)*d**2*l) #Piston print lacement in c.c/cycle
Pd = (Vd/10**6)*(N/2)*n #Piston print lacement in m**3/min
Va = ((wa*R*Ta)/(pa*10**4)) #Volume of air used in m**3/min
nv = (Va/Pd)*100 #Volumetric efficiency in percent
af = (wa/gas) #Air fel ratio
#Output
print 'a) the B.H.P delivered s %3.0f h.p \
\nb) the b.m.e.p is %3.1f kg/cm**2 \
\nc) the b.s.f.c is %3.3f kg/b.h.p.hr \
\nd) the brake specific air consumption is %3.3f kg/b.h.p.hr \
\ne) the brake thermal efficiency is %3.1f percent \
\nf) the volumetric efficiency is %3.0f percent \
\ng) the air fuel ratio is %3.2f'%(bhp,pb,bsfc,bsac,nb,nv,af)
```

In [5]:

```
import math
#Input data
n = 4. #Number of cylinders
N = 2000. #Speed in r.p.m
m = 13.15 #Mass of fuel in kg/hour
Vd = 655.5 #Displacement volume in c.c
da = 1.2 #Density of air in kg/m**3
d = 12.7 #Manometer depression in cm
#Qa = 0.231*math.sqrt(ha); Qa is the flow rate in cu.m/min and ha is the pressure difference in metres
#Calculations
Qa = (0.231*math.sqrt(((d*1000)/da)/100)) #Flow rate in cu.m/min
Wa = (Qa*da) #Weight of air in kg/min
Va = (Qa*(2/N)*(1/n))*10**6 #Volume of air drawn in per cycle per cylinder in c.c
nv = (Va/Vd)*100 #Volumetric efficiency in percent
af = (Wa/(m/60)) #Air fuel ratio
#Output
print 'a) the weight of air drawn is %3.3f kg/min \
\nb) volumetric efficiency taking air into account is %3.1f percent \
\nc) the air-fuel ratio is %i'%(Wa,nv,af)
```

In [6]:

```
import math
#Input data
d = 10. #Diameter in cm
l = 15. #Stroke in cm
r = 6. #Compression ratio
ihp = 20. #Indicated horse power in h.p
N = 1000. #Speed in r.p.m
n = 4. #Number of cylinders
nt = 30. #Thermal efficiency in percent
CV = 10000. #Calorific value in kca/kg
g = 1.4 #Ratio of specific heats
#Output
Vs = ((3.14/4)*d**2*l) #Swept volume in c.c
Vc = (Vs/(r-1)) #Clearance volume in c.c
na = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
pm = ((ihp*4500)/((l/100)*(3.14/4)*(d/100)**2*(N/2)*n)) #Pressure in kg/cm**2
pc = (ihp*4500*60)/(427*(nt/100)*CV) #Petrol consumption in kg/hr
#Output
print 'Clearance volume is %3.1f c.c \
\nThe air standard efficiency is %3.1f percent \
\nPetrol consumption is %3.2f kg/hr'%(Vc,na,pc)
```

In [7]:

```
import math
#Input data
n = 6. #Number of cylinders
P = 62. #Power in HP
N = 3000. #Speed in r.p.m
nv = 85. #Volumetric efficiency in percent
nt = 25. #Thermal efficiency in percent
CV = 10500. #Calorific value in kcal/kg
af = 15. #Air fuel ratio
T = 273. #standard atmosphere temperature in K
p = 1.03 #standard atmosphere pressure in kg/cm**2
R = 29.27 #Characteristic gas constant in kg.m/kg.K
J = 427. #Mechanical equivalent of heat in kg.m/kcal
#Calculations
q = (P*4500)/(J*(nt/100)) #Heat supplied in kcal/min
F = (q/CV) #Fuel supplied per minute in kg
Fc = (F/N)*(2/n) #Fuel supplied per cycle per cylinder in kg
wt = (af*Fc) #Weight of air supplied per cycle in kg
d = ((((wt)*R*T)/(p*10**4*(3.14/4)*(nv/100)))**(1./3))*100 #Diameter in cm
#Output
print 'Cylinder bore = stroke = %3.2f cm'%(d)
```