writing a program on Otto cycle using MATLAB Programming
Aim :Writing a program on OTTO cycle
1.create a plot on PV diagram
2. Thermal Efficiency of the otto cycle
Introduction :

Process:
0-1 is suction process
1-2 is Isentropic compression
2-3 is constant volume heat Addition
3-4 is Isentropic expansion
4-1 is Constant volume heat rejection
1-0 is exhaust process
Thermal Efficeiency:

Software Used : MATLAB Programming
% for create a PV diagram on otto cycle we need Pressure and volume at respected stages
% Assuming Engine Geometric Parameters:
1.bore = 0.1m;
2.stroke = 0.1m;
3.Correcting rod length = 0.15m;
4.Compression ratio = cr = 14;
5.Pressure at stage 1= p1 =1.01235pa
6.Temparature at stage 1= T1 = 500K
7.Peak Temperature at stage2 = T3 = 2300K
8. Gamma= 1.4;
Relations:
PV^gamma = c
PV = MRT
Program:
% otto cycle Progamming
clear all
close all
clc
% inputs
gamma = 1.4;
% Assuming P1, T1 values
p1 = 1.01325
t1 = 500
% Assuming Engine Geometric Parameters
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr =14;
% calculating the Swept volume and clearance volume
v_swept = (pi/4)*bore^2*stroke
v_clearance = v_swept/(cr-1)
v1 = v_swept + v_clearance
v2 = v_clearance
% Process 1-2 Isentropic compression
% p2*v2^gamma = p1*v1^gamma
% p2 = p1*(v1/v2)^gamma
p2 = (p1*v1/v2)^gamma
% P1V1/T1 = P2V2/T2
% T2 = (P2*V2/(P1V1))*T1
t2 = (p2*v2*t1/(p1*v1))
v_compression = piston_kinematics(bore,stroke,con_rod,cr,180,0);
constant_c = p1*v1^gamma;
p_compression = constant_c./v_compression.^gamma
% 2-3 Constant volume Heat addition
% Assuming t3 is peak temperature = 2300K
t3 = 2300;
v3 = v2
p3 = p2*t3/t2
v_expansion = piston_kinematics(bore,stroke,con_rod,cr,0,180);
constant_c = p3*v3^gamma;
p_expansion = constant_c./v_expansion.^gamma
% 4-1 constant volume heat rejection
v4 = v1
% P3*V3^gamma = P4*V4^gamma
p4 = p3*v3^gamma/v4^gamma
% Thermal effecincy
efficiency = 1-1/cr^(gamma-1)
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(v_compression,p_compression,'color','b')
plot(v2,p2,'*','color','r')
plot([v2,v3],[p2 p3],'color','b')
plot(v3,p3,'*','color','r')
plot(v_expansion,p_expansion,'color','b')
plot(v4,p4,'*','color','r')
plot([v4 v1],[p4 p1],'color','b')
xlabel('volume')
ylabel('pressure')
grid on
Function Script:
% Otto-Cycle Kinematics of piston
function [v] = piston_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank)
crank_pin_radius = stroke/2;
r = con_rod/crank_pin_radius;
v_swept = (pi/4)*bore^2*stroke
v_clearance = 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_clearance;
end
Output:
Thermal efficiency =
0.6520
PV diagram:

Conclusion:
The termal effeciency of a otto cycle is 65.20% as per the given inputs