NOTE: This model treats TDC as 180[degrees] and BDC as 0[degrees]. Highlighted Inputs are
those that will need to be changed.
1.)
%Engine Inputs
These are the known engine inputs. The bore, stroke, and connecting rod lengths are used to
calculate the engine displacement and other parameters. The theta values will be altered to
determine the ideal spark advance.
2.)
%Fuel Inputs
AF_ratio = 14.7; %Actual Air Fuel Ratio Of CFR During Testing [unitless]
lambda = 1; %Excess Air Coefficient [unitless]
LHV = 44.6e6; %Lower Heating Value Of Fuel Mixture [J/kg]
eta_comb = .95; %Assumed Combustion Efficiency
These are the fuel inputs. These values should be known based on the type of fuel, test results,
etc. The combustion efficiency should be changed based on intuition.
3.)
%Atmospheric Inputs
The atmospheric inputs should be changed based on the elevation, temperature, etc. at the
point of testing. The wall temperature is assumed in this code, but there are several methods
for predicting the wall temperature based on the equivalence ratio (if interested, look these up
online).
4.)
This section of code uses test values to predict the specific heats ratio as a function of
temperature. These coefficients have been obtained experimentally.
5.)
This block of code sets initial array values at zero. This speeds up the code and sets initial
conditions.
6.)
Because the initial conditions are already set, the loop runs between 2 and 360 (the first loop is
specified in the initial conditions). The first portion of this block of code specifies the different
crank angles, the volume, and the heat transfer surface area.
7.)
If-then statements specify conditions in which the piece of code should operate. In this case,
the burn fraction and fuel mass equations wont calculate unless the crank angle falls within a
certain criteria (between burn initiation and the final degree of burning).
8.)
This piece of code says that the temperature and pressure only change when the intake and
exhaust valves are closed.
9.)
A large portion of last part of the loop is used to calculate the specific heats ratio. This adds
complexity to the code, but also makes the code much more accurate. All that needs to be
known here is that the specific heats ratio decreases with increased temperature (this can
change peak temperature/pressure predictions by several hundred units).
Indicated torque, indicated power, indicated mean effective pressures, etc. are all based on the
equations found in the Heywood book. Strange multiplication factors in the plot statements are
simply conversion factors between English and metric systems.
30
20
10
Power [hp]
-10
-20
15
10
5
Torque [lbf*ft]
-5
-10
The indicated power is the value that occurs at 360[degrees]. This plot was found through
integration (integral of PdV). The exact value can be found by viewing element 360 in the
W_dot array (in the MATLAB workspace). The indicated torque can be found the same way.
Any variable can be found next to the MATLAB command window. The indicated torque
(torque), indicated power (W_dot), and indicated mean effective pressure (imep) can be found
in this menu.
clear all;
close all;
clc;
%__________________________________________________________________________
%Engine Inputs
%__________________________________________________________________________
%__________________________________________________________________________
%Fuel Inputs
AF_ratio = 14.7; %Actual Air Fuel Ratio Of CFR During Testing [unitless]
lambda = 1; %Excess Air Coefficient [unitless]
LHV = 44.6e6; %Lower Heating Value Of Fuel Mixture [J/kg]
eta_comb = .95; %Assumed Combustion Efficiency
%__________________________________________________________________________
%Atmospheric Inputs
%__________________________________________________________________________
%__________________________________________________________________________
%__________________________________________________________________________
for i = 2:360
%_______________________________________________________________________
if theta<theta_0
X(i)=0;
else
X(i) = 1-exp(-5*((theta(i)-theta_0)/theta_b)^3);
end
%__________________________________________________________________
%Solves For Injected Mass Of Fuel During Combustion
if theta_0< theta(i)
if theta(i) < theta_f
M_F(i) = V(theta_0-1)*P_overRT(theta_0-1)/(lambda*AF_ratio);
end
end
%______________________________________________________________________
%______________________________________________________________________
%______________________________________________________________________
%Returns Temperature Values To Beginning Of Loop
T(i) = T(i-1)+DT(i);
%Calculates Cylinder Work [J] As A Function Of Crank Angle
W(i) = W(i-1)+P(i)*DV(i);
%Calculates Power [kW] As A Function Of Crank Angle
W_dot(i) = N_cyl*(W(i)*N)/1000;
%Indicated Mean Effective Pressure
imep = W_dot(360)*N_r*1000/(V_d*1000*N);
%Calculates Torque[N*m] As A Function Of Crank Angle
Torque(i) = (W_dot(i)*1000)/(2*pi*N);
%Calculates Heat Loss [kW] As A Function Of Crank Angle
Q_dot(i) = N_cyl*Q(i)*N/1000;
%______________________________________________________________________
% The Following Section Of Code Calculates An Updated Value Of Gamma
% Using The "Polynomial Method" Developed By Krieger-Borman
% User Of This Code Must Be Careful Because Accuracy Of This Method
% Drops As The Fuel Mixture Becomes Increasingly Rich
%__________________________________________________________________________
%Plot Statements
figure(1)
plot(theta,X)
title('Mass Fraction Burned Vs. Theta')
xlabel('theta[deg]')
ylabel('Mass Fraction Burned (%)')
axis([0 360 -.1 1.1])
figure(2)
plot(theta,V)
title('Volume Vs. Crank Angle')
xlabel('theta[deg]')
ylabel('Volume [m^3]')
axis([0 360 v_min v_max])
figure(3)
plot(theta,P*.000145037738)
title('Cylinder Pressure Vs. Crank Angle English')
xlabel('theta[deg]')
ylabel('Pressure [psi]')
axis([0 360 p_min*0.000145037738 p_max*0.000145037738])
figure(4)
plot(theta,T)
title('Cylinder Temperature Vs. Crank Angle')
xlabel('theta[deg]')
ylabel('Temperature [K]')
axis([0 360 T_min T_max])
figure(5)
plot(theta,W_dot*1.3402209)
title('Power Vs. Crank Angle (English)')
xlabel('theta[deg]')
ylabel('Power [hp]')
axis([0 360 P_min*1.3402209 P_max*1.3402209])
figure(6)
plot(theta,Torque*0.737562149277)
title('Torque Vs. Crank Angle (English)')
xlabel('theta[deg]')
ylabel('Torque [lbf*ft]')
axis([0 360 Tmin*0.737562149277 Tmax*0.737562149277])
figure(7)
plot(theta,P*.000145037738,'b')
title('Pressure,Power,and Heat Transfer')
hold on;
plot(theta,W_dot*1.3402209,'g')
plot(theta,Q_dot*1.3402209,'r')
legend Pressure Power HX
xlabel('theta[deg]')
ylabel('Respective Units (psi,hp)')
axis([0 360 P_min*1.3402209-100 p_max*0.000145037738])