Environmental Engineering Reference
In-Depth Information
functionReadIn_4412
global num_Re num_aoa Re_array aoa_array Cl_array Cd_array
% Function to read in the lift and drag coefficients of any aerofoil
% when the data is available in a data file containing lines:
% aoa Cl Cd for a range of Reynolds numbers. The data is
% assumed to be in ascending order of aoa and Re.
% num_Re - number of values of Reynolds number in data file.
% num_alpha - number of values of angle of attack at each Re.
% Re_array -array holding the Reynolds numbers.
% Re_log - array holding the log of the Reynolds numbers
% alpha_array - array holding the angles of attack.
% Cl_array, Cd_array - arrays holding lift and drag coefficients.
% Values specific to the NACA 4412 data. This function makes use
% of the equal number of Cl and Cd values at the same aoa for each
% Re
num_Re = 5; num_aoa = [16 16 16 16 16];
max_num_aoa=max(num_aoa);
Re_array = [42000 83000 160000 330000 640000];
in = load('naca4412.in'); % This is the data file.
% End of specific data for this aerofoil. The remainder of this function
% is the same for any aerofoil
aoa_in=in(:,1); % Angle of attack is in the first column
Cl_in=in(:,2); % Lift coefficient is in second column
Cd_in=in(:,3); % Drag coefficient is in second column
k=1;
aoa_array=zeros(num_Re, max_num_aoa);
Cl_array=zeros(num_Re, max_num_aoa);
Cd_array=zeros(num_Re, max_num_aoa);
for i = 1: num_Re
for j = 1: num_aoa(i)
aoa_array(i, j) = aoa_in(k);
Cl_array(i, j) = Cl_in(k);
Cd_array(i, j) = Cd_in(k);
k = k+1;
end
end
return
end
Note the use of global variables declared in the line
global num Re num aoa Re array aoa array Cl array Cd array
which provides a way of communicating information between the two functions
without lengthening the argument list. None of these variables is used in the main
program which, therefore, does not need the global statement.
The second function then interpolates that data for the input Reynolds number
and angle of attack.
Search WWH ::




Custom Search