Program to plot P-V Diagram of an Otto cycle and calculate Thermal Efficiency using Matlab
Aim: To plot P-V Diagram of an Otto cycle and calculate Thermal Efficiency using Matlab
Otto Cycle
The Otto Cycle is a four-stroke cycle for internal-combustion engines of the type used in automobiles wherein the first stroke consists of the suction into the cylinder of the explosive charge (as gas and air), the second stroke consists of the compression, ignition, and explosion of the charge, the third stroke consists of the expansion of the gases, and the fourth stroke consists of the expulsion of the products of combustion from the cylinder.
Engine Geometric Parameters:
1.)Bore 2.)Stroke 3.)Connecting Rod length
4.)Compression Ratio
Code 1:
Inputs:
Engine Parameters
p1,v1,t1
gama and t3
%otto Cycle
clear all
close all
clc
%Engine Parameters
bore=0.1;
stroke=0.1;
cr_length=0.15;
cr=12 %compression ratio=v1/v2
%Inputs
p1=101325;
t1=500;
gama=1.4;
t3=2300;
%Volume Calculation
swept_vol=pi*(bore^2/4)*stroke;
clerance_vol = swept_vol/(cr-1);
v1=swept_vol + clerance_vol
v2=clerance_vol
%state variable at pt 2
p2=p1*cr^gama
t2=p2*v2*t1/(p1*v1)
%change in volume in Compression Stroke
V_compression=otto_cycle_volume_change(bore,stroke,cr_length,cr,180,0)
const_c=p1*v1^gama;
p_compression=const_c./V_compression.^gama;
%state variable at pt 3
v3=v2
%p3v3/t3=p2v2/t2 | p3=p2*t3/t2
p3=p2*t3/t2
%change in volume in Expansion/Power Stroke
V_expansion=otto_cycle_volume_change(bore,stroke,cr_length,cr,0,180)
const_c=p3*v3^gama;
p_expansion=const_c./V_expansion.^gama;
%state variables at pt 4
v4=v1
%p4v4^gama=p3v3^gama | p4=p3*v3^gama/v4^gama
p4=p3*v3^gama/v4^gama
figure(1)
hold on
title('Otto Cycle PV Diagram')
xlabel('Volume(v)')
ylabel('Pressure(p)')
plot(v1,p1,'*','color','r')
plot(V_compression,p_compression,'linewidth',1.5,'color','k')
plot(v2,p2,'*','color','r')
plot([v2,v3],[p2,p3],'linewidth',1.5,'color','k')
plot(v3,p3,'*','color','r')
plot(V_expansion,p_expansion,'linewidth',1.5,'color','k')
plot([v4,v1],[p4,p1],'linewidth',1.5,'color','k')
plot(v4,p4,'*','color','r')
%Calculating Thermal Effeciency
%(p1*v1)/t1=(p4*v4)/t4 | t4=((p4*v4)*t1)/(p1*v1)
t4=((p4*v4)*t1)/(p1*v1)
thermal_eff=(1-((t4-t1)/(t3-t2)))*100
Result: In the above code firstly swept volume and clearance volume are calculated, pressure volume and tempratures values at various points are derived using formulaes.
Points are marked at end of each stroke and plots are drawn. Code 2 uses function operator and that function is called in code 1 to calculate change in volume in compression and expansion stroke as shown above.
Code 2:
function[v]=otto_cycle_volume_change(bore,stroke,cr_length,cr,start_crankang,end_crankang)
a=stroke/2;
R=cr_length/a;
theta=linspace(start_crankang,end_crankang,100);
swept_vol=pi*(bore^2/4)*stroke;
clerance_vol = swept_vol/(cr-1);
t1=0.5*(cr-1);
t2=R+1-cosd(theta);
t3=(R^2-sind(theta).^2).^0.5;
v=(1+t1*(t2-t3))*clerance_vol;
end
Thermal Efficiency is calculated using tempratures as inputs as in above code,Thermal Efficiency is calculated to be 62.9893 percent with above values as input.