Air standard cycle using matlab
Objective: plotting the otto cycle using matlab code.
Theory :
otto cycle is air standard cycle and it is also it describe the functioning of spark ignition engines . it has 4 processes basically 2 of them are adiabatic and 2 of them are constant volume process . In S .I engine expansion stroke and exhaust stroke are replaced by constant volume heat addition and constant volume heat rejection . In otto cycle working substance is air .
Matlab code :
close all
clear all
clc
%input
p1 = 1.01*10^5
t1 = 400
t3 = 1900
gamma = 1.4
% volume input
bore = 0.1
stroke = .1
con_rod = 0.15
cr = 9
% volume caluclation
v_swept = pi/4*bore^2*stroke
v_clearence = (v_swept)/(cr-1)
% volume caluclation and pressure calculation At each point
v1 = v_swept +v_clearence
v2 = v_clearence
p2 = (p1*v1^gamma)/v2^gamma
t2 = (p2*v2*t1)/(p1*v1)
p3 = p2*t3/t2
p4 = (p3*v2^gamma)/v1^gamma
t4 = p4*t1/p1
v3 = v2
v4 =v1
%relation of how volume changes from t.d.c to b.d.c in engine based on that
%compression vol. and expansion vol.
const = p1*v1^gamma
v_c = engine_kinematics(bore,stroke,con_rod,cr,180,0)
p_c = const./v_c.^gamma
const = p3*v3^gamma
v_e = engine_kinematics(bore,stroke,con_rod,cr,0,180)
p_e = const./v_e.^gamma
%plotting the result
figure(1)
hold on
plot(v1,p1,'.','color','b')
plot(v_c,p_c,'color','r','linewidth',3)
plot(v2,p2,'.','color','b')
plot(v3,p3,'.','color','b')
plot(v_e,p_e,'color','r','linewidth',3)
plot([v2,v3],[p2,p3],'color','b','linewidth',3)
plot(v4,p4,'.','color','b')
plot([v4,v1],[p4,p1],'color','b','linewidth',3)
so above is the code for the otto cycle plotting now in this we have input as intial pressure (p1) and intial temprature (t1),and maximun temprature (t3) is given as input now as in i.c. engine we also given various parameters like
bore,stroke,length of connecting rod so from that we can find swept voume ,
v_s wept = swept volume
now also we have compression ratio so we can find v1 and v2 from that now
v1 = swept volume + clearence volume
v2 = clearance volume
so that now we have all the values so we can now calculate the rest of points by use of process equations like given below
p 1 ⋅ v 1 ^γ = p 2 ⋅ v 2 ^γ we can find p2 from (here gamma value also has been given to us )
now we have found p2 so to find t2 we use the foloowing equation
(t2/t1) = (p2/p1)^(gamma-1/gamma)
we can find t2 ,simmilarly we can find p4 and t4 also the same way so now that we have all the points we can start plotting the result
but if we directly plot the reslut the volume change will be linear so we have to use piston kinematics to show how voilume changes from top dead center to bottom dead center this is very much important to get the exact plot for an otto cycle so we create a function by the same name engine kinematics to give volume change .
Function for piston kinematics :
function[v] = engine_kinematics(bore,stroke,con_rod,cr,start,End)
% crating function from piston kinematics
% inputs
a = stroke/2
R = con_rod/a
v_swept = pi/4*bore^2*stroke;
v_clearence = v_swept/(cr-1);
theta = linspace(start,End,180);
% formula from piston kinematics divideing the formula in two terms
term1 = 0.5*(cr-1);
term2 = R+1-cosd(theta);
term3 = (R^2 - sind(theta).^2).^0.5;
v = (1+term1.*(term2-term3)).*v_clearence
end
so here is the code to create function for piston kinamatics to show how volume changes now the formula for change in volume is given by below ,
v/(vc)=(1+0.5⋅(cr−1)⋅[(R+1⋅cos^2(θ)−(R^2−sin^2(θ))^0.5]
so from this we can get the otto cycle plot as given below .
RESULT