%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Name: meanFreePath.m
% Author: J. Kristoffer Hultgren
%
% Description:
%
% Calculates and plots the mean free path of an incoming particle/molecule
% on a population of neutral particles/molecules.
%
% Input:  n  - Density of the target population
%         r1 - Radius of the incoming particle/molecule
%         r2 - Radii of the target particles/molecules
%
% Output: -
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function meanFreePath(n,r1,r2)

sigma = pi*(r1+r2)^2;   % Scattering cross section
t = n.*sigma;
l = 1./t;               % Mean free path

lmean = mean(l);        % Mean mean free path
lmax = max(l);          % Max mean free path
lmin = min(l);          % Min mean free path

% Displays the mean free path
disp('Mean mean free path (m) =')
disp(lmean)
disp('Max mean free path (m) =')
disp(lmax)
disp('Min mean free path (m) =')
disp(lmin)

% Plots the mean free path
figure('name','Mean Free Path')
TH = linspace(0,360,max(size(n)));
plot(TH,l)
title('Mean free path')
xlabel('\theta (deg)')
ylabel('\lambda_{m} (m)')