Calculation of Thermal Efficiency and plotting the Pressure Vs Volume diagram for an Otto cycle Engine using MATLAB
Calculation of Thermal Efficiency and Plotting Pressure Vs Volume for an Otto Cycle Engine:
This Project deals with the plotting P Vs V diagram and calculating the thermal efficiency of Otto cycle engine using MATLAB.
Pressure Vs Volume Plot:
Thermal Efficiency:
Code 1: Function code for volume change during compression and expansion strokes
% To calculate volume during compression and expansion
function [V] = piston_kinematics(bore,stroke,cond_rod,cr,start_crank,end_crank)
a = stroke/2;
R = cond_rod/a;
v_s = pi/4*bore^2*stroke;
v_c = v_s/(cr-1);
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;
V = (1+ term1*(term2-term3)).*v_c;
end
Code 2: Main code for calculating Thermal efficiency and plotting the P Vs V plot
clear all
close all
clc
% Calculation of Thermal Efficiency and Plotting p-v diagram for Otto cycle
% Inputs
gamma = 1.4;
t3 = 2300;
% State variables
p1 = 101325;
t1 = 500;
% Engine geometric parameters
bore = 0.1;
stroke = 0.1;
cond_rod = 0.15;
cr = 6;
% 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 = p2v2/t2 t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1);
constant_c = p1*v1^gamma;
v_compression = piston_kinematics(bore,stroke,cond_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 = piston_kinematics(bore,stroke,cond_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;
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(v_compression, p_compression)
plot(v2,p2,'*','color','r')
plot([v2 v3],[p2 p3],'color','b')
plot(v3,p3,'*','color','r')
plot(v_expansion, p_expansion)
plot(v4,p4,'*','color','r')
plot([v4 v1],[p4 p1],'color','g')
xlabel('Volume')
ylabel('Pressure')
% Thermal Efficiency = 1-(1/cr^(gamma-1))
Thermal_Efficiency = (1-(1/cr^(gamma-1)))*100;
Detailed Report for the code written:
For Code 1:
- This is basically a function code written so that it can be called in the main code and utilise there.
- This is for calculating the volume change during the compression and expansion strokes i.e Isentropic processes.
- A formula which is derived from geometric properties of the engine is used i.e
- V/V_c =1+ 1/2(cr-1)[R+1-cos theta-(R^2-sin^2theta)^1/2]
By calling this function in main code we can plot the exact phenomena of volume change that occur during the compression and expansion strokes.
For Code 2:
- This is the main code and as usual the required inputs have to be provided such as p1, t1, bore, stroke, connecting rod length, compression ratio etc..
- Then inorder to plot the Pressure Vs Volume diagram we need the state conditions and for that the swept volume and clearance volume are calculated.
- By using the isentropic process equation and ideal gas equation all the state points are calculated and figure was plotted.
- But to get the exact and correct p-v diagram the function code that was kept aside is called and p-v diagram was plotted.
Lastly, by using the formula of Thermal Efficiency for Otto cycle Engine the Efficiency was calculated.
Output Screenshot:
----------THE END ----------