% demoMie.m
%
% Demonstrate use of Maetzler's MATLAB Mie calculation.
% Plots scattering, anisotropy, and reduced scattering 
% for a range of wavelengths and range of particle diameters.
% - Steven Jacques 2009
%
% Christian Maetzler, 
% MATLAB Functions for Mie Scattering and Absorption
% University of Bern, Institut fuer Angewandte Physik,
% Research Report No. 2002-08,June, 2002 
% http://arrc.ou.edu/~rockee/NRA_2007_website/Mie-scattering-Matlab.pdf
home
disp('=============')


%%%%
% USER CHOICES
%%%
nmed = 1.33; % medium refractive index (water)
npar = 1.57; % particle refractive index (polystyrene)
vf   = 0.05; % volume fraction of spheres in medium

lambdalambda = [300:1:1400]'/1000; % [um]
diadia = [0.1 1 10]'; % [um]

musgp = zeros(length(lambdalambda),length(diadia),3);

for j=1:length(diadia)
    dia = diadia(j);
    
    for i=1:length(lambdalambda)
        lambda = lambdalambda(i);

        musgp(i,j,:) = getMieScatter(lambda, dia, fv, npar,nmed);

    end % i
    
end % j

%% plot results
figure(100);clf
clr = 'rgb';
sz  = 14;

yname(1).s = '\mu_s [cm^{-1}]';
yname(2).s = 'g [-]';
yname(3).s = '\mu_s'' [cm^{-1}]';
ymax = [3000 1 400];

for k=1:3
    subplot(3,1,k)
    for j=1:length(diadia)
        plot(lambdalambda, musgp(:,j,k),[clr(j) '-'])
        hold on
        y = ymax(k); dy = y/10; x = mean(lambdalambda);
        text(x,y-dy*j,sprintf('dia = %0.3f um', diadia(j)), ...
            'fontsize',sz, 'color',clr(j))
    end
    set(gca,'fontsize',sz)
    xlabel('wavelength \lambda [\mum]')
    ylabel(yname(k).s)
end

disp('done')
