PV Diagram of an Otto Cycle and Thermal Efficiency of the engine
Aim: To Plot the PV diagram for an Otto Cycle and calculate the thermal efficiency of the engine.
Theory:
The Otto Cycle which is also called the 'Constant-Volume' cycle has been used in engines such as petrol, gas, and many other types of oil engines. These are the following processes which take place in the constant volume process:
From the figure shown above, we can concur that at point 1 the cylinder is full of air with Volume 1, pressure p1, and temperature T1.
The Line 1-2 represents the adiabatic compression of air due to which p1, V1 and T1 changes to
p2, V2, and T2, respectively.
In the Line 2-3, we can observe that there is a constant volume process (v2 = v3) and the heat addition takes place and the pressure and temperature also increase from p2 to p3 and t2 to t3, respectively.
Line 3-4 represents the adiabatic expansion of air which results in the change of the parameters from p3,v3,t3 to p4,v4, and t4. Because of the expansion process the volume tends to increase and the pressure reduces.
Line 4-1 represents the rejection of heat at constant volume (v4 = v1) and the further reduction in pressure and temperature from p4 to p1 and t4 to t1, respectively.
Process 1-2: Isentropic Compression
Process 2-3: Constant Volume Heat Addition
Process 3-4: Isentropic Expansion
Process 4-1: Constant Volume Heat Rejection
Formula:
The following formulae used which coding the program are mention below:
Program:
Primary Code:
clear all
clear 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 the 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 = p2/v2/t2 | t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1);
constant_c = p1*v1^gamma;
V_compression = engine_kinematics(bore, stroke, con_rod, cr, 180,0);
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 = engine_kinematics(bore, stroke, con_rod, cr, 0,180);
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;
% Thermal Efficiency of the engine
Thermal_efficiency = (1-(1/(cr^(gamma-1))))*100
% Plotting the PV diagram
hold on
figure (1)
plot(v1,p1,'.','color','r')
plot(V_compression,P_compression,'linewidth',1.2)
plot(v2,p2,'.','color','r')
plot([v2 v3],[p2 p3],'linewidth',1.2)
plot(v3,p3,'.','color','r')
plot(V_expansion,P_expansion,'linewidth',1.2)
plot(v4,p4,'.','color','r')
plot([v4 v1],[p4 p1],'linewidth',1.2)
xlabel('Volume')
ylabel('Pressure')
In the code above we have provided the pre-defined inputs and parameters to the MatLab which will be executed when the code is run and there are no user-defined inputs here. Then, the code is written for the formulae which are mentioned in the above section. Similarly, the code has also been written for the pressure, volume at different points in the PV diagram. The expressions for the curve when there are adiabatic compression and expansion are also written. In the end code for the thermal efficiency is also written from the formula mentioned above. The crank angle is considered to be from 0 to 180 because when the expansion happens the piston movement takes place from the BDC to TDC and similarly, for the compression the movement takes place from TDC to BDC so the angle changes from 180 to 0.Then we plot the graph for the curve and the lines which are represented on the graph along with their labels.
Code for the function named engine_kinematics:
function [V] = engine_kinematics(bore, stroke, con_rod, cr, start_rod, end_crank)
a = stroke/2;
R = con_rod/a;
v_s = pi/4*bore^2*stroke;
v_c = v_s/(cr-1);
theta = linspace(start_rod,end_crank,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
In this code, we write the function which is used in the primary code existing in another file which contains the parameters which are input to this function when it is called. Here, the following code from the above-mentiond formulae is written. The formula for volume is divided into three terms and then they are combined in the variable 'V'. The coders also have to be careful and wary of naming the file the same as the function which is used, without which the program may shout an error. Then we save this file and execute the file where the primary code exists.
Errors Observed:
Error 1:
This error has occurred because we are not passing any arguments in the function because it has many parameters in it such as bore, stroke, con_rod, and so on as mention in the above code. So to resolve this problem run or execute the code from the primary code section and not the function code because when you run the primary code it has values which are already declared by the coder which get passed as arguments in the function when it is called in this section, i.e the primary code.
Error 2:
This is a really common mistake that most coders commit because here there's no use of '.' so when the compiler tries to run the code it displays the error. Because the variables in MatLab store data in the form of matrices so when we perform operations they don't happen element-wise so to correct that we use the '.' ahead of the operator to solve the issue.
Result:
The thermal efficiency of the engine is calculated to be 62.9893 as shown above.
This is the plot of the PV diagram which is observed after executing the program.