piston kinematics of an Otto cycle shown in P-V diagram and its Thermal Efficiency
P-V diagram of an otto cycle
%MatLab code for the piston kinematics of an otto cycle and also showing the different processes occuring inside of engine via P-V diagram and hence calculating the thermal efficiency of the otto cycle.
%input
p1=101325;
t1=500;
t3=2300;
gamma=1.4;
bore=0.1;
stroke= 0.1;
con_rod=0.15;
cr=12;
a = stroke/2;
R = con_rod/a;
v_s=(pi/4)*stroke*bore^2;
v_c=v_s/(cr-1);
v1=v_s+v_c;
v2=v_c;
%p1*v1^gamma = p2*v2^gamma, v1/v2 = cr;
p2 = p1*cr^gamma;
t2 = p2*v2*t1/(p1*v1);
theta1 = linspace(0, 180, 100);
term1 = 0.5*(cr-1);
term2 = R+1-cosd(theta1);
term3 = (R^2 - sind(theta1).^2).^0.5;
v_compression = (1+term1.*(term2 - term3)).*v_c;
constant_c = p1*v1^gamma;
p_compression = constant_c./(v_compression).^gamma;
v3 = v2;
p3 = p2*t3/t2;
theta2 = linspace(180, 0, 100);
term4 = 0.5*(cr-1);
term5 = R+1-cosd(theta2);
term6 = (R^2 - sind(theta2).^2).^0.5;
v_expansion = (1+term4.*(term5 - term6)).*v_c;
constant_c = p3*v3^gamma;
p_expansion = constant_c./(v_expansion).^gamma;
v4 = v1;
p4 = p3*(v3/v4)^gamma;
figure(1)
hold on
plot(v1,p1,'r*');
plot(v_compression,p_compression,'k');
plot(v2,p2,'b*');
plot([v2 v3],[p2 p3],'k');
plot(v3,p3,'g*');
plot(v_expansion,p_expansion,'k');
plot(v4,p4,'y*');
plot([v4 v1],[p4 p1],'k');
grid on
xlabel('volume');
ylabel('presure');
%thermal efficiency
n = 1 - 1/(cr)^(gamma-1)