OTTO CYCLE GRAPH
ERRORS DURING PROGRAMMING:
Function calling ; was not used. Error was thrown and ; was later added to code.
Graph was found to be wrong. Error was later found in PV=C
PV=C was used instead of P*V^gamma =C
Plot command was wrongly coded by me. Line is drawn between two points. My input was v1,p1. so it is not a line. It is dot. hence output didn't come.
Plotting was wrong. Instead of plotting v3,v4 and p3,p4
i wrongly plotted v2,v3 and p2,p3. Also Wrong in usage of formula p*V=C instead of p*v^gamma
SOURCE CODE:
clear all;
close all;
clc;
%parameters
stroke = 0.15;
bore = 0.1;
con_rod = 0.45;
cr = 11;
%constant
gamma = 1.4;
%state_variables
p1= 101325; % in pascal
t1 = 300; % in kelvin
t3 = 2000; % in kelvin
% process 1 - 2:
%p1*v1^gamma = p2*v2^gamma !! p2 = p1 * (v1/v2)^gamma !! p2=p1*(cr)^gamma
p2 = p1*(cr)^gamma
%volume calculation
v_s = ((pi/4)*(bore^2)*(stroke)) % in m^3
v_c = v_s / (cr - 1);
v2 = v_c;
v1 = v_s + v_c;
% p1*v1/t1 = p2*v2/t2 !! t2 = p1*v1*t1 / p2*v2
t2= (p2*v2*t1)/(p1*v1)
%pv=constant
c2= p2*(v2^gamma);
v_comp = piston(bore,stroke,con_rod,cr,180,0);
p_comp = c2./((v_comp).^gamma)
% state variable 2-3; v2=v3
p3 = p2*(t3/t2);
v3 = v2;
c3=p3*(v3^gamma);
v_e = piston(bore,stroke,con_rod,cr,0,180);
p_e = c3./((v_e).^gamma)
% state variable 3-4;
v4 = v1;
p4 = p3*((v3/v4)^gamma);
%p3*v3/t3 = p4*v4/t4
t4= (p3*v3*t3)/(p4*v4);
efficiency = 1 - 1/(cr^(gamma-1))
hold on;
plot(v1,p1,'*','color','r')
plot(v_comp,p_comp)
plot(v2,p2,'*','color','b')
plot([v2 v3],[p2 p3])
plot(v3,p3','*','color','g')
plot(v_e,p_e)
plot(v4,p4,'*','color','b')
plot([v4 v1],[p4 p1])
xlabel("Volume inside cylinder in cubic meter");
ylabel("Pressure inside cylinder in Pascal");
gtext("OTTO CYCLE P-V DIAGRAM")
%FUNCTION CODE
function [V] = piston(bore,stroke,con_rod,cr,start_angle,end_angle)
v_s = (pi/4)*(bore^2)*stroke;
v_c = v_s/(cr-1);
theta = linspace(start_angle,end_angle,180)
a=stroke/2;
R= con_rod/a;
term1= 0.5*(cr-1);
term2= R +1 - cosd(theta);
term3= (R^2 - sind(theta).^2).^ 0.5;
V =(1+term1*(term2-term3)).*v_c;
end
HOW CODE WORKS:
Initially basic parameters like Pressure , Temperature at state 1, Compression ratio , Cylinder bore and its stroke length were declared.
Using formulae, Swept volume and clearance volume are determined from which Volume at state 1,2 were found.
State 1-2:
P2 is found using P2*V2^GAMMA = P1*V1^GAMMA, where V1/V2 = COMPRESSION RATIO.
Using p2*v2/t2 = p1*v1*/t1 , t2 is found.
State 2-3:
since v2=v3 ( constant volume heat addition ), p2/t2 = p3/t3 is used to determine either Pressure or temperature at state 3 ( after combustion ).Here T3 is value is taken , hence P3 was found using above formula.
state 3-4:
P4 is found using P3*V3^GAMMA = P4*V4^GAMMA, P4 was found , since v4 = v1 ( constant volume heat rejection )
Function was created to determine volume trace during compression and expansion.
Bore, stroke , compression ratio , crank starting and ending angle were passed as parameter.
Inside function, using relation between volume trace vs clearance volume and based on angle swept, connecting rod length & compression ratio
Volume trace array was determined for every degree movement of crankshaft during compression and expansion.
Function name and program name were same so that value is passed from function to main program.
Volume trace was returned to main program and for every angle of crankshaft rotation , pressure inside cylinder during Isentropic compression and expansion was determined using PV^gamma =C.
The same was plotted in graph.
Efficiency was found using formula: 1-(1/(CR^(gamma-1)))