%**************************************************************************
%This function outputs the field expansion coefficients to the data file.
%
%Input:
%dat_file, data file for results
%bn, field expansion coefficient (T)
%rn, field expansion coefficient ratio Bn/B1
%
%Zachary Wolf, 10/13/09

function [] = field_calc_dat_bn(dat_file, bn, rn)

%Get n values
n = 1 : length(bn);

%Open the data file
fid = fopen(dat_file, 'a');

%Write the values to the data file
fprintf(fid, '\r\n\r\n');
fprintf(fid, 'Field Expansion Coefficients:\r\n');
fprintf(fid, 'By = Sum Bn cosh(nky) sin(nkz)\r\n');
fprintf(fid, 'Bz = Sum Bn sinh(nky) cos(nkz)\r\n');
fprintf(fid, ' n       Bn          Bn/B1    \r\n');
fprintf(fid, '         (T)                  \r\n');
fprintf(fid, '---  -----------  ----------- \r\n');
for ii = 1 : length(n)
    fprintf(fid, '%3i  %11.6f  %11.6f\r\n', n(ii), bn(ii), rn(ii));
end

%Close the file
fclose(fid);

%Done
