Project

otto cycle

P-V DIAGRAM OF OTTO CYCLE

Objective:

To plot the p-v (pressure-volume) diagram of the Otto cycle and calculate the thermal efficiency of an engine using math lab code.

Otto cycle:

The Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition engine. The Otto cycle is named after its inventor, Nicolaus Otto. The Otto cycle consists of the following processes:

Process 0–1 intake stroke

Process 1–2 compression stroke (isentropic compression)

Process 2–3 ignition phase (constant volume heat addition)

Process 3–4 expansion stroke (isentropic expansion)

Process 4–1 idealized heat rejection (constant volume heat rejection)

Process 1–0 exhaust stroke

Formulas:

Swept volume:

`v_s = π/4×d^2×l`

Clearance volume:

`v_c= (v_s)/((cr-1))`

Total volume:

v_total = v_s + v_c

v1= total volume

v2=clearance volume

The isentropic compression process can be defined by,

p2v2^gamma = p1v1^gamma

p2 = p1*(v1/v2) ^gamma

p2= p1*cr^gamma

According to the ideal gas equation (considering air as an ideal gas),

p1v1/t1 = p2v2/t2

So we get,

t2 = p2*v2*t1/(p1*v1)

The state points at 3 are calculated using the ideal gas equation,

p3v3/t3 = p2v2/t2

We know that, v2=v3

p3 = p2*t3/t2

The state points at 4 are calculated as,

p3v3^gamma = p4v4^gamma

We know that, v4=v1

So we get,

p4 = p3(v3/v4)^gamma

Volume Trace:

`V=〖(1+1/2 (cr-1)[R+1-costheta-(R^2-〖sintheta〗^2 )])〗^2 *v_c`

Where,

R=connecting rod length/a

a=stroke/2

Thermal efficiency:

Thermal efficiency= 1-(1/cr^(gamma-1))

Thermal efficiency percentage = thermal efficiency*100

Math lab main code:

clear all
close all 
clc

% inputs
gamma = 1.4
t3 = 2300

% state variables
p1 = 101325
t1 = 500    

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

% calculating the swept volume and 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);

constant_c = p1*v1^gamma;
V_compression = otto_kinematics(bore,stroke,con_rod,cr,0,180);
P_compression = constant_c./V_compression.^gamma;


% state variables at state point 3
v3 = v2

% p3v3/t3 = p2v2/t2 | p3 = p2*t3/t2
p3 = p2*t3/t2


constant_c = p3*v3^gamma;
V_expansion = otto_kinematics(bore,stroke,con_rod,cr,180,0);
P_expansion= constant_c./V_expansion.^gamma;


% state variables at state point 4
v4 = v1

% p3v3^gamma = p4v4^gamma | p4 = p3(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma

% plotting the p-v diagram using the state points and the calculated values
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(V_compression, P_compression,'color','b')
plot(v2,p2,'*','color','r')
plot([v2,v3],[p2,p3],'color','r')
plot(v3,p3,'*','color','r')
plot(V_expansion, P_expansion,'color','b')
plot(v4,p4,'*','color','r')
plot([v1,v4],[p1,p4],'color','r')

xlabel('Volume')
ylabel('Pressure')
title('the otto cycle')

% calculating the thermal efficiency
term1 = 1/cr^(gamma-1)
thermal_efficiency = 1-term1
thermal_efficiency_percentage = thermal_efficiency*100


Explanation:

  • The first step in any Mathalb code is to clear all existing variables, plots and values by using the commands clear all, close all, clc.
  • The second step is to define the input parameters which in our case are the gamma and t3 and then the state variables p1 and t1 are defined.
  • The engine geometric parameters such as the bore, the stroke, connecting rod length and the compression ratio are then entered
  • The next step is to calculate the swept volume and the clearance volume from the formulas known
  • Now using the ideal gas equation the values for p2 and t2 are found.
  • Using these values the other remaining state variable values are found.
  • In order to draw a volume trace which connects all the state variables a separate function program is created and the volume trace is calculated.
  • This function is then called into our main program.
  • All the state variables and the volume trace are plotted in order to achieve the Otto cycle diagram.
  • The last step is calculating the thermal efficiency using the formula given.

Math lab function code:

function [V] = otto_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);

% an array named theta is created for different crank angle values:
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;

% calculating the volume trace by combining all the three terms:
V = (1+term1*(term2 - term3)).*v_c
end



Function code explanation:

  • The function code is given a function name as otto_kinematics in which the names of the input variables are entered
  • Then an array of crank angles is created using the linspace command(theta = linspace(start_crank,end_crank,100);
  • The final step is to calculate the volume trace using the formula known

Errors faced during the code:

An error was faced due to a use of variable t3 which was not assigned a value

Error was rectified by passing t3 as an input variable and assigning it a value of 2300

Results:

The p-v (pressure volume diagram) is drawn using the math lab code. The p-v diagram can be useful to analyze the performance of an engine. Moreover the thermal efficiency of the engine is also calculated which is found as:

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.