Air Standard Cycle
To write a program to create a PV diagram for the Otto Cycle and calculate the thermal efficiency of the engine.
Code for PV Diagram of Otto Cycle:
%Otto Cycle in MATLAB
%Engine Parameters
Bore = 0.1;
Stroke = 0.1;
Con_Rod = 0.15;
Cr = 12;
%State Variables Inputs
P1 = 1;
T1 = 500;
T3 = 2000;
x = 1.4;
%Calculating Swept Volume
V_s = (pi/4)*Bore^2*Stroke; %Volume of Piston
V_c = V_s/(Cr-1);
V = V_s + V_c;
%State Variables Outputs
%State Point 1 (1-2: Isentropic Compression Process)
V1 = V_s + V_c;
Const = P1*V1^x;
V_Compression = Engine_Kinematics(Bore,Stroke,Con_Rod,Cr,180,0);
P_Compression = Const./(V_Compression.^x);
%State Point 2 (1-2: Isentropic Compression Process)
%P1*V1^x = P2*V2^x;
V2 = V_c;
P2 = P1 * (V1/V2)^x;
%P1*V1/T1 = P2*V2/T2;
T2 = P2*V2*T1/(P1*V1);
%State Point 3 (2-3: Constant Volume Heat Addition Process)
V3 = V2;
%P2*V2/T2 = P3*V3/T3;
P3 = P2*V2*T3/(T2*V3);
Const = P3*V3^x;
V_Expansion = Engine_Kinematics(Bore,Stroke,Con_Rod,Cr,0,180);
P_Expansion = Const./(V_Expansion.^x);
%State Point 4 (3-4: Isentropic Expansion Process)
%P3*V3^x = P4*V4^x;
V4 = V1;
P4 = P3 * (V3/V4)^x;
%P3*V3/T3 = P4*V4/T4;
T4 = P4*V4*T3/(P3*V3);
%plot([V1 V2 V3 V4], [P1 P2 P3 P4]);
figure (1)
hold on
plot (V1,P1);
plot (V_Compression, P_Compression);
plot ([V2 V3],[P2 P3]);
plot (V2,P2);
plot (V3,P3);
plot (V_Expansion, P_Expansion);
plot ([V4 V1],[P4 P1]);
plot (V4,P4);
xlabel('Volume')
ylabel ('Pressure')
grid on;
T_eff = (1-(T1/T2))*100
Code for Engine Kinematics Function:
%Piston Kinematics using Functions
function [V] = Engine_Kinematics(Bore,Stroke,Con_Rod,Cr,Start_Crank,End_Crank)
r = Stroke/2;
R = Con_Rod/r;
V_s = (pi/4)*Bore^2*Stroke;
V_c = V_s/(Cr-1);
%Engine Kinematics Governing Equation:
% V/V_c = 1 + 0.5*(Cr-1)[R+1-cosd(y) - (R^2 - (sind(y))^2)^0.5];
y = linspace(Start_Crank,End_Crank,50);
Term1 = 0.5*(Cr-1);
Term2 = R+1-cosd(y);
Term3 = (R^2 - sind(y).^2).^0.5;
V = (1 + Term1.*[Term2-Term3]).*V_c;
end
Report for the Code of the Project:
Theory:
Air Standard Cycles work on assumptions and are different from the Actual Cycles.
Assumptions:
Gas mixture is air.
Air properties are used.
Closed cycle is assumed instead of the actual open cycle.
Almost constant pressure intake and exhaust processes are replaced by perfectly constant pressure intake and exhaust.
Compression and Expansion strokes are isentropic.
All processes are reversible.
Otto Cycle:
0-1: Intake Stroke.
1-2: Compression Stroke.
2-3: Combustion Process (Const. Vol. Heat Addition).
3-4: Expansion Stroke (Power Stroke).
4-1: Heat Rejection.1-0: Exhaust at Constant Pressure.
Thermodynamic Relations for all the processes:
0-1 Intake Stroke:
P1 = P0.
1-2 Isentropic Compression Stroke:
Q1-2 = 0.
P2/P1 = (V1/V2)^k.
T2/T1 = (V1/V2)^(k-1).
2-3 Constant Volume Heat Addition:
V2=V3.
T3= Tmax.
P3 = Pmax.
3-4 Isentropic Expansion Stroke:
Q3-4 = 0. P4/P3 = (V3/V4)^k.
T4/T3 = (V3/V4)^(k-1).
4-1 Constant Volume Heat Rejection:
V4 = V1.
1-0 Exhaust at Constant Pressure:
P0 =P1.
Inputs Given for the Otto Cycle are as follows:
State Variables:
P1 = 1 atm.
T1 = 500 K.
γ = 1.4
Engine Parameters:
Bore = 0.1 m.
Connecting Rod Length = 0.15 m.
Stroke = 0.1 m.
Compression Ratio = 12.
Engine Kinematics:
Swept Volume = (π/4)*(bore)^2*stroke
Clearance Volume = V_Swept/(CR-1)
Governing Equation for piston kinematics:
V/Vc = 1 + 0.5(CR-1)[R + 1 -cosϴ -(R^2 –(sinϴ)^2)]
Calculations of State Variables:
State Point 2:
1-2 : Isentropic Compression
P1(V1)γ = P2(V2)γ
P1V1/T1 = P2V2/T2
State Point 3:
2-3 : Constant Volume Heat Addition
V2 = V3
T3 = 2000 K
P2V2/T2 = P3V3/T3
P3 > P2
State Point 4:
3-4 : Isentropic Expansion P4(V4)γ = P3(V3)γ
Code for P-V Diagram:
%Otto Cycle in MATLAB %
Engine Parameters
Bore = 0.1;
Stroke = 0.1;
Con_Rod = 0.15;
Cr = 12;
%State Variables Inputs
P1 = 1; # Pressure at the beginning of the Compression Stroke, P1 = 1 bar (Given).
T1 = 500; # Temperature at the beginning of the Compression Stroke, T1 = 500 K (Given).
T3 = 2000; # Temperature at the end of Combustion Process, P1 = 2000 K (Given).
x = 1.4; # Ratio of Specific Heats = 1.4.
%Calculating Swept Volume
V_s = (pi/4)*Bore^2*Stroke; # Equation to Calculate the Swept Volume.
V_c = V_s/(Cr-1); # Relation between Swept Volume and Clearance Volume.
V = V_s + V_c; #Equation for the Total Volume.
%State Variables Outputs
%State Point 1 (1-2: Isentropic Compression Process)
V1 = V_s + V_c; #Equation for the Total Volume.
Const = P1*V1^x; #Equation for Isentropic Compression Process.
V_Compression = Engine_Kinematics(Bore,Stroke,Con_Rod,Cr,180,0);
#Calling the function Engine_Kinematics to calculate the compressed volume at different positions of the Crank. The output values of the function are stored in an array V_Compression.
P_Compression = Const./(V_Compression.^x);
#Code to calculate the pressure at different positions of the Crank.
%State Point 2 (1-2: Isentropic Compression Process)
%P1*V1^x = P2*V2^x;V2 = V_c;
#Volume at state point 2 is equal to the Clearance Volume.
P2 = P1 * (V1/V2)^x;
#Equation for Isentropic Compression Process.
%P1*V1/T1 = P2*V2/T2;T2 = P2*V2*T1/(P1*V1);
#Code to calculate the temperature at State Point-2.
%State Point 3 (2-3: Constant Volume Heat Addition Process)
V3 = V2; #Volume at the end of Combustion process is equal to the Volume at the beginning due to Constant Volume heat addition.
%P2*V2/T2 = P3*V3/T3;
P3 = P2*V2*T3/(T2*V3); #Code to calculate the pressure at the end of the Combustion process.
Const = P3*V3^x; #Equation for Isentropic Expansion process.
V_Expansion = Engine_Kinematics(Bore,Stroke,Con_Rod,Cr,0,180);
#Calling the function Engine_Kinematics to calculate the volume after expansion at different positions of the Crank. The output values of the function are stored in an array V_Expansion.
P_Expansion = Const./(V_Expansion.^x);
%State Point 4 (3-4: Isentropic Expansion Process)
%P3*V3^x = P4*V4^x;V4 = V1;
#Volume at the end of Expansion process is equal to the Volume at the beginning due to Constant Volume heat rejection.
P4 = P3 * (V3/V4)^x;
#Code to calculate the pressure at the end of the Expansion process.Const = P3*V3^x; #Equation for Isentropic Expansion process.
%P3*V3/T3 = P4*V4/T4;T4 = P4*V4*T3/(P3*V3);
#Code to calculate the temperature at State Point-4.
%plot([V1 V2 V3 V4], [P1 P2 P3 P4]);
figure (1) #Code to create figure windows for all the conditions
hold on #Using hold on to generate all the plots for all the conditions.
plot (V1,P1); #Plotting the State Point 1.
plot (V_Compression, P_Compression); #Plotting the graph to describe the Isentropic Compression process.
plot ([V2 V3],[P2 P3]); #Plotting the graph to describe the combustion process at constant volume.
plot (V2,P2); #Plotting the State Point 2.
plot (V3,P3); #Plotting the State Point 3.
plot (V_Expansion, P_Expansion); #Plotting the graph to describe the Isentropic expansion process.
plot ([V4 V1],[P4 P1]); #Plotting the graph to describe the heat rejection process at constant volume.
plot (V4,P4); #Plotting the State Point 3.
xlabel('Volume') # x- label for the plot.
ylabel ('Pressure') # y- label for the plot.
grid on; #Switching On grid on the plot.
T_eff = (1-(T1/T2))*100 #Code to calculate the thermal efficiency of the engine.
Code for Engine Kinematics:
%Piston Kinematics using Functions
function [V] = Engine_Kinematics(Bore,Stroke,Con_Rod,Cr,Start_Crank,End_Crank)
#Code for calling the function Engine_Kinematics amd providing the required inputs as the arguments.
r = Stroke/2; #Relation for Crank Pin Radius.
R = Con_Rod/r; #Relation for ratio of Connection Rod to Crank Pin Radius.
V_s = (pi/4)*Bore^2*Stroke; #Equation to calculate the Swept Volume.
V_c = V_s/(Cr-1); #Equation to calculate the Clearance Volume.
%Engine Kinematics Governing Equation:
% V/V_c = 1 + 0.5*(Cr-1)[R+1-cosd(y) - (R^2 - (sind(y))^2)^0.5];
y = linspace(Start_Crank,End_Crank,50);
#Using linspace command to create 50 values between start crank angle and end crank angle.
Term1 = 0.5*(Cr-1); #Term 1 for Governing Equation.
Term2 = R+1-cosd(y); #Term 2 for Governing Equation.
Term3 = (R^2 - sind(y).^2).^0.5; #Term 3 for Governing Equation.
V = (1 + Term1.*[Term2-Term3]).*V_c;
#Equation to calculate the total volume using the governing equation.
end #End of Engine Kinematics function.
Errors during Coding:
Error: Missing . operation for multiplication of array.
Steps to overcome the error:
Including the dot operator for array multiplication.
Output of the Code: