Project

Air Standard Cycle in MATLAB

OBJECTIVES: To write a code in Matlab for :

  1. The PV diagram of an Air Standard Otto Cycle
  2. To calculate the Thermal Efficiency of the engine.

INTRODUCTION:

Otto cycle is a gas power cycle that is used in the spark-ignition internal combustion engine. An Otto cycle consists of two isentropic (reversible adiabatic) processes and two isochoric (constant volume) processes.

p-V Diagram

T-s Diagram

Here,

p - Pressure ; V - Volume ; T - Temperature ; s - Entropy ;

Vc - Clearance Volume ; Vs - Stroke Volume.

Process 1-2: Isentropic compression

In this process, the piston moves from the bottom dead centre (BDC) to top dead centre (TDC) position. Air undergoes reversible adiabatic (isentropic) compression. We know that compression is a process in which volume decreases and pressure increases. Hence, in this process, the volume of air decreases from V1 to V2 and pressure increases from p1 to p2. Temperature increases from T1 to T2. As this an isentropic process, entropy remains constant (i.e., s1=s2).

Process 2-3: Constant Volume Heat Addition:

Process 2-3 is isochoric (constant volume) heat addition process. Here, piston remains at the top dead centre for a moment. Heat is added at constant volume (V2 = V3) from an external heat source. Temperature increases from T2 to T3, pressure increases from p2 to p3 and entropy increases from s2 to s3.

In this process,

Heat Supplied = mCv(T3 – T2)

where,

m - Mass

Cv - Specific heat at constant volume

Process 3-4: Isentropic expansion

In this process, air undergoes isentropic (reversible adiabatic) expansion. The piston is pushed from the top dead centre (TDC) to bottom dead centre (BDC) position. Here, pressure decreases from p3 to p4, volume rises from v3 to v4, the temperature falls from T3 to T4 and entropy remains constant (s3=s4).

Process 4-1: Constant Volume Heat Rejection

The piston rests at BDC for a moment and heat is rejected at constant volume (V4=V1). In this process, the pressure falls from p4 to p1, temperature decreases from T4 to T1 and entropy falls from s4 to s1.

In process 4-1,

Heat Rejected = mCv(T4 – T1)

Thermal efficiency (air-standard efficiency) of the Otto Cycle is given by,

PROCEDURE:

  1. At first, we input the engine parameters and assign and derive the state variables.
  2. We cannot connect the points linearly and thus create another function [V] to derive the Compression and the Expansion curves.
  3. We calculate the Volume Trace inside the function by splitting the formula into smaller terms.
  4. We name the output function of the Volume Trace as V_compression and V_expansion and with the help of this and constant 'c', we calculate the P_compression and P_expansion.
  5. We connect the points 1-2 and 3-4 using the values from above.
  6. We connect the Isochoric (Constant Volume) lines with straight lines using the plot command.
  7. We calculate the Thermal Efficiency of the engine by using the code "E = (1-(1/cr)^(gamma-1))*100"
  8. We use the legend command to introduce multiple legends into the figure to name each of the graphs (processes).

CODE:


1. Main code

clear all
close all
clc

% Inputs
gamma = 1.4;
t3 = 2300;

% Engine geometric parameters
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;

% Calculating the swept volume and the clearance volume
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);

% State variables at point (1)
p1 = 101325;
t1 = 500;

v1 = v_swept + v_clearance
v2 = v_clearance;

% State variables at point 2
% p2v2^gamma = p1v1*gamma
p2 = p1*cr^gamma;

%p1v1/T1 = p2v2/t2
t2 = p2*v2*t1/(p1*v1);

% constant
c = p1*v1^gamma;
V_compression = engine_kinematics_otto_cycle1(bore, stroke, con_rod, cr,180,0);
P_compression = c./(V_compression.^gamma);

% State variables at point 3
v3 = v2
%p3v3/t3 = p2v2/t2
p3 = p2*t3/t2
% constant
c = p3*v3^gamma;
V_expansion = engine_kinematics_otto_cycle1(bore, stroke, con_rod, cr,0,180);
P_expansion = c./(V_expansion.^gamma);



%State variables at state point 4
v4 = v1
%p3v3^gamma = p4v4^gamma
p4 = p3*(v3/v4)^gamma;

%Efficiency
disp('Efficiency of OTTO CYCLE') 
E = (1-(1/cr)^(gamma-1))*100

%plotting
figure(1)
hold on
plot(v1,p1,'*','color','r')
aa = plot(V_compression,P_compression,'linewidth',2,'color','b');

plot(v2,p2,'*','color','r');
plot(v3,p3,'*','color','r');

cc = plot(V_expansion, P_expansion,'linewidth',2,'color','black');
plot(v4,p4,'*','color','r');

bb = plot([v2 v3],[p2 p3],'linewidth',2,'color','g');
dd = plot([v4 v1],[p4 p1],'linewidth',2,'color','yellow');
title('OTTO CYCLE')
xlabel('VOLUME')
ylabel('PRESSURE')
legend([aa,bb,cc,dd],'Isentropic Compression','Isochoric Heat Addition','Isentropic Expansion','Isochoric Heat Rejection')

2. Function

function [V] = engine_kinematics_otto_cycle1(bore, stroke, con_rod, cr, start_crank, end_crank)


a = stroke/2;
R =con_rod/a;

v_s = (pi/4)*bore^2*stroke;
v_c = v_s/(cr-1);

theta = linspace(start_crank,end_crank,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

OUTPUT:

1.

2.

The thermal efficiency of the engine was found to be '62.98%'.

ERRORS:

1.

Case Sensitive Error: yLabel('PRESSURE')

Correction: ylabel('PRESSURE')

2.

Error using plot: plot(V_compression,P_compression,'inewidth',3)

Correction: plot(V_compression,P_compression,'linewidth',2,'color','b')

3.

Error in plotting color: cc = plot(V_expansion, P_expansion,'linewidth',2,'color','p')

The specified character vector 'p' is an invalid color value.

Correction: cc = plot(V_expansion, P_expansion,'linewidth',2,'color','black')

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.