Project

Otto Cycle

% P/V diagram of otto cycle

% Inputs
B = 0.45; %lenght of Bore in m
S = 0.5; %lenght of Stroke in m
R = 0.6; %lenght of Connecting Rod
Cr = 8; %Compression Ratio

% Volumes needed
Vs = (pi/4)*B*B*S;
Vc = Vs/(Cr-1);

%Point 1
P1 = 95000; %Pressure is in N/m^2
V1 = Vs + Vc;
T1 = 527;  %Initial Temperature is in Kelvin

%Point 2
P2 = P1*Cr^1.4;
V2 = Vc;
T2 = (P2*V2*T1)/(P1*V1);

Vcom = Vol_otto_cycle(B,S,R,Cr,180,0);
Pcom = P1*V1^1.4./Vcom.^1.4;

%Point 3
V3 = V2;
T3 = 10000; %Highest Temperature is in Kelvin
P3 = P2*T3/T2;

Vexp = Vol_otto_cycle(B,S,R,Cr,0,180);
Pexp = P3*V3^1.4./Vexp.^1.4;

%Point 4
V4 = V1;
P4 = P3*(V3/V4)^1.4;
T4 = (P4*V4*T3)/(P3*V3);

%Thermal Efficiency

TE = 1 - ((T4-T1)/(T3-T2))

%Figure
hold on
axis([0 0.1 -0.005*10^7 15*10^6])
grid on
plot(V1, P1, \'*\' ,\'color\',\'r\')
plot(Vcom, Pcom,\'color\',\'y\')
plot(V2, P2, \'*\' ,\'color\',\'r\')
plot([V2, V3],[P2, P3],\'color\',\'b\')
plot(V3, P3, \'*\' ,\'color\',\'r\')
plot(Vexp, Pexp,\'color\',\'y\')
plot(V4, P4, \'*\' ,\'color\',\'r\')
plot([V4, V1],[P4, P1],\'color\',\'b\')

Function 2

function [V] = Vol_otto_cycle(B,S,R,Cr,s,e)

% P/V diagram of otto cycle

% Inputs
a = S/2;
r = R/a;

% Volumes needed
Vs = (pi/4)*B*B*S;
Vc = Vs/(Cr-1);
x = linspace(s,e,100); %angle 

t1 = 0.5*(Cr-1);
t2 = r+1-cosd(x);
t3 = (r^2-sind(x).^2).^0.5;

V = (1+t1*(t2-t3)).*Vc;
end

Plot

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.