Project

To calculate the Thermal Efficiency of given Otto cycle and plot it’s PV diagram using MATLAB

Aim:

To calculate the Thermal Efficiency of given Otto cycle and plot it’s PV diagram.

Objective:

  • · To calculate the state variables and plot the corresponding PV diagram.
  • · To calculate the thermal efficiency of the cycle for given engine parameters.

Workflow:

Program Code:

clear all
close all
clc
 
% engine parameters
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;
 
% input variables
p1 = 101325;
t1 = 500;
t3 = 2300;
gamma = 1.4;
 
% calculating stroke and clearance volume
v_s = (pi/4)*bore^2*stroke;
v_c = v_s/(cr-1);
 
% for point 1
v1 = v_s + v_c;             % t1 and p1 are inputs
k1 = p1*v1^gamma;           % pv^gamma = k (constant)
v_comp = piston_kinematics(bore,stroke,con_rod,cr,180,360);
p_comp = k1./(v_comp).^gamma;
 
% for point 2
v2 = v_c;
p2 = p1*(v1/v2)^gamma;      % since pv^gamma = k (constant)
t2 = (p2*v2*t1)/(p1*v1);    % ideal gas equation
 
% for point 3
v3 = v2;                    % t3 is an input
p3 = (p2*v2*t3)/(v3*t2);    % ideal gas equation
k2 = p3*v3^gamma;           % pv^gamma = k (constant)
v_exp = piston_kinematics(bore,stroke,con_rod,cr,360,720);
p_exp = k2./(v_exp).^gamma;
 
% for point 4
v4 = v1;
p4 = p3*(v3/v4)^gamma;      % since pv^gamma = k
t4 = (p4*v4*t3)/(p3*v3);    % ideal gas equation
 
% thermal efficiency
t_e = (1 - (v2/v1)^(gamma-1))*100;
 
% plotting the graph and points
hold on
plot(v1,p1,'*','color','r')         % point 1
plot(v_comp,p_comp,'color','b')     % adiabatic compression
plot(v2,p2,'*','color','r')         % point 2
line([v2 v3],[p2 p3],'color','b')   % isochoric combustion
plot(v3,p3,'*','color','r')         % point 3
plot(v_exp,p_exp,'color','b')       % adiabatic expansion
plot(v4,p4,'*','color','r')         % point 4
line([v4 v1],[p4 p1],'color','b')   % isochoric heat rejection
title('PV diagram of Otto cycle');  % labelling the plot
xlabel('volume');
ylabel('pressure');
xt = [v1 v2 v3 v4];
yt = [p1 p2 p3 p4];
str1 = {'1','2','3','4'};
text(xt,yt,str1);                   % labelling the points
str2 = ['Thermal Efficiency = ',num2str(t_e),' %'];
text(0.0004,5000000,str2);          % displaying the thermal efficiency on the plot

Function Code:

function [v] = piston_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)
 
r = con_rod*2/stroke;
 
v_s = (pi/4)*bore^2*stroke;             % swept volume
v_c = v_s/(cr-1);                       % clearance volume
 
theta = linspace(start_crank,end_crank,end_crank-start_crank);
 
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;      % variation of volume with theta
 
end

Code Explanation:

1. Clearing workspace and setting engine parameters and input variables. These can be changed as per the problem.

2. Calculating the stroke and clearance volume. These will be used to calculate the state variables.

3. Calculating the state variables for point 1, before start of compression stroke using adiabatic gas law.

4. Calculating the state variables during compression stroke by calling piston kinematics function and passing appropriate crank angles.

5. Calculating the state variables for point 2, at the end of compression stroke.

6. Calculating the state variables for point 3, before start of combustion stroke using ideal gas law.

7. Calculating the state variables during combustion stroke by calling piston kinematics function and passing appropriate crank angles.

8. Calculating the state variables for point 4, at the end of combustion stroke.

9. Calculating the thermal efficiency.

10. Plotting the individual points of all 4 states and labelling them.

11. Plotting the curve between points 1-2 and 3-4.

12. Labelling the plot appropriately.

13. Displaying the thermal efficiency on the plot using text function.

14. Function Explanation: The “piston_kinematics” function takes the engine parameters as inputs and calculates the variation of volume as the crank angle changes.

Errors:

Only typo errors were encountered which were resolved immediately.

Output:

The PV diagram for the Otto cycle was obtained with thermal efficiency as 62.9893 %.

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.