Otto Cycle P-V diagram
% plotting of pv diagram
clc
clear all
close all
%input Parameters
%pressure(bar) and temperature( 25 degree celcius) at point1
p1=1;
t1=273.15+25;
%max temperature attained during compression 500 degree c
t3=273.15+1800;
%gamma
y=1.4
stroke=0.2
bore=0.1
%compression ratio
cr=12
%connecting rod length (m)
conrod=0.3
crank_start=0
crank_end=180
%stroke volume(m^3)
vs=(pi/4)*stroke*bore^2
% clearence volume(m^3)
vc=vs/(cr-1)
%volumes calculation
%volume at point 1
v1=vs+vc
v2=vc
vcompress=engine_kinematics(conrod,stroke,bore,cr,crank_end,crank_start)
c1=p1*v1^y
%pressure and temperature at state point 2
pcompress=c1./vcompress.^y
p2=p1*cr^y
t2=t1*cr^(y-1)
%pressure ,volume at state point 3
p3=p2*t3/t2
v3=vc
%pressure ,volume and temperature at state point 4
v4=v1
vexpansion=engine_kinematics(conrod,stroke,bore,cr,crank_start,crank_end)
c2=p3*v3^y
pexpansion=c2./vexpansion.^y
p4=p3/cr^y
t4=t3/cr^(y-1)
hold on
plot(vcompress,pcompress)
plot([v2 v3],[p2 p3])
plot(vexpansion,pexpansion)
plot([v4 v1],[p4 p1])
title(\'P-V diagram\')
xlabel(\'Volume\')
ylabel(\'Pressure\')
thermal_efficiency=1-1/cr^(y-1)
DEFINED FUNCTION
function [V]=engine_kinematics(conrod,stroke,bore,cr,crank_start,crank_end)
%stroke volume(m^3)
vs=(pi/4)*stroke*bore^2
% clearence volume(m^3)
vc=vs/(cr-1)
theta=linspace(crank_start,crank_end)
r=stroke/2
R=conrod/r;
V=vc*(1+0.5*(cr-1)*(R+1-cosd(theta)-(R^2-(sind(theta)).^2).^0.5))
end
P-V DIAGRAM