Project

Air Standard Otto Cycle- path simulation using Matlab

AIM: To plot P-V Diagram of Otto cycle from given conditions.

also, to determine the thermal efficiency of the engine.

CODE for function 'piston_kinematics'

function [V]= piston_kinematics(bore,stroke,conrod,cr,start_angle,end_angle)

a= stroke/2;
R= conrod/a;

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

theta = linspace(start_angle,end_angle,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

CODE for otto cycle P-V diagram

% solving otto cycle and plotting PV diagram using piston kinematics
clear all
close all
clc

%input parameters
gamma= 1.4;
p1= 100000;
t1=300;
t3=2000;

%piston input parameters
bore= 0.25;
stroke= 0.3;
conrod= 0.35;
cr= 8;

%calculating swept volume and clearance volume
v_s= (pi/4)*bore^2*stroke;
v_c= v_s/(cr-1);

v1= v_s+ v_c;
v2= v_c;

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

c= p1*(v1)^gamma;
V_compression= piston_kinematics(bore,stroke,conrod,cr,180,0);  
p_compression= c./(V_compression).^gamma;

%state variables at point 3
v3= v2;
%p3v3/t3= p2v2/t2
p3= p2*(t3/t2);

c_1= p3*(v3)^gamma;
V_expansion= piston_kinematics(bore,stroke,conrod,cr,0,180);  
p_expansion= c_1./(V_expansion).^gamma;


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

%thermal efficiency of engine
eta=  1-(cr)^(1-gamma);


figure(1)
hold on
plot(v1,p1,'*','color','g');
plot(V_compression,p_compression,'color','r');
plot(v2,p2,'*','color','g');
plot(v3,p3,'*','color','g');
plot([v2 v3],[p2 p3],'color','r');
plot(V_expansion,p_expansion,'color','r');
plot(v4,p4,'*','color','g');
plot([v4 v1], [p4 p1],'color','r');

ASSUMPTIONS taken for required data:

gamma has a value of 1.4

input pressure has a value of 1 bar i.e. 100000 pascal.

temperature 1= 300 K

temperature 3= 2000 k

bore diameter= 250 mm

stroke length= 300 mm

connecting rod length= 350 mm

compression ratio= 8

Procedure:

1. after giving all input parameters (both state variable parameters and engine parameters), the formula for stroke volume and clearance volume is written (taken as v_s and v_c respectively).

2. the formula for

a. stroke volume = v_s= (pi/4)*bore^2*stroke

b. clearance volume= `v_c= v_s/(cr-1);`

3. then according to the 4 processes which constitue otto cycle, the required formula are written the 4 processes in otto cycle are

process 1-2: isentropic compression

process 2-3: constant volume heat addition

process 3-4: isentropic expansion

process 4-1: constant volume heat rejection

formulae used:

process 1-2: `p2*(v2)^gamma= p1*(v1)^gamma`

`p_1*v_1/t_1= p_2*v_2/t_2`

process 2-3: `p_3*v_3/t_3= p_2*v_2/t_2`

process 3-4: `p_3*v_3^gamma= p_4*v_4^gamma`

thermal efficiency: `eta= 1-(cr)^(1-gamma)`

4. after writing all formulae, we use 'figure' and hold on to put multiple plots in a single figure.

5. first, we plot all 4 points namely, [x1,y1], [x2, y2], [x3, y3], [x4, y4]

6. to plot the line joining these 4 points we cannot simply use 'plot' because it would result in wrong area under the curve which gives the work done.

7. for process 2-3, 4-1, we can use simple 'plot' function as it is constant volume processes which results in vertical straight lines.

8. for the other 2 processes, we use 'function' operator.

9. the function operator is used because it is a complex code that should be pasted accordingly in the above code. it is a time-consuming and cumbersome process.

10. in order to simplify this task, we use function operator which ensures that the separate complex code can be used in other codes whenever, that equation/formula is required.

11. hence, in another code tab, which is pasted above, we initialize a function named as 'V'.

12. it is a function from which we can find the pressure and volume for expansion and compression processes.

13. by using the function operator 'piston_kinematics', we can obtain the pressure and volume of both expansion ad compression processes, from which, in turn, we can plot those values to obtain the correct graph line joining the points 1,2 and 3,4.

ERRORS MADE AND STEPS TAKEN TO CORRECT THEM:

ERROR 1:

the equation of constant= p1* v1^gamma was written with the constant on the right side of the equation. this led to an error and was subsequently corrected.

ERROR 2:

the element wise operator was not properly included. this was subsequently corrected to get the correct code.

ERROR 3:

instead of [v2 v3], [p2 p3], undefined variables x and y were used. this error was corrected to get the correct plot

RESULT: The THERMAL EFFICIENCY was found to be 56.47% or 0.5647

the above plot denotes the 4 state variable points 1,2,3,4.

THE ABOVE PLOT SHOWS THE COMPLETE OTTO CYCLE FOR THE GIVEN CONDITIONS.

hence, we can analyse the thermal efficiency of given engine following any air standard cycle using similar procedure with Matlab.

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.