In [1]:

```
import math
#Input data
p = [1,8] #Pressure at the beginning and end of compression in kg/m**3
g = 1.4 #Ratio of specific heats
#Calculations
r = (p[1]/p[0])**(1/g) #Compression ratio
n = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
#Output
print 'Air standard efficiency of an engine working on the Otto cycle is %3.1f percent'%(n)
```

In [2]:

```
import math
#Input data
D = 0.25 #Bore in m
L = 0.45 #Stroke in m
Cv = 5. #Clearance volume in litres
g = 1.4 #Ratio of specific heats
IHP = 32. #Indicated Horse power in h.p
m = 14. #Gas consumption in m**3/hr
CV = 4000. #Calorific value of gas in kcal/m**3
#Calculations
Vs = (3.14/4)*D**2*L #Stroke volume in m**3
Vc = Cv/1000 #Clearance volume in m**3
r = (Vs+Vc)/Vc #Compression ratio
na = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
q = (m*CV)/60 #Heat supplied in kcal/min
aI = (IHP*4500)/427 #Heat equivalent of I.H.P in kcal/min
itn = (aI/q)*100 #Indicated thermal efficiency in percent
rn = (itn/na)*100 #Relative efficiency in percent
#Output
print 'The air standard efficiency is %3.1f percent \
\nIndicated thermal efficiency is %3.1f percent \
\nRelative efficiency is %3.1f percent'%(na,itn,rn)
```

In [3]:

```
import math
#Input data
r = 6. #Compression ratio
It = 0.6 #Indicated thermal efficiency ratio
CV = 10000. #Calorific value in kcal/kg
g = 1.4 #Ratio of specific heats
#Calculations
an = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
In = (It*(an/100)) #Indicated thermal efficiency
SFC = ((4500*60)/(427*CV*In)) #Specific fuel consumption in kg/I.H.P.hr
#Output
print 'Specific fuel consumption is %3.3f kg/I.H.P. hr'%(SFC)
```

In [4]:

```
import math
#Input data
T = [100.+273,473.+273] #Temperatures at the beginning and at the end of adiabatic compression in K
g = 1.4 #Ratio of specific heats
#Calculations
an = (1-(T[0]/T[1]))*100 #Air standard efficiency in percent
r = (T[1]/T[0])**(1/(g-1)) #Compression ratio
#Output
print 'The compression ratio is %3.2f \
\nAir standard efficiency is %i percent'%(r,an)
```

In [5]:

```
import math
#Input data
T1 = 45.+273 #Temperature at the beginning of compression in K
p1 = 1. #Pressure at the beginning of compression in kg/cm**2
T2 = 325.+273 #Temperature at the end of compression in K
T3 = 1500.+273 #Temperature at the end of consmath.tant volume heat addition in K
g = 1.4 #Ratio of specific heats
#Calculations
r = (T2/T1)**(1/(g-1)) #Compression ratio
an = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
p2 = (p1*r**g) #Pressure at the end of compression in kg/cm**2
p3 = (p2*(T3/T2)) #Pressure at the end of consmath.tant volume heat addition in kg/cm**2
p4 = p3/p2 #Pressure at the end of adiabatic expansion in kg/cm**2
T4 = T3/r**(g-1) #Temperature at the end of adiabatic expansion in K
t4 = T4-273 #Temperature at the end of adiabatic expansion in degree C
#Output
print 'The air standard efficiency is %3.1f percent \
\nTemperature at the end of adiabatic expansion is %i degree C \
\nPressure at the end of adiabatic expansion is %3.0f kg/cm**2'%(an,t4,p4)
```

In [6]:

```
import math
#Input data
T1 = 40.+273 #Temperature at the beginning of compression in K
p1 = 1. #Pressure at the beginning of compression in kg/cm**2
p2 = 15. #Pressure at the end of adabatic compression in kg/cm**2
T3 = 2000.+273 #Maximum temperature during the cycle in K
Cv = 0.17 #Specific heat at consmath.tant volume in kJ/kg.K
g = 1.4 #Ratio of specific heats
#Calculations
T2 = T1*(p2/p1)**((g-1)/g) #Temperature at the end of adabatic compression in K
na = (1-(T1/T2))*100 #Air standard efficiency in percent
q = (Cv*(T3-T2)) #Heat added in kcal/kg of air
W = ((na/100)*q) #Workdone per kg of air in kcal
W1 = (4.28*W) #Workdone per kg of air in kg.m
p3 = (p2*(T3/T2)) #Pressure at the end of consmath.tant volume heat addition in kg/cm**2
p4 = (p3*p1)/p2 #Pressure at the end of adiabatic expansion in kg/cm**2
#Output
print 'a) The heat supplied is %3.0f kcal/kg of air \
\nb) The workdone is %i kcal/kg of air \
\nc) The pressure at the end of adiabatic expansion is %3.2f kg/cm**2'%(q,W,p4)
```

In [7]:

```
import math
#Input data
r = 16. #Compression ratio
k = 5. #Cut off takes place at 5% of the stroke
g = 1.4 #Ratio of specific heats
#Calculations
c = (((k/100)*(r-1))+1) #Cut off ratio
na = (1-((1/r**(g-1))*((c**g-1)/(g*(c-1)))))*100 #Air standard efficiency in percent
#Output
print 'The air standard efficiency is %3.1f percent'%(na)
```

In [8]:

```
import math
#Input data
p1 = 1.05 #Inlet pressure in kg/cm**2
T1 = 15.+273 #Inlet temperature in K
p2 = 33.4 #Pressure at the end of adiabatic compression in kg/cm**2
r = 5. #The ratio of expansion
Cp = 0.238 #Specific heat at consmath.tant pressure in kJ/kg.K
Cv = 0.17 #Specific heat at consmath.tant volume in kJ/kg.K
g = 1.4 #Ratio of specific heats
#Calculations
r1 = (p2/p1)**(1/g) #Compression ratio
k = r1/r #Cutoff ratio
T2 = (p2/p1)**((g-1)/g)*T1 #Temperature at the end of adiabatic compression in K
T3 = T2*k #Temperature at the end of consmath.tant pressure heat addition in K
T4 = T3*(1/r)**(g-1) #Temperature at the end of adiabatic expansion in K
qa = (Cp*(T3-T2)) #Heat added in kcal/kg of air
qre = (Cv*(T4-T1)) #Heat rejected in kcal/kg of air
nt = ((qa-qre)/qa)*100 #Ideal thermal efficiency in percent
#Output
print 'The ideal thermal efficiency is %3.1f percent'%(nt)
```

In [9]:

```
#Input data
p1 = 1. #Pressure at the end of suction stroke in kg/cm**2
T1 = 30.+273 #Temperature at the end of suction stroke in kg/cm**2
T3 = 1500.+273 #Maximum temperature during the cycle in K
r = 16. #Compression ratio
Cp = 0.24 #Specific heat at consmath.tant pressure in kJ/kg.K
Cv = 0.17 #Specific heat at consmath.tant volume in kJ/kg.K
g = 1.41 #Ratio of specific heats
#Calculations
T2 = T1*r**(g-1) #Temperature at the end of adiabatic compression in K
s = (((T3/T2)-1)/(r-1))*100 #Percentage of the stroke at which cut off occurs
r1 = (r/(T3/T2)) #Expansion ratio
T4 = T3/(r1)**(g-1) #Temperature at the end of adiabatic expansion in K
qa = (Cp*(T3-T2)) #Heat added in kcal/kg of air
qre = (Cv*(T4-T1)) #Heat rejected in kcal/kg of air
nt = ((qa-qre)/qa)*100 #Air standard efficiency in percent
#Output
print 'a) The percentage of stroke at which cut off takes place is %3.2f percent \
\nb) The temperature at the end of expansion stroke is %3.0f K \
\nc) The theoretical efficiency is %3.0f percent'%(s,T4,nt)
```

In [10]:

```
import math
#Input data
p1 = 1. #Pressure at the beginning of compression in kg/cm**2
T1 = 80.+273 #Temperature at the beginning of compression in K
r = 14. #Compression ratio
p4 = 2.7 #Pressure at the end of expansion in kg/cm**2
Cp = 0.24 #Specific heat at consmath.tant pressure in kJ/kg.K
g = 1.4 #Ratio of specific heats
#Calculations
p2 = p1*r**g #Pressure at the end of compression in kg/cm**2
s = (((r*(p4/p2)**(1/g))-1)/(r-1))*100 #Percentage of stroke when the fuel is cut off in percent
T2 = (T1*(p2/p1))/r #Temperature at the end of compression in K
T3 = (T2*r*(p4/p2)**(1/g)) #Temperature at the end of adiabatic expansion in K
q = (Cp*(T3-T2)) #Heat supplied in kcal/kg
#Output
print 'a) The maximum pressure attained during the cycle is %3.1f kg/cm**2 \
\nb) The percentage of working stroke at which the heat supply to the working fluid ceases is %3.2f percent \
\nc) The heat received per kg of woring substance during the cycle is %3.0f kcal/kg'%(p2,s,q)
```

In [11]:

```
import math
# variables
d = 0.25 #Diameter of the cylinder in m
L = 0.35 #Stroke in m
Cv = 1500. #Clearance volume in c.c
s = 5. #cut off ratio takes place at 5 percent of stroke
a = 1.4 #Explosion ratio
g = 1.4 #Ratio of specific heats for air
#Calculations
Vs = (3.14/4)*d**2*L #Stroke volume in m**3
r = (Vs*10**6+Cv)/Cv #Compression ratio
k = (Cv+((s/100)*Vs*10**6))/Cv #Cut off ratio
na = (1-((1/(r**(g-1)))*((a*k**g-1)/((a-1)+a*g*(k-1)))))*100 #Air standard efficiency in percent
#Output
print 'The air standard efficiency of the engine is %3.1f percent'%(na)
```

In [12]:

```
import math
#Input data
d = 0.2 #Diameter of the cylinder in m
L = 0.4 #Stroke in m
r = 13.5 #Compression ratio
a = 1.42 #Explosion ratio
s = 5.1 #Cut off occurs at 5.1 percent of the stroke
g = 1.4 #Ratio of specific heats for air
#Calculations
Vs = (3.14/4)*d**2*L*10**-6 #Stroke volume in c.c
Vc = Vs/r #Clearance volume in c.c
k = (((s/100)*Vs)+Vc)/Vc #Cut off ratio
ASE = (1-((1/(r**(g-1)))*((a*k**g-1)/((a-1)+a*g*(k-1)))))*100 #Air standard efficiency in percent
#Output
print 'The air standard efficiency of the engine is %3.1f percent'%(ASE)
```

In [13]:

```
import math
#Input data
x = [2./3,1./3] #The dual cycle atkes two-thirds of its total heat supply at consmath.tant volume and one-third at consmath.tant pressure
r = 13. #Compression ratio
p3 = 43. #Maximum pressure of the cycle in kg/cm**2
p1 = 1. #Pressure at intake in kg/cm**2
T1 = 15.+273 #Intake temperature in K
Cp = 0.24 #Specific heat at consmath.tant pressure in kJ/kg.K
Cv = 0.17 #Specific heat at consmath.tant volume in kJ/kg.K
g = 1.41 #Ratio of specific heats
#Calculations
T2 = T1*r**(g-1) #Temperature at the end of compression in K
p2 = (p1*r**g) #Pressure at the end of compression in kg/cm**2
T3 = T2*p3/p2 #Temperature at the end of consmath.tant volume heat addition in K
q23 = Cv*(T3-T2) #Heat added at consmath.tant volume in kcal/kg
q34 = (1./2)*q23 #Heat added at consmath.tant pressure in kcal/kg
T4 = (q34/Cp)+T3 #Temperature at the end of consmath.tant pressure heat supply in K
T5 = (T4*((p1*(T4/T3))/r)**(g-1)) #Temperature at the end of expansion in K
na = (1-((Cv*(T5-T1))/((Cv*(T3-T2))+(Cp*(T4-T3)))))*100 #Efficiency in percent
T = [T1-273,T2-273,T3-273,T4-273,T5-273] #Temperature at the five cardinal points in degree C
#Output
print 'a) The temperature at the five cardinal points of the cycle are : point 1 is %3.0f degree C \
\npoint 2 is %3.0f degree C \
\npoint 3 is %3.0f degree C \
\npoint 4 is %3.1f degree C \
\npoint 5 is %3.0f degree C \
\nb) The ideal thermal efficiency of the cycle is %3.1f percent'%(T[0],T[1],T[2],T[3],T[4],na)
```

In [14]:

```
import math
#Input data
p1 = 1. #Pressure at intake in kg/cm**2
T1 = 100.+273 #Intake temperature in K
r = 10. #Compression ratio
p3 = 70. #Maximum pressure of the cycle in kg/cm**2
q = 400. #Amount of heat added in kcal/kg of air
Cp = 0.24 #Specific heat at consmath.tant pressure in kJ/kg.K
Cv = 0.17 #Specific heat at consmath.tant volume in kJ/kg.K
g = 1.41 #Ratio of specific heats
#Calculations
T2 = (T1*r**(g-1)) #Temperature at the end of compression in K
p2 = (p1*r**g) #Pressure at the end of compression in kg/cm**2
T3 = T2*(p3/p2) #Temperature at the end of consmath.tant volume heat addition in K
qv = (Cv*(T3-T2)) #Heat added at consmath.tant volume in kcal/kg
qp = (q-qv) #Heat added at consmath.tant pressure in kcal/kg
T4 = (qp/Cp)+T3 #Temperature at the end of consmath.tant pressure heat supply in K
k = (T4/T3) #Cut off ratio
T5 = T4/(r/k)**(g-1) #Temperature at the end of expansion in K
qv2 = Cv*(T5-T1) #Heat added at consmath.tant volume in kcal/kg
W = q-qv2 #Workdone in kcal/kg of air
na = (W/q)*100 #Air standard efficiency in percent
#Output
print 'The temperature at the five cardinal points of the cycle are : \
\npoint 1 is %3.0f K \
\npoint 2 is %3.0f K \
\npoint 3 is %3.0f K \
\npoint 4 is %3.0f K \
\npoint 5 is %3.0f K \
\nThe air standard efficiency of the engine is %3.1f percent'%(T1,T2,T3,T4,T5,na)
```

In [15]:

```
import math
#Input data
r = 12. #Compression ratio
p1 = 0.955 #Pressure at the start of compression in kg/cm**2
T1 = 85.+273 #Temperature at the start of compression in K
p3 = 55. #Maximum pressure of the cycle in kg/cm**2
x = (1./30) #Consmath.tant pressure heat reception contnues for 1/30 of the stroke
Cp = 0.238 #Specific heat at consmath.tant pressure in kJ/kg.K
Cv = 0.17 #Specific heat at consmath.tant volume in kJ/kg.K
g = 1.4 #Ratio of specific heats
#Calculations
T2 = T1*r**(g-1) #Temperature at the end of compression in K
p2 = (p1*r**g) #Pressure at the end of compression in kg/cm**2
T3 = T2*(p3/p2) #Temperature at the end of consmath.tant volume heat addition in K
T4 = (T3*((p1+x*(r-1))/p1)) #Temperature at the end of consmath.tant pressure heat supply in K
T5 = T4*((p1+x*(r-1))/r)**(g-1) #Temperature at the end of expansion in K
qs = (Cv*(T3-T2))+(Cp*(T4-T3)) #Heat supplied in kcal/kg of air
qre = (Cv*(T5-T1)) #Heat rejected in kcal/kg of air
W = (qs-qre) #Workdone in kcal/kg of air
an = ((qs-qre)/qs)*100 #Air standard efficiency in percent
#Ouptut
print 'The wordone per kg of air is %3.2f kcal \
\nThe ideal thermal efficiency is %3.1f percent'%(W,an)
```

In [16]:

```
import math
#Input data
p1 = 1. #Pressure of air intake in kg/cm**2
T1 = 50.+273 #Temperature of air intake in K
v = (1./14) #Volume compresses by it adiabatically of its original volume
r = (1/v) #Compression ratio
Cp = 0.237 #Specific heat at consmath.tant pressure in kJ/kg.K
Cv = 0.169 #Specific heat at consmath.tant volume in kJ/kg.K
g = 1.4 #Ratio of specific heats for air
#Calculations
T2 = T1*r**(g-1) #Temperature at the end of compression in K
p2 = (p1*r**g) #Pressure at the end of compression in kg/cm**2
p3 = x*p2 #Pressure at the end of the heat addition at consmath.tant volume in kg/cm**2
T3 = T2*(p3/p2) #Temperature at the end of consmath.tant volume heat addition in K
T4 = (T3*x) #Temperature at the end of consmath.tant pressure heat supply in K
T5 = T4/(r/x)**(g-1) #Temperature at the end of expansion in K
qs = (Cv*(T3-T2))+(Cp*(T4-T3)) #Heat supplied in kcal/kg of air
qre = (Cv*(T5-T1)) #Heat rejected in kcal/kg of air
na = ((qs-qre)/qs)*100 #Air standard efficiency in percent
T = [T1-273,T2-273,T3-273,T4-273,T5-273] #Temperature at the five key points in degree C
#Output
print 'a) The temperature at the five key points of the cycle are : \
\npoint 1 is %3.0f K = %3.0f degree C \
\npoint 2 is %3.0f K = %3.0f degree C \
\npoint 3 is %3.0f K = %3.0f degree C \
\npoint 4 is %3.0f K = %3.0f degree C \
\npoint 5 is %3.0f K = %3.0f degree C \
\nb) The ideal thermal efficiency of the cycle is %3.2f percent'%(T1,T[0],T2,T[1],T3,T[2],T4,T[3],T5,T[4],na)
```

In [17]:

```
import math
#Input data
n = 6. #Six cylinder engine
r = 5. #Compression ratio
Vc = 110. #Clearance volume in c.c
a = 0.66 #Efficiency ratio referred to the air standard cycle
N = 2400. #Speed in r.p.m
m = 9.9 #Mass of petrol in kg
CV = 10600. #Calorific value of fuel in kcal/kg
g = 1.4 #Ratio of specific heats
#Calculations
Vs = (r*Vc-Vc) #Swept Volume in c.c
na = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
nt = (na/100)*a #Thermal efficiency
IHP = (nt*CV*m*427)/(4500*60) #Indicated Horse Power in h.p
pm = (((IHP/n)*4500*100*2)/(Vs*N)) #Average indicated mean effective pressure in kg/cm**2
#Output
print 'The average indicated mean effective pressure in each cylinder is %3.3f kg/cm**2'%(pm)
```

In [18]:

```
import math
#Input data
n = 4. #Four cylinder engine
BHP = 40. #Brake horse power in h.p
N = 3000. #Speed in r.p.m
nm = 70. #Mechanical efficiency in percent
pm = 13.5 #Indicated mean effective pressure in kg/cm**2
#Bore is equal to stroke
#Calculations
#case(i)
d1 = ((BHP*100*4500*n*2)/(n*(nm/100)*pm*N*3.14))**(1/3) #Cylinder bore or stroke length in cm
#Case(ii)
d2 = ((BHP*100*4500*n)/(n*(nm/100)*pm*N*3.14))**(1/3)*10 #Cylinder bore or stroke length in cm
#Output
print 'The cylinder sizes for a bore equal to stroke of a four cylinder in case of \
\ni)Four stroke engine is %3.1f cm \
\nii)Two stroke engine is %3.0f mm'%(d1,d2)
```

In [19]:

```
import math
#Input data
T = [50.+273,345.+273] #Temperatures at the beginning and end of compression in K
g = 1.4 #ratio of specific heats
IHP = 25. #Indicated horse power in h.p
m = 5.44 #Mass of fuel consumed per hour in kg
CV = 10300. #Calorific value in kcal/kg
#Calculations
na = (1-(T[0]/T[1]))*100 #Air standard efficiency in percent
r = (T[1]/T[0])**(1/(g-1)) #Compression ratio
qIHP = (IHP*4500)/427 #Heat equivalent of I.H.P in kcal/min
q = (m*CV)/60 #Heat supplied per minute in kcal/min
Ith = (qIHP/q)*100 #Indicated thermal efficiency in percent
nr = (Ith/na)*100 #Efficiency ratio
#Output
print 'The air standard efficiency is %3.1f percent \
\nThe compression ratio is %3.2f \
\nIndicated thermal efficiency is %3.1f percent \
\nEfficiency ratio is %3.1f percent'%(na,r,Ith,nr)
```

In [20]:

```
import math
#Input data
CV = 10000. #Calorific value of petrol in kcal/kg
pe = [30.,70.] #Percentage of compression strokes in percent
p = [1.33,2.66] #Pressures in the cylinder corresponding to the compression strokes in kg/cm**2
n = 1.33 #Polytropic consmath.tant
rn = 50. #Relative efficiency in percent
g = 1.4 #ratio of specific heats
#Calculations
v = (p[1]/p[0])**(1/n) #Ratio of specific volumes
r = ((pe[1]/100)*v-(pe[0]/100))/((pe[1]/100)-((pe[0]/100)*v)) #Compression ratio
na = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
ith = (rn*na)/100 #Indicated thermal efficiency in percent
q = (4500*60)/(427*(ith/100)) #Heat supplied in kcal/i.h.p.hr
Sc = (q/CV) #Specific consumption in kg/i.h.p.hr
#Output
print 'Compression ratio is %3.2f \
\nSpecific consumption is %3.3f kg/i.h.p.hr'%(r,Sc)
```

In [21]:

```
import math
#Input data
n = 4. #Four cylinder four stroke
d = 7.5 #Bore in cm
L = 8.75 #Stroke in cm
r = 6. #Compression ratio
n1 = 55. #Efficiency in percent
g = 1.4 #ratio of specific heats
N = 2400. #Speed in r.p.m
pm = 7. #Brake mean effective pressure in kg/cm**2
m = 9. #Mass of fuel per hour in kg
CV = 10500. #Calorific Value in kcal/kg
#Calculations
an = (1-(1/r)**(g-1))*100 #Air standard efficiency in percent
In = (an*n1)/100 #Indicated thermal efficiency in percent. In textbook, answer is wrong
BHP = (pm*(3.14/4)*d**2*(L/100)*(N/2)*n) #Brake horse power in kg.m/min
Bth = ((BHP*60)/(427*CV*m))*100 #Brake thermal efficiency in percent
nm = (Bth/In)*100 #Mechanical efficiency in percent
Sc = ((4500*60)/(427*(Bth/100)*CV)) #Specific consumption in g/i.h.p.hr
#Output
print 'Indicated thermal efficiency is %3.1f percent \
\nBrake thermal efficiency is %3.1f percent \
\nMechanical efficiency is %3.1f percent \
\nSpecific fuel consumption is %3.3f kg/i.h.p.hr'%(In,Bth,nm,Sc)
```

In [22]:

```
import math
#Input data
r = 7. #Compression ratio
v = 1. #Specific heat at consmath.tant volume increases by 1 percent
g = 1.4 #Ratio of specific heats
#Calculations
e = (1-(1/r**(g-1))) #Air standard efficiency
dee = -(((1-e)*(g-1)*math.log(r)*(v/100))/e)*100 #Change in efficiency to the original efficiency
x = -(dee) #For Output purpose
#Output
print 'Percentage change is efficiency is %3.2f percent i.e. a decrease of %3.2f percent'%(dee,x)
```

In [23]:

```
import math
#Input data
N = 210. #Speed in r.p.m
d = 0.3 #Diameter of the piston in m
L = 0.4 #Stroke in m
v = 2.5 #Clearance volume is 2.5% of the swept volume. But in textbook it is given wrong as 25%
CO = 19.7 #Percentage of CO gas
H2 = 28.8 #Percentage of H2 gas
CO2 = 14.4 #Percentage of CO2 gas
N2 = 37.1 #Percentage of N2 gas
x = 0.875 #Total mixture at N.T.P admitted per suction stroke is 0.875 of the total volume behind the piston at the end of the stroke
tn = 35. #Thermal efficiency in percent
CVH2 = 13200. #Calorific value of H2 per kg in kcal
CVC = 2540. #Calorific value of carbon burning from CO to CO2 in kcal/kg
de = 1.293 #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
mCO = 28. #Molecular weight of CO
#Calculations
a = ((100./21)*((CO2/100)+((CO/2)/100))) #Air per cu.m of gas in cu.m
Vm = (a+1) #Volume of mixture per cu.m of gas in cu.m
Vs = ((3.14/4)*d**2*L) #Swept volume in cu.m
Vc = (Vs*v)/100 #Clearance volume in cu.m
V = Vc+Vs #Total volume in cu.m
VC = V*x #Volume of charge admitted per stroke in cu.m
VM = VC*(N/2) #Charge volume per minute in cu.m
VG = (VM/Vm) #cu.m of gas per minute
vH2 = (VG*(H2/100)) #Volume of H2 per minute in cu.m
vCO = (VG*(CO/100)) #Volume of CO per minute in cu.m
CVH2cum = (mH2*CVH2)/(vH2*1000) #Calorific value of H2 per cu.m in kcal
CVCO = (CVC*(2*mC)/(2*mCO)) #Calorific value of CO per kg in kcal
CVCOcum = (mCO*CVCO)/(vH2*1000) #Calorific value of CO per cu.m in kcal
qH2 = (16.09*CVH2cum) #Heat in charge due to H2 in kcal
qCO = (11*CVCOcum) #Heat in charge due to CO in kcal
qt = (qH2+qCO) #Heat supplied per minute in kcal
qu = (qt*(tn/100)) #Heat utilised in kcal
hp = (qu*427)/4500 #H.P developed
#Output
print 'Maximum horse power that can be developed is %3.1f H.P'%(hp)
```

In [24]:

```
import math
#Input data
vCH4 = 65. #Composition by volume of CH4
vH2 = 2. #Composition by volume of H2
vN2 = 2. #Composition by volume of N2
vCO2 = 31. #Composition by volume of CO2
O2 = 5.3 #Composition of O2 in dry exhaust gases when analysed in orsat apparatus
N2 = 83. #Composition of N2 in dry exhaust gases when analysed in orsat apparatus
CO = 0.3 #Composition of CO in dry exhaust gases when analysed in orsat apparatus
CO2 = 11.4 #Composition of CO2 in dry exhaust gases when analysed in orsat apparatus
an = 79. #Air contains 79% by volume of nitrogen
#Calculations
a = (100./(100-an))*(((vCH4/100)*2)+((vN2/100)*(1./2))) #Total air required for complete combustion of 1 cu.m of gas in cu.m
xCO = (CO/2) #O2 required to burn the CO in cu.m
xCO2 = CO #CO2 formed in cu.m
tO2 = O2-xCO #Total O2 in cu.m
tN2 = N2 #Total N2 in cu.m
tCO2 = CO2+xCO2 #Total CO2 in cu.m
T = tO2+tN2+tCO2 #Total mixture in cu.m
pCO2 = (tCO2*100)/T #Percentage of CO2 in percent
mm = (a*100) #Minimum air supply required for complete combustion of 100 cu.m of the gas in cu.m
an2 = (an/100)*mm #N2 for this air in cu.m
tn2 = (an2+vN2) #Total N2 in cu.m
v = (((vCH4+vCO2)*100)/pCO2)-(vCH4+vCO2+tn2) #Increase in air supply for reduction in percentage of CO2 in cu.m
pea = (v*100)/mm #Percentage of excess air. In textbook it is given wrong as 26.7 percent
#Output
print 'a) the air-fuel ratio by volume to give complete combustion is %3.3f \
\nb) the percentage of excess air actually used in the test is %3.1f percent'%(a,pea)
```

In [25]:

```
import math
#Input data
Vs = 9.45 #Swept volume in litres
Vc = 2.32 #Clearance volume in litres
m = 4.25 #Consumption of gas per hour in cu.m
N = 165. #Speed in r.p.m
bhp = 5.62 #Brake horse power in h.p
nm = 73.4 #Mechanical efficiency in percent
CV = 3500. #Calorific value in kcal per cubic meter
vn = 0.87 #Volumetric efficiency
g = 1.4 #Ratio of specific heats
#Calculations
tV = (Vs+Vc)*1000 #Total volume in c.c
rc = (tV/Vc) #Compression ratio
na = (1-(1/rc**(g-1)))*100 #Air math.radians(numpy.arcmath.tan(ard efficiency in percent
W = (bhp*4500)/427 #Workdone per minute in kcal
Iw = (W/(nm/100)) #Indicated work in kcal/min
q = (m/60)*CV #Heat supplied in kcal/min
ith = (Iw/q)*100 #Indicated thermal efficiency in percent
rn = (ith/na)*100 #Relative efficiency in percent
Vm = (Vs*1000)*vn #Volume of mixture taken in per stroke in c.c
Vg = (m*2*10**6)/(60*N) #Volume of gas taken in per stroke in c.c
Va = (Vm-Vg) #Volume of air taken in per stroke in c.c
agr = (Va/Vg) #Air gas ratio
CVc = (CV/(agr+1)) #Calorific value of charge in kcal
#Output
print 'Ratio of air to gas used is %3.2f \
\nCalorific value of 1 cu.m of the mixture in the cylinder is %3.1f kcal'%(agr,CVc)
```

In [26]:

```
import math
#Input data
d = 18. #Bore in cm
l = 37.5 #Stroke in cm
N = 220. #Speed in r.p.m
#Mean effective pressure in kg/cm**2
#Firing
pp = 5.9 #Positive loop
pn = 0.248 #Negative loop
#Mismath.sing
nn = 0.432 #Negative loop
bhp = 8.62 #Brake horse power in h.p
ex = 100. #Explosions per minute
vg = 0.101 #Gas used in cu.m per minute
#Calculations
tc = (N/2) #The number of cycles
nw = ex #Number of working cycles
nm = (tc-nw) #Number of mismath.sing cycles
ihp = ((l/100)*(3.14/4)*(d**2/4500))*((pp-pn)*(100-nn)) #Net I.H.P in h.p
fhp = (ihp-bhp) #Friction horse power in h.p
W = ((pp-pn)*(3.14/4)*(d**2*(l/100))) #Workdone per firing done in kg.m
Wp = (nn*(3.14/4)*d**2*(l/100)) #Workdone per pumping stroke in kg.m
n = ((fhp*4500)+(Wp*tc))/(W+Wp) #Number of strokes
gf = (vg/nw) #Gas per firing stroke in cu.m
gl = (n*gf) #Gas per minute at no load in cu.m
#Output
print 'Friction horse power of the engine is %3.2f Gas consumption at no load is %3.3f cu.m/min'%(fhp,gl)
```