Working of an Otto Cycle using MATLAB
The thermal efficiency came out to be 0.6299 i.e. 62.99%. (MAX Temp. is taken as 2500'C)
We define the starting point state variables and the geometric parameters of the cylinder.
Using geometric parameters of the cylinder we calculate the clearance volume and the stroke volume.
Now we know that there are two adiabatic and two isochoric processes in an otto cycle.
We code a function which gives us the volume at different pressure values in an adiabatic process using cylinder kinematics equation
1 + (0.5*(cr-1)*(R+1-cosd(theta)-(R^2-sind(theta)^2)^0.5))*clearance vol.
So with help of these parameters we plot the graph of the otto cycle.
clear all
close all
clc
%state variables
t1=500;
p1=101325;
gamma=1.4;
%engine geometric parameters
bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=12;
%calculation of swept vol and clearance volume
v_s=(pi/4)*bore^2*stroke;
v_c=v_s/(cr-1);
v1=v_s+v_c;
v2=v1/cr;
const_c=p1*v1^gamma;
V_comp=cyl_kinematics(bore,stroke,con_rod,cr,180,0);
P_comp=const_c./V_comp.^gamma;
%state variables at point 2
p2=p1*(cr^gamma);
t2=(p2*v2*t1)/(p1*v1);
%state variables at point 3
v3=v2;
t3=2300;
p3=(p2*t3)/t2;
const_d=p3*v3^gamma;
V_exp=cyl_kinematics(bore,stroke,con_rod,cr,180,360);
P_exp=const_d./V_exp.^gamma;
%state variables at point 4
v4=v1;
p4=p3/(cr^gamma);
t4=(p4*t1)/p1;
figure(1)
hold on
plot(v1,p1,'.','color','r')
plot(v2,p2,'.','color','r')
plot(v3,p3,'.','color','r')
plot(v4,p4,'.','color','r')
plot(V_comp,P_comp,'color','b')
plot(V_exp,P_exp,'color','b')
plot([v2 v3],[p2 p3],'color','b')
plot([v4 v1],[p4 p1],'color','b')
%caclulating efficiency
efficiency=1-((t4-t1)/(t3-t2))
%cylinder kinematics function
function[V]=cyl_kinematics(bore,stroke,con_rod,cr,start_crankangle,end_crankangle)
%engine geometric parameters
crankpin_radius=stroke/2;
R=con_rod/crankpin_radius;
v_s=pi/4*bore^2*stroke;
v_c=v_s/(cr-1);
theta=linspace(start_crankangle,end_crankangle,180);
term1=0.5*(cr-1);
term2=R+1-cosd(theta);
term3=(R^2-sind(theta).^2).^0.5;
V=(1+term1*(term2-term3)).*v_c;
end