Week 2 Air standard Cycle
Aim: To write a program in python to calculate thermal efficiency and PV diagram of otto cycle
Equation used to solve thermal efficiency and otto cycle and volume relationship:`v/v_c =1+1/2*(r_c-1)*[R+1-cosθ-〖(R^2-〖sinθ〗^2)]〗^(1/2)`
`ηthermal=1-1/〖cr〗^(Υ-1)`
Introduction:
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines.
Ratio of power output to that of energy supplied by the fuel is known as thermal efficiency.
The Otto cycle consists of isentropic compression, heat addition at constant volume, isentropic expansion, and rejection of heat at constant volume which are represented in PV diagram.
Objectives:
- To find the thermal efficiency of otto cycle
- To plot the P-V diagram of otto cycle
Solution procedure:
Code to plot PV diagram
import math
import matplotlib.pyplot as plt
import numpy as np
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank): # defining function
a=stroke/2
R=con_rod/a
sc= math.radians(start_crank) # starting crank angle
ec=math.radians(end_crank) # ending crank angle
num_value=50 # number of divisions to be made
dtheta=(ec-sc)/(num_value-1) # interval values
v=[] # Empty array for storing volume values
for i in range (0,num_value): # for loop for
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))*v2) # appending the value of v for i values
return v # returning value of v to array
# Geometric specifications
bore=0.16# bore diameter in m
stroke= 0.2# stroke length in m
con_rod=0.25 # length of connecting rod in m
cr=12 # compression ratio
# volume parameters
v_s=math.pi*(1/4)* pow(bore,2)* stroke # v_s
v2=v_s/(cr-1) # v_c
v1=v2+v_s
gama=1.4
# Input thermal parameters
p1= 101325 # inlet pressure in pascal
t1=500 # temperature at inlet
t3=3000 # peak temperature
# parameters at state point 2
p2=(p1*pow(v1,gama))/(pow(v2,gama))
t2=(t1/pow((v2/v1),gama-1))
v_compression=engine_kinematics(bore,stroke,con_rod,cr,180,0) # function values during compression
constant=p1*pow(v1,gama)
p_compression=[]
for v in v_compression:
p_compression.append(constant/pow(v,gama))
# parameters at state point 3
v3=v2
p3=(p2*t3)/t2
v_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180) # function values during expansion
constant=p3*pow(v3,gama)
p_expansion=[] # array for storing p expansion values
for v in v_expansion:
p_expansion.append(constant/pow(v,gama))
# state point 4
v4=v1
t4=((t3)/pow((v4/v3),gama-1))
p4=((p3)/pow((t3/t4),3.5))
# plotting of PV diagram
plt.plot((v_compression),(p_compression))
plt.plot((v2,v3),(p2,p3))
plt.plot((v_expansion),(p_expansion))
plt.plot((v4,v1),(p4,p1))
plt.legend(['ad_compression','cv_heat addition','ad_expansion','cv_heat regection'])
plt.xlabel('volume')
plt.ylabel("pressure")
plt.title("Pressure volume diagram ")
plt.savefig("Pressure volume diagram")
plt.show()
Code to calculate thermal efficiency
Th_efficiency=1-((1)/pow(cr,gama-1))
print(Th_efficiency)