Create PV diagram of OTTO cycle using MATLAB
- AIM:- Create PV diagram of OTTO cycle using MATLAB
- THEORY:- All the spark ignition engine which is used in bikes or cars are working on otto cycle.It used air as working fluid and patrol as energy source that's why it is also called air standerd cycle. Mainly,it is combination of four processes these are 1. Adiabatic compression 2. Constant volume heat addition 3. Adiabatic expansion 4. Constant volume heat rejection.So, it is also called as constant volume heat addition process. It is combination of all the precesses occures inside the cylinder of engine and after drawing the pressure vs volume plot of processes we can actually anlyse the variation of pressure with respect to volume and as we know that pressure is also an another form of work i.e after getting the idea about the pressure we can actually know that how cycle will be effective and how much work it can give to us with respect to input.
- ASSUMPTION:- Here, we are consideringg all the assumption which is taken for air standerd cycle like only air will be working fluid and it will be considerd as ideal gas,all the specific heat during the processes will be constant,and gamma will be also constant. Another assumption for drawing the plot of pv diagram of otto cycle on MATLAB taking some inputs which is generally known to us like initial temperature(t1=300),pressure(101325),bore(d=0.1),stroke(l=1),length of connecting rod(0.15),compression ratio(10),maximum temperature(2500),crank radius(l/2).
- PROCEDURE:-
- Firstly to draw the plot we will insert the all the input variable and by using the adiabatic relation and ideal gas relation we will find out the value of all the pressure and volume at every end point of processes and to make plot using it we will use the plot command the programming for it will be
clear all close all clc % inputs bore = 0.1; stroke = 0.1; con_rod = 0.15; cr = 10; gamma = 1.4; t1 = 300; t3 = 2500; p1 = 101325; %engine parameters v_s = pi/4*bore^2*stroke; v_c = v_s/(cr-1); %state variable at 1 v1 = v_s + v_c %state variable at 2 v2 = v_c; p2 = p1*(cr)^gamma; t2 = p2*v2*t3/p3*v3 %state variable at 3 v3 = v2; p3 = p2*t3/t2; %state variable at 4 v4 = v1; p4 = p3*(v3/v4)^gamma t4 = p4*v4*t3/p3*v3 figure(1) hold on plot(v1,p1,'*','color','r'); plot(v2,p2,'*','color','r'); plot(v3,p3,'*','color','r'); plot(v4,p4,'*','color','r'); figure(2) plot([v1 v2 v3 v4],[p1 p2 p3 p4],'linewidth',3)
and after running the programme result will be
2. In the above plot we can see that the result after running the programme fr otto cycle is not look like otto cycle pv diagram, MATLAB just connected all the state varibale and make a plot that's wrong. Because, we didn't tell the matlab about processes between 1 and 2 is compression and between 3 and 4 is expansion. So, to understand it for matlab we will use fuction to tell the matlab about change in volume inside the cylinder during the compression an expansion processes will depends on the crank angle and cylinder geometry so the progamming to create this function will be
function [V] = engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)
a = stroke/2;
R = con_rod/a;
v_s = pi/4*bore^2*strok;
v_c = v_s/(cr-1);
theta =linspace(start_crank,end_crank,100);
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
after saving it we can make a V_compression array and we can see the plot will be like adiabatic processes
3. So, finally after creating the V_compression volume array by using the plot command we can make the plot of otto cycle and by usnig the legend command we can write the name of the process on plot in sequence. so the final programming will be
clear all
close all
clc
% inputs
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 10;
gamma = 1.4;
t1 = 300;
t3 = 2500;
p1 = 101325;
%engine parameters
v_s = pi/4*bore^2*stroke;
v_c = v_s/(cr-1);
%state variable at 1
v1 = v_s + v_c
constant_c = p1*v1^gamma
V_compression = cylinder_geometry(bore,stroke,con_rod,cr,180,0);
P_compression = constant_c/V_compression.^gamma;
%state variable at 2
v2 = v_c;
p2 = p1*(cr)^gamma;
t2 = p2*v2*t3/p3*v3
%state variable at 3
v3 = v2;
p3 = p2*t3/t2;
constant_c = p3*v3^gamma
V_expansion = cylinder_geometry(bore,stroke,con_rod,cr,0,180);
P_expansion = constant_c/V_expansion.^gamma;
%state variable at 4
v4 = v1;
p4 = p3*(v3/v4)^gamma
t4 = p4*v4*t3/p3*v3
figure(1)
hold on
plot(V_compression,P_compression;
plot([v2 v3],[p2 p3],'linewidth',3);
plot(V_expansion,P_expansion;
plot([v4 v1],[p4 p1],'linewidth',3);
legend('compression','heat addition','expansion','heat rejection');
xlabel('Volume');
ylable('Pressure');
grid on
%figure(2)
%plot([v1 v2 v3 v4],[p1 p2 p3 p4],'linewidth',3);
and the plot of pv diagram will be