Esempio n. 1
0
def xrayFluo(atom,density,energy=7.,length=30.,I0=1e10,\
        det_radius=1.,det_dist=10.,det_material="Si",det_thick=300,verbose=True):
  """ compound: anything periodictable would understand 
      density:  in mM
      length: sample length in um
      energy: in keV, could be array
  """
  import periodictable
  from periodictable import xsf
  wavelength = 12.398/energy
  atom = periodictable.__dict__[atom]
  # 1e3 -> from mM to M
  # 1e3 -> from L to cm3
  # so 1 mM = 1e-3M/L = 1e-6 M/cm3
  density_g_cm3 = density*1e-6*atom.mass
  n = xsf.index_of_refraction(atom,density=density_g_cm3,wavelength=wavelength)
  attenuation_length = xrayAttLenght( atom,density=density_g_cm3,energy=energy )
  # um-> m: 1e-6
  fraction_absorbed = 1.-np.exp(-length*1e-6/attenuation_length)
  if verbose:
    print("Fraction of x-ray photons absorbed by the sample:",fraction_absorbed)
  ## detector ##
  det_area = np.pi*det_radius**2
  det_solid_angle = det_area/(4*np.pi*det_dist**2)
  if verbose:
    print("Detector fraction of solid angle:",det_solid_angle)
  det_att_len = xrayAttLenght(det_material,wavelength=atom.K_alpha)
  det_abs     = 1-np.exp(-det_thick*1e-6/det_att_len)
  if verbose:
    print("Detector efficiency (assuming E fluo = E_K_alpha):",det_abs)
  eff = fraction_absorbed*det_solid_angle*det_abs
  if verbose:
    print("Overall intensity (as ratio to incoming one):",eff)
  return eff
Esempio n. 2
0
def xrayAttLenght(*args,**kw):
  from periodictable import xsf
  n = xsf.index_of_refraction(*args,**kw)
  if not "wavelength" in kw:
    wavelength = 12.398/np.asarray(kw["energy"])
  else:
    wavelength = np.asarray(kw["wavelength"])
  attenuation_length = np.abs( (wavelength*1e-10)/ (4*np.pi*np.imag(n)) )
  return attenuation_length
Esempio n. 3
0
def refractive_index(element, eV, mass_density=None):
    """Refractive index using periodictable package.
    
    Imaginary part is positive i.e. optics rather than x-ray convention.
    
    Args:
        mass_density (float or None): in kg/m^3. If not given, then :func:`physdata.periodic_table.mass_density`
        is used.
    """
    if mass_density is None:
        mass_density = periodic_table.mass_density(element)
    # xsf function accepts keV and g/cm^3
    n = xsf.index_of_refraction(compound=element, energy=eV / 1e3, density=mass_density / 1e3).conj()
    return n
def attenuation_length(compound,
                       density=None,
                       natural_density=None,
                       energy=None,
                       wavelength=None):
    """
    Calculates the attenuation length for a compound
                Transmisison if then exp(-thickness/attenuation_length)

    :Parameters:
        *compound* : Formula initializer
            Chemical formula.
        *density* : float | |g/cm^3|
            Mass density of the compound, or None for default.
        *natural_density* : float | |g/cm^3|
            Mass density of the compound at naturally occurring isotope abundance.
        *wavelength* : float or vector | |Ang|
            Wavelength of the X-ray.
        *energy* : float or vector | keV
            Energy of the X-ray, if *wavelength* is not specified.

    :Returns:
        *attenuation_length* : vector | |m|
            as function of (energy)

    :Notes:

    against http://henke.lbl.gov/optical_constants/
    """
    if energy is not None: wavelength = xray_wavelength(energy)
    assert wavelength is not None, "scattering calculation needs energy or wavelength"
    if (numpy.isscalar(wavelength)): wavelength = numpy.array([wavelength])
    n = index_of_refraction(compound=compound,
                            density=density,
                            natural_density=natural_density,
                            wavelength=wavelength)
    attenuation_length = (wavelength * 1e-10) / (4 * numpy.pi * numpy.imag(n))
    return numpy.abs(attenuation_length)
Esempio n. 5
0

E = 12			# Energy in keV

M = 'Be'		# Material 
R = 50			# CRL radius of curvature 
N = 40			# number of refractive lens 


M = getattr(pt, '%s'%M)							# I dont know how, but 'eval' - not good idea!)
name = getattr(pt.elements, '%s'%M).name		# name of element
density = M.density								# density
mass = M.mass									# mass of element

lyamda = ptx.xray_energy(E)
n = ptx.index_of_refraction(M, energy=E)		# index of refraction
delta = 1-n.real								# Delta
beta = -n.imag									# Beta
u = 4*np.pi*beta/(lyamda*1e-10)					# Linear attenuation coefficient
Lpi = 1e-10*lyamda/(2*delta)


F = (R*1e-6)/(2*N*delta)							# CRL focus distance (thin lens)
e1 = (2*np.log(2)/np.pi)**.5					# V.Kohn coefficient
Aeff = e1*(F*lyamda*1e-10*delta/beta)**.5		# CRL effective aperture (V.Kohn)
Aeff_1m = e1*(1*lyamda*1e-10*delta/beta)**.5	# CRL effective aperture @ 1m focus distance

print ('Material	%s (%s)'%(M, name))
print ('Density		%s g/cm^3'%density)

print ('\nEnergy		%s keV'%E)
def getDelta(E, material="Be", density=None):
    """ returns 1-real(index_of-refraction) for a given material at a given energy"""
    delta = 1 - real(
        xsf.index_of_refraction(material, density=density, energy=E))
    return delta
Esempio n. 7
0
 def get_delta(self, E, material="Be", density=None):
     delta = 1-np.real(xsf.index_of_refraction(material, density=density,
                       energy=E))
     return delta