Calculation of Thermal Efficiency of a engine and plotting of Otto cycle in PYTHON programming
Aim:-
To plot the Otto cycle and calculate the thermal efficiency of the engine by PYTHON programming.
Governing equations:-
Equation that play main role to fulfill the aim of this
project:-
(v/v_c)=1+1/2(r_c-1)[R+1-cos_theta-(R^2-sin^2_theta)^0.5]
i.e change in volume due to various processes.
where,
r_c=compression ratio
R=connecting rod length
v_c=clearance volume
Swept volume = (pi/4)*bore^2*stroke
Clearance volume = Swept volume/(r_c-1)
r_c = v_s+v_c/v_c
Objective:-
The main objective of this project is to calculate engine efficiency and plot Otto cycle (p-v) diagram using PYTHON programming.
Brief Theory:-
Otto cycle project depends on engine kinematics.
Engine kinematics:- It is the kinematics by which an IC engine converts chemical energy into Mechanical energy that produces from fuel.
Otto cycle:- It is basically an air standard cycle (Air standard cycle gives the data about the performance of the IC engine). Otto cycle is purely based on isentropic compression and expansion, constant volume heat addition, and rejection (Generally heat addition is called the combustion process).
Isentropic process:- Both of adiabatic and reversible process together is called isentropic process in Thermodynamics. This is two types --- compression and expansion.
P-V diagram of Otto cycle:-
1-2 is isentropic compression
2-3 is constant volume heat addition
3-4 is isentropic expansion
4-1 is constant volume heat rejection
Workflow:-
1) Initial pressure, the temperature is assumed.
2) Engine parameters are assumed.
3) for loop is used and Swept volume and clearance volume is calculated.
4)State variables calculating.
5) Thermal Efficiency is calculated.
6) Plotting of graph completed.
Brief Content of this project:-
This project has been done by PYTHON programming. The code of the program has been attached below.
#calculation of thermal efficiency of the otto cycle
import math
import matplotlib.pyplot as plt
def eng_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
#taking geometric parameters
a=stroke/2
R=con_rod/a
#taking vol parameters
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
sc=math.radians(start_crank)
ec=math.radians(end_crank)
num_values=50
dtheta=(ec-sc)/(num_values-1)
v=[]
#taking for loop
for i in range( 0 ,num_values):
theta=sc+i*dtheta
term1=.5*(cr-1)
term2=R+1-math.cos(theta)
term3=pow(pow(R,2)-pow(math.sin(theta),2),.5)
v.append((1+term1*(term2-term3))*v_c)
return v
#taking inputs
gamma=1.4
p1=101.325
t1=500
t3=2300
#taking engine geometric parameters inputs
bore=0.1
stroke=0.1
con_rod=.15
cr=12
#swept volume and clearence volume calculation
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1);
v1=v_s+v_c
#at state point 2
v2=v_c
#p2*v2^gamma=p1*v1^gamma
p2=p1*pow(v1,gamma)/pow(v2,gamma)
#p2*v2/t2=p1*v1/t1 | rhs=p1*v1/t1 | lhs=p2*v2/t2
t2=t1*p2*v2/(p1*v1)
v_compression=eng_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 point 3
v3=v2
p3=p2*t3/t2
v_expansion=eng_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))
#at state point 4
v4=v1
p4=p3*pow((v3/v4),gamma)
t4=t3/pow(cr,gamma-1);
#calculating thermal efficiency
thermal_efficiency=1-(1/pow(cr,gamma-1))
print('Thermal efficiency is=',thermal_efficiency*100)
#plotting of otto cycle plot
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('v')
plt.ylabel('p')
plt.show()
Algorithm of the program:-
1)Engine geometric parameters, volume, etc inputs are taken
2)for loop is used(i is used)
3)inputs of state points are taken and values, formulas are put
4)thermal efficiency is calculated
5)plot command is used to plot graphs
6)xlabel,ylabel command is used to show necessary property names of x-axis and y-axis
7)using show command plot is shown in output screen.
Result:-
Graph:-
Conclusion:-
Through this whole project, we have learned about the Otto cycle and its uses in engine and figures are plotted. Lastly, saying whole about Otto cycle was clearly learned by this project and the inner was fulfilled that enables us to solve engine kinematics problems in industry level by PYTHON programming.