In [5]:

```
from __future__ import division
# Initialisation of Variables
t1=673#.....................#Max temp in Kelvin
t3=313##...................#Min temp in Kelvin
W=130#.................#Work produced in kJ
#calculations
etath=(t1-t3)/t1#................#Engine thermal efficiency
print "Engine thermal efficiency = %0.2f %%"%(etath*100)
ha=W/etath#.................#Heat added in kJ
print "Head added = %0.2f kJ"%ha
dels=(ha-W)/t3#...........#Change in entropy
print "Change in entropy = %0.3f kJ/K"%dels
```

In [6]:

```
from __future__ import division
# Initialisation of Variables
m=0.5#.....................#Mass of air in kg
etath=0.5#.................#Thermal efficiency of engine
hie=40#...................#Heat transferred during isothermal expansion in kJ
p1=7#....................#Pressure in bar at the beginning of expansion
v1=0.12#..................#Volume in m**3 at the beginning of expansion
cv=0.721#...................#Specific heat at constant volume in kJ/kgK
cp=1.008#..................#Specific heat at constant pressure in kJ/kgK
R=287#......................#Gas constant in J/kgK
#Calculations
t1=(p1*10**5*v1)/(R*m)#....................#Max temp in K
t2=t1*(1-etath)#.......................#Min temp in K
print "The maximum temperature = %0.2f Kelvin"%t1
print "The minimum temperature = %0.2f Kelvin"%t2
from math import exp
v2=(exp((hie*1000)/(m*R*t1)))*v1#..................#Volume at the end of isothermal expansion in m**3
print "Volume at the end of isothermal expansion = %0.2f m**3"%v2
print "\n\n"
print "Process Heat transfer\n"
print "_______________________________________________________________\n"
print "Isothermal expansion %d kJ\n"%(hie)
print "Adiabatic reversible expansion %d kJ\n"%(0)
print "Isothermal compression %d kJ\n"%(-hie)
print "Adiabatic reversible compressions %d kJ"%(0)
```

In [7]:

```
from __future__ import division
from math import log
# Initialisation of Variables
p1=18#..................#Maximum pressure in bar
t1=410+273#.............#Maximum temperature in Kelvin
ric=6#.....................#Ratio of isentropic compression
rie=1.5#.................#Ratio of isothermal expansion
v1=0.18#..................#Volume of air at the beginning of expansion
ga=1.4#...................#Degree of freedom of gas
R=287#.....................#Gas constant in J/kgK
nc=210#..................#no of working cycles
#Calculations
t4=t1/(ric**(ga-1))#.............#Min temp in K
t3=t4#
p4=p1/(ric**ga)#..................#Min pressure in bar
p2=p1/rie#.......................#pressure of gas before isentropic expansion in bar
p3=p2*((1/6)**ga)#.................#Pressure of gas after isentropic expansion in bar
print "p1=%.f bar \np2=%.f bar \np3=%.3f bar \np4=%.3f bar \nt1=t2=%0.f Kelvin \nt3=t4=%.f Kelvin \n"%(p1,p2,p3,p4,t1,t3)
dels=(p1*10**5*v1*log(rie))/(1000*t1)#....................#Change in entropy
print "Change in entropy = %0.2f kJ/K"%dels
qs=t1*dels#.......................#Heat supplied in kJ
Qr=t4*dels#.......................#Heat rejected in kJ
eta=(qs-Qr)/qs#............#Efficiency of the cycle
v3byv1=ric*rie#
Vs=(v3byv1-1)*v1#.................#Stroke volume
pm=((qs-Qr)*10**3)/(Vs*10**5)#........#Mean effective pressure of the cycle in bar
print "Mean effective pressure of the cycle = %0.2f bar"%pm
P=(qs-Qr)*(nc/60)#.........................#Power of engine
print "Mean effective pressure of the cycle = %0.2f bar"%P
```

In [1]:

```
from __future__ import division
# Initialisation of Variables
eta=1/6#...................#Efficiency of the engine
rts=70#.................#The amount of temp which is reduced in the sink in C
#Calculation
t1byt2=1/(1-eta)#
t2=(rts+273)/((2*eta*t1byt2)-t1byt2+1)#............#Temperature of the sink in K
print "Temperature of the sink = %0.f Celsius"%(t2-273)
t1=t1byt2*t2#...............#Temperature of source in K
print "temperature of source = %0.f Celsius:"%(t1-273)
```

In [2]:

```
from __future__ import division
# Initialisation of Variables
t1=1990#....................#Temperature of the heat source in K
t2=850#..................#Temperature of the sink in K
Q=32.5#...................#Heat supplied in kJ/min
P=0.4#....................#Power developed by the engine in kW
#Calculations
eta=1-(t2/t1)#..........#Efficiency of carnot engine
etath=P/(Q/60)#..................#Efficiency of the given engine
if (etath>eta):
print "Since the efficiency of the given engine is more than efficiency of carnot engine, the claim is not true."
```

In [3]:

```
from __future__ import division
# Initialisation of Variables
etaotto=0.6#............#Efficiency of otto engine
ga=1.5#.................#Ratio of specific heats
#Calculations
r=(1/(1-etaotto))**(1/(ga-1))#................#Compression ratio
print "The compression ratio of the engine is:",r
```

In [4]:

```
from __future__ import division
from math import pi
# Initialisation of Variables
D=0.25#......................#Engine bore in m
L=0.375#...................#Engine stroke in m
Vc=0.00263#................#Clearence volume in m**3
p1=1#..................#Initial pressure in bar
t1=323#...................#Initial temperature in K
p3=25#....................#Max pressure in bar
ga=1.4#....................#Ratio of specific heats
#Calculations
Vs=(pi/4)*D*D*L#................#Swept volume in m**3
r=round((Vs+Vc)/Vc)#..........................#Compression ratio
etaotto=1-(1/(r**(ga-1)))#..................#Air standard efficiency of otto cycle
print "The air standard efficiency of otto cycle = %0.2f %%"%(etaotto*100)
p2=p1*((r)**ga)#
rp=p3/p2#..........................#Pressure ratio
pm=(p1*r*((r**(ga-1))-1)*(rp-1))/((ga-1)*(r-1))#................#Mean effective pressure in bar
print "Mean effective pressure = %0.2f bar"%pm
```

In [12]:

```
from __future__ import division
# Initialisation of Variables
p1=1#.....................#Pressure in bar
t1=300#......................#Temperature in K
Q=1500#.....................#Heat added in kJ/kg
r=8#.......................#Compression ratio
Cv=0.72#....................#Specific heat at constant volume
ga=1.4#......................#Ratio of specific heats
#Calculations
t2=t1*(r)**(ga-1)#..........#Temperature after adiabatic compression in K
p2=p1*(r**ga)#..............#Pressure after adiabatic compression in bar
t3=(Q/Cv)+t2#.................#Temperature after isochoric compression in K
p3=(p2*t3)/t2#................#Pressure after isochoric compression in bar
t4=t3/(r**(ga-1))#.......................#Temperature after adiabatic expansion in K
p4=p3*(1/(r**(ga)))#................#Pressure after adiabatic expansion in bar
Ws=Cv*(t3-t2-t4+t1)#.........#Specific work in kJ/kg
etath=1-(1/(r**(ga-1)))#............#Thermal efficiency
print "Temperature after adiabatic compression = %0.2f K"%t2
print "Pressure after adiabatic compression = %0.2f bar"%p2
print "Temperature after isochoric compression = %0.2f K"%t3
print "Pressure after isochoric compression = %0.2f bar"%p3
print "Temperature after adiabatic expansion = %0.2f K"%t4
print "Pressure after adiabatic expansion = %0.2f bar"%p4
print "Specific work = %0.2f kJ/kg"%Ws
print "Thermal efficiency = %0.2f %%"%(etath*100)
```

In [13]:

```
from __future__ import division
# Initialisation of Variables
r=6#..............#Compression ratio
p1=1#................#Pressure after isochoric expansion in bar
t1=300#................#Temperature after isochoric expansion in K
t3=1842#...............#Temperature after isochoric compression in K
ga=1.4#...............#Ratio of specific heats
#Calculations
p2=p1*(r**ga)#...............#Pressure after adiabatic compression in bar
t2=t1*(r**(ga-1))#.............#Temperature after adiabatic compression in K
p3=p2*(t3/t2)#..................#pressure after isochoric compression in bar
t4=t3/(r**(ga-1))#..............#Temperature after adiabatic expansion in K
p4=p3*(1/(r**(ga)))#...........#Pressure after adiabatic expansion in bar
etaotto=1-(1/(r**(ga-1)))#............#Efficiency of otto cycle
p5=p1#
t5=((p5/p3)**((ga-1)/ga))*t3#................#Atkinson cycle temp after further adiabatic expansion in K
etatk=1-((ga*(t5-t1))/(t3-t2))#...........#Efficiency of atkinson cycle
print "Temperature after adiabatic compression = %0.2f K"%t2
print "Pressure after adiabatic compression = %0.2f bar"%p2
print "Temperature after isochoric compression = %0.2f K"%t3
print "Pressure after isochoric compression = %0.2f bar"%p3
print "Temperature after adiabatic expansion = %0.2f K"%t4
print "Pressure after adiabatic expansion = %0.2f bar"%p4
print "Thermal efficiency = %0.2f %%"%(etath*100)
```

In [1]:

```
from __future__ import division
# Initialisation of Variables
p1=1#...................#Initial pressure in bar
t1=343#..................#Initial temperature in K
p2=7#....................#Pressure after adiabatic compression
Qs=465#...............#Heat addition at constant volume in kJ/kg
cp=1#.....................#Specific heat at constant pressure in kJ/kg
cv=0.706#..................#Specific heat at constant volume in kJ/kg
ga=cp/cv#.................#Ratio of specific heats
#Calculations
r=(p2/p1)**(1/ga)#...............#Compression ratio
t2=t1*(r**(ga-1))#.....................#Temperature at the end of compression in K
t3=t2+(Qs/cv)#.............#Temperature at the end of heat addition in K
print "Compression ratio:",round(r,2)
print "Temperature at the end of compression = %0.2f K"%t2
print "Temperature at the end of heat addition = %0.2f K"%t3
```

In [2]:

```
from __future__ import division
# Initialisation of Variables
ga=1.4#..............#Ratio of specific heats
p2byp1=15#...............#Ratio pressure at the end of compression to that of pressure at the start
t1=311#................#Initial temperature in K
t3=2223#...............#Maximum temperature in K
R=0.287#...............#Gas constant in kJ/kg K
#Calculations
r=p2byp1**(1/ga)#...............#Compression ratio
etath=1-(1/(r**(ga-1)))#.............#Thermal efficiency
t2=t1*(r**(ga-1))#............#Temperature at the end of compression in K
t4=t3/(r**(ga-1))#...........#Temperature at the end of isothermal expansion in K
cv=R/(ga-1)#................#Specific heat at constant volume in kJ/kg
Q=cv*(t3-t2)#..............#Heat supplied in kJ/kg of air
Qr=cv*(t4-t1)#.................#Heat rejected in kJ/kg of air
W=Q-Qr#.................#Work done
print "Compression ratio:",round(r,2)
print "Thermal efficiency = %0.2f %%"%(etath*100)
print "Work done = %0.2f kJ"%W
```

In [3]:

```
from __future__ import division
# Initialisation of Variables
v1=0.45#.............#Initial volume in m**3
p1=1#...............#Initial pressure in bar
t1=303#.............#Initial temperature in K
p2=11#...................#Pressure at the end of compression stroke in bar
Q=210#...................#heat added at constant volume in kJ
N=210#.................#No of working cycles per min
ga=1.4#.............#Ratio of specific heats
R=287#.................#Gas constant in kJ/kgK
cv=0.71#.................#Specific heat at constant volume in kJ/kg
#Calculations
r=(p2/p1)**(1/ga)#...................#Compression ratio
t2=t1*(r**(ga-1))#...................#Temperature at the end of adiabatic compression
v2=(t2*p1*v1)/(t1*p2)#.................#Volume at the end of adiabatic compression in m**3
m=(p1*v1*10**5)/(R*t1)#................#Mass of engine fluid in kg
t3=(Q/(m*cv))+t2#...................#Temperature at the end of isochoric compression in K
p3=(t3/t2)*p2#................#Pressure at the end of isochoric compression in bar
v3=v2#
t4=t3*(1/r)**(ga-1)#...................#Temperature at the end of adiabatic expansion in K
p4=p3*(1/r)**ga#......................#Pressure at the end of adiabatic expansion in bar
v4=v1#
pc=(v2*100)/(v1-v2)#..................#Percentage clearence
etaotto=1-(1/(r**(ga-1)))#........................#Efficiency of otto cycle
Qr=m*cv*(t4-t1)#...............................#Heat rejected in kJ/kg
pm=((Q-Qr)*1000)/((v1-v2)*100000)#......#Mean effective pressure in bar
P=(Q-Qr)*(N/60)#........................#Power developed in kW
print "Temperature after adiabatic compression: %0.2f K\n"%(t2)
print "Pressure after adiabatic compression: %0.2f bar\n"%(p2)
print "Volume after adiabatic compression: %0.2f m**3\n"%(v2)
print "Temperature after isochoric compression: %0.2f K\n"%(t3)
print "Pressure after isochoric compression: %0.2f bar\n"%(p3)
print "Volume after isochoric compression: %0.2f m**3\n"%(v3)
print "Temperature after adiabatic expansion: %0.2f K\n"%(t4)
print "Pressure after adiabatic expansion: %0.2f bar\n"%(p4)
print "Volume after adiabatic expansion: %0.2f m**3\n"%(v4)
print "Percentage clearance: %0.2f\n"%(pc)
print "Efficiency of otto cycle: %0.2f\n"%(etaotto*100)
print "Mean effective pressure: %0.2f bar:\n"%(pm)
print "Power developed: %0.2f kW\n"%(P)
```

In [4]:

```
from __future__ import division
# Initialisation of Variables
t1=310#................#Min temperature in K
t3=1220#................#Max temperature in K
ga=1.4#................#Ratio of specific heats for air
cph=5.22#............#Specific heat at constant volume for helium in kJ/kg
cvh=3.13#...............#Specific heat at constant pressure for helium in kJ/kg
#Calculations
r=(t3/t1)**(1/((ga-1)*2))#..............#Compression ratio
etaotto=1-(1/(r**(ga-1)))#................#Air standard efficiency
gah=cph/cvh#................#Ratio of specific heats for Helium
rh=(t3/t1)**(1/((gah-1)*2))#..............#Compression ratio when Helium is used
etaottoh=1-(1/(rh**(gah-1)))#................#Air standard efficiency when Helium is used
print "Air standard efficiency of the engine = %0.2f %%"%(etaotto*100)
if ((round (etaotto)- round (etaottoh)) == 0):
print "There is no change in efficiency when Helium is used as working fluid instead of air"
```

In [5]:

```
from __future__ import division
from math import sqrt
# Initialisation of Variables
t1=310#.........#Minimum temperature in K
t3=1450#............#maximum temperature in K
m=0.38#...........#Mass of working fluid in kg
cv=0.71#...........#Specific heat at constant volume in kJ/kg
#Calculations
t4=sqrt(t1*t3)#............#Temperature at the end of adiabatic expansion in K
t2=t4#
W=cv*(t3-t2-t4+t1)#..................#Work done in kJ/kg
P=W*(m/60)#.................#Power developed in kW
print "Power developed = %0.2f kW"%P
```

In [6]:

```
from __future__ import division
# Initialisation of Variables
r=15#...................#Compression ratio
ga=1.4#..............#Ratio os fpecific heats for air
perQ=6#................#Heat addition at constant pressure takes place at 6% of stroke
#Calculations
rho=1+((perQ/100)*(r-1))#.............#Cut off ratio
etad=1-((((rho**ga)-1)/(rho-1))*(1/(ga*(r**(ga-1)))))#..................#Efficiency of diesel engine
print "Efficiency of diesel engine = %0.2f %%"%(etad*100)
```

In [7]:

```
from __future__ import division
from math import sqrt,pi
# Initialisation of Variables
L=0.25#...............#Engine stroke in m
D=0.15#..................#Engine bore in m
v2=0.0004#...............#Clearance volume in m**3
pers=5#...............#Percentage of stroke when fuel injection occurs
ga=1.4#..............#Ratio of specific heats
#Calculations
Vs=(pi/4)*D*D*L#..............#Swept volume in m**3
Vt=Vs+v2#....................#Total cylinder volume in m**3
v3=v2+((pers/100)*Vs)#..............#Volume at point of cut off
rho=v3/v2#............#Cut off ratio
r=1+(Vs/v2)#.............#Compression ratio
etad=1-((((rho**ga)-1)/(rho-1))*(1/(ga*(r**(ga-1)))))#..................#Efficiency of diesel engine
print "Efficiency of diesel engine = %0.2f %%"%(etad*100)
```

In [8]:

```
from __future__ import division
# Initialisation of Variables
r=14#....................#Compression ratio
pers1=5#...............#Percentage of stroke when fuel cut off occurs
pers2=8#...............#Percentage of stroke when delayed fuel cut off occurs
v2=1#.....................#Clearance volume in m**3
ga=1.4#..................#Ratio of specific heats
#Calculations
#When the fuel is cut off at 5 %
rho1=((pers1/100)*(r-1))+1#.............#Cut off ratio
etad1=1-((((rho1**ga)-1)/(rho1-1))*(1/(ga*(r**(ga-1)))))#..................#Efficiency of diesel engine
#When the fuel is cut off at 8 %
rho2=((pers2/100)*(r-1))+1#.............# Delayed Cut off ratio
etad2=1-((((rho2**ga)-1)/(rho2-1))*(1/(ga*(r**(ga-1)))))#..................#Efficiency of diesel engine when cut off ratio is deyaled
print "Percentage loss in efficiency due to delay in cut off : %0.2f"%((etad1-etad2)*100)
```

In [9]:

```
from __future__ import division
from scipy.optimize import fsolve
# Initialisation of Variables
pm=7.5#.................#Mean effective pressure in bar
r=12.5#..................#Compression ratio
p1=1#....................#Initial pressure in bar
ga=1.4#.................#Ratio of specific heats
#Calculations
k=(pm*(ga-1)*(r-1))/(p1*(r**ga))#
c1=(r**(1-ga))/k#
c2=(-ga)/k#
c=1+(ga/k)-((r**(1-ga))/k)#
def F(rho):
f=c1*(rho**ga)+c2*rho+c#
return f
#Initial guess
rho=2#
#Derivative
def D(rho):
z=c1*ga*(rho**(ga-1))+c2#
return z
y=fsolve(F,rho)
perc=((y-1)/(r-1))*100#..................#Percentage of cutoff
print "Cut off Percentage : %0.2f"%perc
```

In [1]:

```
from __future__ import division
from math import pi
# Initialisation of Variables
D=0.2#.................#Engine bore in m
L=0.3#.............#Engine stroke in m
p1=1#................#Initial pressure in bar
N=380#.................#No of working cycles per min
t1=300#..............#Initial temperature in K
co=8#................#Cut off percentage
r=15#..................#Compression ratio
R=287#.................#gas constant in J/kg
ga=1.4#................#Ratio of specific heats
#Calculations
Vs=(pi/4)*D*D*L#.............#Stroke volume in m
v1=(r/(r-1))*Vs#................#Volume at the end of isochoric compression in m**3
m=(p1*v1*10**5)/(R*t1)#................#Mass of air in cylinder in kg/cycle
p2=p1*(r**ga)#.......................#Pressure at the end of isentropic compression in bar
t2=t1*(r**(ga-1))#....................#Temperature at the end of isentropic compression in K
v2=Vs/(r-1)#..................#Volume at the end of isentropic compressionin m**3
p3=p2#
rho=((r-1)*(co/100))+1#................#Cut off ratio
v3=rho*v2#.......................#Volume at the end of isobaric expansion in m**3
t3=t2*(v3/v2)#..................#Temperature at the end of isobaric expansion in K
p4=((rho/r)**ga)*p3#..............#Pressure at the end of adiabatic expansion in bar
t4=((rho/r)**(ga-1))*t3#..............#Temperature at the end of adiabatic expansion in K
v4=v1#
print "Temperature after adiabatic compression: %f K\n"%(t2)
print "Pressure after adiabatic compression: %f bar\n"%(p2)
print "Volume after adiabatic compression: %f m**3\n"%(v2)
print "Temperature after isobaric compression: %f K\n"%(t3)
print "Pressure after isobaric compression: %f bar\n"%(p3)
print "Volume after isobaric compression: %f m**3\n"%(v3)
print "Temperature after adiabatic expansion: %f K\n"%(t4)
print "Pressure after adiabatic expansion: %f bar\n"%(p4)
print "Volume after adiabatic expansion: %f m**3\n"%(v4)
etad=1-((((rho**ga)-1)/(rho-1))*(1/(ga*(r**(ga-1)))))#..................#Efficiency of diesel engine
print "Efficiency of diesel engine = %0.2f %%"%(etad*100)
pm=p1*(r**ga)*(ga*(rho-1)-((r**(1-ga))*((rho**ga)-1)))*(1/(ga-1))*1/(r-1)#.......#Mean effective pressure
print "Mean effective pressure : %0.2f"%pm
Wdc=(pm*Vs*10**5)/1000#..................#Work done per cycle in kJ/cycle
P=(Wdc*N)/60#...........................#Power developed in kW
print "Power developed = %0.2f kW "%P
```

In [2]:

```
# Initialisation of Variables
rc=15.3#....................#Compression ratio
re=7.5#...................#Expansion ratio
cp=1.005#.................#Specific heat at constant pressure in kJ/kg K
cv=0.718#..................#Specific heat at constant volume in kJ/kgK
ga=1.4#....................#Ratio of specific heats
p1=1#....................#Initial pressure in bar
t1=300#..................#Initial temperature in K
etamech=0.8#..................#Mechanical efficiency
C=42000#...........................#Calorific value of fuel in kJ/kg
rita=0.5#.........................#Ratio of indicated thermal efficiency to air standard efficiency
R=287#..........................#Gas constant in kJ/kgK
#Calculations
t2=t1*(rc**(ga-1))#.................#Temperature at the end of adiabatic compression in K
p2=p1*(rc**ga)#...................#Pressure at the end of adiabatic compression in bar
t3=(rc*t2)/re#....................#Temperature at the end of constant pressure process in K
v2=1#..................#Volume at the end of adiabatic process in m**3
m=(p2*v2*10**5)/(R*t2)#..................#Mass of working fluid in kg
t4=t3*((1/re)**(ga-1))#...................#Temperature at the end of adiabatic expansion in K
W=(m*(cp*(t3-t2)))-(m*(cv*(t4-t1)))#........#Work done in kJ
pm=W/(rc-1)#..............................#Mean effective pressure in kN/m**2
print "Mean effective pressure = %0.2f bar "%(pm/100)
print "Ratio of maximum pressure to mean effective pressure %0.2f"%((p2*100)/(pm))
etacy=W/(m*cp*(t3-t2))#...............#Cycle efficiency
print "Cycle efficiency = %0.2f %%"%(etacy*100)
etaith=rita*etacy#..................#Indicated thermal efficiency
etabth=etaith*etamech#...............#Brake thermal efficiency
mf=3600/(etabth*C)#................#Fuel consumption per kWh
print "Fuel consumption = %0.2f kg/kWh"%mf
```

In [3]:

```
# Initialisation of Variables
Vs=0.0053#................#Swept volume in m**3
Vc=0.00035#...............#Clearance volume in m**3
v3=Vc#
v2=Vc#
p3=65#..................#Max pressure in bar
co=5#...................#Cut off percentage
p4=p3#ga=1.4#...............#Ratio of specific heats
t1=353#....................#Temperature at the start of compression in K
p1=0.9#...................#Pressure at the start of compression in bar
#Calculations
r=1+(Vs/Vc)#...................#Compression ratio
rho=(((co/100)*Vs)/Vc)+1#...................#Cut off ratio
p2=p1*(r**ga)#
Beta=p3/p2#.............................#Explosion ratio
etadual=1-((1/(r**(ga-1)))*((Beta*(rho**ga))-1)*(1/((Beta-1)+(Beta*ga*(rho-1)))))#............#Efficiency of dual cycle
print "Efficiency of dual cycle : %0.2f"%(etadual*100)
```

In [4]:

```
# Initialisation of Variables
r=14#......................#Compression ratio
Beta=1.4#................#Explosion ratio
co=6#..................#Cut off percentage
ga=1.4#.................#Ratio of specific heats
#Calculation
rho=((co/100)*(r-1))+1#...............#Cut off ratio
etadual=1-((1/(r**(ga-1)))*((Beta*(rho**ga))-1)*(1/((Beta-1)+(Beta*ga*(rho-1)))))#............#Efficiency of dual cycle
print "Efficiency of dual cycle : %0.2f"%(etadual*100)
```

In [5]:

```
from math import pi
# Initialisation of Variables
D=0.25#.................#Engine bore in m
L=0.3#.............#Engine stroke in m
p1=1#................#Initial pressure in bar
N=3#...............#No of cycles per second
p3=60#................#Maximum pressure in bar
t1=303#..............#Initial temperature in K
co=4#................#Cut off percentage
r=9#..................#Compression ratio
R=287#.................#gas constant in J/kg
cv=0.71#...............#Specific heat at constant volume in kJ/kgK
cp=1.0#.................#Specific heat at constant pressure in kJ/kgK
ga=1.4#...............#Ratio of specific heats
#Calculations
p4=p3#
Vs=(pi/4)*D*D*L#.............#Stroke volume in m**3
Vc=Vs/(r-1)#..................#Clearance volume in m**3
rho=((r-1)*(co/100))+1#................#Cut off ratio
v1=Vc+Vs#.................#Volume after isochoric compression in m**3
p2=p1*(r**ga)#................#Pressure after adiabatic compression in bar
t2=t1*(r**(ga-1))#..............#Temperature after adiabatic expansion in K
t3=(p3*t2)/p2#..............#Temperature after isochoric compression in K
t4=t3*rho#.....................#Temperature after isobaric expansion in K
t5=t4*((rho/r)**(ga-1))#.........#Temperature after adiabatic expansion in K
p5=p4*(rho/r)**ga#...............#Pressure after adiabatic expansion in bar
Qs=(cv*(t3-t2)+cp*(t4-t3))#.....#Heat supplied in kJ/kg
Qr=cv*(t5-t1)#...................#Heat rejected in kJ/kg
etast=1-(Qr/Qs)#.................#Air standard efficiency
print "Air standard efficiency = %0.2f %%"%(etast*100)
m=(p1*v1*10**5)/(R*t1)#...............#Mass of air in cycle
W=m*(Qs-Qr)#....................#Work done per cycle in kJ
P=W*N#............................#Power developed in kW
print "Power developed = %0.2f kW"%P
```

In [1]:

```
from __future__ import division
# Initialisation of Variables
p1=1#................#Initial pressure in bar
t1=363#.............#Initial temperature in K
r=9#.................#Compression ratio
p3=68#...............#Max pressure
p4=p3#
Qs=1750#..............#Total heat supplied
ga=1.4#...............#Ratio of specific heats
R=287#................#Gas constant in kJ/kgK
cv=0.71#..............#Specific heat at constant volume in kJ/kgK
cp=1#................#Specific heat at constant pressure in kJ/kgK
#Calculations
p2=p1*((r)**ga)#............#Pressure at the end of adiabatic compression in bar
t2=t1*((r)**(ga-1))#..........#Temperature at the end of adiabatic compression in K
t3=t2*(p3/p2)#............#Temperature at the end of isochoric compression in K
Qv=cv*(t3-t2)#.............#Heat added at constant volume in kJ/kg
Qp=Qs-Qv#.....................#Heat added at constant pressure in kJ/kg
t4=(Qp/cp)+t3#................#Temperature at the end of isobaric expansion in kJ/kg
rho=t4/t3#.....................#Cut off ratio
p5=p4*((rho/r)**ga)#................#Pressure at the end of adiabatic expansion in kJ/kg
t5=t4*((rho/r)**(ga-1))#...........#Temperature at the end of adiabatic expansion in kJ/kg
print "Temperature after adiabatic compression: %0.2f K\n"%(t2)
print "Pressure after adiabatic compression: %0.2f bar\n"%(p2)
print "Temperature after isochoric compression: %0.2f K\n"%(t3)
print "Pressure after isochoric compression: %0.2f bar\n"%(p3)
print "Temperature after isobaric expansion: %0.2f K\n"%(t4)
print "Pressure after isobaric expansion: %0.2f bar\n"%(p4)
print "Temperature after adiabatic expansion: %0.2f K\n"%(t5)
print "Pressure after adiabatic expansion: %0.2f bar\n"%(p5)
Qr=cv*(t5-t1)#....................#Heat rejected in kJ
etast=1-(Qr/Qs)#.................#Air standard efficiency
print "Air standard efficiency = %0.2f %%"%(etast*100)
pm=(1/(r-1))*((68*(rho-1))+(((p4*rho)-(p5*r))/(ga-1))-((p2-r)/(ga-1)))#................#Mean effective pressure in bar
print "Mean effective pressure = %0.2f bar"%pm
```

In [2]:

```
from __future__ import division
# Initialisation of Variables
t1=300#...............#Initial temperature
rmami=70#....................#Ratio of max pressure and min pressure
r=15#....................#Compression ratio
ga=1.4#.................#Ratio of specific heats
R=287#....................#Gas constant in kJ/kgK
t2=t1*(r**(ga-1))#.................#Temperature at the end of adiabatic compression in K
t3=t2*(rmami/(r**ga))#............#Temperature at the end of isochoric compression in K
t4=t3+((t3-t2)/ga)#..............#Temperature at the end of isobaric process in K
t5=t4/((1/(t4/(t3*r)))**(ga-1))#..........#Temperature at the end of adiabatic expansion in K
etast=1-((t5-t1)/((t3-t2)+ga*(t4-t3)))#..............#Air standard efficiency
print "Air standard efficiency = %0.2f %%"%(etast*100,)
```

In [3]:

```
from __future__ import division
# Initialisation of Variables
t1=373#.............#Initial temperature in K
p1=1#...............#Initial pressure in bar
p3=65#..............#Maximum pressure in bar
R=287#.................#Gas constant in kJ/kg
p4=p3#
ga=1.41#.................#Ratio of specific heats
Vs=0.0085#............#Swept volume in m**3
afr=21#...............#Air fuel ratio
r=15#.................#Compression ratio
C=43890#..............#Calorific value of fuel in kJ/kg
cp=1#................#Specific heat at constant pressure in kJ/kgK
cv=0.71#..............#Specific heat at constant volume in kJ/kgK
#Calculations
Vc=Vs/(r-1)#...............#Clearance volume in m**3
v2=Vc
v1=Vs+v2#
v3=Vc
v5=v1#
p2=p1*(r**ga)#.....................#Pressure at the end of adiabatic compression in bar
t2=t1*(r**(ga-1))#................#Temperature at the end of adiabatic compression in K
t3=(t2*p3)/p2#...................#Temperature at the end of isochoric compression in K
m=(p1*v1*10**5)/(R*t1)#............#Mass of air in the cycle in kg
Qv=m*cv*(t3-t2)#.....................#Heat added during constant volume process in kJ
fv=Qv/C#.............................#Fuel added during constant volume process in kg
mf=m/afr#..................#Total amount of fuel added in kg
mfib=mf-fv#....................#Total amount of fuel added in isobaric process in kg
Qib=mfib*C#....................#Total amount of heat added in isobaric process in kJ
t4=(Qib/((m+mf)*cp))+t3#........#Temperature at the end of isobaric process in K
v4=(v3*t4)/t3#..................#Volume at the end of isobaric process in m**3
t5=t4/((v5/v4)**(ga-1))#.........#Temperature at the end of isochoric expansion in K
Qrv=(m+mf)*cv*(t5-t1)#...............#Heat rejected during constant volume process in kJ
W=(Qib+Qv)-Qrv#................#Work done in kJ
etath=W/(Qib+Qv)#..................#Thermal efficiency
print "Thermal efficiency = %0.2f %%"%(etath*100)
```

In [4]:

```
from __future__ import division
from math import pi
# Initialisation of Variables
D=0.25#.............#Engine bore in m
L=0.4#..............#Engine stroke in m
t1=303#.............#Initial temperature in K
R=287#...............#Gas constant in kJ/kgK
p1=1#...............#Initial pressure in bar
N=8#................#No of working cycles per sec
cv=0.71#.............#Specific heat at constant volume in kJ/kgK
cp=1#.................#Specific heat at constant pressure in kJ/kgK
n=1.25#.............#Adiabatic index
rc=9#...............#Compression ratio
re=5#...............#Expansion ratio
rqptqe=2#...........#Ratio of heat liberated at constant pressure to heat liberated at constant volume
#Calculations
p2=p1*(rc**n)#.......................#Pressure at the end of adiabatic compression in bar
t2=t1*(rc**(n-1))#...................#Temperature at the end of adiabatic compression in K
rho=rc/re#..........................#Cut off ratio
t3=(2*cv*t2)/((2*cv)-(cp*(rho-1)))#...............#Temperature at the end of isochoric compression in K
p3=p2*(t3/t2)#....................................#Pressure at the end of isochoric compression in bar
p4=p3#t4=rho*t3#.................................#Temperature and pressure at the end of isobaric process
p5=p4*(1/(re**n))#.................................#Pressure at the end of adiabatic expansion in bar
t5=t4*(1/(re**(n-1)))#.............................#Temperature at the end of adiabatic expansion in K
pm=(1/(rc-1))*((p3*(rho-1))+(((p4*rho)-(p5*rc))/(n-1))-((p2-(p1*rc))/(n-1)))#...............#Mean effective pressure
print "Temperature after adiabatic compression: %0.2f K\n"%(t2)
print "Pressure after adiabatic compression: %0.2f bar\n"%(p2)
print "Temperature after isochoric compression: %0.2f K\n"%(t3)
print "Pressure after isochoric compression: %0.2f bar\n"%(p3)
print "Temperature after isobaric expansion: %0.2f K\n"%(t4)
print "Pressure after isobaric expansion: %0.2f bar\n"%(p4)
print "Temperature after adiabatic expansion: %0.2f K\n"%(t5)
print "Pressure after adiabatic expansion: %0.2f bar\n"%(p5)
print "Mean effective pressure = %0.2f bar"%pm
Vs=(pi/4)*D*D*L#....................#Swept volume in m**3
W=(pm*(10**5)*Vs)/1000#.................#Work done per cycle in kJ
m=(p1*(10**5)*(rc/(rc-1))*Vs)/(R*t1)#.....................#Mass of air per cycle in kg
Qs=m*(cv*(t3-t2)+cp*(t4-t3))#.....................#Heat supplied per cycle in kJ
eta=W/Qs#....................#Engine efficiency
print "Engine efficiency = %0.2f %%"%(eta*100)
P=W*N#.................#Power of the engine in kW
print "Power of the engine = %0.2f kW"%P
```

In [5]:

```
from __future__ import division
# Initialisation of Variables
cp=0.92#..................#Specific heat at constant pressure in kJ/kgK
cv=0.75#..................#Specific heat at constant volume in kJ/kgK
p1=1#...................#Pressure at the end of adiabatic expansion in bar
p2=p1#...................#Pressure at the end of isobaric compression in bar
p3=4#....................#Pressure at the end of isobaric compression in bar
p4=16#...................#Final pressure after heat addition in bar
t2=300#.....................#Temperature at the end of isobaric compression in K
ga=1.22#................#Ratio of specific heats
#Calculations
t3=t2*((p3/p2)**((ga-1)/ga))#............#Temperature at the end of isobaric compression in K
t4=(p4*t3)/p3#........................#Final temperature after heat addition in K
t1=t4/((p4/p1)**((ga-1)/ga))#...................#Temperature at the end of adiabatic compression in K
Qs=cv*(t4-t3)#.........................#Heat supplied in kJ/kg
Qr=cp*(t1-t2)#.........................#Heat rejected in kJ/kg
W=Qs-Qr#.......................#Work done per kg of gas in kJ
print "Work done = %0.2f kJ/kg"%W
eta=W/Qs#......................#Efficiency of cycle
print "Efficiency of cycle = %0.2f %%"%(eta*100)
```

In [6]:

```
from __future__ import division
# Initialisation of Variables
p1=101.325#....................#Pressure of intake air in kPa
t1=300#.......................#Temperature of intake air in kPa
rp=6#.........................#Pressure ratio in the cycle
ga=1.4#.........................#Ratio of specific heats
rtc=2.5#...........................#Ratio of turbine work and compressor work
#Calculations
t2=t1*(rp**((ga-1)/ga))#..................#Temperature at the end of isentropic expansion in K
t3=(rtc*(t2-t1))/(1-(1/(rp**((ga-1)/ga))))#........#Temperature at the end of isobaric expansion in K
t4=t3/(rp**((ga-1)/ga))#.......................#Temperature at the end of isentropic compression in K
eta=(t3-t4-t2+t1)/(t3-t2)#...................#Cycle efficiency
print "Cycle efficiency = %0.2f %%"%(eta*100)
```

In [7]:

```
from __future__ import division
# Initialisation of Variables
p1=1#....................#Intake pressure in bar
p2=5#....................#Supply pressure in bar
t3=1000#..................#Supply temperature in Kelvin
cp=1.0425#................#Specific heat at constant pressure in kJ/kgK
cv=0.7662#.................#Specific heat at constant volume in kJ/kgK
ga=cp/cv#..................#Ratio of specific heats
#Calculations
t4=t3*((p1/p2)**((ga-1)/ga))#
P=cp*(t3-t4)#.....................#Power developed per kg of gas per second in kW
print "Power developed per kg of gas per second = %0.2f kW "%P
```

In [8]:

```
from __future__ import division
# Initialisation of Variables
ma=0.1#...................#Air supplied in kg/s
p1=1#.....................#Supply pressure in bar
t4=285#.................#Temperature of air when supplied to cabin in K
p2=4#...................#Pressure at inlet to turbine in bar
cp=1.0#..................#Specific heat at constant pressure in kJ/kgK
ga=1.4#..................#Ratio of specific heats
#Calculations
t3=t4*((p2/p1)**((ga-1)/ga))#................#Temperature at turbine inlet in K
print "Temperature at turbine inlet = %0.2f K"%t3
P=ma*cp*(t3-t4)#...........................#Power developed in kW
print "Power developed = %0.2f kW"%P
```

In [9]:

```
from __future__ import division
# Initialisation of Variables
p1=1#......................#Pressure of air entering the compressor in bar
p2=3.5#.................#Pressure of air while leaving the compressor in bar
t1=293#..................#Temperature of air at the onlet of the compressor in K
t3=873#.................#Temperature of air at the turbine inlet in K
cp=1.005#...............#Specific heat at constant pressure in kJ/kgK
ga=1.4#...................#Ratio of specific heats
#Calculations
rp=p2/p1#....................#Pressure ratio of the cycle
eta=1-(1/(rp**((ga-1)/ga)))#..............#Efficiency of the cycle
print "Efficiency of the cycle : %0.2f"%(eta*100)
t2=t1*((rp**((ga-1)/ga)))#................#Temperature of air while leaving the compressor in K
q1=cp*(t3-t2)#................#Heat supplied to the air in kJ/kg
print "Heat supplied to the air = %0.2f kJ/kg "%(q1)
W=eta*q1#........................#Work available at the shaft in kJ/kg
print "Work available at the shaft = %0.2f kJ/kg "%W
q2=q1-W#................#Heat rejected in the cooler in kJ/kg
print "Heat rejected in the cooler = %0.2f kJ/kg "%q2
t4=t3/(rp**((ga-1)/ga))#.......................#Temperature of air leaving the turbine in K
print "Temperature of air leaving the turbine = %0.2f K "%t4
```

In [10]:

```
from __future__ import division
# Initialisation of Variables
p1=1#...................#Pressure of air entering the compressor in bar
t1=300#.................#Temperature of air entering the compressor in bar
rp=6#...................#Pressure ratio
rtc=2.5#.................#Ratio of turbine work to compressor work
ga=1.4#............#Ratio of specific heats
#calculations
t2=t1*(rp**((ga-1)/ga))#..................#Temperature at the end of isentropic expansion in K
t3=(rtc*(t2-t1))/(1-(1/(rp**((ga-1)/ga))))#........#Temperature at the end of isobaric expansion in K
t4=t3/(rp**((ga-1)/ga))#.......................#Temperature at the end of isentropic compression in K
eta=(t3-t4-t2+t1)/(t3-t2)#...................#Cycle efficiency
print "Maximum temperature = %0.2f K "%t3
print "Cycle efficiency = %0.2f %%"%(eta*100)
```

In [11]:

```
from __future__ import division
from math import sqrt
# Initialisation of Variables
t1=303#........................#Min temperature in K
t3=1073#........................#Max temperature in K
C=45000#.....................#Calorific value of fuel in kJ/kg
cp=1#....................#Specific heat at constant pressure in kJ/kgK
ga=1.4#........................#Ratio os specific heats
diftc=100#..................#Difference between work done by turbine and compressor in kW
#Calculations
t2=sqrt(t1*t3)# t4 = t2#.....#Assumed
mf=diftc/(C*(1-((t4-t1)/(t3-t2))))#................#Fuel used in kg per second
print "Rate of fuel consumption = %0.2f kg/s "%mf
ma=(diftc-(mf*(t3-t4)))/((t3-t4-cp*(t2-t1)))#............#Rate of air consumption in kg/s
print "Mass flow rate of air = %0.2f kg/s "%(ma)
```

In [12]:

```
from __future__ import division
# Initialisation of Variables
t1=300#.................#Inlet temperature in K
p1=1#....................#Inlet pressure in bar
ma=1#....................#Mass of air in kg
rp=6.25#.............#Pressure ratio
t3=1073#.....#Maximum temperature in K
etac=0.8#............#Efficiency of compressor
etat=0.8#.............#Efficiency of turbine
ga=1.4#.................#Ratio of specific heats
cp=1.005#.............#Specific heat at constant pressure in kJ/kgK
#Calculations
t2=t1*(rp**((ga-1)/ga))#...........#Ideal Temperature of air while leaviing the compressor in K
t21=((t2-t1)/etac)+t1#............#Actual Temperature of air while leaviing the compressor in K
Wcomp=ma*cp*(t21-t1)#.............#Compressor work in kJ/kg
t4=t3/(rp**((ga-1)/ga))#........#Ideal temperature of air while leaving the turbine in K
t41=t3-(etat*(t3-t4))#..........#Actual temperature of air while leaving the turbine in K
Wtur=ma*cp*(t3-t41)#..............#Turbine work in kJ/kg
Wnet=Wtur-Wcomp#.................#Net work produced in kJ/kg
Qs=ma*cp*(t3-t21)#.................#Heat supplied in kJ/kg
print "Compressor work = %0.2f kJ/kg "%(Wcomp)
print "Turbine work = %0.2f kJ/kg "%Wtur
print "Heat supplied = %0.2f kJ/kg "%Qs
print "Cycle efficiency = %0.2f %%"%((Wnet/Qs)*100)
print "Actual exhaust temperature of turbine = %0.2f K"%t41
```

In [13]:

```
# Initialisation of Variables
etat=0.85#..............#Turbine efficiency
etac=0.8#...............#Compressor efficiency
t3=1148#................#Max temperature in K
t1=300#................#Temperature of working fluid when entering the compressor in Kelvin
cp=1#...................#specific heat at constant pressure in kJ/kgK
ga=1.4#................#ratio of specific heats
p1=1#...................#Pressure of working fluid while entering the compressor in bar
rp=4#...................#Pressure ratio
C=42000#...............#Calorific value of fuel used in kJ/kgK
perlcc=10#.............#Percentage loss of calorific value in combustion chamber
#calculations
p2=p1*rp#.................#pressure of air while leaving the compressor in bar
etacc=1-(perlcc/100)#............#efficiency of combustion chamber
t2=t1*(rp**((ga-1)/ga))#...........#Ideal Temperature of air while leaviing the compressor in K
t21=((t2-t1)/etac)+t1#............#Actual Temperature of air while leaviing the compressor in K
afr=((C*etacc)/(cp*(t3-t21)))-1#...........#Air fuel ratio
print "Air fuel ratio is %d:1"%round(afr)
```

In [14]:

```
from math import log
# Initialisation of Variables
p1=1#...........#pressure before isothermal compression in bar
t1=310#.........#temperature before isothermal compression in K
p3=16#.........#pressure before isothermal expansion in bar
t3=930#.........#temperature before isothermal expansion in K
R=287#.............#Gas constant in kJ/kgK
#Calculations
v1=(R*t1)/(p1*10**5)#...............#Volume before isothermal compression in m**3
v3=(R*t3)/(p3*10**5)#...............#Volume before isothermal expansion in m**3
v2=v3#v4=v1#.................#2-3 and 1-4 are isochoric processes
r=v1/v2#...................#Compression ratio
q12=R*t1*log(r)#...............#Work done and heat rejected in process 1-2
w12=q12#
print "Work done in process 1-2 = %0.2f kJ/kg "%(q12/1000)
print "Heat rejected in process 1-2 = %0.2f kJ/kg "%(w12/1000)
q23=0#w23=q23#..................#COnstant volume process and hence work done is zero
print "Work done in process 2-3 = %0.2f kJ/kg "%(q23/1000)
print "Heat rejected in process 2-3 = %0.2f kJ/kg "%(q23/1000)
q34=R*t3*log(r)#...............#Work done and heat rejected in process 1-2
w34=q34#
print "Work done in process 3-4 = %0.2f kJ/kg "%(q34/1000)
print "Heat rejected in process 3-4 = %0.2f kJ/kg"%(w34/1000)
q41=q34-q12
w41=q41#
print "Work done in process 4-1 = %0.2f kJ/kg "%(q41/1000)
print "Heat rejected in process 4-1 = %0.2f kJ/kg "%(w41/1000)
etath=w41/q34#.....................#Thermal efficiency
print "Thermal efficiency of the cycle = %0.2f %%"%(etath*100)
```