Challenge

Week 2 Air standard Cycle

OBJECTIVE - To write a code for PV diagram of an Otto cycle and calculate thermal efficiency

PROCEDURE –

ASSUMPTIONS

  • Initially state variables p1,t1,t3 and gamma are assumed.
  • Necessary Engine geometric parameters are also assumed.

#program for plotting PV diagram of Otto Cycle

import math
import matplotlib.pyplot as plt

def engine_kinematics(Bore,Stroke,Con_Rod,Cr,Start_crank,End_crank):

#Geometric parameters
a=Stroke/2 #crank pin radius
R=Con_Rod/a #constant

#Volume computation
V_s=(math.pi/4)*pow(Bore,2)*Stroke #Swept volume
V_c=V_s/(Cr-1) #Clearance volume

sc=math.radians(Start_crank)
ec=math.radians(End_crank)

num_valunes=50

dtheta=(ec-sc)/(num_valunes-1)

V=[]

for i in range(0,num_valunes):
theta=sc+i*dtheta

#V/Vc=1+0.5(Cr-1)[R+1-cos(theta)-(R^2-sin^2(theta))^0.5]
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

#inputing intial values

P1=0.1 #pressure at state-1
t1=500 #temperature at state-1
gamma=1.4
t3=2300

#Geometric parameters values
Bore=0.1
Stroke=0.1
Con_Rod=0.15
Cr=12
V_s=(math.pi/4)*pow(Bore,2)*Stroke #Swept volume
V_c=V_s/(Cr-1) #Clearance volume
V1=V_c+V_s

#at state point-2
V2=V_c

#P2V2^gamma=P1V1^gamma
P2=P1*pow(V1,gamma)/pow(V2,gamma)

#P2V2/t2=P1V1/t1
#P1V1/t1=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))

#at state-3
V3=V2
#P3V3/t3=P2V2/t2
#P2V2/t2=rhs
rhs=P2*V2/t2
P3=rhs*t3/V3

V_expansion=engine_kinematics(Bore,Stroke,Con_Rod,Cr,180,0)
constant=P3*pow(V3,gamma)
P_expansion=[]

for V in V_compression:
P_expansion.append(constant/pow(V,gamma))


#at state-4
V4=V1
#P4V4^gamma=P3V3^gamma
P4=P3*pow(V3,gamma)/pow(V4,gamma)
t4=P4*V4/rhs

#thermal efficiency of otto cycle
Th_eff=(1-((t4-t1)/(t3-t2)))*100
print(Th_eff)

#plotting PV diagr)
plt.plot([V2,V3],[P2,P3])
plt.plot(V_compression,P_compression)
plt.plot(V_expansion,P_expansion)
plt.plot([V4,V1],[P4,P1])
plt.xlabel('Volume')
plt.ylabel('pressure')
plt.title('Otto cycle')
plt.savefig('PV Diagram')
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.