Air Standard Cycle : Otto Cycle
Problem Statement :-
Write MATLAB code that can solve an Otto cycle and make plots for it.
Answer should include a PV diagram and Output the thermal efficiency of cycle.
Theory :-
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. Otto cycle is made up from four processes as shown in figure.
Process 1-2 Isentropic Compression Process
Process 2-3 Constant volume heat addition process
process 3-4 Isentropic Expansion Process
Process 4-1 Constant volume heat rejection process.
On this four processes an Otto cycle works.
Main Formula Used:-
For Isentropic process:-
`pv^gamma=constant`
Volume Trace :-
`V = (1 + {0.5*(cr-1)}{R + 1 - cosd(theta)- (R^2 -sind(theta)^2)^0.5}`
Theramal efficiency = `1- 1/(cr^(gamma-1))`
Procedure to create MATLAB program :-
- To plot the data on PV diagram first we define some data related to cycle and then calculate other required data.
- Let we assume that we already know following data i.e. P1 , T1 , T3, Bore diameter, Stroke Length, Connecting Rod Length, Compression ratio. We treat this data as predefine data.
- We also take some standard data i.g value of Gamma for air.
- After the defining all this data we will calculate other data using standard formulas.
- After calulation the various state data we use plot command to plot this data in graphical form.
- A function is created for calculation volume trace by using volume trace formula.
- All this data is ploted and get desire result.
- For more explanation kindly go throuth MATLAB codes.
MATLAB Codes : -
1. Following codes are use to plot the PV diagram and thermal efficiency.
% Air Standard Cycle : Otto Cycle Project
close all
clear all
clc
% Input
% Value of Gamma (for Air gamma value is 1.4)
gamma = 1.4 ;
% State number 1 variable
p1 = 101125 ;
t1 = 550 ;
% Assume that at the end of the combustion process temperature of charge is
% 2300 K, So we take it as an input
t3 = 2300 ;
% Engine Geometric Parameters
bore = 0.1; % Bore Diameter
stroke = 0.1; % Stroke Length
con_rod = 0.15; % Connecting Rod Length
cr = 12; % Compression Ratio
% Caculating the Swept volume and Clearance Volume
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);
% v1 is Total volume of Cylinder which is equal to the sum of Swept
% volume and Clearance volume
v1 = v_swept+v_clearance;
% v2 is volume at TDC position which is equal to clearance volume
v2 = v_clearance;
% Calculating State variable at state point 2
% Isentropic compression process from State 1 to state 2
% For Isentropic compression process {p1v1^gamma = p2v2^gamma}
% By above equation we get p2 = p1*(v1/v2)^gamma = p1*cr^gamma
% cr is known as (v1/v2)
p2 = p1*cr^gamma ;
% Using Ideal gas law { pv/t =constant }
% p1v1/t1 = p2v2/t2
% From above equation t2 = (p2*v2*t1)/(p1*v1)
t2 = (p2*v2*t1)/(p1*v1);
% It is known that for Isentropic compression process pv^gamma = constant
% Here calculating the constant c
constant_c = p1*v1^gamma;
% Compression Volume Trace through function calling
V_compression = engine_kinematics(bore, stroke, con_rod, cr, 180, 0);
% Compute pressure change with volume trace through equation pv^gamma =constant
P_compression = constant_c ./ (V_compression.^gamma);
% Calculating State variable at state point 3
% Constant volume heat addition process from State 2 to state 3
% Volume at state 2 is equal to volume at state 3
v3 = v2 ;
% Pressure at state 3 is determine by ideal gas law (pv/t =constant)
% p2v2/t2 = p3v3/t3
% From above equation p3 = p2v2t3/v3t2
p3 = p2*(t3/t2);
% Calculating State variable at state point 4
% Isentropic expansion process from State 3 to state 4
% Volume of state 4 is equal to volume of state 1
v4 = v1 ;
% It is known that for Isentropic expansion process pv^gamma = constant
% Here calculating the constant c
constant_c1 = p3*v3^gamma;
% Expansion Volume Trace through function calling
V_expansion = engine_kinematics(bore, stroke, con_rod, cr, 0, 180);
% Compute pressure change with volume trace through equation pv^gamma =constant
P_expansion = constant_c1 ./ (V_expansion.^gamma);
% For isentropic expansion process {p3v3^gamma = p4v4^gamma}
% By above equation we get p4 = p3*(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma ;
% Calculationg Thermal Efficiency of Cycle
% Formula used efficiency = 1- 1/(cr^(gamma-1))
efficiency = 1- 1/(cr^(gamma-1))
% Plot the Cycle
hold on
plot(v1,p1,'*','color','r');
plot(V_compression,P_compression)
plot(v2,p2,'*','color','r');
plot([v2 v2],[p2 p3]);
plot(v3,p3,'*','color','r');
plot(V_expansion,P_expansion)
plot(v4,p4,'*','color','r');
plot([v1 v1],[p4 p1]);
xlabel('volume');
ylabel('pressure');
title('Otto Cycle');
2. With this code a Function file is also required. For the function file following code is used. This file should be save as name "engine_kinematics.m" and should be save in same folder in which codes are saved. This function file gives volume trace.
function [V] = engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank)
crank = stroke/2; % Crank Radius
theta = linspace(start_crank,end_crank,100); % Crank Angle
R = con_rod / crank ;
% Caculating the Swept volume and Clearance Volume
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);
% Define the equation
% V = (1 + {0.5*(cr-1)}{R + 1 - cosd(theta)- (R^2 -sind(theta)^2)^0.5}
% Divide this equation in various term and then calculate
term1 = 0.5*(cr-1);
term2 = R + 1 - cosd(theta);
term3 = (R^2 - sind(theta).^2).^0.5;
V = ( 1 + term1*(term2 - term3)).* v_clearance;
end
Result :-
After the run the program following output of program is displayed.
1. PV plot
2. Thermal efficiency = 0.6299
which is equal to 62.99 %
Errors During Programming:-
During programmign main errors are arise due to case sensitivity of variable.
and Second proble arise in calling functions.
By the changing the variable first problem get resolved and second problem resolved by using proper calling variable in function.
END