-Go back home-

DEfusination

Theoretical Otto Cycle Calculation SOURCE CODE

clearvars
clc
disp('Theoretical Otto Cycle calculation by Kerem İnce - built 18.06.2024')
z=input('Amount of cylinders=');
d=input('Cylinder diameter(mm)=');
lk=input('Stroke length(mm)=');
rv=input('Comp ratio=');
t3=input('Max cycle temperature(K)=');
n=input('Max engine speed(rpm)=');
nm=input('Mechanical efficiency(%)=');
d=d/1000;
lk=lk/1000;
p1=100;
t1=295;
cv=0.718;
r=0.287;
k=1.4;
f=1/2;
nm=nm/100;

%%calc start
vk=((pi*d^2)/4)*lk;
liter=vk*1000*z;
cc=vk*1000000;
cc=liter*1000;
v2=vk/(rv-1);
v1=v2+vk;
m=(v1*p1)/(r*t1);
p2=(p1*v1^k)/v2^k;
t2=((v1/v2)^(k-1))*t1;
p3=p2*(t3/t2);
v3=(r*t3*m)/p3;
t4=t3*((1/rv)^(k-1));
p4=p3*(1/rv)^k;
v4=(r*t4*m)/p4;
%%nt is Thermal Efficiency
nt=1-(1/(rv^(k-1)));
w12=(m*r*(t1-t2))/(k-1);
w34=(m*r*(t3-t4))/(k-1);
q23=m*cv*(t3-t2);
q41=m*cv*(t4-t1);
wnet=w34-w12;
qnet=q23-q41;
acp=qnet/vk;
pmi=qnet/vk;
%%pip is induced power
pip=(pmi*pi*d^2*lk*f*n*z)/(4*60);
pe=pip*nm;

%%sheet prep
nt=nt*100;
pe=pe*1.34102209;
pip=pip*1.34102209;


%%datasheetstart
Strokes=[1;2;3;4];
Pressure=[p1;p2;p3;p4];
Temperature=[t1;t2;t3;t4];
Volume=[v1;v2;v3;v4];
StrokesData = table(Strokes,Pressure,Temperature,Volume)
disp('Engine Displacement(Liters & CC):')
disp(liter)
disp(cc)
disp('Thermal Efficiency(%):')
disp(nt)
disp('Average induced cycle pressure(kPa):')
disp(acp)
disp('Induced Power(HP):')
disp(pip)
disp('Effective Power(HP):')
disp(pe)