Project

Plot P-V diagram of ‘Otto cycle’ with the help of Matlab program.

Title: Plot P-V diagram of ‘Otto cycle’ with the help of Matlab program.

Objective: The objective of this Mat lab program is to plot P-V curve of an Otto cycle by using Mat lab.

Introduction: Otto cycle is an air standard cycle of internal combustion engine which is a type of a ‘spark-ignition’ engine used in automobiles. Generally it has four processes:

Process 1-2: Intake- the inlet valve is open and piston moves from TDC (top dead center) to BDC( bottom dead center ). And air-fuel mixture is admitted inside the cylinder.

Process 2-3: Compression: in this process air-fuel mixture get compressed when piston moves from BDC to TDC. This process also known as ‘Reversible adiabatic.

Process 3-4: Combustion: then mixture get ignited by spark and combustion takes place. And there is an increase in temperature and pressure. This process is also called as ‘Isochoric heat addition’.

Process 4-5: Expansion: Due to high pressure and temperature piston will start moving from TDC to BDC. And get useful work from it. This process is also called as ‘Reversible adiabatic expansion’ process.

Process 5-2: Exhaust and blow down: now exhaust valve open and gases go outside and decrease pressure up to atmospheric. This process is takes place at constant volume.

All above processes is explained below in Figure 1:

Figure 1: plot of an otto cycle in p-v diagram

Code Explanation:

1. Initial data is to be assumed:

Bore =0.1m

Stroke = 0.1m;

Connecting rod length = 0.15m;

Compression ratio = 10;

Cp = 1.014 J/Kg-K

Cv = 0.718 J/Kg-K

Gamma = Cp/ Cv

2. Now calculating cylinder volume

Total volume of engine have sum of swept volume & clearence volume

V_swept = (pi/4)*bore^2*stroke

V_clearance = V_swept/(cr -1)

3. Before plotting p-v diagram otto cycle we need four state points.

a). State point 1 values

p1 = 101325 Pa

t1 = 310 K

v1 = v_swept + v_clearance

b). State point 2 values

p2 = p1*cr^gamma;

v2 = v_clear;

t2 = p2*v2*t1/(p1*v1);

c ). State point 3 values

Process 2-3 is a constant volume process.

t3 = 500;

p3 = p2*t3/t2;

v3 = v2;

d ). State point 4 values

Process 4-1 is also a constant volume process.

v4 = v1;

p4 = p3*(v3/v4)^gamma;

t4 = t1*p4/p1;

4. Now we plot all state points and path with the help of plot command.

5. We used ‘engine kinematics function’ to help in plotting compression & expansion path.

But actually process 1-2 & 3-4 is an isentropic process. The volume traced by following equation

`V = 1+ 0.5(cr -1)*((R + 1-costheta- (R^2 - sin^2theta ^ 0.5)*Vc`

We created an 'engine_kinematics' function with several inputs variable

As we know that p*v^gamma = constant

constant_c = p1*v1^gamma

v_compression = engine_kinematics(bore, stroke,con_rod, cr, 180,0)

p_compression = constant_c./v_compression.^gamma

6. Now we calculate the thermal efficiency of Otto cycle…by following formula

`Efficiency = 1- 1/(cr - 1)^(gamma - 1)`

Matlab program:

code 1: Functions of engine kinematcs

function [V] = engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank)
   a = stroke/2;
   R = con_rod/a;
  
   v_swept = (pi/4)*bore^2*stroke;
   v_clear = v_swept/(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_clear
end

code 2: Program for otto cycle

 clear all
 close all
 clc
 
% Otto cycle program with Matlab
% engine cylinder configuration
  bore = 0.1;       % diameter of cylinder
  stroke = 0.1;     % length of stroke
  con_rod = 0.15;   % length of connecting rod
  cr = 10;          % compression ratio
  
 % inputs of ideal gas data
   Cp= 1.01325;
   Cv = 0.7185;
 % calculation of gamma = Cp/Cv
   gamma  = 1.4;
  
 % Now calculating cylinder volume
 % Total volume of engine have sum of swept volume & clearence volume
   v_swept = (pi/4)*bore^2*stroke;
   v_clear = v_swept/(cr -1);
   
 % Before plotting p-v diagram otto cycle need four state points.
 % State point 1 values
   p1 = 101325;        % Pressure in 'pascal'
   t1 = 310;           % Temperature value in 'kelvin'.
  
   v1 = v_swept + v_clear;  % volume in cubic meter.
 % State point 2 values
   p2 = p1*cr^gamma;
   v2 = v_clear;
   t2 = p2*v2*t1/(p1*v1);
   
 % But actually process 1-2 is an isentropic process. the volume traced by following equation
 % V = 1+ 0.5(cr -1)*((R + 1-cos(theta)- (R^2 - sin^2(theta)^0.5)*v_clearence
 % we created an 'engine_kinematics' function with several inputs veriable
 % as we know that p*v^gamma = constant
   constant_c = p1*v1^gamma;
   v_compression = engine_kinematics(bore, stroke,con_rod, cr, 180,0);
   p_compression = constant_c./v_compression.^gamma;
   
 % State point 3 values
 % process 2-3 is a constant volume process.
   t3 = 500;
   p3 = p2*t3/t2;
   v3 = v2;
   
   constant_c = p3*v3^gamma;
   v_expansion = engine_kinematics(bore, stroke,con_rod, cr, 0,180);
   p_expansion = constant_c./v_expansion.^gamma;
   
 % State point 4 values
 % process 4-1 is also a constant volume process.
   v4 = v1;
   p4 = p3*(v3/v4)^gamma;
   t4 = t1*p4/p1;
   
 % now plot otto cycle in P-V diagram
   figure(1)
   hold on
 % now first we create the state points
   plot(v1, p1,'*', 'color','r') % plotting state point 1
   plot(v2, p2,'*', 'color','r') % plotting state point 2
   plot(v3, p3,'*', 'color','r') % plotting state point 3
   plot(v4, p4,'*', 'color','r') % plotting state point 4
 % now creating path with ponints 1,2, 3, 4.
 % plot path 1-2
   plot(v_compression, p_compression, 'color','b')
 % plot path 2-3 
   plot([v2 v3],[p2 p3], 'color','r')
 % plot path 3-4 
   plot(v_expansion, p_expansion, 'color','g')
 % plot path 4-1   
   plot([v1 v4],[p1 p4], 'color','r')
   xlabel('Volume')
   ylabel('Pressure')
  
 % Efficiency calculation of an otto cycle
   Efficiency = 1- 1/(cr - 1)^(gamma - 1);
   
   
   

Output:

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.