STUDY OF A AIR STANDARD CYCLE USING MATLAB PROGRAMMING
Aim of the Project:
To make a plot of Pressure vs Volume of Otto cycle and calculate the thermal efficiency using MATLAB.
Objectives:
- To write a MATLAB program to create a PV diagram of Otto Cycle.
- To calculate the thermal efficiency using MATLAB.
Theory:
Otto Cycle:
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines.
The processes are described by:
- Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
- Process 1–2 is an adiabatic (isentropic) compression of the charge as the piston moves from the bottom dead center (BDC) to top dead center (TDC).
- Process 2–3 is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead center. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.
- Process 3–4 is an adiabatic (isentropic) expansion (power stroke).
- Process 4–1 completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead center.
- Process 1–0 the mass of air is released to the atmosphere in a constant pressure process.
Fig: P-V diagram of Otto Cycle
Calculation of different parameters of the Otto cycle to be used the MATLAB program:
Engine Geometric Parameters:-
- Bore = 0.1m
- Stroke = 0.1m
- Connecting Rod Length = 0.15m
- Compression Ratio (CR) = 12
- Swept Volume = (π /4)*Bore2*Stroke
- Clearance Volume = Swept Volume / (CR-1)
Given Parameters:
- P1 = 101325 Pa
- T1 = 500 K
- T3 = 2300 K
- Gamma (ɣ) = 1.4
Parameters for State Point-1
- V1 = Swept Volume + Clearance Volume
- V2= Clearance Volume
Parameters for State Point-2
- (P2 V2) ɣ = (P1V1) ɣ
- P2 = P1 (V1/V2) ɣ
- T2 = P2V2T1 / P1V1
Parameters for State Point-3
- V3 = V2
- P3 = P2V2T3/T2V3
Parameters for State Point-4
- V4 = V1
- P4 = P3 (V3/V4) ɣ
Calculation of Thermal Efficiency Of Otto Cycle:
- Thermal Efficiency = 1-(1/CR (ɣ-1))
- % Thermal Efficiency = Thermal Efficiency* 100
Volume Trace = V/ Vc = 1 + ½(CR-1)*[R +1 – Cosϴ – (R2 – Sinϴ2) (1/2) ]
Where,
- a = Stroke/2
- R = connecting Rod length/a.
Code for the Function Called engine_kinematics_func (bore, stroke, con_rod, cr, statr_crank, end_crank) :
% Program to create a function to be called in the otto cycle program.
function [V] = engine_kinematics_func(bore, stroke, con_rod, cr, start_crank, end_crank)
% Crank Radius
a = stroke/2;
R = con_rod/a;
% Swept Volume
v_s = pi/4*bore^2*stroke;
% Clearance Volume
v_c = v_s/(cr-1);
% Crank Angle array over which the graph is plotted
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;
% Volume Trace
V = (1 + term1*(term2 - term3)).*v_c;
end
Explanation:
- To plot the perfect PV diagram we need to plot the curves in between the points.
- The curves need to follow the above function based on the Engine’s Piston Kinematics.
- The engine kinematics is given by the Volume Trace Formula as we mentioned above.
- Using this formula the function “engine_kinematics_func()” is written.
- This function depends on the various function inputs like Bore, Stroke, Connecting rod, Compression Ratio (CR), Starting crank angle, and Ending crank angle.
- This function is called in the main program according to the compression process and Expansion process while mentioning the correct function inputs.
MATLAB Codes for the main program:
% program to plot the P-V graph of Otto cycle and calculate Thermal Efficiency
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=p2v2t1/p1v1
t2= p2*v2*t1/(p1*v1);
constant_c = p1*v1^gamma;
v_compression = engine_kinematics_func(bore,stroke,con_rod,cr,180,0);
p_compression = constant_c./(v_compression.^gamma);
%State variables at state-3
v3=v2;
%p3v3/t3=p2v2/t2
p3=p2*v2*t3/(t2*v3);
constant_c = p3*v3^gamma;
v_expansion = engine_kinematics_func(bore,stroke,con_rod,cr,0,180);
p_expansion = constant_c./(v_expansion.^gamma);
% State variables at statepoint-4
v4=v1;
%p3v3^gamma= p4v4^gamma
p4=p3*(v3/v4)^gamma;
%Plotting the curves
figure(1)
hold on
title('Pressure vs Volume')
plot(v1,p1,'*','color','r')
plot(v_compression,p_compression,'color','blue')
plot(v2,p2,'*','color','r')
plot([v2,v3],[p2,p3])
plot(v3,p3,'*','color','r')
plot(v_expansion,p_expansion,'color','green')
plot(v4,p4,'*','color','r')
plot([v4,v1],[p4,p1])
xlabel('Volume')
ylabel('Pressure')
% Calculating the Thermal Efficiency
therm_e=1/cr^(gamma-1)
thermal_efficiency=1-therm_e
thermal_efficiency_percentage=thermal_efficiency*100
Explanation:
- First we put the Given input values i.e; Gamma, T3, P1, T1, The Engine geometric parameters like Bore, Stroke, Connecting rod length, Compression ratio.
- Then we put calculate the Swept Volume and Clearance Volume using the engine geometric parameters. V1 = Swept volume + Clearance volume
- Then The State variables for State -2 are found i.e; V2 = clearance volume.
- P2 and T2 are also calculated for state-2.
- The values of V_compression and P_compression are calculated using the engine kinematics function.
- Then the values for State variables at state point – 3 are calculated.
- V3 and P3 are calculated.
- V_expansion and P_expansion are calculated using the engine kinematics function.
- State variables at state Point-4 are calculated. P4 and V4 are calculated.
- While putting the Hold on command the plots for all the four points are written.
- The plots for P_compression and V_compression are written after the P1, V1 plot command.
- The plots for P_expansion and V_expansion are given after the P3, V3 plot command.
OUTPUT:
Plot for Pressure vs Volume:
Output for Thermal efficiency calculation:
Workspace Values:
Results and Conclusion:
As we can see in the above pictures it clearly shows the outputs of the MATLAB program, the output plot is the correct resemblance of the Otto cycle P-V curve, and the calculation of the thermal efficiency is also correctly shown by the program.
References: