Air standard Cycle using MATLAB
Objective: - Write MATLAB code that can solve or check the engine kinematics of an engine operating on the OTTO cycle and make plots for it. Create a PV diagram and also output the thermal efficiency of the engine.
Theory: - 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.
Processes: -
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 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.
Thermal efficiency (air-standard efficiency) of Otto Cycle: - Basic terms used in derivation of air-standard efficiency of Otto cycle:
Compression Ratio:
Compression ratio (r) is the ratio of total cylinder volume to the clearance volume.
Now that we know the basic terms, let us derive expressions for T2 and T3. These expressions will be useful for us to derive the expression for air-standard efficiency of Otto cycle. For finding T2, we take process 1-2 and for finding T3, we take process 3-4.
Process 1-2:
This process is an isentropic (reversible adiabatic) process. For this process, the relation between T and V is as follows:
Process 3-4:
This is also an isentropic process. The relation between T and V in this process is similar to the relation between T and V in process 1-2:
Here,
Air-standard efficiency of Otto cycle:
It is defined as the ratio between work done during Otto cycle to the heat supplied during Otto cycle.
Air-Standard Efficiency (thermal efficiency) of Otto cycle,
thermal eff. calculates by using different values of temperatures.
nth = Thermal efficiency and r = compression ratio.
The Geometric parameters of Engine: -
- bore = 0.1
- stroke = 0.1
- con_rod = 0.15 #connecting rod
- cr = 12 #compression ratio
- a = stroke/2 #crank pin radius
- R = con_rod/a
- gamma = 1.4
Inputs: -
State point 1: -
- p1 = 101325 #unit - pascal
- t1 = 500 #unit – kelvin
- v1 = v_swept + v_clearance (v_s is swept volume and v_c is clearance volume)
State point 3: -
- t3 = 2300 #unit – kelvin
The following equation shows the relationship between crank angle and volume inside the crank chamber: -
Formula for thermal efficiency: -
Coding: -
First we have to define a funtion named as engine kinematics:
function [V] = engine_kinematics(bore, stroke, con_rod, cr, start_crank, 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_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
Main code:
clear all
close all
clc
% Inputs
gamma = 1.4;
t3 = 2300;
% State Variables
p1 = 101325;
t1 = 500;
% Engine gepmetric 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 varaible 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, 180, 0);
P_compression = constant_c./V_compression.^gamma;
% State varaible 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 varaible at state point 4
v4 = v1;
% p3v3^gamma = p4v4^gamma | p4 = p3(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma;
% p4v4/t4 = p3v3/t3 | t4 = (p4*v4*t3)/(p3*v3)
t4 = (p4*v4*t3)/(p3*v3);
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(V_compression,P_compression,'color','b')
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot(V_expansion, P_expansion,'color','b')
plot(v4,p4,'*','color','r')
plot([v2 v3],[p2 p3],'color','b')
plot([v1 v4],[p1 p4],'color','b')
xlabel('Volume')
ylabel('Pressure')
title('OTTO CYCLE')
% Thermal efficiency
term4 = t4-t1;
term5 = t3-t2;
Thermal_efficiency = (1-(term4/term5))*100
Explanation:-
- First we have to define inputs like bore, stroke, connecting rod, compression ratio, gamma, and temp and pressure at state point 1 and temp at state point 3.
- Then by using the formul like p1v1^gamma = p2v2^gamma and ideal gas law p1v1/t1 = p2v2/v3. By using this equation we can find the other value of pressure, temp and volume at different state points.
- By this point we can plot the pv diagram, but the diagram is not accurate, all the lines are straight. For getting the accurate P-V diagram we have to use engine kinematics.
- We have to define a fuction called engine kinematics by this we can change the angle and find he actual volume in engine.
- In main code we call that fuction called engine kinematics, and find the the different vaule of volume at different angles for compression and expansion.
- By this we get accurate vaule of pressure, temp and volume at differnet state point from 1 to 4.
- By this point we get the accurate P-V diagram as shown belown in the results.
Result: -
P-V Diagram: -
Thermal efficiency is 62.9893
Conclusion: -The above Matlabcode was written to plot a P-V Diagram of the Air standard cycle or Otto Cycle and also calculates thermal efficiency of Otto cycle.
Thermal efficiency is 62.9893