otto cycle
clear all
close all
clc
%inputs
gamma=1.4
t3=2500
% state variable at point1
p1=101325
t1=500
%engine geometry parameter
bore=0.1
stroke=0.1
con_rod=0.15
cr=12
a=stroke/2
R=con_rod/a
%calculating swept 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
p2=p1*cr^gamma
t2=p2*v2*t1/p1*v1
%state variable at point 3
v3=v2
p3=p2*t3/t2
%state variable at point 4
v4=v1
p4=p3*(v3/v4)^gamma
%inputs 2
theta= linspace(0,180,100)
term1=0.5*(cr-1)
term2= R+1-cosd(theta);
term3=(R^2-sind(theta)^2)*0.5;
V=(1+term*(term2-term3))*v_c
figure(1)
hold on
plot([v1 v2 v3 v4],[p1 p2 p3 ],\'color\',\'r\')
thermal_efficiency =1-(t4-t1)/(t3-t2)