Week 2 Air standard Cycle
Aim- Write a code that shows an otto cycle and make plots of pressure-volume with scripting the piston kinematics function.
Theory- An Ic engine is an internal combustion engine in which combustion takes place inside the cylinder which converts the chemical energy of fuel into mechanical energy. chemical energy first converted into heat energy and that helps in movement of piston. There are many types of ic engine but mainly there are two types petrol engine and diesel engine.
There are four steps in which an engine works - 1) suction - air or air fuel mixture comes inside the cylinder. 2) compression - air or air fuel mixture compressed by the piston , 3) Expansion- fuel burnt and power is taken ,this stroke is also known as power stroke. 4) Expansion - the burnt gases are carried out by opening of exhaust valve.
For functioning these cycle well the process is analyzed by means of air standard cycle, certain assumptions are taken place for these anaysis of engine. Air standard cycle is used to estimate the engine performance.
Otto cycle- It is the thermodynamic cycle that describes the function of petrol engine or spark ignition engine.
It is known as constant volume cycle.
Mathematical equations or formulas-
- P*V^gamma = constant
- from this equation and pv=nrt equation , we get
- 1) p2/p1 = (v1/v2)^gamma , 2) t2/t1 = (v1/v2)^(gamma-1) , 3)(p2/p1)^(1/gamma) = (t2/t1)^(1/gamma-1)
where, P is pressure , v is volume , gamma is adiabatic index ( constant ) ,
Some engine paramters are also used which are shown in python code.
import numpy as np
import matplotlib.pyplot as plt
import cmath
import math
def engine_kinematics(bore, stroke, con_rod, cr, 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
# Input parameters of engine
gamma = 1.4 #for air
T3 = 2000 # max. temp.
# parameters at inlet to engine, ambient conditions are assuemed
P1 = 101325
T1 = 500
# Engine geometry parameters
bore = 0.15
stroke = 0.2
connecting_rod = 0.15
c_r = 12
# calculating swept volume and clearance volume
V_swept = (cmath.pi/4)*np.power(bore,2)*stroke
V_clearance = V_swept/(c_r - 1)
V1 = V_swept + V_clearance
V2 = V_clearance
# calculation of P2 and T2
P2 = P1*np.power(c_r,gamma)
#print(P2)
# from this equation- (P1*V1)/T1 = (P2*V2)/T2
T2 = P2*V2*T1/(P1*V1)
# To find the variation of volume during the 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 = []
print(V_comp)
for V in V_comp :
P_comp.append(C_const/pow(V,gamma))
print(P_comp)
# calculation of P3 and V3
# (PV/T) = constant , for process 2 to 3 V2 = V3.
P3 = P2*(T2/T3)
V3 = V2
# To find the 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 = []
#print(V_expp)
for V in V_expp:
P_expp.append(C_const/pow(V,gamma))
#print(P_expp)
# calculation of P4, V4 and T4
#P3*V3^gamma = P4*V4^gamma
V4 = V1
P4 = P3*np.power(V3,gamma)/np.power(V4,gamma) # Isentropic expansion
# plotting
plt.plot([V1,V2,V3,V4,V1],[P1,P2,P3,P4,P1])
plt.xlabel('volume(V)')
plt.ylabel('pressure(P)')
plt.title('P-V diagram of an otto cycle',fontweight='bold')
plt.grid()
plt.show()
#plotting
plt.plot(V_comp,P_comp)
plt.plot(V_expp,P_expp)
plt.plot([V2,V3],[P2,P3])
plt.plot([V4,V1],[P4,P1])
plt.grid()
plt.show()
P-V plots - 
