Project

Air standard Cycle

P-V diagram of an Otto Cycle

Introduction:

Air Standard cycle (Otto Cycle)

Thermodynamic Otto cycle is considered to be one of the most commonly used practical cycles. Present days’ all four stroke internal combustion (IC) engines used in your gasoline cars, trucks, motorcycles, constructions machines etc work on the principle of four strokes of Otto cycle. The internal combustion engine working on the principle of Otto cycle is called Spark Ignition (SI) engine in which used gasoline as the fuel. The four strokes of the Otto cycle or four-stroke engine are: suction of fuel, compression of fuel, combustion and expansion of fuel and exhaust of burnt fuel.

AIM

To write a MATLAB program to plot the P-V curve of the Otto cycle and to display the 'thermal efficiency' value along the plot.

PROCEDURE

From the above diagram the various processes are as follows:

Process 0-1 : Intake stroke

In this process air fuel mixture at constant pressure is let into the cylinder.

Process 1-2 : Compression stroke

It is an adiabatic(isentropic) compression process, where the air fuel mixture is ‘compressed’ and the piston moves from BDC to TDC.

Process 2-3: Heat addition or Ignition

It is a constant volume process as the compressed fuel is ‘burnt’ using a spark plug and the piston is at TDC.

Process 3-4: Expansion stroke

It is an adiabatic (isentropic) expansion process, where piston is pushed down by the detonation due to ignition from TDC to BDC. This is also termed as ‘Power stroke’

Process 4-1: Heat Rejection

It is a constant volume process in which the burnt gases is sent out to ‘exhaust’, and piston is at BDC.

Process 1-0: Exhaust

In this process the burnt gases are let outside through the exhaust.

The four states along with the known inputs can be initially typed into MATLAB and the unknown values can be found at each states using the following conditions and Equations.

  • Compression ratio (cr)

It is the ratio of maximum to the minimum volume of the cylinder.

cr = v1/v2 = (v_s + v_c)/v_c

  • Swept volume(v_swept) = (pi/4) *bore^2*stroke, where pi = 3.14
  • Clearance Volume (v_c) = v_swept/(cr-1)
  • Initial volume (v1)= v_clearance + v_swept (as piston will be in BDC)
  • Volume at 2 (v2) = v_clearance(since piston is in TDC)
  • Volume at 3 (v3) = Volume at 2 (v2)

also, Volume at 4 (v4) = Volume at 1(v1).

To find p2: use expression p2v2^gamma = p1v1^gamma (gas eqn for isentropic process (1-2)pv^gamma =c)

To find t2 : use p1v1/t1 = p2v2/t2 (from Ideal gas equation pv=mRt )

To find p3 : use p3/t3 = p2/t2 (gas equation for constant volume process, p/t = constant)

To find p4: use expression p3v3^gamma = p4v4^gamma (gas eqn for isentropic process (3-4)pv^gamma =c)

PROCEDURE FOR CODE WRITING

1) First we find the unknown pressure values using the above equations

2)Then we have to create a volume function (otto_cycle_kinematics) with an array of volume as a function of crank angle. The reason for creating an array is to plot the isentropic curve as a curved line (actual) than a strraight line.

3) The main aim to create afunction is to plot the isentropic curve for both compression and expansion processes.

4) The volume function is the used to calculate the corresponding Pressure array. This is done for state points 2 and 4(compression and expansion).

5) The equation for thermal efficiency is also defined at the end to output the value of thermal efficiency along with the plot.

5) All the values are then plotted.

6) A box is created to plot the 'Thermal Efficiency' along the plot. This can be accomplished using the annotation function in MATLAB.

FitBoxToText — Option to fit box width and height to text (refered in Mathworks website)

Option to fit the box width and height to the text, specified as 'on' or 'off', or as numeric or logical 1 (true) or 0 (false). A value of 'on' is equivalent to true, and 'off' is equivalent to false. Thus, you can use the value of this property as a logical value.

  • 'on' — Resize the text box to fit the text.
  • 'off' — Wrap the text to fit the width of the text box. Wrapping can cause some of the text to extend below the text box.

If you resize a text box when in plot edit mode, or if you change the Position property, then the FitBoxToText property changes to 'off'

The normal plotting of isentrops yield us a straight line.

Hence in order to obtain the actual curved path of the isentrops the values between each and every point (in this case crank angle) in between process 1 and 2 should be calculated.

The equation governing the volume of the cylinder as afunction of crank angle is given as

The above equation is used inside the function, 'otto_cycle_kinematics' and is called into the main program.

clear all 
close all
clc

% ====== Inputs====== %
gamma = 1.4
t3 = 2300

%======  State Variables at 1====== %
p1 = 101325
t1 = 500
% ====== Engine Geometric Parameters====== %
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;

%====== Calculating Swept & Clearance Volume======%
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);

v1 = v_swept +v_clearance
v2 = v_clearance

%====== state variables at state point 2======%
%p2v2^gamma = p1v1^gamma
%p2 = p1*(v1/v2)^gamma = p1*cr^gamma
p2 = p1*cr^gamma;

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

%====== For isentropic exapnsion is governed by the equation PV^gamma = constant======%
constant_c = p1*v1^gamma;
V_expansion = otto_cycle_kinematics(bore, stroke, con_rod, cr,180,0);
P_expansion = constant_c./V_expansion.^gamma

%====== state variables at state point 3 ======%
v3 = v2

p3 = p2*t3/t2


constant_c = p3*v3^gamma;
V_compression = otto_cycle_kinematics(bore, stroke, con_rod, cr,0,180);

P_compression = constant_c./V_compression.^gamma
%====== state variables at state point 4 ======%
v4 = v1
p4 = p3*(v3/v4)^gamma

%======plotting Commands======%
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(V_compression, P_compression)
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot([v2,v3],[p2,p3],'color','b')
plot(V_expansion, P_expansion)
plot(v4,p4,'*','color','r')
plot([v4,v1],[p4,p1],'color','g')

grid on
title('P-V Diagram of Otto Cycle')
xlabel('Volume (m^3)')
ylabel('Pressure (Pa)')

%Thermal_efficiency=1-1/cr^gamma-1)
term5 = cr^(gamma-1);
Thermal_eff = (1-(1/term5))*100

dim = [0.45 0.75 .1 .1]; % This is the position of the text box in the plot and places the box at 45%width from y axis and 75% height from x-axis of the plot and size being 10% width and height of plot.
str = ['Thermal Efficiency (in %) = ',num2str(Thermal_eff)]; % This is the string that needs to be inside text box with the vakue of thermal eff calculated from above.
annotation('textbox',dim,'String',str,'FitBoxToText','on');

The below program is the otto_cycle_kinematics function which was called into the above program in order to get the curved lines of the isentropic processes.

function [V] = otto_cycle_kinematics(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,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

Errors:

  1. Typo in P_compression equation dot multiplication, forget to put '.' for multiplying with gamma.

Error was eliminated after typo error correction.

  1. The function name while calling in the main program was different. So had a error in command window saying 'undefined' function.

This error was overcome by correcting the typo and maintaining the same function name.

Error_1:

Error_2:

OUTPUT PLOT:

From the output the below points can be inferred,

  • The two isentropic curves(blue and the red) are not a straight line and is curved since we defined the isentropic function in the otto_cycle_kinematics.
  • The thermal efficiency of the otto cycle is 62.98% and the value is plotted into the plot in a box.

Thus the otto cycle with all the major processes are plotted along with thermal efficiency and results can be obtained.

References

1) For text box creation in plot

https://www.mathworks.com/help/matlab/ref/annotation.html

https://in.mathworks.com/matlabcentral/answers/385245-how-can-i-create-a-text-box-alongside-my-plot

https://in.mathworks.com/help/matlab/ref/matlab.graphics.shape.textbox-properties.html#buchq94-1-FitBoxToText

2) Otto Cycle theory

https://web.mit.edu/16.unified/www/FALL/thermodynamics/notes/node26.html

https://www.nuclear-power.net/nuclear-engineering/thermodynamics/thermodynamic-cycles/otto-cycle-otto-engine/thermal-efficiency-for-otto-cycle/

https://www.engr.colostate.edu/~allan/thermo/page5/page5.html

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.