Demonstrate x-ray attenuation

X-rays are from bremsstrahulung. Requires RFromCPAndGamma.

%--------------------------------------------------------------------------
% See also: XRayMassAttenCoeff, BremsstrahlungFrequency, PhotonEnergy,
% RFromCPAndGamma
%--------------------------------------------------------------------------

%--------------------------------------------------------------------------
%   Copyright (c) 2018 Princeton Satellite Systems, Inc.
%   All rights reserved.
%--------------------------------------------------------------------------
%   Since 2018.1
%--------------------------------------------------------------------------


nI      = [1e14 1e14];
zI      = [1 2];
tE      = 30000;
nu	    = logspace(2,14);
b       = BremsstrahlungFrequency( nu, tE, nI, zI );
e       = PhotonEnergy(nu);
yL      = {'\epsilon_\lambda (W/cm^3 nm)' };
s       = sprintf('Bremsstrahlung vs. Frequency T_e = %5.2f keV',tE/1000);
Plot2D(e,b,'Energy (eV)',yL,s,'log')


% Gas
t     = linspace(300,1600);
cP    = 424;
thick = 4; % cm
gamma = 1.659;
r     = RFromCPAndGamma( cP, gamma );
pAtm  = 4;
p     = pAtm*101325;
rho   = (p./(r*t))*1e-3;
el    = {'xenon',0.7,'helium',0.3};
e     = logspace(-5,-3); % eV
m     = XRayMassAttenCoeff( el, e );
x     = rho*thick;
m     = exp(-m'*x);
s     = sprintf('Density at %4.1f ATM',pAtm);
Plot2D(t,rho,'T (deg-K)','\rho (g/cm^3)',s)

NewFig('Attenuation')
mesh(t,e,m)
grid on
rotate3d on
XLabelS('T (deg-K)');
YLabelS('eV');
ZLabelS('Attenuation')
set(gca,'yscale','log');
set(gca,'zscale','log');

% Titanium
rhoTi = 4.500; % g/cm^3

thick = 0.01; % cm
e     = logspace(-5,-3); % eV
m     = XRayMassAttenCoeff( {'titanium'}, e );
x     = rhoTi*thick;
m     = exp(-m*x);


s     = sprintf('Attenuation Ti');
Plot2D(e,m,'eV','Attenuation',s,'log')

if 0
  PrintFig(1,4,1,'BremsstrahlungFrequency');
  PrintFig(1,4,2,'GasDensity');
  PrintFig(1,4,3,'AttenuationGas');
  PrintFig(1,4,4,'AttenutationTi');
end


%--------------------------------------