fisx
fisx::Elements Class Reference

Class handling the physical properties. More...

#include <fisx_elements.h>

Public Member Functions

 Elements (std::string dataDirectory="")
 
 Elements (std::string dataDirectory, short pymca)
 
 Elements (std::string dataDirectory, std::string bindingEnergiesFile, std::string crossSectionsFile="")
 
bool isElementNameDefined (const std::string &elementName) const
 
const ElementgetElement (const std::string &elementName) const
 
Element getElementCopy (const std::string &elementName)
 
void addElement (const Element &elementInstance)
 
std::vector< std::string > getElementNames ()
 
std::map< std::string, double > getEmittedXRayLines (const std::string &elementName, const double &energy=1000.) const
 
const std::map< std::string, double > & getNonradiativeTransitions (const std::string &elementName, const std::string &subshell) const
 
const std::map< std::string, double > & getRadiativeTransitions (const std::string &elementName, const std::string &subshell) const
 
std::map< std::string, std::vector< double > > getInitialPhotoelectricVacancyDistribution (const std::string &elementName, const std::vector< double > &energies) const
 
std::map< std::string, double > getInitialPhotoelectricVacancyDistribution (const std::string &elementName, const double &energy) const
 
std::map< std::string, double > getCascadeModifiedVacancyDistribution (const std::string &elementName, const std::map< std::string, double > &distribution) const
 
std::map< std::string, std::map< std::string, double > > getXRayLinesFromVacancyDistribution (const std::string &elementName, const std::map< std::string, double > &distribution, const int &cascade=1, const int &useFluorescenceYield=1) const
 
std::map< std::string, double > getShellConstants (const std::string &elementName, const std::string &subshell) const
 
void setShellConstantsFile (const std::string &mainShellName, const std::string &fileName)
 
void setShellRadiativeTransitionsFile (const std::string &mainShellName, const std::string &fileName)
 
void setShellNonradiativeTransitionsFile (const std::string &mainShellName, const std::string &fileName)
 
const std::string & getShellConstantsFile (const std::string &mainShellName) const
 
const std::string & getShellRadiativeTransitionsFile (const std::string &mainShellName) const
 
const std::string & getShellNonradiativeTransitionsFile (const std::string &mainShellName) const
 
void setMassAttenuationCoefficientsFile (const std::string &fileName)
 
void setMassAttenuationCoefficients (const std::string &elementName, const std::vector< double > &energy, const std::vector< double > &photoelectric, const std::vector< double > &coherent, const std::vector< double > &compton, const std::vector< double > &pair)
 
std::map< std::string, std::vector< double > > getMassAttenuationCoefficients (const std::string &elementName) const
 
std::map< std::string, std::vector< double > > getMassAttenuationCoefficients (const std::string &formula, const std::vector< double > &energies) const
 
std::map< std::string, std::vector< double > > getMassAttenuationCoefficients (std::map< std::string, double > elementMassFractions, std::vector< double > energies) const
 
std::map< std::string, double > getMassAttenuationCoefficients (std::string formula, double energy) const
 
std::map< std::string, double > getMassAttenuationCoefficients (std::map< std::string, double > elementMassFractions, double energies) const
 
Material createMaterial (const std::string &name, const double &density=1.0, const double &thickness=1.0, const std::string &comment="")
 
void setMaterialComposition (const std::string &materialName, const std::map< std::string, double > &composition)
 
void setMaterialComposition (const std::string &materialName, const std::vector< std::string > &names, const std::vector< double > &amounts)
 
const MaterialgetMaterial (const std::string &materialName)
 
std::vector< std::string > getMaterialNames ()
 
Material getMaterialCopy (const std::string &materialName)
 
void addMaterial (const Material &materialInstance, const int &errorOnReplace=1)
 
void addMaterial (const std::string &name, const double &density=1.0, const double &thickness=1.0, const std::string &comment="", const int &errorOnReplace=1)
 
void removeMaterial (const std::string &name)
 
void removeMaterials ()
 
std::map< std::string, double > getCompositionFromFormula (const std::string &formula) const
 
std::map< std::string, double > getComposition (const std::string &name) const
 
std::map< std::string, double > getComposition (const std::string &name, const std::vector< Material > &materials) const
 
std::map< std::string, double > parseFormula (const std::string &formula) const
 
std::vector< std::map< std::string, std::map< std::string, double > > > getExcitationFactors (const std::string &element, const std::vector< double > &energy, const std::vector< double > &weights=std::vector< double >()) const
 
std::map< std::string, std::map< std::string, double > > getExcitationFactors (const std::string &element, const double &energy, const double &weights=1.0) const
 
std::vector< std::pair< std::string, double > > getPeakFamilies (const std::string &name, const double &energy) const
 
std::vector< std::pair< std::string, double > > getPeakFamilies (const std::vector< std::string > &elementList, const double &energy) const
 
const double & getAtomicMass (const std::string &name) const
 
const int & getAtomicNumber (const std::string &name) const
 
const std::map< std::string, double > & getBindingEnergies (const std::string &name) const
 
double getDensity (const std::string &name) const
 
std::string getLongName (const std::string &name) const
 
int getColumn (const std::string &name) const
 
int getRow (const std::string &name) const
 
std::map< std::string, std::map< std::string, double > > getEscape (const std::map< std::string, double > &composition, const double &energy, const double &energyThreshold=0.010, const double &intensityThreshold=1.0e-7, const int &nThreshold=4, const double &alphaIn=90., const double &thickness=0.0) const
 
void updateEscapeCache (const std::map< std::string, double > &composition, const std::vector< double > &energy, const double &energyThreshold=0.010, const double &intensityThreshold=1.0e-7, const int &nThreshold=4, const double &alphaIn=90., const double &thickness=0.0)
 
void setElementCascadeCacheEnabled (const std::string &elementName, const int &flag=1)
 
int isElementCascadeCacheFilled (const std::string &elementName) const
 
void fillElementCascadeCache (const std::string &elementName)
 
void emptyElementCascadeCache (const std::string &elementName)
 
void setEscapeCacheEnabled (const int &flag=1)
 
int isEscapeCacheEnabled () const
 
void fillCache (const std::string &elementName, const std::vector< double > &energy)
 
void setCacheEnabled (const std::string &elementName, const int &flag=1)
 
void updateCache (const std::string &elementName, const std::vector< double > &energy)
 
void clearCache (const std::string &elementName)
 
void clearEscapeCache (void)
 
const int isCacheEnabled (const std::string &elementName) const
 
int getCacheSize (const std::string &elementName) const
 

Static Public Member Functions

static const std::string defaultDataDir ()
 
static bool stringToDouble (const std::string &str, double &number)
 
static std::string toString (const double &number)
 

Detailed Description

Class handling the physical properties.

This class initializes a default library of physical properties and allows the user to modify and to access those properties.

Constructor & Destructor Documentation

§ Elements() [1/3]

fisx::Elements::Elements ( std::string  dataDirectory = "")

Initialize the library from the EADL and EPDL97 data files found in the provided directory.

§ Elements() [2/3]

fisx::Elements::Elements ( std::string  dataDirectory,
short  pymca 
)

Initialize the library from the data files found in the provided directory.

By default it uses EADL and EPDL97 files. If the optional flag is set to 1, it will only use the non-radiative transition rates and partial photoelectric cross sections from EADL and EPDL97. For the rest of files, it will use those used by default by PyMca (they have to be in the directory).

§ Elements() [3/3]

fisx::Elements::Elements ( std::string  dataDirectory,
std::string  bindingEnergiesFile,
std::string  crossSectionsFile = "" 
)

Initialize the library from the EPDL97 data files found in the provided directory. It forces the EPDL97 photon photoelectric cross sections to follow the shell binding energies found in the provided binding energies file (full path needed because it is not necessarily found in the the same directory as the EPDL97 data).

If the cross sections file is provided, it calls setMassAttenuationCoefficientes method with the values extracted from the crossSectionFile.

Member Function Documentation

§ addElement()

void fisx::Elements::addElement ( const Element elementInstance)

Add an element instance to the library.

§ addMaterial() [1/2]

void fisx::Elements::addMaterial ( const Material materialInstance,
const int &  errorOnReplace = 1 
)

Copy a material into the set of defined materials.

§ addMaterial() [2/2]

void fisx::Elements::addMaterial ( const std::string &  name,
const double &  density = 1.0,
const double &  thickness = 1.0,
const std::string &  comment = "",
const int &  errorOnReplace = 1 
)

Create and add Material instance to the set of defined materials.

§ clearCache()

void fisx::Elements::clearCache ( const std::string &  elementName)

Clear the calculation cache

§ clearEscapeCache()

void fisx::Elements::clearEscapeCache ( void  )

Clear the escape peak calculation cache

§ createMaterial()

Material fisx::Elements::createMaterial ( const std::string &  name,
const double &  density = 1.0,
const double &  thickness = 1.0,
const std::string &  comment = "" 
)

Create a new Material given name and initialize its density, thickness and comment. The material is not added to the internal list of materials.

§ defaultDataDir()

const std::string fisx::Elements::defaultDataDir ( )
static

Default directory where the library looks for the data files

§ fillCache()

void fisx::Elements::fillCache ( const std::string &  elementName,
const std::vector< double > &  energy 
)

Optimization methods to keep the calculations at a set of energies in cache Clear the calculation cache of given element and fill it at the selected energies

§ getAtomicMass()

const double & fisx::Elements::getAtomicMass ( const std::string &  name) const

Convenience function to simplify python use ...

§ getAtomicNumber()

const int & fisx::Elements::getAtomicNumber ( const std::string &  name) const

Convenience function to simplify python use ...

§ getBindingEnergies()

const std::map< std::string, double > & fisx::Elements::getBindingEnergies ( const std::string &  name) const

Convenience function to simplify python use ...

§ getCacheSize()

int fisx::Elements::getCacheSize ( const std::string &  elementName) const

Return the number of energies for which the calculations are stored

§ getColumn()

int fisx::Elements::getColumn ( const std::string &  name) const

Convenience function to simplify python use ...

§ getComposition() [1/2]

std::map< std::string, double > fisx::Elements::getComposition ( const std::string &  name) const

Try to interpret a given string as a chemical formula or a defined material, returning the associated mass fractions as a map of elements and mass fractions. In case of failure, it returns an empty map.

§ getComposition() [2/2]

std::map< std::string, double > fisx::Elements::getComposition ( const std::string &  name,
const std::vector< Material > &  materials 
) const

Try to interpret a given string as a chemical formula or a defined material, returning the associated mass fractions as a map of elements and mass fractions using the supplied list of materials. In case of failure, it returns an empty map.

§ getCompositionFromFormula()

std::map< std::string, double > fisx::Elements::getCompositionFromFormula ( const std::string &  formula) const

Try to interpret a given string as a formula, returning the associated mass fractions as a map of elements and mass fractions. In case of failure, it returns an empty map.

§ getDensity()

double fisx::Elements::getDensity ( const std::string &  name) const

Convenience function to simplify python use ...

§ getElement()

const Element & fisx::Elements::getElement ( const std::string &  elementName) const

Returns a reference to the element with name elementName if defined in the library.

§ getElementCopy()

Element fisx::Elements::getElementCopy ( const std::string &  elementName)

Get a copy of the element with name elementName.

§ getElementNames()

std::vector< std::string > fisx::Elements::getElementNames ( )

Retrieve the names of the elements already defined in the library.

§ getEmittedXRayLines()

std::map< std::string, double > fisx::Elements::getEmittedXRayLines ( const std::string &  elementName,
const double &  energy = 1000. 
) const

Convenience method to simplify access to element properties from binding (ex. python)

Given an element and an excitation energy (in keV), return a map where the key is the line name and the content the energy. The method getPeakFamilies is more complete.

§ getEscape()

std::map< std::string, std::map< std::string, double > > fisx::Elements::getEscape ( const std::map< std::string, double > &  composition,
const double &  energy,
const double &  energyThreshold = 0.010,
const double &  intensityThreshold = 1.0e-7,
const int &  nThreshold = 4,
const double &  alphaIn = 90.,
const double &  thickness = 0.0 
) const

Return escape peak energy and rate per detected photon of given energy. Given a detector composition and an incident energy in keV, gives back a map of the form: result["element_transitionesc"]["energy"] result["element_transitionesc"]["rate"] For instance, if the incident energy is 5 keV and the composition is Si, the output would have the form:

result["Si_KL3esc"] ["energy"] = 5.0 - Si KL3 transition energy result["Si_KM3esc"] ["energy"] = 5.0 - Si KM3 transition energy ...

The rest of (optional) parameters condition the output as follows:

energyThreshold - Separation between two lines to be considered together. Default 0.010 keV. intensityThreshold - Minimum absolute peak intensity to consider. Default 1.0e-7 nThreshold - Maximum number of escape peaks to consider. Default is 4. alphaIn - Incoming beam angle with detector surface. Default 90 degrees. thickness - Material thickness in g/cm2. Default is 0 to indicate infinite thickness

§ getExcitationFactors() [1/2]

std::vector< std::map< std::string, std::map< std::string, double > > > fisx::Elements::getExcitationFactors ( const std::string &  element,
const std::vector< double > &  energy,
const std::vector< double > &  weights = std::vector<double>() 
) const

Given a set of energies and (optional) weights, for the specfified element, this method returns the emitted X-rays already corrected for cascade and fluorescence yield. It is the equivalent of the excitation factor in D.K.G. de Boer's paper.

§ getExcitationFactors() [2/2]

std::map< std::string, std::map< std::string, double > > fisx::Elements::getExcitationFactors ( const std::string &  element,
const double &  energy,
const double &  weights = 1.0 
) const

Given an energy and its (optional) weight, for the specfified element, this method returns the emitted X-ray already corrected for cascade and fluorescence yield. It is the equivalent of the excitation factor in D.K.G. de Boer's paper.

§ getInitialPhotoelectricVacancyDistribution() [1/2]

std::map< std::string, std::vector< double > > fisx::Elements::getInitialPhotoelectricVacancyDistribution ( const std::string &  elementName,
const std::vector< double > &  energies 
) const

Convenience method to simplify access to element calculations from binding (ex. python)

Given a set of energies, give the initial distribution of vacancies (before cascade) due to photoelectric effect. The output map keys correspond to the different partial photoelectric shells and the values are just vectors of mu_photoelectric(shell, E)/mu_photoelectric(total, E)

§ getInitialPhotoelectricVacancyDistribution() [2/2]

std::map< std::string, double > fisx::Elements::getInitialPhotoelectricVacancyDistribution ( const std::string &  elementName,
const double &  energy 
) const

Convenience method to simplify access to element calculations from binding (ex. python)

Given one energy, give the initial distribution of vacancies (before cascade) due to photoelectric effect. The output map keys correspond to the different subshells and the values are just mu_photoelectric(shell, E)/mu_photoelectric(total, E).

§ getLongName()

std::string fisx::Elements::getLongName ( const std::string &  name) const

Convenience function to simplify python use ...

§ getMassAttenuationCoefficients() [1/5]

std::map< std::string, std::vector< double > > fisx::Elements::getMassAttenuationCoefficients ( const std::string &  elementName) const

Retrieve the internal table of photon mass attenuation coefficients of the requested element.

§ getMassAttenuationCoefficients() [2/5]

std::map< std::string, std::vector< double > > fisx::Elements::getMassAttenuationCoefficients ( const std::string &  formula,
const std::vector< double > &  energies 
) const

Given an element or formula and a set of energies, give back the mass attenuation coefficients at the given energies as a map where the keys are the different physical processes and the values are the vectors of the calculated values via log-log interpolation in the internal table.

§ getMassAttenuationCoefficients() [3/5]

std::map< std::string, std::vector< double > > fisx::Elements::getMassAttenuationCoefficients ( std::map< std::string, double >  elementMassFractions,
std::vector< double >  energies 
) const

Given a map of elements and mass fractions and a set of energies, give back the mass attenuation coefficients at the given energies as a map where the keys are the different physical processes and the values are the vectors of the calculated values via log-log interpolation in the internal table.

§ getMassAttenuationCoefficients() [4/5]

std::map< std::string, double > fisx::Elements::getMassAttenuationCoefficients ( std::string  formula,
double  energy 
) const

Convenience method. Given an element or formula and an energy, give back the mass attenuation coefficients at the given energy as a map where the keys are the different physical processes and the values are calculated values via log-log interpolation in the internal table.

§ getMassAttenuationCoefficients() [5/5]

std::map< std::string, double > fisx::Elements::getMassAttenuationCoefficients ( std::map< std::string, double >  elementMassFractions,
double  energies 
) const

Convenience method. Given a map of elements and mass fractions element and one energy, give back the mass attenuation coefficients at the given energy as a map where the keys are the different physical processes and the values are the calculated values via log-log interpolation in the internal table.

§ getMaterial()

const Material & fisx::Elements::getMaterial ( const std::string &  materialName)

Retrieve a reference to instance of the material identified by materialName

§ getMaterialCopy()

Material fisx::Elements::getMaterialCopy ( const std::string &  materialName)

Retrieve a copy of the instance of the material identified by materialName

§ getMaterialNames()

std::vector< std::string > fisx::Elements::getMaterialNames ( )

Retrieve the names of the materials already defined in the library.

§ getNonradiativeTransitions()

const std::map< std::string, double > & fisx::Elements::getNonradiativeTransitions ( const std::string &  elementName,
const std::string &  subshell 
) const

Convenience method to simplify access to element properties from binding (ex. python)

§ getPeakFamilies() [1/2]

std::vector< std::pair< std::string, double > > fisx::Elements::getPeakFamilies ( const std::string &  name,
const double &  energy 
) const

Given an element, formula or material return an ordered vector of pairs. The first element is the peak family ("Si K", "Pb L1", ...) and the second the binding energy.

§ getPeakFamilies() [2/2]

std::vector< std::pair< std::string, double > > fisx::Elements::getPeakFamilies ( const std::vector< std::string > &  elementList,
const double &  energy 
) const

Given a list of elements return an ordered vector of pairs. The first element is the peak family ("Si K", "Pb L1", ...) and the second the binding energy.

§ getRadiativeTransitions()

const std::map< std::string, double > & fisx::Elements::getRadiativeTransitions ( const std::string &  elementName,
const std::string &  subshell 
) const

Convenience method to simplify access to element properties from binding (ex. python)

§ getRow()

int fisx::Elements::getRow ( const std::string &  name) const

Convenience function to simplify python use ...

§ getShellConstants()

std::map< std::string, double > fisx::Elements::getShellConstants ( const std::string &  elementName,
const std::string &  subshell 
) const

Convenience method to simplify access to element properties from binding (ex. python)

§ getShellConstantsFile()

const std::string & fisx::Elements::getShellConstantsFile ( const std::string &  mainShellName) const

Get file used to load main shell (K, L or M) constants (fluorescence and Coster-Kronig yields)

§ getShellNonradiativeTransitionsFile()

const std::string & fisx::Elements::getShellNonradiativeTransitionsFile ( const std::string &  mainShellName) const

Get file used to load main shell (K, L or M) Coster-Kronig and Auger emission ratios from file. The library separates Coster-Kronig from Auger and normalizes internally.

§ getShellRadiativeTransitionsFile()

const std::string & fisx::Elements::getShellRadiativeTransitionsFile ( const std::string &  mainShellName) const

Get file used to load main shell (K, L or M) X-ray emission rates from file. The library normalizes internally.

§ getXRayLinesFromVacancyDistribution()

std::map< std::string, std::map< std::string, double > > fisx::Elements::getXRayLinesFromVacancyDistribution ( const std::string &  elementName,
const std::map< std::string, double > &  distribution,
const int &  cascade = 1,
const int &  useFluorescenceYield = 1 
) const

Convenience method to simplify access to element calculations from binding (ex. python)

Given an initial vacancy distribution, returns the emitted X-rays.

Input: distribution - Map[key, double] of the form [(sub)shell][amount of vacancies] cascade - Consider de-excitation cascade (default is 1 = true) useFluorescenceYield - Correct by fluorescence yield (default is 1 = true)

Output: map[key]["rate"] - emission rate where key is the transition line (ex. KL3) map[key]["energy"] - emission energy where key is the transition line (ex. KL3)

§ isCacheEnabled()

const int fisx::Elements::isCacheEnabled ( const std::string &  elementName) const

Return 1 if the calculation cache is enabled

§ isElementNameDefined()

bool fisx::Elements::isElementNameDefined ( const std::string &  elementName) const

Returns true if the element with name elementName is already defined in the library.

§ parseFormula()

std::map< std::string, double > fisx::Elements::parseFormula ( const std::string &  formula) const

Try to parse a given string as a formula, returning the associated number of "atoms" per single molecule. In case of failure, it returns an empty map.

§ removeMaterial()

void fisx::Elements::removeMaterial ( const std::string &  name)

Remove a material (if present) from the set of defined materials

§ removeMaterials()

void fisx::Elements::removeMaterials ( )

Empty the list of defined materials

§ setCacheEnabled()

void fisx::Elements::setCacheEnabled ( const std::string &  elementName,
const int &  flag = 1 
)

Enable or disable the use of the stored calculations (if any). It does not clear the cache when disabling.

§ setElementCascadeCacheEnabled()

void fisx::Elements::setElementCascadeCacheEnabled ( const std::string &  elementName,
const int &  flag = 1 
)

Optimization methods to keep the complete emission cascade following a single vacancy in a shell into cache.

§ setMassAttenuationCoefficients()

void fisx::Elements::setMassAttenuationCoefficients ( const std::string &  elementName,
const std::vector< double > &  energy,
const std::vector< double > &  photoelectric,
const std::vector< double > &  coherent,
const std::vector< double > &  compton,
const std::vector< double > &  pair 
)

Update the total mass attenuation coefficients of the supplied element. The partial mass attenuation photoelectric coefficients are updated by the library in order to be consistent with the supplied mass attenuation coefficients

§ setMassAttenuationCoefficientsFile()

void fisx::Elements::setMassAttenuationCoefficientsFile ( const std::string &  fileName)

Update the total mass attenuation coefficients of the default elements with those found in the given file.

§ setMaterialComposition() [1/2]

void fisx::Elements::setMaterialComposition ( const std::string &  materialName,
const std::map< std::string, double > &  composition 
)

Set the material composition of the material with name materialName. The material must belong to the internal list defined materials. A composition is a map where the keys are elements/materials already defined in the library and the values are mass amounts. The library is supposed to normalize to make sure the mass fractions sum unity.

§ setMaterialComposition() [2/2]

void fisx::Elements::setMaterialComposition ( const std::string &  materialName,
const std::vector< std::string > &  names,
const std::vector< double > &  amounts 
)

Set the material composition of the material with name materialName. It is composed of the elements/materials with the given names and mass amounts. The library is supposed to normalize to make sure the mass fractions sum unity.

§ setShellConstantsFile()

void fisx::Elements::setShellConstantsFile ( const std::string &  mainShellName,
const std::string &  fileName 
)

Load main shell (K, L or M) constants from file (fluorescence and Coster-Kronig yields)

§ setShellNonradiativeTransitionsFile()

void fisx::Elements::setShellNonradiativeTransitionsFile ( const std::string &  mainShellName,
const std::string &  fileName 
)

Load main shell (K, L or M) Coster-Kronig and Auger emission ratios from file. The library separates Coster-Kronig from Auger and normalizes internally.

§ setShellRadiativeTransitionsFile()

void fisx::Elements::setShellRadiativeTransitionsFile ( const std::string &  mainShellName,
const std::string &  fileName 
)

Load main shell (K, L or M) X-ray emission rates from file. The library normalizes internally.

§ stringToDouble()

bool fisx::Elements::stringToDouble ( const std::string &  str,
double &  number 
)
static

Utility to convert from string to double.

§ toString()

std::string fisx::Elements::toString ( const double &  number)
static

Utility to convert from double to string.

§ updateCache()

void fisx::Elements::updateCache ( const std::string &  elementName,
const std::vector< double > &  energy 
)

Update the cache with those energy values not already present. The existing values will be kept.

§ updateEscapeCache()

void fisx::Elements::updateEscapeCache ( const std::map< std::string, double > &  composition,
const std::vector< double > &  energy,
const double &  energyThreshold = 0.010,
const double &  intensityThreshold = 1.0e-7,
const int &  nThreshold = 4,
const double &  alphaIn = 90.,
const double &  thickness = 0.0 
)

Calculate the expected escape and stores it into cache. The cache will be emptied if needed.


The documentation for this class was generated from the following files: