Week 2 Air standard Cycle
% define the function to calculate volume
function[func]= engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)
a = sroke/2;
R= con_rod/a
v_swept=(pi/4)*bore^2*stroke;
v_clearance=v_swept/(cr-1);
theta= linspace(start_crank,end_crank,100);
term1= 0.5*(cr-1);
term2= R+1-cosd(theta);
term3= (R^2-sind(theta)^2)^0.5;
v_trace= (1+term1*(term2-term3))*v_clearnce;
end
% main console
clear all
clase all
clc
% Input Parameters
% temperatures(in kelvin)
t1=600
t3=2400
% pressure(in Pa)
p1=101325
gamma=1.4
% engine geometric parameters
bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=12;
%swept_volume and clearance_volume
v_swept=(pi/4)*bore^2*stroke;
v_clearance=v_swept/(cr-1);
v1= v_swept+v_clearance;
v2= v_clearance;
% calculating the state variables at point 2
p2= p1*cr^gamma;
t2= t1*cr^(gamma-1);
v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0);
constant_compression= p1*v1^gamma;
p_compression= constant_compression/(v_compression.^gamma);
% calculating state variablesat point 3
v3=v2;
p3=p2*t3/t2;
% calculating the state variables at point 4
v4=v1;
p4 = p3*(1/cr)^(gamma-1);
t4 = t3*(1/cr)^(gamma-1);
v_expansion= engine_kinematics(bore,stroke,con_rod,cr,0,180);
constant_expansion= p3*v3^gamma;
p_expansion = constant_expansion./(v_expansion.^gamma);
% calculating efficiency
thermal eficiency = 1-{(t4-t1)/(t3-t2)}
% plotting
figure(1)
hold on
plot(v1,p1,\'*r\')
plot(v2,p2,\*b\')
plot(v3,p3,\*g\')
plot(v4,p4,\*r\')
plot(v_compression,p_compression)
plot([v2 v3], [p2 p3])
plot(v_expansion, p_expansion)
plot( [v4 v1], [p4,p1])
xlabel("volume");
ylabel("pressure")