PV diagram and thermal efficiency of otto cycle
clear all
close all
clc
%Inputs of the required values
p1 = 101325;
t1 = 500;
gamma = 1.4;
t3 = 2300;
%Engine geometric parameters
bore = 0.1;
stroke = 0.1;
con_rod =0.15;
cr = 12;
%Calculating swept volume, clearance volume and total cylinder volume
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);
v1 = v_swept + v_clearance;
v2 = v_clearance;
%Piston Kinematics
function [V] = engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank);
v_s = (pi/4)*bore^2*stroke;
v_c = v_s/(cr-1);
y = stroke/2;
R = con_rod/y;
theta = linspace(start_crank,end_crank,100);
x1 = 0.5*(cr-1);
x2 = R + 1 - cosd(theta);
x3 = (R^2 - sind(theta).^2).^0.5;
V = (1 + x1*(x2 - x3)).*v_c;
end
%Calculations at state point 1
constant_c = p1*v1^gamma;
v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0);
p_compression = constant_c./v_compression.^gamma;
%Calculation of pressure and temperature at state point 2
p2 = p1*cr^gamma;
t2 = p2*v2*t1/(p1*v1);
%Values of parameters at state point 3
v3 = v2;
p3 = p2*t3/t2;
%Calculation of volume and pressure during expansion stroke
constant_c1 = p_expansion*v_expansion^gamma;
v_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180);
p_expansion = constant_c./v_expansion.^gamma;
%Determining values at state point 4
v4 = v1;
p4 = p3*(v3/v4)^gamma;
t4 = p4*v4*t3/(p3*v3);
%Thermal Efficiency of the otto cycle
x = (t4-t1)/(t3-t2);
TE = 1-x;
%plotting
hold on
plot(v1,p1,\'*\',\'color\',\'r\')
plot(v_compression,p_compression,\'color\',\'r\')
plot(v2,p2,\'*\',\'color\',\'r\')
plot(v3,p3,\'*\',\'color\',\'r\')
plot([v2 v3],[p2 p3],\'color\',\'b\')
plot(v_expansion,p_expansion,\'color\',\'b\')
plot(v4,p4,\'*\',\'color\',\'r\')
plot([v4 v1],[p4 p1],\'color\',\'b\')
grid on