Project

Air Standard Otto Cycle Plotting and Efficiency using MATLAB

I) Code and Function Code :

Function Code:

Function file name : Vol_trace.m

% Function Code
function Vol_Tr = Vol_trace(bore,stroke,con_rod,Cr,start_angle,end_angle)

a = stroke/2;
r = con_rod/a;

Vs = pi/4*(bore^2)*stroke;
Vc = Vs/(Cr-1);

thheta = linspace(start_angle,end_angle,100);
term1 = 0.5*(Cr-1);
term2 = r+1-cosd(thheta);
term3 = (r^2-sind(thheta).^2).^0.5;

Vol_Tr = (1+term1*(term2-term3)).*Vc;

end

Main Code :

% Otto Cycle using Matlab  =========>>>
% ****All dimensions are in SI units*****

clear all
close all
clc

% Fixed Parameters ====================>>>
% State Variables and constants
p1 = 101325;
gamma = 1.4;
t1 = 300;
t3 = 2300;

% Engine Geometric parameters
bore = 0.1;
stroke = 0.2;
con_rod = .3;
Cr = 12;

%Calculating swept volume(Vs) and clearance volume(Vc) ==============>>>
Vs = pi*(bore^2)*stroke/4;
Vc = Vs/(Cr-1);

% State variables calculations start ======================>>>

% 1. State-1
v1 = Vs+Vc;


%2. State-2

%p1(v1^gamma)= p2(v2^gamma) & Cr=v1/v2
p2 = p1*Cr^gamma;
v2 = Vc;
%t2/t1= p2*v2/(p1*v1)
t2 = p2*v2*t1/(p1*v1);

c1 = p1*v1^gamma;
v_comp = Vol_trace(bore,stroke,con_rod,Cr,180,0);
p_comp = c1./ (v_comp.^gamma);

%3. State-3

v3 = v2;
% p3/p2=t3/t2
p3 = p2*t3/t2;

%4. State-4
v4 = v1;
% p4*(v4^gamma) = p3*(v3^gamma) & v4/v3 = Cr
p4 = p3*((v3/v4)^gamma);

% t3/t4 = (v3/v4)^(1-gamma)
t4 = t3*(v4/v3)^(1-gamma);

c = p3*v3^gamma;
v_exp = Vol_trace(bore,stroke,con_rod,Cr,0,180);
p_exp = c./ (v_exp.^gamma);

% Calculations for Efficiency of the Otto cycle ===============>>>

% Formula : Efficiency = 1 - 1/(Cr^(gamma-1))

disp('%') 
Efficiency = (1 - 1/(Cr^(gamma-1)))*100 


% Plotting ========================================>>>
hold on
label1 = {'1' };
label2 = {'2' };
label3 = {'3' };
label4 = {'4' };
% Plotting of state points :
plot(v1,p1,'*','color','r')
text(v1,p1,label1,'VerticalAlignment','top','HorizontalAlignment','left')
plot(v2,p2,'*','color','[0.5 0.75 0]')
text(v2,p2,label2,'VerticalAlignment','top','HorizontalAlignment','right')
plot(v3,p3,'*','color','[0.0 0.5 1]')
text(v3,p3,label3,'VerticalAlignment','bottom','HorizontalAlignment','right')
plot(v4,p4,'*','color','[0.5 0.3 0.2]')
text(v4,p4,label4,'VerticalAlignment','bottom','HorizontalAlignment','right')
% Plotting of the path followed :
plot(v_comp,p_comp,'linewidth',3)
plot(v_exp,p_exp,'linewidth',3)
plot( [v2 v3], [p2 p3],[ v4 v1], [p4 p1], 'linewidth',3)

xlabel('Volume (m^3)')
ylabel('Pressure (Pa)')
axis([0 1.8*10^(-3) -2*10^6 10*10^6])

II) Output of the code :

1. Efficiency(%) of the cycle :

Efficiency obtained = 62.9893%

2. P-V plot :

III) Stepwise Explanation of Code and Thermodynamic processes in the cycle :

1. Initially used commands - 'clear all' used to clear all the assigned values to the variables.

'close all' - force deletes all figures

'clc' - clears the command window.

2. Fixed Parameters - The main code includes 8 fixed parameters whose value is to be defined by the user.These parameters are : Initial pressure and temperature, compression ratio, adiabatic constant (gamma), bore, stroke, connecting rod length. All the values are in SI units only.

3. Calculating swept volume(Vs) and clearance volume(Vc) - The swept volume is the volume covered by the displacement of the piston from TDC to BDC or viceversa. The clearance volume indicates the gap maintained between the cylinder head and piston head at TDC. The formulae used for calculations are :

Vs =pi*(bore^2)*stroke/4
Vc = Vs/(compession ratio-1)

4. Calculation of the state variables - These calculations are essential for plotting of the graph. It is done in 4 major steps. In each step calculation of variables (pressure, temperature, volume) included in the respective stage is done. Formulae used in calculations are :

i) For Isentropic processes (From state 1 to state 2 and state 3 to state 4):

Pi*(Vi^gamma) = Pf *(Vf^gamma)= c .....(i and f stand for initial and final states ; c=constant); V1 = Vs + Vc ; PV = mRT .... ideal gas equation

ii) For constant volume process : Vi = Vf ; PV = mRT

iii) For piston kinematics and volume changes : The function named 'Vol_trace' was created and used for calculations. More information on the function is given further below.

iv) For changes in pressure along isentropic curve: P = c/(v^(gamma-1)) ...(P*V^gamma = c)

5. Calculations for the kinematics of piston positions and its effect on volume : For this a seperate function file was created named 'Vol_trace'.Using this function differrent values of the volume changes with respect to changes in crank angle were found. The values for crank angle (thheta) were generated by using linspace command.The following formula was used for the calculation :

The P-V plot of the isentropic process is a curved path. Hence, to get the accurate plot , it was imperative to use this formula.

6. Calculation of efficiency : The formula for efficiency of the Otto Cycle is :

Efficiency = (1 - 1/(Cr^(gamma-1)))*100 .

This shows that the efficiency is directly proportional to compression ratio and the adiabatic conastant - gamma.

7. Plotting of the Graph : The graph was plotted by plotting of the 4 state points initially and then the path of the cycle using the 'plot' and the 'hold' command. Also the 'X' and 'Y' axes were labelled using the 'xlabel' and 'ylabel' commands.This gives us the the final plot as shown in the output above.

IV) Errors faced and their corrections :

1. Inverted values of Pressure and Volume : This occured because of the typing error in the 'plot' command. Pressure values were given first followed by volume values.

Correction: Replaced pressure by volume in the 'plot' command.

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.