Project

P-V Diagram visualizer for otto cycle

clc
clear all
close all

%inputs
p1 = 101325;
t1 = 500;
gamma = 1.4;
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;

%calculations
vs = (pi/4) * bore * bore * stroke;
vc = vs / (cr -1);

%point1
p1 = 101325;
t1 = 500;
v1 = vc + vs;
constant1 = p1 * v1^gamma;

%point2
p2 = p1 * (cr^gamma);
v2 = vc;
t2 = (p2 * v2 * t1)/(p1 * v1);
v_compression = engine_kinematics(stroke,bore,con_rod,cr,180,0);
p_compression = constant1 ./ v_compression.^gamma;

%point3
t3 = 2300;
v3 = v2;
p3 = (t3 * p2)/t2;
constant2 = p3 * v3^gamma;

%point4
v4 = v1;
p4 = p3 * ((v3 / v4)^gamma);
t4 = p4 * t1 / p1;
v_expansion = engine_kinematics(stroke,bore,con_rod,cr,0,180);
p_expansion = constant2 ./ v_expansion.^gamma;

%plot
figure(1);
hold on;
plot(v1,p1,\'*\',\'color\',\'r\');
plot(v_compression,p_compression);
plot(v2,p2,\'*\',\'color\',\'r\');
plot(v3,p3,\'*\',\'color\',\'r\');
plot(v_expansion,p_expansion);
plot(v4,p4,\'*\',\'color\',\'r\');
plot([v2 v3],[p2,p3]);
plot([v4 v1],[p4,p1]);
xlabel(\'volume\');
ylabel(\'pressure\');
efficiency = (1 - ((t4-t1)/(t3-t2))) *100

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.