In [12]:

```
#given
N=3000 #The speed of the engine in rpm
r=9 #Compression ratio
l=17.2 #The length of the connecting rod in cm
t=20 #The combustion ends at a TDC in degrees
k=3 #Three litre spark engine
n=6.0 #V-6 Engine
#Calculations
import math
Vs=(k/n)*10**-3
d=(((Vs*4)/math.pi)**(1/3.0))
L=d*100
up=2*d*N/60.0
Vc=(Vs/(r-1))*10**6
cr=L/2.0
R=l/cr
up1=up*((math.pi/2.0)*math.sin(math.pi/9.0)*(1+(math.cos(math.pi/9.0)/(R**2-(math.sin(math.pi/9.0)**2))**(1/2.0))))
s=(cr*math.cos(math.pi/9.0))+(l**2-(cr**2)*(math.sin(math.pi/9.0))**2)**(1/2.0)
x=l+cr-s
V=Vc+(math.pi/4.0)*(d*100)**2*x
#Output
print"(a)The cylinder bore and The stroke length (d = L) = ",round(L,2),"cm"
print"(b) The average piston speed = ",round(up,2),"m/s"
print"(c) The clearence volume of one cylinder = ",round(Vc,2),"cm**3"
print"(d) The piston speed at the end of combustion = ",round(up1,2),"m/s"
print"(e) The distance the piston travels from TDC at the end of combustion = ",round(x,2),"cm"
print"(f) Instantaneous volume = ",round(V,2),"cm**3"
```

In [7]:

```
#Input data
d=0.175 #The diameter of the bore in m
L=0.32 #The length of the stroke in m
p=6.5 #Mean effective pressure in bar
pp=0.4 #Pumping loop mean effective pressure in bar
N=510.0 #The speed of the engine in rpm
pm=0.65 #Diagrams from the dead cycle give a mep in bar
n=55.0 #Firing strokes per minute
#Calculations
import math
pmi=p-pp
c=((N/2.0)-n)
ipw=pmi*10**5*L*(math.pi/4.0)*d**2*(n/60.0)*(1/1000.0)
Pp=pm*10**5*L*(math.pi/4.0)*d**2*(c/60.0)*(1/1000.0)
fp=ipw-Pp #Power in kW
fip=pmi*10**5*L*(math.pi/4.0)*d**2*(N/(2*60))*(1/1000.0)
fbp=fip-fp
nm=(fbp/fip)*100
#Output
print" The full load break power = ",round(fbp,2),"kW"
print"The mechanical efficiency of the engine = ",round(nm,2),"percent"
```

In [8]:

```
#given
d=0.09 #The diameter of the bore in m
L=0.1 #The length of the stroke in m
T=120 #The torque measured in Nm
n=4 #Number of cylinders
#Calculations
import math
pmb=((4*math.pi*T)/(L*(math.pi/4)*d**2*n))/10.0**5
#Output
print"The brake mean effective pressure = ",round(pmb,2),"bar"
```

In [1]:

```
#Input data
d=0.06 #The diameter of the bore in m
L=0.085 #The length of the stroke in m
N=3000 #The speed of the engine in rpm
r=0.35 #Torque arm radius in m
W=160 #Weight in N
f=6.6 #Fuel consumption in l/h
g=0.78 #specific gravity of the fuel
CV=44000 #The calorific value of the fuel in kJ/kg
w1=114 #Brake load for cylinder 1 in N
w2=110 #Brake load for cylinder 2 in N
w3=112 #Brake load for cylinder 3 in N
w4=116 #Brake load for cylinder 4 in N
n=4 #Number of cylinders
#Calculations
import math
Vf=(f*10**-3)/3600.0
df=g*1000
mf=df*Vf
T=W*r
bp=(2*math.pi*N*T)/(60.0*1000.0)
pmb=((120*bp*1000)/(L*(math.pi/4.0)*d**2*N*n))/10.0**5
nb=((bp)/(mf*CV))*100
bsfc=(mf*3600)/bp
bp1=((2*math.pi*N*w1*r)/(60.0*1000.0))
ip1=bp-bp1
ip2=bp-((2*math.pi*N*w2*r)/(60*1000))
ip3=bp-((2*math.pi*N*w3*r)/(60*1000))
ip4=bp-((2*math.pi*N*w4*r)/(60*1000))
ip=ip1+ip2+ip3+ip4
nm=(bp/ip)*100
pmi=pmb/(nm/100.0)
#Output
print"The brake power =",round(bp,3),"kW "
print"The brake mean effective pressure = ",round(pmb,3),"bar"
print"The brake thermal efficiency =" ,round(nb,0),"percent"
print"The brake specific fuel consumption = ",round(bsfc,3),"kg/kWh"
print"The indicated power = ",round(ip,2),"kW "
print"The mechanical efficiency =", round(nm,1),"percent "
print"The indicated mean effective pressure = ",round(pmi,1),"bar"
```

In [2]:

```
#given
d=0.15 #The diameter of the bore in m
L=0.16 #The length of the stroke in m
N=500 #The speed of the engine in rpm
mf=0.0475 #Fuel consumption in kg/min
CV=42000 #The calorific value in kJ/kg
w=400 #The tension on either side of the pulley in N
c=2.2 #Brake circumference in m
l=50 #Length of the indicator diagram in mm
ap=475 #Area of the positive loop of indicator diagram in mm**2
an=25 #Area of the negative loop of indicator diagram in mm**2
s=0.8333 #Spring constant in bar/mm
#Calculations
import math
r=c/(2.0*math.pi)
T=w*r
bp=(2*math.pi*N*T)/(60.0*1000.0)
M=(ap-an)/l
imep=M*s
ip=(imep*10**5*L*(math.pi/4.0)*d**2*(N/(2.0*60.0))*(1/1000.0))
nm=(bp/ip)*100
nb=((bp*60)/(mf*CV))*100
ni=((nb/100.0)/(nm/100.0))*100
bsfc=(mf*60)/bp
#Output
print"(a) The brake power = ",round(bp,3),"kW"
print "(b) The indicated power = ",round(ip,3),"kW"
print"(c) The mechanical efficiency = ",round(nm,0),"percent"
print"(d) The brake thermal efficiency = ",round(nb,3)
print"(e) The indicated thermal efficiency = ",round(ni,3)
print"(f) The brake specific fuel consumption = ",round(bsfc,3)," kg/kWh"
```

In [7]:

```
#given
n=8 #Number of cylinders
d=0.08 #The diameter of the bore in m
L=0.1 #The length of the stroke in m
N=4500 #The speed of the engine in rpm
dy=0.55 #The dynamometer readings in m
w=40 #The weight of the dynamometer scale reading in kg
c=100 #Fuel consumption in cc
t=9.5 #Time taken for fuel consumption in s
CV=44000 #The calorific value of the fuel in kJ/kg
p=1 #The atmospheric air pressure in bar
T=300 #The atmospheric air temperature in K
ma=6 #Mass flow rate of air in kg/min
g=0.7 #Specific gravity of the fuel
Vc=65 #The clearance volume of each cylinder in cc
R=287 #Real gas constant in J/kgK
g=1.4 #Isentropic index
#Calculations
import math
bp=(2*math.pi*N*dy*w*9.81)/(60.0*1000.0)
bmep=((bp*1000*60)/(L*(math.pi/4.0)*d**2*(N/2.0)*n))/10.0**5
mf=(c*g*3600)/(t*2.0*1000.0)
bsfc=(mf/bp)
bsac=(ma*60)/bp
a=bsac/bsfc
nb=((bp*3600)/(mf*CV))*100
Va=(ma*R*T)/(p*10.0**5)
Vs=(math.pi/4.0)*d**2*L*(N/2.0)*n
nv=(Va/Vs)*100
Vs1=((math.pi/4.0)*d**2*L)*10**6
cr=(Vs1+Vc)/Vc
na=(1-(1/cr)**(g-1))*100
re=((nb)/(na))*100
#Output
print"The brake power = ",round(bp,1),"kW"
print"The brake mean effective pressure = ",round(bmep,3),"bar"
print"The brake specific fuel consumption = ",round(bsfc,3),"kg/kWh"
print"The brake specific air consumption = ",round(bsac,3),"kg/kWh"
print"The air fuel ratio = ",round(a,2)
print"The brake thermal efficiency = ",round(nb,3),"percent"
print"The volumetric efficiency = ",round(nv,1),"percent"
print"The relative efficiency = ",round(re,1),"percent"
```

In [12]:

```
#given
n=6 #Number of cylinders
Do=0.03 #Orifice diameter in m
Cd=0.6 #Coefficient of discharge
H=0.14 #Pressure drop across the orifice
d=0.1 #The diameter of the bore in m
L=0.11 #The length of the stroke in m
W=540 #Brake load in N
N=2500 #Engine speed in rpm
ch=83/17 #C/H ratio by mass
p=1 #Ambient pressure in bar
t=18 #Time taken for fuel consumption in s
f=100 #The amount of fuel consumption in cc
T=300.0 #Ambient air temperature in K
df=780 #The density of the fuel in kg/m**3
R=287.0 #Real gas constant in J/kgK
g=9.81 #Gravitational force constant in m/s**2
dhg=13600 #Density of Hg in kg/m**3
#Calculations
import math
da=(p*10**5)/(R*T)
Va=(Cd*(math.pi/4.0)*Do**2*(2*g*H*(dhg/da))**(1/2.0))
Vs=(math.pi/4.0)*d**2*L*(N/(2.0*60.0))*n
nv=(Va/Vs)*100
bp=(W*N)/(20000.0)
bmep=((bp*1000)/(L*(math.pi/4.0)*d**2*(N/(2.0*60.0))*n))/10.0**5
T=(60*bp*1000)/(2.0*math.pi*N)
mf=(f/18.0)*(780/1000.0)*(1/1000.0)*3600
bsfc=mf/bp
so=(0.83*(32/12.0))+(0.17*(8/1.0))
sa=so/bsfc
maa=Va*da
af=(maa*3600)/mf
pea=((af-sa)/sa)*100
#Output
print"The volumetric efficiency = ",round(nv,3),"percent"
print"The brake mean effective pressure = ",round(bmep,3),"bar"
print"The brake power = ",bp,"kW"
print"The Torque = ",round(T,3),"Nm"
print"The brake specific fuel consumption = ",round(bsfc,3),"kg/kWh"
print"The percentage of excess air = ",round(pea,1),"percent"
```

In [11]:

```
#given
d=0.2 #The diameter of bore in m
L=0.3 #The length of the stroke in m
r=5.5 #The compression ratio of the engine
N=400 #The speed of the engine in rpm
imep=4.5 #The indicative mean effective pressure in bar
a=6 #Air to gas by volume
CV=12000 #The calorific value of the gas in kJ/m**3
T=340 #The temperature at the beginning of the compression stroke in K
p=0.97 #The pressure at the beginning of the compression stroke in bar
g=1.4 #Adiabatic index
#Calculations
import math
Vs=(math.pi/4.0)*d**2*L
Vc=Vs/(r-1)
V=Vs+Vc
Vg=V/7.0
Vntp=((p*Vg)/T)*(273/1.013)
Q=Vntp*CV*(N/(2.0*60.0))
ip=(imep*10**5*L*(math.pi/4.0)*d**2*(N/(2.0*60.0))*(1/1000.0))
ni=(ip/Q)*100
na=(1-(1/r)**(g-1))*100
nr=(ni/na)*100
#Output
print"The indicated power = ",round(ip,2),"kW"
print"The thermal efficiency = ",round(ni,1),"percent"
print"The relative efficiency = ",round(nr,1),"percent"
```

In [13]:

```
#given
n=6.0 #Number of cylinder
bp=130.0 #Brake power in kW
N=1800.0 #The speed of the engine in rpm
CV=42000.0 #The calorific value of the fuel in kJ/kg
C=86.0 #The composition of carbon in the fuel in percent
H=13.0 #The composition of Hydrogen in the fuel in percent
NC=1.0 #The non combustibles present in the fuel in percent
na=85.0 #The absolute volumetric efficiency in percent
ni=38.0 #The indicated thermal efficiency in percent
nm=80.0 #The mechanical efficiency in percent
ac=110.0 #The excess consumption of air in percent
sb=1.2 #The stroke to the bore ratio
da=1.3 #The density of air in kg/m**3
#Calculations
import math
saf=(((C/100.0)*(32/12.0))+((H/100.0)*(8/1.0)))*(1/0.23)
aaf=saf*(1+1.1)
Ma=(0.23*32)+(0.77*28)
a=(C/100)/12.0
b=(H/100.0)/2.0
x=aaf/Ma
c=(0.21*x)-a-(b/2.0)
d1=0.79*x
ip=bp/(nm/100.0)
mf=ip/((ni/100.0)*CV)
ma=mf*aaf
Va=ma/da
Vs=Va/(na/100.0)#The swept volume per second in m**3/s
d=((Vs*(4/math.pi)*(1/1.2)*((2*60)/N)*(1/n))**(1/3.0))*1000
L=1.2*d
T=a+c+d1
CO2=(a/T)*100
O2=(c/T)*100
N2=(d1/T)*100
#Output
print"The volumetric composition of dry exhaust gas :"
print"1) CO2 = ",round(a,2),"kmol","and"
print"volume = ",round(CO2,2),"percent"
print"2) O2 = ",round(c,3),"kmol","and"
print"volume = ",round(O2,3),"percent"
print"3) N2 = ",round(d1,3),"kmol","and"
print"volume = ",round(N2,3),"percent"
print"The bore of the engine = ",round(d,0),"mm"
print"The stroke of the engine = ",round(L,1),"mm"
```

In [20]:

```
#given
d=0.18 #The diameter of the cylinder in m
L=0.24 #The length of the stroke in m
t=30.0 #Duration trail in min
N=9000.0 #Number of revolutions
Ne=4450.0 #Total number of explosions
pmi=5.35 #Gross imep in bar
pp=0.35 #Pumping imep in bar
W=40.0 #Net load on brake wheel in kg
dd=0.96 #Diameter of the brake wheel drum in m
dr=0.04 #Diameter of the rope in m
V=2.6 #Volume of gas used in m**3
pg=136.0 #pressure of gas in mmof Hg
dg=0.655 #The density of gas in kg/m**3
T=290.0 #The ambient temperature of air in K
CV=19000.0 #The calorific value of the fuel in kJ/m**3
ta=40.0 #Total air used in m**3
p=720.0 #Pressure of air in mm of Hg
Te=340.0 #Temperature of exhaust gas in degree centigrade
Cpg=1.1 #Specific heat of gas in kJ/kgK
C=80.0 #Cooling water circulated in kg
Tr=30.0 #Rise in temperature of cooling water in degree centigrade
R=287.0 #Real gas constant in J/kgK
#Calculations
#import math
ip=(pmi-pp)*10**5*L*(math.pi/4.0)*d**2*(Ne/(30.0*60.0))*(1/1000.0)
bp=(math.pi*(N/(30.0*60.0))*W*9.81*(dd+dr)*(1/1000.0))
pgs=760+(pg/13.6)
Vg=((pgs*V)/290.0)*(273/760.0)
Q=(Vg*CV)/30.0
Qbp=bp*60
Qc=(C/t)*4.18*Tr
Va=(((p*ta)/T)*(273/760.0))/30.0
da=(1.013*10**5)/(R*273)
ma=Va*da
mg=(Vg/30)*dg
me=ma+mg
Qe=me*Cpg*(Te-(T-273))
Qu=Q-(Qe+Qc+Qbp)
nm=(bp/ip)*100
ni=((ip*60)/Q)*100
x=((Qbp/1571.0)*100)
y=((Qc/1571.0)*100)
z=((Qe/1571.0)*100)
k=((Qu/1571.0)*100)
Qf=Qbp+Qc+Qe+Qu
#Output
print Qe
print" HEAT BALANCE SEAT"
print " \nHeat input kj/min % heat expenditure Kj/min %"
print"--------------------------------------------------------------------------------------------------"
print"heat supplied by fuel ",round(Q,0)," 100 (a)Heat in bp ", round(Qbp,1)," ",round(x,1)
print" (b)Heat loss to cooling tower ",round(Qc,0)," ",round(y,1)
print" (c) Heat to exhaust gases ",round(Qe,0)," ",round(z,0)
print" (d)unaccounted losses ",round(Qu,0)," ",round(k,1)
print"Total ",round(Q,0)," 100 total ",round(Qf,0), " 100.0"
print"\nMechanical efficiency is",round(nm,2),"percent"
print"Thermal efficiency is",round(ni,1),"percent"
```

In [85]:

```
#given
bp=30 #The brake power in kw
mf=10 #Mass flow rate of fuel in kg/h
CV=42000 #Calorific value of the fuel in kJ/kg
mw=9 #Mass flow rate of water in kg/min
Tr=60 #Rise in temperature of the cooling water in degree centigrade
mwe=9.5 #Mass flow rate of water through exhaust gas calorimeter in kg/min
Tc=40 #Rise in temperature when passing through calorimeter in degree centigrade
Te=80 #Temperature of exhaust gas leaving the calorimeter in degree centigrade
a=20 #Air fuel ratio
T=17 #Ambient temperature in degree centigrade
Cpw=4.18 #Specific heat of water in kJ/kgK
Cpg=1 #Mean specific heat of gas in kJ/kgK
#Calculations
Qf=(mf/60.0)*CV
Qbp=bp*60
Qc=mw*Cpw*Tr
mg=(mf/60.0)+(mf/60.0)*a
Qe=(mwe*Cpw*Tc)+(mg*Cpg*(Te-T))
Qu=Qf-(Qbp+Qc+Qe)
x=((Qbp/Qf))*100
y=(Qc/Qf)*100
z=(Qe/Qf)*100
k=(Qu/Qf)*100
#Output
print" HEAT BALANCE SEAT"
print "\n Heat input kj/min % heat expenditure Kj/min %"
print"--------------------------------------------------------------------------------------------------"
print"heat supplied by fuel ",Qf," 100 (a)Heat in bp ", Qbp," ",round(x,0)
print" (b)Heat loss to cooling tower ",round(Qc,0)," ",round(y,0)
print" (c) Heat to exhaust gases ",round(Qe,0)," ",round(z,0)
print" (d)unaccounted losses ",round(Qu,0)," ",round(k,0)
print"Total ",Qf," 100 total ",Qf, " 100"
```

In [21]:

```
#given
n=4.0 #Number of cylinders
d=0.085 #The diameter of the bore m
L=0.095 #The length of the stroke in m
tr=0.35 #Torque radius in m
N=3000.0 #The speed of the engine in rpm
w=430.0 #Net brake load in N
w1=300.0 #Net brake load produced at the same speed by three cylinders in N
mf=0.24 #The mass flow rate of fuel in kg/min
CV=44000.0 #The calorific value of the fuel in kJ/kg
mw=65.0 #Mass flow rate of water in kg/min
Tw=12.0 #The rise in temperature in degree centigrade
a=15.0 #The air fuel ratio
Te=450.0 #The temperature of the exhaust gas in degree centigrade
Ta=17.0 #Ambient temperature in degree centigrade
p=76.0 #Barometric pressure in cm of Hg
H=15.5 #The proportion of hydrogen by mass in the fuel in percent
Cpe=1.0 #The mean specific heat of dry exhaust gas in kJ/kgK
Cps=2.0 #The specific heat of super heated steam in kJ/kgK
Cpw=4.18 #The specific heat of water in kJ/kgK
Ts=100.0 #At 76 cm of Hg The temperature in degree centigrade
hfg=2257 #The Enthalpy in kJ/kg
R=287.0 #Real gas cons tant in J/kgK
#Calculations
import math
bp=(2*math.pi*N*w*tr)/(60.0*1000.0)
bp1=(2*math.pi*N*w1*0.35)/(60.0*1000.0)
ip=bp-bp1
ip1=n*ip
imep=((ip1*60*1000)/(L*(math.pi/4.0)*d**2*(N/2.0)*n))/10.0**5
ni=((ip1*60)/(mf*CV))*100
bsfc=(mf*60)/bp
Vs=(math.pi/4.0)*d**2*L*(N/2.0)*n
ma=a*mf
da=(1*10**5)/(R*(Ta+273))
Va=ma/da
nv=(Va/Vs)*100
Qf=mf*CV
Qbp=bp*60
Qc=mw*Cpw*Tw
mv=9*(H/100.0)*mf
me=ma+mf-mv
Qe=me*Cpe*(Te-Ta)
Qs=(mv*((Cpw*(Ts-Ta))+hfg+(Cps*(Te-Ts))))
Qu=Qf-(Qbp+Qc+Qe+Qs)
x=(Qbp/Qf)*100
y=(Qc/Qf)*100
z=(Qe/Qf)*100
k=(Qs/Qf)*100
l=(Qu/Qf)*100
#Output
print" HEAT BALANCE SEAT"
print " Heat input kj/min % heat expenditure Kj/min %"
print"----------------------------------------------------------------------------------------------------"
print"heat supplied by fuel ",Qf," 100 (a)Heat in bp ", Qbp," ",round(x,2)
print" (b)Heat loss to cooling tower ",round(Qc,0)," ",round(y,2)
print" (c) Heat to dry exhaust gases ",round(Qe,0)," ",round(z,1)
print" (d)Heat loss in steam ",round(Qs,0)," ",round(k,1)
print" (e)unaccounted losses ",round(Qu,0)," ",round(l,2)
print"Total ",Qf," 100 total ",Qf, " 100"
print"\nimpep ",round(imep,2),"bar"
print"Thermal efficiency ",round(ni,1),"percent"
print"bsfc=",round(bsfc,4),"kg/kwh"
print"Volumetric efficiency=",round(nv,1),"percent"
```