Matlab Program to solve an Air Standard Cycle(Otto cycle)
Aim
To write a Program in Matlab that can solve an otto cycle and to make plots for it.
Objective:
- 1.The main objective is to write a code to create a PV diagram
- 2.To calculate the thermal efficiency of the engine.
Theory
An Internal combustion engine or heat engine works by using chemical energy i.e. fuel-air oxidation processes and these energies then converted into combustion inside the cylinder chamber which then create energy to operate mechanical components. All the combustion processes are depending upon the mixture of air-fuel.
IC engine is classified in different categories depending upon combustion, cycle, head design, fuel type, engine geometry size and stroke.
The main engine components are as piston, cylinder, crankshaft, connecting rod, valves, intake and exhaust system.
Otto Cycle:
Otto cycle is a process of gas compression into combustion processes, generally the mass of gas depends upon the changes of pressure, temperature, volume, the addition of heat, and removal of heat. During the combustion processes of gasoline or Otto cycle, it operates on the constant volume processes and at this time the combustion processes are so fast which depend upon the piston position.
Process involved:
- 1-2 isentropic compression process
- 2-3 constant volume heat addition process
- 3-4 isentropic expansion process
- 4-1 constant volume heat rejection process
Governing Equations:
Thermal efficiency,
Since remains constant and is independent of temperature,
In thermal efficiency,
State Point 1:
Initially the all required values (bore,stroke,connecting rod, and compression ratio etc.) taken.
State Point 2:
For the isentropic compression we know,
State Point 3:
At state point-3 the volume is constant (v3=v2)
State Point 4:
To check the change of volume inside the engine cylinder,
On substitution then, we get
Where,
p1,p2,p3 and p4 are the pressures at the states 1,2,3 and 4 respectively.
T1,T2,T3 and T4 are the Temperatures at the states 1,2,3 and 4 respectively.
v1,v2,v3 and v4 are the volumes at the states 1,2,3 and 4 respectively.
Software used:
MATLAB R2020(Online)
CODE:
%Matlab Program to solve an Air Standard Cycle(otto cycle)
clear all
close all
clc
%input values
bore= 1; %cylinder bore diameter
stroke=1; %stroke length
connecting_rod= 1.5; %length of connecting rod
gamma=1.4;
% compression ratio
cr = 8;
% swept volume
v_swept= pi/4*bore^2*stroke;
% clearance volume
v_clearance= v_swept/(cr-1);
% at state 1
p1 = 1000; %pressure(N/m^2)
t1 = 500; %Temperature(K)
v1 = v_clearance + v_swept;
v2 = v_clearance;
% Compression
p2 = p1*cr^gamma;
t2 = p2*v2*t1/p1*v1;
V_compression = engine_keinematics(bore, stroke, connecting_rod, cr, 180 , 0);
constant_c = p1* v1 ^gamma;
P_compression = constant_c./V_compression.^gamma;
% at state 2-3
v3=v2; %since constant volume process
t3 = 2000; %temperature after combustion
p3= p2*t3/t2;
% Expansion
constant_c = p3* v3 ^gamma;
V_expansion = engine_keinematics(bore, stroke, connecting_rod, cr, 0 ,180);
P_expansion = constant_c./V_expansion.^gamma;
v4 = v1; %since constant volume process
p4 = p3*(v3/v4)^gamma;
t4 = p4*v4*t3/p3*v3;
%Plotting
hold on
plot(v1,p1,'*','color','g')
plot( V_compression ,P_compression) %to plot the state 1-2
plot(v2,p2,'*','color','g')
plot(v3,p3,'*','color','g')
plot( V_expansion,P_expansion) %to plot the state 3-4
plot(v4,p4,'*','color','g')
plot([v2 v3],[p2 p3],'color','b') %to connect state 2-3
plot([v4 v1],[p4 p1],'color','b') %to connect state 4-1
xlabel('VOLUME')
ylabel('PRESSURE')
% Thermal Efficency
Th_eff = (1-(1/cr^(gamma-1)))* 100
Calling function:
% calling the function
function [V] = engine_keinematics(bore,stroke,connecting_rod,cr,start_crank,end_crank)
a = stroke/2; %crank pin radius
r = connecting_rod/a;
v_swept= pi/4*bore^2*stroke;
v_clearance= v_swept/(cr-1);
theta= linspace(start_crank,end_crank,720); %crank angle
term1 = 0.5*(cr-1);
term2 = r + 1 - cosd(theta);
term3 = (r^2 - sind(theta)).^0.5;
V = (1 + term1*(term2 - term3)).* v_clearance ;
end
Code Explanation:
1.Process (1-2) which is isentropic compression process and for that Swept volume & Clearance Volume of given engine geometry is need to calculated.Assuming the inlet conditions of pressure as 1000 N/m^2 and temperature as 500 K.
2.Respective formulae are used in the program to find pressure and temperature values at state 2
3.Now next step is to calculate for process 2-3 for Combustion , essentially constant volume heat addition. Heat addition by spark plug ignition at temperatures T2 to T3.
4.Assuming ‘t3’ to be 2000K. Basically Process 2-3 is the endpoint of the combustion process and for that v3 = v2(constant volume process), Here t3 is the temperature of combustion which is 200K at the end of combustion.
5.And the output value in the workspace for pressure and temperature is seen.Now we have to find the value for process 3-4 which is an adiabatic (isentropic) expansion. This can be calculated using Ideal gas law.
6.when we get this all data then we have to plot the graph.For plotting the figure, by using piston kinematics, we are going to plot a correct figure.
7.We have to under thermodynamics process during combustion.Piston kinematics is basically the reciprocating movement of the piston from TDC to BDC & BDC to TDC. So, we get the change of combustion process during the piston reciprocating.
8.Now using formula
using the formula, we can check the change of volume inside the engine cylinder.The formula broke into different terms so that it will be easy to code it.
In given program R is the ratio of connecting rod length to crankpin radius.Also “a’ is Stroke/2
9.Changing the value of 'theta' results in change in volume.If theta is 0 then the volume will be corresponding to clearance volume.If theta is 180 then this will be the sum of clearance volume and swept volume.
10.Now for plotting figure for theta vs volume,So a “function” is used.“engine_ kinematics” command is to recall the code.The important thing is to see the order of input values which will be same as “[v]= engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank)”
11.Another important factor is to write the file name same as the “function” name i.e engine_kinematics.Now final step is to create PV diagram of the Otto cycle.
12.Then compute the Volume compression, Volume expansion, Constant C value & P_compression.Finally the values are plotted respectively in a graph.
13.For thermal efficiency enter the formula in codes.
Output:
Errors faced:
1)
Mentioned the keyword 'xlabel' as "xlebel"
2)
Mentioned the variable 'gamma' as 'gama'
Conclusions:
Finally the thermal efficiency of a particular engine is 56.4725% after the calculation which is determined using MATLAB and the P-V plot is drawn. Thermal efficiency is an important factor for any engine. Similarly using programs like these the efficiency of the Diesel cycle and Dual cycle can also be calculated.