To plot the Otto cycle using MATLAB and find the thermal efficiency
AIR STANDARD CYCLE (OTTO CYCLE)
AIM
To plot the Otto cycle using MATLAB and find the thermal efficiency.
GOVERNING EQUATIONS
For Isentropic process 1-2:
`P_1 〖V_1〗^γ= P_2 〖V_2〗^γ`
For Isentropic process 3-4:
`(P_1 V_1)/T_1 =(P_2 V_2)/T_2`
Where numbers represent their states.
Assumptions:
- Specific Heat Ratio(γ) = 1.4
- Temperature after compression`(T_3) = 2500K`
- `P_1 = 101325K`
- `T_1 = 400K`
Geometric Assumptions:
- Bore Diameter = 0.5m
- Stroke = 0.5m
- Compression Ratio (CR) = 12
- Connecting Rod length = 0.25m
- V/= 1 + ½(CR – 1)[R + 1 – cos(θ) – `(R^2 - cos^2theta)^(1/2)`]
Where θ is crank angle
- Thermal efficiency = = 1 – 1/C`R^(gamma-1)`
OBJECTIVES OF THE PROJECT
- To plot the Otto cycle (Air standard cycle) for Pressure v/s Volume in MATLAB.
- To find thermal efficiency of the engine.
FLOW OF THE PROJECT
- Assume necessary geometric components and initial values of pressure of temperature.
- Calculate values of pressure and temperature at different stages of the cycle from 1 to 4 using governing equations of the different processes that are used.
- Plot the required graphs as mentioned in the objectives.
- Find the thermal efficiency.
MATLAB CODE
Code for the function used:
% Create a function whose output is V and input paraneters are bore,
% stroke length, connecting rod length, compression ratio, starting crank
% angle and ending crank angle
function [V] = engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank)
a = stroke/2;
R = con_rod/a;
% Swept volume and Clearance angle
v_s = pi/4*bore^2*stroke;
v_c = v_s/(cr-1);
% Defining array of angles for crank angle
theta = linspace(start_crank,end_crank,100);
% Dividing the equation for Volume into three terms
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 for main function:
clear all
close all
clc
% Inputs
gamma = 1.4
t3 = 2500
% State Variables at state point 1
p1 = 101325
t1 = 400
% Engine Geometric Parameters
bore = 0.5;
stroke = 0.5;
con_rod = 0.25;
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 = 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, 0, 180);
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 variable at state point 4
v4 = v1
%p3v3^gamma = p4v4^gamma | p4 = p3(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma
% Finding Thermal Efficiency
thermal_eff = 1 - (1/(cr^(gamma-1)));
final_eff = thermal_eff*100+"%"
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(V_compression, P_compression)
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot(V_expansion, P_expansion)
plot(v4,p4,'*','color','r')
plot([v2,v3],[p2,p3],'color','b')
plot([v4,v1],[p4,p1],'color','b')
figure(2)
plot([v1 v2 v3 v4],[p1 p2 p3 p4],'color','b')
Explanation of code:
- Assume parameters like specific heat ratio(gamma), temperature at state point 3 (after heat addition).
- Assume initial pressure, temperature and other geometrical parameters.
- Find swept volume and clearance volume to find value for by using the formula for volume of cylinder and clearance volume i.e., the volume at top dead centre.
- Find temperature and pressure at state point 2 by using he governing equations for isentropic process.
- Next, the function is called to find compression volume and pressure.
- Steps 4 and 5 are repeated for the process 3-4.
- Thermal efficiency is found out using the formula.
- Graph is plotted for Pressure v/s Volume and the required result is obtained.
Observation:
- Required plot is as below which shows the PV diagram for the Otto cycle (an air standard cycle)
- Thermal efficiency was found as shown below:
Errors faced:
- Did not maintain consistency while defining the function and using the same name in the formula for finding the volume. Defined the function as V and formula as Volume. Corrected it by changing the formula definition back to V.
- Forgot to define V_expansion and hence, P_expansion for the expansion process after state point 3 variable stating. Corrected it by defining the same.
Conclusion:
- PV diagram was plotted as asked in the challenge using MATLAB.
- Thermal efficiency was obtained as 62.9893%.