6#ifndef NURI_CORE_ELEMENT_H_
7#define NURI_CORE_ELEMENT_H_
16#include <absl/container/flat_hash_map.h>
24 constexpr double kElectronMass = 5.48579909065e-4;
159 enum class Type : std::uint8_t {
187 return valence_electrons_;
194 constexpr std::int16_t
period() const noexcept {
return period_; }
201 constexpr std::int16_t
group() const noexcept {
return group_; }
209 return internal::check_flag(flags_, ElementFlags::kRadioactive);
217 return internal::check_flag(flags_, ElementFlags::kMainGroup);
225 return internal::check_flag(flags_, ElementFlags::kLanthanide);
233 return internal::check_flag(flags_, ElementFlags::kActinide);
240 constexpr Type type() const noexcept {
return type_; }
252 constexpr std::string_view
symbol() const noexcept {
return symbol_; }
258 constexpr std::string_view
name() const noexcept {
return name_; }
279 constexpr double vdw_radius() const noexcept {
return vdw_rad_; }
287 constexpr double eneg() const noexcept {
return eneg_; }
297 return *major_isotope_;
306 auto it = std::find_if(isotopes_.begin(), isotopes_.end(),
307 [mass_number](
const Isotope &iso) {
308 return iso.mass_number == mass_number;
310 if (it == isotopes_.end()) {
321 constexpr const std::vector<Isotope> &
isotopes() const noexcept {
326 enum class ElementFlags : std::uint16_t {
335 std::vector<Isotope> &&
isotopes)
noexcept;
345 std::int16_t valence_electrons_;
346 std::int16_t period_;
351 std::string_view symbol_;
352 std::string_view name_;
353 double atomic_weight_;
358 std::vector<
Isotope> isotopes_;
366 return lhs.atomic_number() != rhs.atomic_number();
479 std::
string symb_name_buf_;
480 absl::flat_hash_map<std::string_view, const
Element *> symbol_to_element_;
481 absl::flat_hash_map<std::string_view, const
Element *> name_to_element_;
The class for element data.
Definition element.h:157
constexpr std::string_view name() const noexcept
Get the IUPAC Name of the atom.
Definition element.h:258
constexpr double eneg() const noexcept
Get electronegativity of the element (Pauling scale).
Definition element.h:287
friend class PeriodicTable
Definition element.h:342
~Element() noexcept=default
constexpr const std::vector< Isotope > & isotopes() const noexcept
Get all known isotopes of the element.
Definition element.h:321
constexpr bool main_group() const noexcept
Test if the molecule is a main group element.
Definition element.h:216
constexpr double covalent_radius() const noexcept
Get the covalent radius of the atom.
Definition element.h:272
Type
Definition element.h:159
@ kUnknown
Definition element.h:160
@ kMetalloid
Definition element.h:162
@ kMetal
Definition element.h:161
@ kNonmetal
Definition element.h:163
constexpr std::string_view symbol() const noexcept
Get the IUPAC Symbol of the atom.
Definition element.h:252
constexpr bool radioactive() const noexcept
Test if the molecule is radioactive. That is, all of its isotopes has natural abundance of 0.
Definition element.h:208
constexpr Type type() const noexcept
Get the type of the element.
Definition element.h:240
constexpr bool actinide() const noexcept
Test if the molecule is an actinide.
Definition element.h:232
const Isotope * find_isotope(int mass_number) const noexcept
Find an element with the given mass number.
Definition element.h:305
State
Definition element.h:166
@ kLiquid
Definition element.h:169
@ kSolid
Definition element.h:168
@ kGas
Definition element.h:170
constexpr bool lanthanide() const noexcept
Test if the molecule is a lanthanide.
Definition element.h:224
constexpr std::int16_t group() const noexcept
Get the group of the element.
Definition element.h:201
constexpr const Isotope & major_isotope() const noexcept
Get the representative isotope of the element.
Definition element.h:296
constexpr int atomic_number() const noexcept
Get the atomic number of the atom.
Definition element.h:180
constexpr double atomic_weight() const noexcept
Get the atomic weight of the atom.
Definition element.h:265
constexpr double vdw_radius() const noexcept
Get the Van der Waals radius of the atom.
Definition element.h:279
constexpr std::int16_t period() const noexcept
Get the period of the atom.
Definition element.h:194
constexpr State state() const noexcept
Get the standard state of the element.
Definition element.h:246
constexpr std::int16_t valence_electrons() const noexcept
Get the number of valence electrons of the atom.
Definition element.h:186
bool has_element(std::string_view symbol) const noexcept
Check if the periodic table has an element with the given atomic symbol.
const Element * find_element_of_name(std::string_view name) const noexcept
Find element with the given name.
PeriodicTable(const PeriodicTable &)=delete
static constexpr bool has_element(int atomic_number) noexcept
Check if the periodic table has an element with the given atomic symbol.
Definition element.h:441
static constexpr int kElementCount_
Definition element.h:473
static const PeriodicTable & get() noexcept
Get the singleton instance of the periodic table.
PeriodicTable(PeriodicTable &&) noexcept=delete
constexpr const Element * find_element(int atomic_number) const noexcept
Find element with the given atomic number.
Definition element.h:408
const Element * find_element(std::string_view symbol) const noexcept
Find element with the given atomic symbol.
const Element * end() const noexcept
Definition element.h:469
bool has_element_of_name(std::string_view name) const noexcept
Check if the periodic table has an element with the given atomic name.
const Element * begin() const noexcept
Definition element.h:468
constexpr bool operator==(const Isotope &lhs, const Isotope &rhs) noexcept
Definition element.h:34
constexpr bool operator!=(const Isotope &lhs, const Isotope &rhs) noexcept
Definition element.h:38
int atomic_number
Definition element.h:28
double atomic_weight
Definition element.h:30
int mass_number
Definition element.h:29
double abundance
Definition element.h:31