Matlab Program to Plot the P-V diagram for an Otto cycle based on the dimensions of Pulsar 220 cc bike.
AIM:
To understand and analyze the working of Otto cycle through Matlab program.
OBJECTIVE:
- To plot all the state points of the otto cycle.
- To obtain the P-V diagram.
- To calculate the efficiency of the cycle.
THEORY:
Otto cycle is also known as constant volume cycle is an air standard cycle on which the working of a petrol (Spark Ignition) engine is fully dependent. However, there is a vast difference between the Ideal Otto cycle and the actual Otto cycle due to the consideration of the external environmental factors and practical possibilities. But the Otto cycle is very essential to understand the working and also based on which the whole of the petrol engine technologies were developed.
MATLAB PROGRAM:
- The below program is to determine the cylinder volume(V) derived from the slider-crank model.
function [V] = Piston_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank)
a = stroke/2;
R = (con_rod/a);
%Calculation of swept volume and clearance volume
V_swept = (pi/4)*(bore^2)*(stroke);
V_clr = (V_swept)/(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_clr;
end
- The below program is used to obtain the plot of P-V diagram based on the formulas derived at various state points.
%Input
gamma = 1.2;
T3 = 2300;
%State Variables at State Point 1
P1 = 101325;
T1 = 500;
%Engine Dimension Parameters
bore = 0.067;
stroke = 0.0624;
con_rod = 0.107;
cr = 12.8;
a = 0.015;
%Calculation of swept volume and clearance volume
V_swept = (pi/4)*(bore^2)*(stroke);
V_clr = (V_swept)/(cr-1);
V1 = V_swept + V_clr;
V2 = V_clr;
%State Variables at State Point 2
%P1(V1^gamma) = P2*(V2^gamma)
%P2 = P1*(V1/V2)^gamma
P2 = P1*(cr)^gamma;
%(T1*(V1^(gamma-1))) = (T2*(V2^(gamma-1)))
%T2 = T1*((V1/V2)^(gamma-1))
T2 = T1*(cr^(gamma-1));
% (OR)
%(P1V1)/T1 = (P2V2)/T2
%T2 = ((P2*V2)/(P1*V1))*T1
constant = P1*(V1.^gamma);
V_compression = Piston_kinematics(bore, stroke, con_rod, cr,180,0);
P_compression = constant./(V_compression.^gamma);
%State Variable at State Point 3
V3 = V2;
%P3V3/T3 = P2V2/T2
P3 =(P2*V2*T3)/(T2*V3);
constant = P3*(V3.^gamma);
V_expansion = Piston_kinematics(bore, stroke, con_rod, cr,0, 180);
P_expansion = constant./(V_expansion.^gamma);
%State Variables at State Point 4;
V4 = V1;
er = (V4/V3);
%expansion ratio(er) = compression ratio(cr)
%P3(V3^gamma) = P4*(V4^gamma)
%P4 = P3*(V3/V4)^gamma
P4 = P3*(V3/V4)^gamma;
%(T3*(V3^(gamma-1))) = (T4*(V4^(gamma-1)))
T4 = T3*((V3/V4)^(gamma-1));
% (OR)
%(P3V3)/T3 = (P4V4)/T4
%T4 = ((P4*V4)/(P3*V3))*T3
%Efficiency of Otto Cycle
%Efficiency = (workdone/heat supplied) = cv((T3-T2)-(T4-T1))/cv(T3-T2)
%effi_otto = 1-((T4-T1)/(T3-T2))
%(OR)
effi_otto = 1-(1/cr.^(gamma-1));
%Plotting
plot([V1 V_compression V3 V_expansion V1], [P1 P_compression P3 P_expansion P1],'-r','LineWidth',3);
title("Otto Cycle")
xlabel('Volume (m^3)')
ylabel("Pressure (bar)")
EXPLANATION OF THE PROGRAM:
- The required inputs are typed in the program and based on the derivation and relations in Otto cycle the appropriate formulas are applied to calculate the unknown values like V1, V2, V3, V4, P2, P3, P4, T2, T3, T4.
- For obtaining the shape of an adiabatic process curve we have created a function V based on the geometry of the engine components and substituted the function in the original Otto cycle Program.
- After writing the appropriate form.ulas in correct Matlab syntax the program is executed.
ERRORS FACED WHILE EXECUTING THE ABOVE PROGRAMS:
- The error shown below is due to the difference in the number of opening parentheses and closing parentheses. In the below picture the opening parenthesis is one more than the closing parentheses. The error was rectified by making equal the opening and closing parentheses.
- The below error was the most difficult and confusing error for me to get recognised. Later I found with the help of [email protected] that the error was due to inclusion of clear and 'clc' command while declaring a new function [V]. The error was rectified by eliminating the clear and 'clc' commands.
- The below error occurred due to the mistake in the syntax of the equation in line 30. The unknown variable should be typed on the LHS and the variables whose values are known should be typed to the RHS. Since I did it in reverse manner the below error occurred. The error was later rectified by reordering the LHS and RHS accordingly.
RESULT:
The P-V diagram of the Otto Cycle for the given dimensions are obtained and also the Efficiency of the cycle could be calculated.
- Efficiency for the given values was found as, `eta` = 39.94%
THANK YOU