AlmaBTE  1.3
A solver of the space- and time-dependent Boltzmann transport equation for phonons
periodic_table.hpp
Go to the documentation of this file.
1 // Copyright 2015-2018 The ALMA Project Developers
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 // implied. See the License for the specific language governing
13 // permissions and limitations under the License.
14 
15 #pragma once
16 
19 
20 #include <string>
21 #include <vector>
22 #include <algorithm>
23 #include <exceptions.hpp>
24 
25 namespace alma {
28 const std::vector<std::string> elements{
29  "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na",
30  "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti",
31  "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As",
32  "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru",
33  "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs",
34  "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy",
35  "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir",
36  "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra",
37  "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es",
38  "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt"};
39 
44 inline int symbol_to_Z(const std::string& element) {
45  auto pos = std::find(elements.begin(), elements.end(), element);
46 
47  if (pos == elements.end()) {
48  throw value_error("unknown chemical symbol");
49  }
50  return std::distance(elements.begin(), pos) + 1;
51 }
52 
53 
58 inline std::string Z_to_symbol(decltype(elements.size()) Z) {
59  if ((Z < 1) || (Z > elements.size()))
60  throw value_error("invalid atomic number");
61  return elements[Z - 1];
62 }
63 
64 
71 double get_mass(const std::string& element, bool disablev = false);
72 
80 double get_gfactor(const std::string& element, bool disablev = false);
81 
85 public:
90  Virtual_element(const std::vector<std::string>& symbols,
91  const std::vector<double>& ratios);
102  Virtual_element(const std::string& composition);
107  std::size_t get_nelements() const {
108  return this->symbols.size();
109  }
110 
111 
116  std::string get_symbol(std::size_t i) const {
117  if (i >= this->symbols.size())
118  throw value_error("invalid element number");
119  return this->symbols[i];
120  }
121 
122 
128  double get_ratio(std::size_t i) const {
129  if (i >= this->symbols.size())
130  throw value_error("invalid element number");
131  return this->ratios[i];
132  }
133 
134 
139  std::string get_name() const;
140 
141 private:
143  std::vector<std::string> symbols;
146  std::vector<double> ratios;
147 };
148 } // namespace alma
double get_mass(const std::string &element, bool disablev=false)
Compute the average mass of an element.
Definition: periodic_table.cpp:215
Definition: analytic1d.hpp:26
Exception related to the parameters passed to a function.
Definition: exceptions.hpp:33
std::size_t get_nelements() const
Return the number of elements in the mix.
Definition: periodic_table.hpp:107
Exceptions used in ALMA.
std::string Z_to_symbol(decltype(elements.size()) Z)
Return the symbol corresponding to an atomic number.
Definition: periodic_table.hpp:58
std::string get_symbol(std::size_t i) const
Return the symbol of the i-th component of the mixture.
Definition: periodic_table.hpp:116
std::string get_name() const
Obtain a textual representation of the virtual element.
Definition: periodic_table.cpp:367
const std::vector< std::string > elements
Names of all supported elements (and then some) sorted by atomic number.
Definition: periodic_table.hpp:28
double get_ratio(std::size_t i) const
Return the atomic ratio of the i-th component of the mixture.
Definition: periodic_table.hpp:128
double get_gfactor(const std::string &element, bool disablev=false)
Compute the squared Pearson deviation factor of the mass distribution for an element.
Definition: periodic_table.cpp:243
int symbol_to_Z(const std::string &element)
Return the atomic number of an element.
Definition: periodic_table.hpp:44
Virtual_element(const std::vector< std::string > &symbols, const std::vector< double > &ratios)
Trivial constructor.
Definition: periodic_table.cpp:272
Class whose objects describe a virtual "element" in an alloy, i.e., a statistical mixture of chemical...
Definition: periodic_table.hpp:84