fisx: fisx_element.h Source File

fisx

fisx_element.h
1 #/*##########################################################################
2 #
3 # The fisx library for X-Ray Fluorescence
4 #
5 # Copyright (c) 2014-2020 European Synchrotron Radiation Facility
6 #
7 # This file is part of the fisx X-ray developed by V.A. Sole
8 #
9 # Permission is hereby granted, free of charge, to any person obtaining a copy
10 # of this software and associated documentation files (the "Software"), to deal
11 # in the Software without restriction, including without limitation the rights
12 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 # copies of the Software, and to permit persons to whom the Software is
14 # furnished to do so, subject to the following conditions:
15 #
16 # The above copyright notice and this permission notice shall be included in
17 # all copies or substantial portions of the Software.
18 #
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 # THE SOFTWARE.
26 #
27 #############################################################################*/
28 #ifndef FISX_ELEMENT_H
29 #define FISX_ELEMENT_H
30 #include <string>
31 #include <ctype.h>
32 #include <vector>
33 #include <map>
34 #include "fisx_shell.h"
35 #include "fisx_epdl97.h"
36
37 namespace fisx
38 {
39
40 class Element
41 {
42 public:
47 Element(); // Do not use
53 Element(std::string name, int z); //
54 // TODO: Element copy constructor to be added in order to be able to generate a new
55 // element from a given one and modify some properties
56
61 void setName(const std::string & name);
62
66 std::string getName() const;
67
72 void setAtomicNumber(const int & z);
76 const int & getAtomicNumber() const;
77
82 void setAtomicMass(const double & mass);
83
87 const double & getAtomicMass() const;
88
89 // density (initialized by default to 1.0)
95 void setDensity(const double &);
96
100 double getDensity() const;
101
105 void setLongName(const std::string & name);
106
110 std::string getLongName() const;
111
115 void setColumn(const int &);
116
120 int getColumn() const;
121
125 void setRow(const int &);
126
130 int getRow() const;
131
132 // binding energies
133
138 void setBindingEnergies(std::map<std::string, double> bindingEnergies);
139
143 void setBindingEnergies(std::vector<std::string> labels, std::vector<double> energies);
144
148 const std::map<std::string, double> & getBindingEnergies() const;
149
153 std::vector<std::string> getExcitedShells(const double & energy) const;
154
155 // Mass attenuation coefficients
156
157 // This methods overwrites any totals given
162 void setMassAttenuationCoefficients(const std::vector<double> & energies, \
163 const std::vector<double> & photoelectric, \
164 const std::vector<double> & coherent, \
165 const std::vector<double> & incoherent, \
166 const std::vector<double> & pair);
167
172 void setMassAttenuationCoefficients(const std::vector<double> & energies, \
173 const std::vector<double> & photoelectric, \
174 const std::vector<double> & coherent, \
175 const std::vector<double> & incoherent);
176
183 void setTotalMassAttenuationCoefficient(const std::vector<double> & energies, \
184 const std::vector<double> & total);
185
189 const std::map<std::string, std::vector<double> > & getMassAttenuationCoefficients() const;
190
195 std::map<std::string, std::vector<double> > getMassAttenuationCoefficients(\
196 const std::vector<double> & energy) const;
201 std::map<std::string, double> getMassAttenuationCoefficients(const double & energy) const;
202
203 std::map<std::string, std::pair<double, int> > extractEdgeEnergiesFromMassAttenuationCoefficients();
204 std::map<std::string, std::pair<double, int> > extractEdgeEnergiesFromMassAttenuationCoefficients(\
205 const std::vector<double> & energies,\
206 const std::vector<double> & muPhotoelectric);
207
208 // Partial shell mass attenuation photoelectric coefficients
213 void setPartialPhotoelectricMassAttenuationCoefficients(const std::string & shell,\
214 const std::vector<double> & energy, \
215 const std::vector<double> & partialPhotoelectric);
216
220 std::map<std::string, double> getPartialPhotoelectricMassAttenuationCoefficients(\
221 const double & energy) const;
222
223 // Shell transitions description
224 void setRadiativeTransitions(std::string subshell, std::map<std::string, double> values);
225
226 void setRadiativeTransitions(std::string subshell,\
227 std::vector<std::string>,\
228 std::vector<double> values);
229
230 const std::map<std::string, double> & getRadiativeTransitions(const std::string & subshell) const;
231
232 void setNonradiativeTransitions(std::string subshell,
233 std::vector<std::string>,
234 std::vector<double> values);
235
236 void setNonradiativeTransitions(std::string subshell,
237 std::map<std::string, double> values);
238
239 const std::map<std::string, double> & getNonradiativeTransitions(const std::string & subshell) const;
240
241 // Shell constants (fluorescence yield, Coster-Kronig yields)
242 void setShellConstants(std::string subshell, std::map<std::string, double> constants);
243 std::map<std::string, double> getShellConstants(const std::string & subshell) const;
244
245
249 double getTransitionEnergy(const std::string & transition) const;
250
251
255 const std::map<std::string, double> & getXRayLines(const std::string & family = "") const;
256
261 std::map<std::string, double> getEmittedXRayLines(const double & energy= 1000.) const;
262
269 std::map<std::string, std::vector <double> >getInitialPhotoelectricVacancyDistribution(\
270 const std::vector<double> & energies) const;
271
278 std::map<std::string, double> getInitialPhotoelectricVacancyDistribution(const double & energy) const;
279
280 std::map<std::string, double> getCascadeModifiedVacancyDistribution(const std::map<std::string, \
281 double> & distribution) const;
282
295 std::map<std::string, std::map<std::string, double> >\
296 getXRayLinesFromVacancyDistribution(const std::map<std::string, double> & distribution, \
297 const int & cascade = 1,
298 const int & useFluorescenceYield = 1) const;
299
305 std::vector<std::map<std::string, std::map<std::string, double> > > \
306 getPhotoelectricExcitationFactors( \
307 const std::vector<double> & energy,
308 const std::vector<double> & weights = std::vector<double>()) const;
309
316 std::map<std::string, std::map<std::string, double> > getPhotoelectricExcitationFactors( \
317 const double & energy,
318 const double & weight = 1.0) const;
319
320
321 const Shell & getShell(const std::string &) const;
322
326 const std::map<std::string, double> & getFluorescenceRatios(const std::string & subshell) const;
327 const std::map<std::string, double> & getAugerRatios(std::string subshell);
328 const std::map<std::string, std::map<std::string, double> > & getCosterKronigRatios(std::string subshell);
329
333 std::pair<long, long> getInterpolationIndices(const std::vector<double> &, const double &) const;
334
343 void setCascadeCacheEnabled(const int & flag = 1);
344 int isCascadeCacheFilled() const;
345
346 void fillCascadeCache();
347 void emptyCascadeCache();
348
352 void fillCache(const std::vector< double> & energy);
353
358 void setCacheEnabled(const int & flag = 1);
359
364 void updateCache(const std::vector< double> & energy);
365
366
370 void clearCache();
371
375 const int isCacheEnabled() const;
376
380 int getCacheSize() const;
381
382 private:
383 std::string name;
384 int atomicNumber;
385 int column;
386 int row;
387 double atomicMass;
388 double density;
389 std::string longName;
390
391
392 std::map<std::string, double> bindingEnergy;
393 // Mass attenuation coefficients and energies
394 std::vector<double> muEnergy;
395 std::map< std::string, std::vector<double> >mu;
396
397 // Partial photoelectric mass attenuation coefficients
398 // For each shell (= key), there is a vector for the energies
399 // and a vector for the value of the mass attenuation coefficients
400 // Expected map key values are:
401 // K, L1, L2, L3, M1, M2, M3, M4, M5, "REST"
402 void initPartialPhotoelectricCoefficients();
403 std::map<std::string, std::vector<double> > muPartialPhotoelectricEnergy;
404 std::map<std::string, std::vector<double> > muPartialPhotoelectricValue;
405
406 // A cache for storing calculations
407 static const unsigned int cacheMaximumSize = 10000;
408 bool calculationCacheEnabledFlag;
409 std::map< double, std::map< std::string, double> > muCache;
410 std::map< double, std::map<std::string, std::map<std::string, double> > > excitationFactorsCache;
411
412 // Shell instance to handle cascade
413 std::map<std::string, Shell> shellInstance;
414
415 // map of the form {"L2":{"omega": fluorescence_yield,
416 // "f12": f12,
417 // "f13": f13}
418 // std::map<std::string, std::map<std::string, double> > shellConstants;
419
420 // map of the form {"KL3":{"energy": bindingEnergy["K"] - bindingEnergy["L3"],
421 // "rate": shellInstance["K"].getFluorescenceRatios()["KL3"]}
422 std::map<std::string, std::map<std::string, double> > shellXRayLines;
423
424 bool cascadeCacheEnabledFlag;
425 // Map of the form
426 // map[(sub)shell][emission_line]["rate"]
427 // map[(sub)shell][emission_line]["energy"]
428 // Providing the emitted X-rays following a single vacancy on a particular (sub)shell considering
429 // cascade and fluorescence yields
430 std::map<std::string, std::map<std::string, std::map<std::string, double> > > cascadeCache;
431 };
432
433 } // namespace fisx
434
435 #endif // FISX_ELEMENT_H
fisx::Element::setName
void setName(const std::string &name)
Definition: fisx_element.cpp:91
fisx::Element::getDensity
double getDensity() const
Definition: fisx_element.cpp:116
fisx::Element::getPartialPhotoelectricMassAttenuationCoefficients
std::map< std::string, double > getPartialPhotoelectricMassAttenuationCoefficients(const double &energy) const
Definition: fisx_element.cpp:682
fisx::Element::clearCache
void clearCache()
Definition: fisx_element.cpp:1699
fisx
Definition: fisx_element.cpp:34
fisx::Shell
Definition: fisx_shell.h:39
fisx::Element::getInitialPhotoelectricVacancyDistribution
std::map< std::string, std::vector< double > > getInitialPhotoelectricVacancyDistribution(const std::vector< double > &energies) const
Definition: fisx_element.cpp:907
fisx::Element::getTransitionEnergy
double getTransitionEnergy(const std::string &transition) const
Definition: fisx_element.cpp:1163
fisx::Element::getExcitedShells
std::vector< std::string > getExcitedShells(const double &energy) const
Definition: fisx_element.cpp:886
fisx::Element::getEmittedXRayLines
std::map< std::string, double > getEmittedXRayLines(const double &energy=1000.) const
Definition: fisx_element.cpp:1118
fisx::Element::getPhotoelectricExcitationFactors
std::vector< std::map< std::string, std::map< std::string, double > > > getPhotoelectricExcitationFactors(const std::vector< double > &energy, const std::vector< double > &weights=std::vector< double >()) const
Definition: fisx_element.cpp:1496
fisx::Element::getBindingEnergies
const std::map< std::string, double > & getBindingEnergies() const
Definition: fisx_element.cpp:198
fisx::Element::getAtomicMass
const double & getAtomicMass() const
Definition: fisx_element.cpp:1472
fisx::Element::getAtomicNumber
const int & getAtomicNumber() const
Definition: fisx_element.cpp:1489
fisx::Element::isCacheEnabled
const int isCacheEnabled() const
Definition: fisx_element.cpp:1687
fisx::Element::setBindingEnergies
void setBindingEnergies(std::map< std::string, double > bindingEnergies)
Definition: fisx_element.cpp:144
fisx::Element::getInterpolationIndices
std::pair< long, long > getInterpolationIndices(const std::vector< double > &, const double &) const
Definition: fisx_element.cpp:1565
fisx::Element::setMassAttenuationCoefficients
void setMassAttenuationCoefficients(const std::vector< double > &energies, const std::vector< double > &photoelectric, const std::vector< double > &coherent, const std::vector< double > &incoherent, const std::vector< double > &pair)
Definition: fisx_element.cpp:214
fisx::Element::updateCache
void updateCache(const std::vector< double > &energy)
Definition: fisx_element.cpp:1740
fisx::Element::setDensity
void setDensity(const double &)
Definition: fisx_element.cpp:111
fisx::Element::getColumn
int getColumn() const
Definition: fisx_element.cpp:126
fisx::Element
Definition: fisx_element.h:40
fisx::Element::setAtomicMass
void setAtomicMass(const double &mass)
Definition: fisx_element.cpp:1462
fisx::Element::setCascadeCacheEnabled
void setCascadeCacheEnabled(const int &flag=1)
Definition: fisx_element.cpp:1629
fisx::Element::getXRayLines
const std::map< std::string, double > & getXRayLines(const std::string &family="") const
Definition: fisx_element.cpp:1113
fisx::Element::getMassAttenuationCoefficients
const std::map< std::string, std::vector< double > > & getMassAttenuationCoefficients() const
Definition: fisx_element.cpp:320
fisx::Element::fillCache
void fillCache(const std::vector< double > &energy)
Definition: fisx_element.cpp:1705
fisx::Element::setColumn
void setColumn(const int &)
Definition: fisx_element.cpp:121
fisx::Element::getCacheSize
int getCacheSize() const
Definition: fisx_element.cpp:1783
fisx::Element::getLongName
std::string getLongName() const
Definition: fisx_element.cpp:106
fisx::Element::setAtomicNumber
void setAtomicNumber(const int &z)
Definition: fisx_element.cpp:1479
fisx::Element::setLongName
void setLongName(const std::string &name)
Definition: fisx_element.cpp:101
fisx::Element::getRow
int getRow() const
Definition: fisx_element.cpp:136
fisx::Element::Element
Element()
Definition: fisx_element.cpp:37
fisx::Element::getFluorescenceRatios
const std::map< std::string, double > & getFluorescenceRatios(const std::string &subshell) const
Definition: fisx_element.cpp:1081
fisx::Element::setCacheEnabled
void setCacheEnabled(const int &flag=1)
Definition: fisx_element.cpp:1679
fisx::Element::setPartialPhotoelectricMassAttenuationCoefficients
void setPartialPhotoelectricMassAttenuationCoefficients(const std::string &shell, const std::vector< double > &energy, const std::vector< double > &partialPhotoelectric)
Definition: fisx_element.cpp:616
fisx::Element::setRow
void setRow(const int &)
Definition: fisx_element.cpp:131
fisx::Element::getName
std::string getName() const
Definition: fisx_element.cpp:96
fisx::Element::setTotalMassAttenuationCoefficient
void setTotalMassAttenuationCoefficient(const std::vector< double > &energies, const std::vector< double > &total)
Definition: fisx_element.cpp:306