Air Standard Cycle
Otto cycle is an idealised thermodynamic cycle which describes the functioning of a spark ignition piston engine or petrol engine. There are 4 stages in the cycle & are as follows;
1-2 - isentropic compression,
2-3 - isochoric compression,
3-4 - isentropic expansion,
4-1 - isochoric expansion.
With help of following formulas, we are able to obtain the required values. They are;
swept volume=(pi/4)*bore^2*stroke,
clearance volume=swept volume/(compression ratio-1)
All the state points were calculated using the below relations;
(Pi*Vi^gamma)=(Pj*vj^gamma)
(Pi*Vi/Ti)=(Pj*Vj/Tj)
V/Vc=1+0.5(rc-1)[R+1-cosθ-(R^2-sinθ^2)^0.5]
Wnet/Qin=1-((t4-t1)/(t3-t2)
The following program is written to obtain the required PV Diagram & thermal efficiency value of the system.
otto_main.m
clear all %1%
close all
clc
p1=101325; %2%
t1=500;
bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=12;
gamma=1.4;
t3=2300;
v_swept=(pi/4)*bore^2*stroke; %3%
v_clearance=v_swept/(cr-1); %4%
v1=v_swept+v_clearance; %5%
v2=v_clearance; %6%
p2=p1*cr^gamma;
t2=(p2*v2*t1)/(p1*v1);
c1=p1*v1^gamma; %7%
V_compression=engine_kinematics(bore,stroke,con_rod,cr,v_clearance,180,0);
P_compression=c1./V_compression.^gamma;
v3=v2; %8%
p3=p2*t3/t2;
v4=v1; %9%
p4=p3*(v3/v4)^gamma;
t4=(p4*v4*t3)/(p3*v3);
c2=p3*v3^gamma; %10%
V_expansion=engine_kinematics(bore,stroke,con_rod,cr,v_clearance,0,180);
P_expansion=c2./V_expansion.^gamma;
figure(1) %11%
hold on
plot(v1,p1,'*','color','k')
plot(v2,p2,'*','color','k')
plot(v3,p3,'*','color','k')
plot(v4,p4,'*','color','k')
plot(V_compression,P_compression,'color','r')
plot(V_expansion,P_expansion,'color','r')
plot([v2 v3],[p2 p3],'color','r')
plot([v4 v1],[p4 p1],'color','r')
hold off
xlabel('Volume')
ylabel('Pressure')
title('P-V Diagram')
Values=[1 p1 v1 t1;2 p2 v2 t2;3 p3 v3 t3;4 p4 v4 t4]; %12%
ColumnNames={'state_point','pressure(Pa)','volume(m^3)',' temperature(K)'}; %13%
T=table(Values(:,1),Values(:,2),Values(:,3),Values(:,4),'VariableNames',ColumnNames); %14%
disp(T);
eeta=(1-((t4-t1)/(t3-t2)))*100 %15%
fprintf('The thermal efficiency=%d',eeta); %16%
engine_kinematics.m
function V=engine_kinematics(bore,stroke,con_rod,cr,v_clearance,start_crank,end_crank) %1%
a=stroke/2; %2%
R=con_rod/a;
theta=linspace(start_crank,end_crank,100); %3%
term1=0.5*(cr-1); %4%
term2=R+1-cosd(theta);
term3=(R^2-sind(theta)).^0.5;
V=(1+term1*(term2-term3)).*v_clearance; %5%
end
Step-wise Explanation;
otto_main.m;
1- The first 3 lines are used to clear the previous values, to avoid inaccurate values.
2 - The next few lines are used to provide the required inputs for the program.
3 - This line is used to calculate the swept volume value.
4 - This line is used to calculate the clearance volume.
5 - This line provies the initial volume at stage 1 as pressure & temperature at stage 1 are given.
6 - The next few lines provide the pressure,volume & temperature values at stage 2.
7 - The next few lines are used to obtain the isentropic compression curve as P*V^gamma = Constant with help of calling a function.
8 - The next few lines provide the pressure & volume value at stage 3.
9 - The next few lines provide the pressure,volume & temperature value at stage 4.
10 - The next few lines are used to obtain the isentropic expansion curve as P*V^gamma = Constant with help of calling a function.
11 - The next few lines are used to generate a P-V diagram representing the otto cycle.
12 - This line is used to create array with the pressure,volume & temperature values.
13 - This line is used to generate the colume names.
14 - This line is used to generate a table with the values obtained.
15 - This line is used to calculate the thermal efficiency.
16 - This line is used to print the thermal efficiency value.
engine_kinematics.m
1 - This line is used to create a function for Volume compression & expansion.
2 - The next 2 lines provides the required inputs to solve the volume formula.
3 - This line creates the array of angle values.
4 - The next few lines provide the formula to solve the volume formula.
5 - This line helps the function to obtain the calculated value of volume.
The error faced during the programming;
The table of values wasn't generated.
The thermal efficiency value wasn't generated with the statement.


Steps taken to overcome the error;
The 'VariableNames' string was missing the table creation line & the same was added before the ColumnNames.
Instead of printf, fprintf was implemented to obtain the thermal efficiency value with statement.
Output;

