
% for ploting a otto cycle PV diagram it is necessary to calculate
% temp,pressure and volume at each state of cycle, finding these variable
% at four points,isentropic compression and isentropic expansion derivative
% was carried out with formula [V/Vc]=1+0.5(r^2-1)[R+1-cos theta-(R2-sin^2
% theta)^0.5]
% For finding relation between pressure ,temp, volume at different points
% "Combined gas law" [P1V1/T1]=[P2V2/T2] equation was used.
% programming for ploting PV curve for Otto cycle
clear all
close all
clc
% assign inputs values
p1=101325;
t1=500;
bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=12;
gamma= 1.4;
t3 = 2300;
% Calculating swept volume & Clearance volume
v_swept=(pi/4)*bore^2*stroke;
v_clearence=v_swept/(cr-1);
v1=v_swept+v_clearence
v2=v_clearence
% state variable at point 2
% p2v2^gamma=p1v1^gamma | p2=p1*cr^gamma
p2=p1*cr^gamma;
% for calculating temperature at state 2
% p1v1/t1=p2v2/t2 | t2=p2*v2*t1/(p1*v1)
t2=p2*v2*t1/(p1*v1);
% PV=nRT we require implementation od constant
constant_c1=p1*v1^gamma;
%calling a function of engine kinematics
v_compression=engine_kinematics(bore,stroke,con_rod,cr,180,360);
p_compression=constant_c1./v_compression.^gamma;
% state varibale for point 3
v3=v2
% p3v3/t3=p2v2/t2 | p3=p2*t3/t2
p3=p2*t3/t2;
% state value at point 4
v4=v1;
% p3v3^gamma=p4v4^gamma by whuch below expression came
p4=p3*(v3/v4)^gamma;
%t4=(p4*v4*t3)/(p3*v3)
t4=(p4/p1)*t1;
% PV=nRT we require implementation od constant
constant_c2=p3*v3^gamma;
%calling a function of engine kinematics
v_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180);
p_expansion=constant_c2./v_expansion.^gamma;
figure(1)
hold on
plot(v1, p1, '*','color','r')
plot(v_compression, p_compression, 'linewidth',3)
plot(v2, p2, '*','color','r')
plot(v3, p3, '*','color','r')
plot(v_expansion, p_expansion, 'linewidth',3)
plot(v4, p4, '*','color','g')
plot([v2 v3], [p2 p3], 'color','y', 'linewidth',3)
plot([v1 v4], [p1 p4], 'color', 'b', 'linewidth',3)
xlabel('Volume')
ylabel('Pressure')
% Theorotical p-V diagram
figure(2)
plot([v1 v2 v3 v4 v1], [p1 p2 p3 p4 p1], 'color', 'b')
xlabel('Volume')
ylabel('Pressure')
% Calculting thermal Efficiency of otto cycle.
% we will be using t4,t1 & t2 t3 ratio
etta_efficiency= 1-((t4-t1)/(t3-t2));
% in percentage
etta = etta_efficiency * 100;