P V diagram and thermal efficiency of otto cycle
clear all
close all
clc
%state variables
p1 = 101325
t1 = 500
t3 = 2300
g = 1.4
%engine parameters
b = 0.1
s = 0.1
cr = 12
con= 0.2
% calculating swept_vol and clearance vol
v_swept = (pi/4)*b^2*s
v_clearance = v_swept/(cr-1)
%state 1
v1= v_swept + v_clearance
%stage 2
v2 = v_clearance
% due to isentropic compression p1*v1^g=p2*v2^g
p2= p1*cr^g
% due to universal gas law p1*v1/t1 = p2*v2/t2
t2 = p2*v2*t1/(p1*v1)
c1= p1*v1^g
v_comp= engine_kinematics(b,s,con,cr,180,360);
p_comp= c1./v_comp.^g;
%stage 3
v3 = v2
p3 = p2*t3/t2
% stage 4
v4= v1
p4= p3*(v3/v4)^g
t4= p4*t1/p1
c2= p3*v3^g
v_exp= engine_kinematics(b,s,con,cr,0,180);
p_exp= c2./v_exp.^g;
%plot
hold on
plot(v1,p1,'*','color','r')
plot(v_comp,p_comp,'color','b')
plot(v2,p2,'*','color','r')
plot([v2 v3],[p2 p3],'color','b')
plot(v3,p3,'*','color','r')
plot(v_exp,p_exp,'color','b')
plot(v4,p4,'*','color','r')
plot([v4 v1],[p4 p1],'color','b')
xlabel('volume')
ylabel('pressure')
grid on
%thermal efficiency of otto cycle
th_eff = 1- ((t4-t1)/(t3-t2))
The above code is used to generate a p v diagram of otto cycle engine.
function [volume_trace] = engine_kinematics(b,s,con_rod,cr,start_crank,end_crank)
%inputs
a= s/2;
r= con_rod/a;
th = start_crank:end_crank;
% outputs
v_s = (pi/4)*b^2*s
v_c = v_s/(cr-1)
t1= 0.5*(cr-1);
t2= r+1-cosd(th);
t3= (r^2-sind(th).^2).^0.5;
[volume_trace]= (1+t1*(t2-t3))*v_c;
end
The above code is the function used to generate the instantaneous volume in the isentropic compression and expansion process.
The above graph shows the P V diagram of otto cycle.
The above image shows the results of pressure, volume and temperature of an otto cycle engine at each state. The thermal efficiency of the engine is also calculated, resulting in 62.9%.
The program starts with inputs such as bore, stroke, connecting rod length, compression ratio. Pressure and temperature at state 1 is usually given and either temperature or pressure at state 3 is also given. swept volume and clearance volume are calculated using given inputs.
The temperature, pressure and volume at all the other stages are calculated using universal gas law, isentropic relation and constant volume relation.
Instantaneous volume at each time is calculated as a function in different program and is called when required.