Project

Plotting an Air Standard Cycle using MATLAB

AIM : To write a program in Matlab to plot a PV diagram for air standard Otto cycle.

OBJECTIVES : To plot the PV diagram

To find the thermal efficiency of the cycle

THEORY :

An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines.

Otto cycle consists of 4 processes -

1. Isentropic compression 2. Constant volume heat addition

3. Isentropic expansion 4. Constant pressure heat rejection

CODE :

clear all
close all
clc

% inputs
gamma = 1.4;        % ratio of heat capacities
p1 = 2*101325;        % pressure at pt 1 (Pa)
T1 = 300;           % temp at pt 1 (K)
T3 = 2000;          % temp at pt 3 (K)

bore = 0.1;         % cylinder dia. (m)
stroke = 0.1;       % stroke length (m)
con_rod = 0.2;      % connecting rod length (m)
CR = 8;            % compression ratio


% calculations
Vs = (pi/4)*bore*bore*stroke;
Vc = Vs/(CR-1);

v1 = Vs + Vc;

const1 = p1*(v1^gamma);
v_comp = eng_kinematics(bore,stroke,con_rod,CR,180,0);
p_comp = const1./v_comp.^gamma;

v2 = Vc;
p2 = p1*(CR^gamma);
T2 = (T1*p2*v2)/(p1*v1);

v3 = v2;
p3 = (p2*T3)/T2;

const2 = p3*(v3^gamma);
v_exp = eng_kinematics(bore,stroke,con_rod,CR,0,180);
p_exp = const2./v_exp.^gamma;

v4 = v1;
p4 = p3*((v3/v4)^gamma);
T4 = (p4*T1)/p1;

% plotting the cycle
figure(1)
hold on
plot(v1,p1,'color','r',v2,p2,'color','r',v3,p3,'color','r',v4,p4,'color','r')
plot(v_comp,p_comp,'linewidth',2,'color','b');
plot([v2 v3],[p2 p3],'linewidth',2,'color','b');
plot(v_exp,p_exp,'linewidth',2,'color','b');
plot([v4 v1],[p4 p1],'linewidth',2,'color','b');

EXPLANATION OF CODE :

1. clear all : clears the workspace data

close all : clears all the figures and plots

clc : clears the command window

2. Input values are provided for the ratio of heat capactites, initial state point, bore diameter,

stroke and connecting rod length, and compression ratio.

3. The stroke volume and clearance volume is calculated using their formulae.

4. Since volume at state 1 is the volume at BDC, therefore, v1 = VS + Vc.

5. The function eng_kinematics is called to evaluate the piston kinematics for the isentropic

compression process. The function has been ddefined in another script file.

function [V] = eng_kinematics(bore,stroke,con_rod,CR,crank_start,crank_end)
 

r = stroke/2;
R = con_rod/r;

% calculations
Vs = (pi/4)*bore*bore*stroke;
Vc = Vs/(CR-1);

theta = linspace(crank_start,crank_end,100);

term1 = 0.5*(CR-1);
term2 = R+1-cosd(theta);
term3 = (R*R-sind(theta).^2).^0.5;

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

end

6. The same function is again called to evaluate the piston kinematics for the isentropic expansion process.

7. All the remaining state paramters are calculated using the thermodynamic relations for the respective processes.

8. Once all the state parameters are calculated, the cycle is plotted on the PV diagram using the plot commands. However, plot command tends to plot the last specified command only. To take care of this, hold on command has been used.

OUTPUT :

( Otto Cycle )

ERRORS FACED :

plot(v1,p1,'color','r',v2,p2,'color','r',v3,p3,'color','r',v4,p4,'color','r')
plot(v_comp,p_comp,'linewidth',2,'color','b');
plot([v1 v2],[p1 p2],'linewidth',2,'color','b');
plot(v_exp,p_exp,'linewidth',2,'color','b');
plot([v3 v4],[p3 p4],'linewidth',2,'color','b');

While plotting the cycle, I committed a mistake in line 3 by specifying the array as [v1 v2],[p1 p2]

instead of [v2 v3],[p2 p3]. The same mistake was repeated in line 5. This resulted in a distorted shape of the cycle (shown above).

This error was overcame afterwards.

THERMAL EFFICIENCY OF THE ENGINE :

Thermal efficiency of an Otto cycle is given by the relation -

`E = 1 - 1/(CR^(gamma- 1))`

TE = 1 - 1/(CR^(gamma-1))                 % Thermal Efficiency
TE =  0.56472
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.