Challenge

Week 2 Air standard Cycle

Aim: To plot the P-V diagram and determine the thermal efficiency of Air standard Cycle.
Objective: i) Write a program to plot the air standard processes in P-V diagram.
	          ii) To determine the thermal efficiency of Air standard cycle.
Procedure:
1)	   Air standard cycle consists of four main processes
i)	Isentropic compression(1-2).
ii)	Constant volume heat addition, Intake(2-3)
iii)	Isentropic expansion(3-4)
iv)	Constant volume heat rejection, Exhaust(4-1)
2)	Input conditions:
Bore = 0.1 m
Stroke = 0.1 m
Connecting rod length = 0.15 m
Compression ratio(cr) = 10
Pressure at point 1 = 101325 Pa
Temperature at point 1 = 300 K
Gamma =1.4
Temperature at point 3 = 2300 K
3)	Swept volume and clearance volume are calculated using the formula
V_s = (pi)/4*Bore2*Stroke           (Swept Volume)
V_c = V_s/(cr-1)                             (Clearance Volume)
4)	Volume at point 1 is the sum of Swept Volume and Clearance Volume			    
V1 = v_s + v_c
5)	Volume at state point 2 is the clearance volume.
V2 = v_c
6)	 Pressure at point 2 is calculated using the isentropic gas law equation pv^gamma = constant
p2 = p1*pow(v1,gamma)/pow(v2,gamma)
7)	Temperature at state point 2 is calculated using ideal gas law equation. Pv/T = constant
  	
  #p2v2/t2 = p1v1/t1  | RHS = p1v1/t1| p2v2/t2 = RHS| t2 = p2v2/RHS
     rhs = p1*v1/t1
     t2 = p2*v2/rhs
8)	At state point 3, v3=v2
9)	Pressure at point 3 is calculated using ideal gas law equation.
   #p3v3/t3 = p2v2/t2  | RHS = p2v2/t2| p3 = RHS*t3/v3
    rhs = p2*v2/t2
    p3 = rhs*t3/v3
10)	At state point 4, v4 = v1
11)	Pressure at point 4 is calculated using isentropic gas law equation and temperature at point 4 is calculated using ideal gas law equation.
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
t4 = p4*v4/rhs
12)	If we plot the above equations, we get the linear relation between all the processes. But in practical application, the process 1-2 and 3-4 are isentropic in nature.
13)	So these processes are defined by the isentropic gas law equation pv^gamma = constant.
14)	To plot the above processes we need to calculate the Total volume which is given by the formula
V = Vc + Vs/2*(cr-1)*[R+1-cos(theta)-(R2  - sin2(theta)0.5]
15)	This equation is used to calculate the compression and expansion volume. For compression crank angle starts at 180 degrees and ends at 0 degrees. For expansion, the crank angle starts at 0 degrees and ends at 180 degrees.
16)	To calculate the above equation in python, we need to define a function.
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
17)	R= con_rod/a, R is constant which is the ratio of connecting rod to the crank pin radius.
18)	The empty volume array is created, and the volume which is calculated using above equation is appended into this volume array for n no. of values specified.
The code is given as below.
     sc = math.radians(start_crank)
    ec = math.radians(end_crank)    
    
    num_values = 100     # no. of values for which total volume is calculated
    dtheta = (ec-sc)/(num_values-1)   # crank angle spacing
    
    V = []
    
    for i in range(0,num_values):
      
        theta = sc + i*dtheta
        
        term1 = 0.5*(cr-1)
        term2 = R + 1-math.cos(theta)
        term3 = pow(R,2) - pow(math.sin(theta),2)
        term3 = pow(term3,0.5)
        V.append((1 + term1*(term2-term3))*V_c)
    return V
19)	To obtain V_compreesion, function is written as,
V_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
20)	To obtain V_expansion, function is written as,
V_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
21)	Similarly P_Compression and P_ expansion can be generated by creating an empty array and appending the value of pressure using isentropic gas law equation.
i)	constant = p1*pow(v1,gamma)
    
P_compression = []
    
for v in V_compression:
      	P_compression.append(constant/pow(v, gamma))
ii)	constant = p3*pow(v3,gamma)
P_expansion = []
for v in V_expansion:
        P_expansion.append(constant/pow(v, gamma))
22)	Finally the thermal efficiency of Air standard cycle is calculated using formula,
n = (1-(1/pow(cr,gamma-1)))*100

Python code:
import math
import matplotlib.pyplot as plt

bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 10

def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
  
    a= stroke/2       # Crank pin radius
    R= con_rod/a      # Ratio of connecting rod by crank pin radius
    V_s = math.pi*(1/4)*pow(bore,2)*stroke
    V_c = V_s/(cr-1)
    
    sc = math.radians(start_crank)
    ec = math.radians(end_crank)    
    

    num_values = 100     # no. of values for which total volume is calculated
    dtheta = (ec-sc)/(num_values-1)   # crank angle spacing
   
    V = []
    
    for i in range(0,num_values):
        theta = sc + i*dtheta
       term1 = 0.5*(cr-1)
        term2 = R + 1-math.cos(theta)
        term3 = pow(R,2) - pow(math.sin(theta),2)
        term3 = pow(term3,0.5)
        V.append((1 + term1*(term2-term3))*V_c)
    return V
# Inputs
p1 = 101325
t1 = 500
gamma = 1.4
t3 = 2300
 # Volume Computation
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr - 1)
v1 = v_c + v_s
# State point 2
v2 = v_c
# p2v2^gamma=p1v1^gamma
    
p2 = p1*pow(v1,gamma)/pow(v2,gamma)

    
#p2v2/t2 = p1v1/t1  | RHS = p1v1/t1| p2v2/t2 = RHS| t2 = p2v2/RHS
 
rhs = p1*v1/t1
t2 = (p2*v2)/rhs
V_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant = p1*pow(v1,gamma)
    
P_compression = []
    
for v in V_compression:
      P_compression.append(constant/pow(v, gamma))
        
# State point 3
    
v3 = v2
    
    #p3v3/t3 = p2v2/t2  | RHS = p2v2/t2| p3 = RHS*t3/v3
    
rhs = p2*v2/t2
p3 = rhs*t3/v3
V_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
constant = p3*pow(v3,gamma)
P_expansion = []
    

for v in V_expansion:
        P_expansion.append(constant/pow(v, gamma))
     
# State point 4
v4 = v1
    
# p4v4^gamma = p3v3^gamma

p4 = p3*pow(v3,gamma)/pow(v4,gamma)

    #p4v4/t4=p3v3/t3  | rhs = p3v3/t3  | t4 = p4v4/rhs
    

t4 = p4*v4/rhs
    
    
    # Thermal efficiency of an otto cycle
    
n = (1-(1/pow(cr,gamma-1)))*100
print('Thermal efficiency of Otto cycle =',n, '%')
    
    # Plotting the otto cycle
plt.plot(V_compression,P_compression, label ='Compression stroke')
plt.plot([v2,v3],[p2,p3], label = 'Constant volume Heat Addition,Intake')
plt.plot(V_expansion,P_expansion, label = 'Expansion stroke')
plt.plot([v4,v1],[p4,p1], label = 'Constant volume heat rejection, Exhaust')
plt.xlabel('Volume')
plt.ylabel('Pressure')
plt.title('Air Standard Otto Cycle',fontweight = 'bold')
plt.legend()
plt.show()	




Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.