| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef AVOGADRO_CORE_ELEMENTS_H |
| 7 |
#define AVOGADRO_CORE_ELEMENTS_H |
| 8 |
|
| 9 |
#include "avogadrocoreexport.h" |
| 10 |
|
| 11 |
#include <string> |
| 12 |
|
| 13 |
namespace Avogadro::Core { |
| 14 |
|
| 15 |
constexpr unsigned char element_count = 119; //!< from 0 to 118 |
| 16 |
|
| 17 |
/** |
| 18 |
* @class Elements elements.h <avogadro/core/elements.h> |
| 19 |
* @brief The Elements class stores basic data about chemical elements. |
| 20 |
* |
| 21 |
* The elements class gives a simple interface to basic data about chemical |
| 22 |
* elements. |
| 23 |
* |
| 24 |
* The atomic numbers between the symbolic constants CustomElementMin and |
| 25 |
* CustomElementMax are used to represent non-elemental entities, such as |
| 26 |
* particles or structures units from MD simulations. Custom elements names and |
| 27 |
* symbols are returned as name="CustomElement_aa" and symbol="Xaa", where 'aa' |
| 28 |
* is some combination of lowercase letters that is unique to the particular |
| 29 |
* custom element atomic number. For all custom elements, the radii will match |
| 30 |
* Carbon, the color is random (but consistent), and the mass is zero. |
| 31 |
*/ |
| 32 |
|
| 33 |
class AVOGADROCORE_EXPORT Elements |
| 34 |
{ |
| 35 |
public: |
| 36 |
Elements() = default; |
| 37 |
~Elements() = default; |
| 38 |
|
| 39 |
/** @return the number of elements in the database. */ |
| 40 |
static unsigned char elementCount(); |
| 41 |
|
| 42 |
/** |
| 43 |
* @return the atomic number from the supplied element @p name. If the name is |
| 44 |
* not recognised then Avogadro::InvalidElement will be returned. 0 represents |
| 45 |
* the dummy atom ("Dummy"). |
| 46 |
* @note The input string is expected to be lowercase with the first letter |
| 47 |
* capitalized. |
| 48 |
*/ |
| 49 |
static unsigned char atomicNumberFromName(const std::string& name); |
| 50 |
|
| 51 |
/** |
| 52 |
* @return the atomic number from the supplied @p symbol. If the symbol is not |
| 53 |
* recognised then Avogadro::InvalidElement will be returned. 0 represents the |
| 54 |
* dummy atom ("Xx"). |
| 55 |
* @note The input string is expected to be lowercase with the first letter |
| 56 |
* capitalized. |
| 57 |
*/ |
| 58 |
static unsigned char atomicNumberFromSymbol(const std::string& symbol); |
| 59 |
|
| 60 |
/** |
| 61 |
* Given a string @p str, attempt to identify an element symbol, name, or |
| 62 |
* atomic number. This method is slower and less reliable than the |
| 63 |
* atomicNumberFrom*() methods, and is only intended for making an initial |
| 64 |
* guess of user input. |
| 65 |
* @return the atomic number that best matches the string, or InvalidElement |
| 66 |
* if no match can be made. |
| 67 |
*/ |
| 68 |
static unsigned char guessAtomicNumber(const std::string& str); |
| 69 |
|
| 70 |
/** @return the name of the element with the supplied @p atomicNumber. */ |
| 71 |
static const char* name(unsigned char atomicNumber); |
| 72 |
|
| 73 |
/** @return the symbol of the element with the supplied @p atomicNumber. */ |
| 74 |
static const char* symbol(unsigned char atomicNumber); |
| 75 |
|
| 76 |
/** @return the mass of the element with the supplied @p atomicNumber. */ |
| 77 |
static double mass(unsigned char atomicNumber); |
| 78 |
|
| 79 |
/** |
| 80 |
* @return the Van der Waals radius of the element with the supplied |
| 81 |
* @p atomicNumber. |
| 82 |
*/ |
| 83 |
static double radiusVDW(unsigned char atomicNumber); |
| 84 |
|
| 85 |
/** @return the covalent radius of the element with the supplied |
| 86 |
* @p atomicNumber. |
| 87 |
*/ |
| 88 |
static double radiusCovalent(unsigned char atomicNumber); |
| 89 |
|
| 90 |
/** |
| 91 |
* @return the default color of the element with the supplied @p atomicNumber. |
| 92 |
* This is a pointer to a static three component unsigned char color. |
| 93 |
*/ |
| 94 |
static const unsigned char* color(unsigned char atomicNumber); |
| 95 |
|
| 96 |
/** @return the number of valence electrons for the supplied @p atomicNumber |
| 97 |
*/ |
| 98 |
static unsigned char valenceElectrons(unsigned char atomicNumber); |
| 99 |
|
| 100 |
/** |
| 101 |
* @return the mass of the element with the supplied @p atomicNumber and |
| 102 |
* isotope @p isotopeNumber. |
| 103 |
* @param atomicNumber The atomic number of the element. |
| 104 |
* @param isotopeNumber The isotope number of the element. |
| 105 |
*/ |
| 106 |
static double isotopeMass(unsigned char atomicNumber, |
| 107 |
unsigned short isotopeNumber); |
| 108 |
}; |
| 109 |
|
| 110 |
} // namespace Avogadro::Core |
| 111 |
|
| 112 |
#endif // AVOGADRO_CORE_ELEMENTS_H |