Week 2 Air standard Cycle
Aim: To plot p-V diagram of Otto cycle and to calculate its thermal efficiency and air standard efficiency using Python code
Theory:
Otto cycle is an air standard cycle used to model the thermodynamics performance of petrol engine. It is ideal cycle which predicts the thermodynamic performance of petrol engine. It consists of four processes.
- Reversible adiabatic compression
- Constant volume heat addition
- Reversible adiabatic expansion
- Constant volume heat rejection
Assumptions made in Otto cycle
- Air is working substance with constant specific heats and air is a calorically perfect gas.
- All processes are internally reversible.
- Combustion takes place by heat addition from external source.
- Exhaust from engine is modelled by rejecting heat at constant volume, which brings back air to its initial state.
Thermal efficiency of Otto cycle is given by,
`η = 1 − 1/r^( γ − 1 )`
Python code
# To plot P-v diagram of otto cycle and to calculate efficieny (thermal and air-std) using Python code.
import math
import matplotlib.pyplot as plt
# Function code to calculate variation of volume as a function of crank angle theta
def engine_kinematics (bore,stroke,connecting_rod, c_r,start_crank_angle, end_crank_angle) :
# Engine geometry properties
r = stroke/2
n = connecting_rod/r
# Volume parameters
v_swept = (math.pi/4)*pow(bore,2)*stroke
v_clearance = v_swept/(c_r -1)
theta_startcrank=math.radians(start_crank_angle)
theta_endcrank=math.radians(end_crank_angle)
num_val = 100
dtheta = (theta_endcrank - theta_startcrank)/(num_val - 1)
v = []
for i in range(0,num_val):
theta = theta_startcrank + i*dtheta
term_1 = 0.5*(c_r - 1)
term_2 = n + 1 - math.cos(theta)
term_3 = (pow(n,2)- pow(math.sin(theta),2))
term_3 = pow(term_3,0.5)
v.append((1 + term_1* (term_2 -term_3))*v_clearance)
return v
# Main code
# Inputs varibale
gamma = 1.4 # for air gamma= 1.4
T3 = 2000 # max temp inside engine cylinder
# State variables at inlet to engine
# ambient atmospheric conditions assumed
p1 = 101325
T1 = 350
# Engine geometric parameters
bore = 0.15
stroke = 0.2
connecting_rod = 0.8
c_r = 10
# Calculating swept volume and clearance volume
v_swept = (math.pi/4)*pow(bore,2)*stroke
v_clearance = v_swept/(c_r -1)
v1=v_swept + v_clearance
v2 = v_clearance
# state variables at state point 2
# p2*v2^gamma = pl*v1^hgamma (Isentropic compression)
p2 = p1* pow(c_r,gamma)
# (p1*v1)/T1 = (p2*v2)/T2
# T2=p2*v2*T1/(p1*v1)
T2=p2*v2*T1/(p1*v1)
# To find variation of volume during compression stroke as a function of crank angle theta
V_comp = engine_kinematics (bore,stroke,connecting_rod, c_r,180,0)
C_const = p1*pow(v1,gamma)
P_comp = []
for v in V_comp:
P_comp.append(C_const/pow(v,gamma))
# State variables at state point 3
v3 = v2 #Isochoric process
#(p3*v3)/T3=(p2*v2)/T2
# p3=p2*T3/(T2)
p3=p2*T3/(T2)
# To find variation of volume during expansion stroke as a function of crank angle theta
V_expp = engine_kinematics (bore,stroke,connecting_rod, c_r,0,180)
C_const = p3*pow(v3,gamma)
P_expp = []
for v in V_expp:
P_expp.append(C_const/pow(v,gamma))
# state variables at state point 4
v4 = v1 # Isochoric process
# p3*v3^gamma = p4*v4^gamma
p4 = p3*pow(v3,gamma)/pow(v4,gamma) # Isentropic expan sion process
# (p3*v3)/T3 = (p4*v4)/T4
# T4 = p4*v4*T3/(p3*v3)
T4 = p4*v4*T3/(p3*v3)
# Plotting of results
plt.plot(V_comp,P_comp, label = 'Isentropic compression')
plt.plot([v2,v3],[p2,p3],label = 'Constant volume heat addition')
plt.plot(V_expp,P_expp, label = 'Isentropic expansion')
plt.plot([v4,v1],[p4,p1], label = 'Constant volume heat rejection')
plt.legend()
plt.ylim ((-500000,8000000))
plt.xlim((0,0.005))
plt.xlabel('Volume (m^3)')
plt.ylabel('Pressure(Pa)')
plt.title('p-V diagram of an Otto Cycle')
plt.text(0.00385,-250000,r'$ 1 $')
plt.text(0.0002,2000000,r'$ 2 $')
plt.text(0.0002,5850000,r'$ 3 $')
plt.text(0.00385,400000,r'$ 4 $')
plt.grid()
plt.show()
#Calculating Air standard efficiency
Air_std_efficincy = 1- (1/pow((c_r),(gamma-1)))
print('Air standard efficiency of given Otto Cycle is :',Air_std_efficincy)
# To calculate thermal efficiency of engine using 2nd law of Thermodynamics
heat_added = 0.718*(T3-T2)
heat_rejected = 0.718*(T4-T1)
work_done = heat_added-heat_rejected
thermal_efficincy = work_done/heat_added
print('Thermal efficiency of given Otto Cycle is :',thermal_efficincy)
Results:

Figure: p-V diagram for auto cycle
Results for efficiency

Conclusion:
Using Python code, pressure and temperature values are calculated at all state points with known pressure and temperature at starting of compression and maximum temperature in the cycle.
Also, thermal efficiency of Otto cycle and air-standard efficieny is calculated. In both the cases efficiency is same. It shows that MATLAB code is working correctly.