To determine the Efficiency of Otto cycle, to plot PV diagram and the variation of Efficiency with compression ratio using MATLAB
AIM: To Write MATLAB code to solve and determine the efficiency of Otto cycle, to plot P-V diagram and to plot the variation of Efficiency with compression ratio.
PROCESS:
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 Otto cycle is a description of what happens to a mass of gas as it is subjected to changes of pressure, temperature, volume, the addition of heat, and removal of heat. The mass of gas that is subjected to those changes is called the system.
1) Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
2) Process 1–2 is an adiabatic (isentropic) compression `P V^γ=C` of the charge as the piston moves from bottom dead centre (BDC) to top dead centre (TDC).
Swept volume:
Volume swept by the piston from the bottom dead centre to top dead centre
`V_s=π/4`*(bore^2)*stroke`
Clearance volume:
`V_c= V_s/((γ-1))`
Volume occupied by the cylinder at Bottom dead centre:
`V_1=(V_s+V_c)`
Volume occupied by the cylinder at Top dead centre:
`V_2=V_c`
`P_2/P_1 = (V_1/V_2 )^γ=(cr)^γ` (to determine pressure at state 2)
`T_2/T_1 =(V_1/V_2 )^(γ-1)=(cr)^((γ-1))` (To determine temperature at state 2)
`(P_1 V_1)/T_1 =(P_2 V_2)/T_2` (Ideal gas equation)
3) Process 2–3 is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead centre. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.
`V_3=V_2` (to determine the volume at state 3)
`T_(3 )` temperature at end of combustion usually given (state 3)
`P_3/P_2 =T_3/T_2` (to determine pressure at state 3)
`Q_a=C_V (T_3-T_2)` (Heat added per unit kg at constant volume)
4) Process 3–4 is an adiabatic (isentropic) expansion `P V^γ=C`(power stroke).
`P_4/P_3 = (V_3/V_4 )^γ=(cr)^γ` (to determine pressure at state 4)
`T_4/T_3 =(V_3/V_4 )^(γ-1)=(cr)^((γ-1))` (to determine temperature at state 4)
`(P_(3 ) V_3)/T_3 =(P_4 V_4)/T_4` (Ideal gas equation)
5) 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 centre.
`V_4=V_1` (to determine the volume at state 4)
`Q_r=C_V (T_4-T_1)` (Heat rejected per unit kg at constant volume)
6) Process 1–0 the mass of air is released to the atmosphere in a constant pressure process.
- Engine kinematics:
The volume occupied by the cylinder at any instant is a function of the crank angle is given:
`V/V_c =1+1/2 (cr-1)*[R+1-cos(θ)-(R^2-sin(θ) ^2 )^(1/2)]`
This formula is derived from geometrical relationships.
This formula is used to determine the volume change during the isentropic compression and expansion
At `θ=0` we get `V = V_c`
At `θ=180` we get `V = (V_s+V_c)=V_1`
- Calculation of Efficiency:
Efficiency of otto cycle = (Work done / Heat added) * 100
Heat added at constant volume per unit mass = `Q_a=C_v (T_3-T_2 )`
Heat rejected at constant volume per unit mass = `Q_r=C_v (T_4-T_1 )`
Work done = `(Q_a-Q_r )=C_v (T_3-T_2 )-C_v (T_4-T_1 )`
`η=((Q_a-Q_r)/Q_a ) * 100` = `1-1/(cr)^(γ-1)`
OBJECTIVES:
- To solve and determine the Efficiency of the of Otto cycle.
- To plot P-V diagram.
- To analyse and plot Efficiency V/s compression ratio.
CODE:
%%%%%%%%%%%%%%%%%%%%%%%%%%% OTTO CYCLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all
clc
%input parameters
gamma=1.4; % Specific heat ratio
Cv = 0.718; % Specific heat at Constant volume [kJ/kg. K]
t3=2300; % Given value of temp at state 3 in [K]
bore= 0.1; % An engine's bore is the diameter of each cylinder [m]
stroke=0.1; % Stroke is the distance within the cylinder the piston travels [m]
crank_shaft_length=0.15; % Crank shaft length [m]
cr=12; % Compression ratio = (Volume at bottom dead center / Volume at top dead center)
%%%%%%%%%%%% state 1 %%%%%%%%%%
p1=101325; % p1=1atm = 101325 Pa given
t1=500; % t1=500K given
v_s= pi/4*bore^2*stroke; % swept volume [m^3]
%cr=v1/v2= (v_s+v_c)/v_c it is the ratio of the volume occupied by of cylinder at top dead center to volume occupied at top dead center.
%cr=(v_s/v_c)+1
%(cr-1)=(v_s/v_c)
v_c=(v_s)/(cr-1); %clearnace volume [m^3]
v1=v_s+v_c; %volume occupied at bottotm dead center
%%%%%%%%%%%% state 2 %%%%%%%%%%%
v2=v_c; %volume at state 2 - volume occupied at top dead center
%p1*v1^gamma=p2*v2^gamma;
%p2=p1*(v1/v2)^gamma;
p2=p1*(cr)^gamma; %pressure at state 2
%p1*v1/t1=p2*v2/t2 %using ideal gas equation
t2=p2*v2*t1/(p1*v1); %temperature at state 2
% we can also use to determine the value of t2
%t2/t1 = (v1/v2)^(gamma-1)
%t2=t1*(cr)^(gamma-1)
constant_c = p1 * v1^gamma;
v_compression = engine_kinematics(bore,stroke,crank_shaft_length,cr,180,0);
p_compression = constant_c ./ v_compression.^gamma;
%%%%%%%%%%%%%% state-3 %%%%%%%%%%%%%
v3 = v2; %since for the constant volume heat addition process
t3;
%p3/p2 = t3/t2
p3= (t3/t2)*p2;
%%%%%%%%%%%% state-4 %%%%%%%%%%%%%
v4 = v1; %constant volume heat rejection
%p4*v4^gamma = p3*v3^gamma;
p4 = p3*(v3/v4)^gamma;
%p3*v3/t3=p4*v4/t4 %using ideal gas equation
t4=p4*v4*t3/(p3*v3);
constant_c = p3 * v3^gamma;
v_expansion = engine_kinematics(bore,stroke,crank_shaft_length,cr,0,180);
p_expansion = constant_c ./ v_expansion.^gamma;
%%%% CALCULATION OF EFFICIENCY %%%%
% Efficiency_of_otto_cycle= ( Work done / Heat added );
% Efficiency_of_otto_cycle = (Qa-Qr)/(Qa) % Qa=heat_added and Qr=heat_rejected
Qa = Cv*(t3-t2); % Qa=heat_added at constant volume KJ/Kg
Qr = Cv*(t4-t1); % Qr=heat_rejected at constant volume KJ/kg
Work_done = (Qa-Qr) % Work done per unit mass
Efficiency_of_otto_cycle= ( Work_done / Qa )*100 % Efficiency of Otto cycle
% Efficiency_of_otto_cycle= 100*(1-(1/(cr)^(gamma-1))) %in terms of compression ratio
% plotting
hold on
figure(1)
plot(v_compression,p_compression,'r','linewidth',2);
plot([v2 v3],[p2 p3],'g','linewidth',2);
plot( v_expansion,p_expansion,'b','linewidth',2);
plot([v4 v1],[p4 p1],'m','linewidth',2);
text(v1,p1,'1');
text(v2,p2,'2');
text(v3,p3,'3');
text(v4,p4,'4');
xlabel('Volume [m^3]');
ylabel('Pressure [Pa]');
title('P-V Diagram');
legend('1-2 Isentropic compression','2-3 Constant volume heat addition','3-4 Isentropic expansion','4-1 Constant volume heat rejection')
%%%%%%%%%%%%%%%% COMPRESSION RATIO VS THERMAL EFFICIENCY %%%%%%%%%%%%%%%%%%
figure(2)
for cr_varying= linspace(2,12,500)
Efficiency_of_otto_cycle= 100*(1-(1/(cr_varying)^(gamma-1)));
hold on
plot(cr_varying,Efficiency_of_otto_cycle,'b.-')
xlabel('Compression Ratio (cr)');
ylabel('Efficiency [%]');
title('Compression Ratio V/s Efficiency');
end
hold off
CODE FOR FUNCTION USED:
function [V] = engine_kinematics(bore,stroke,crank_shaft_length,cr,crank_start_angle,crank_end_angle)
a = (stroke)/2; %crank_pin_radius = a
R = (crank_shaft_length)/a; %crank_shaft_length/crack_pin_radius
v_s = pi/4*bore^2*stroke; %swept volume
v_c = v_s/(cr-1); %clearnace volume
theta=linspace(crank_start_angle,crank_end_angle,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
PLOTS:
Pressure V/s Volume:
Efficiency V/s Compression ratio:
RESULT:
Explanation for Code:
- clc, clear all, and close all is used to start the code as it clears the command window, clears the variables from the workspace, and closes all the plot respectively.
- Gamma, Cv ,t3, bore, stroke, crankshaft length and compression ratio are given as inputs.
- The swept volume and the clearance volume are calculated from inputs using formulae.
- At state 1,2,3 and 4 the calculation for the pressure, volume and temperature is done using the formulas explained in PROCESS step
- The plot command is used to create a plot between pressure and volume for all the processes
- Text function is used to label the state points.
- Xlabel and ylabel functions is used to label the x and y-axis.
- Title function is used to give title for the plot
- Legend function is used to create legends for different processes
- In order to plot the variation between the compression ratio and efficiency of the Otto cycle for loop is used to plot the efficiencies at a different compression ratio
- cr_varying compression ratio array is created using lispace command first point as 2 and last compression ratio to be 12 and between the two 500 points were are created.
- The function code is used to determine the volume during the isentropic compression and isentropic expansion in order to plot exact the volume change Engine kinematics formula is used to determine the volume occupied by the cylinder at different crank angle positions.
- In creating the function, volume V is used as the output and the inputs used are bore, stroke, connecting rod length, compression ratio, crank start angle, and crank end angle.
ERRORS FACED AND STEPS TO OVERCOME THAT:
1) This error occurred because of using “^”and this error was solved by using “.^” to compute element wise power.
2) This error occurred because of using “/”and this error was solved by using “./”
CONCLUSION:
- In this project, I have learned to solve and determine the Efficiency of the of Otto cycle and to plot the P-V diagram. From code output results, we can see by increasing the compression ratio the amount of work done by cycle increases.
- From the plot Efficiency V/s compression ratio we can see that the Efficiency of the cycle increases as the compression ratio increases.