Chemical Data Processing Library C++ API - Version 1.1.1
AtomDictionary.hpp
Go to the documentation of this file.
1 /*
2  * AtomDictionary.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_ATOMDICTIONARY_HPP
30 #define CDPL_CHEM_ATOMDICTIONARY_HPP
31 
32 #include <cstddef>
33 #include <string>
34 #include <utility>
35 #include <unordered_map>
36 #include <memory>
37 #include <functional>
38 
39 #include <boost/iterator/transform_iterator.hpp>
40 #include <boost/functional/hash.hpp>
41 
42 #include "CDPL/Chem/APIPrefix.hpp"
43 #include "CDPL/Util/Array.hpp"
44 #include "CDPL/Util/Map.hpp"
45 
46 
47 namespace CDPL
48 {
49 
50  namespace Chem
51  {
52 
58  {
59 
60  public:
62  {
63 
64  public:
66 
67  Entry();
68 
69  Entry(unsigned int atom_type, std::size_t iso, const std::string& sym,
70  const std::string& name, std::size_t most_abdt_iso, double avg_weight,
71  std::size_t iupac_grp, std::size_t period, bool metal, bool non_metal, const Util::STArray& val_states,
72  double vdw_rad, const double cov_radii[3], double ar_eneg, const IsotopeMassMap& iso_masses);
73 
74  unsigned int getType() const;
75 
76  std::size_t getIsotope() const;
77 
78  const std::string& getSymbol() const;
79 
80  const std::string& getName() const;
81 
82  std::size_t getMostAbundantIsotope() const;
83 
84  double getAverageWeight() const;
85 
86  std::size_t getIUPACGroup() const;
87 
88  std::size_t getPeriod() const;
89 
90  bool isMetal() const;
91 
92  bool isNonMetal() const;
93 
95 
96  double getVdWRadius() const;
97 
98  double getCovalentRadius(std::size_t order) const;
99 
101 
103 
104  private:
105  unsigned int atomType;
106  std::size_t isotope;
107  std::string symbol;
108  std::string name;
109  std::size_t mostAbundantIso;
110  double avgWeight;
111  std::size_t iupacGroup;
112  std::size_t period;
113  bool isMet;
114  bool isNonMet;
115  Util::STArray valenceStates;
116  double vdwRadius;
117  double covalentRadii[3];
118  double allredRochowEneg;
119  IsotopeMassMap isoMassMap;
120  };
121 
122  private:
123  typedef std::unordered_map<std::pair<unsigned int, std::size_t>, Entry, boost::hash<std::pair<unsigned int, std::size_t> > > EntryLookupTable;
124  typedef std::unordered_map<std::string, unsigned int> SymbolToTypeLookupTable;
125 
126  public:
127  typedef std::shared_ptr<AtomDictionary> SharedPointer;
128 
129  typedef boost::transform_iterator<std::function<const Entry&(const EntryLookupTable::value_type&)>,
130  EntryLookupTable::const_iterator>
132 
133  void addEntry(const Entry& entry);
134 
135  bool containsEntry(unsigned int type, std::size_t isotope) const;
136 
137  void removeEntry(unsigned int type, std::size_t isotope);
138 
139  const Entry& getEntry(unsigned int type, std::size_t isotope) const;
140 
141  void clear();
142 
143  std::size_t getNumEntries() const;
144 
146 
148 
150 
152 
153  void loadDefaults();
154 
155  static void set(const SharedPointer& dict);
156 
157  static const SharedPointer& get();
158 
170  static const std::string& getSymbol(unsigned int type, std::size_t isotope = 0);
171 
184  static const std::string& getName(unsigned int type, std::size_t isotope = 0);
185 
194  static unsigned int getType(const std::string& symbol, bool strict = false);
195 
203  static std::size_t getMostAbundantIsotope(unsigned int type);
204 
211  static std::size_t getIUPACGroup(unsigned int type);
212 
219  static std::size_t getPeriod(unsigned int type);
220 
227  static std::size_t getNumValenceElectrons(unsigned int type);
228 
243  static double getAtomicWeight(unsigned int type, std::size_t isotope = 0);
244 
251  static double getVdWRadius(unsigned int type);
252 
260  static double getCovalentRadius(unsigned int type, std::size_t order = 1);
261 
269  static double getAllredRochowElectronegativity(unsigned int type);
270 
276  static const Util::STArray& getValenceStates(unsigned int type);
277 
283  static bool isChemicalElement(unsigned int type);
284 
290  static bool isMainGroupElement(unsigned int type);
291 
297  static bool isTransitionMetal(unsigned int type);
298 
304  static bool isMetal(unsigned int type);
305 
311  static bool isSemiMetal(unsigned int type);
312 
318  static bool isNonMetal(unsigned int type);
319 
325  static bool isHalogen(unsigned int type);
326 
332  static bool isNobleGas(unsigned int type);
333 
334  private:
335  static SharedPointer defaultDict;
336  EntryLookupTable entries;
337  SymbolToTypeLookupTable strictSymToTypeTable;
338  SymbolToTypeLookupTable nonstrictSymToTypeTable;
339  };
340  }; // namespace Chem
341 } // namespace CDPL
342 
343 #endif // CDPL_CHEM_ATOMDICTIONARY_HPP
CDPL::Chem::AtomDictionary::Entry::isMetal
bool isMetal() const
CDPL::Chem::AtomDictionary::Entry::getName
const std::string & getName() const
CDPL::Chem::AtomDictionary::Entry::getPeriod
std::size_t getPeriod() const
CDPL::Chem::AtomDictionary::getType
static unsigned int getType(const std::string &symbol, bool strict=false)
Returns the numeric atom type that is associated with the specified atom type symbol.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::AtomDictionary::Entry::getIUPACGroup
std::size_t getIUPACGroup() const
CDPL::Chem::AtomDictionary::getIUPACGroup
static std::size_t getIUPACGroup(unsigned int type)
Returns the IUPAC group of the chemical element specified by type.
CDPL::Chem::AtomDictionary::containsEntry
bool containsEntry(unsigned int type, std::size_t isotope) const
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::AtomDictionary::isNobleGas
static bool isNobleGas(unsigned int type)
Tells whether the chemical element specified by type is a noble gas.
CDPL::Util::Map< std::size_t, double >
CDPL::Chem::AtomDictionary::loadDefaults
void loadDefaults()
CDPL::Chem::AtomDictionary::isHalogen
static bool isHalogen(unsigned int type)
Tells whether the chemical element specified by type is a halogen.
CDPL::Chem::AtomDictionary::Entry::getSymbol
const std::string & getSymbol() const
CDPL::Chem::AtomDictionary::removeEntry
void removeEntry(unsigned int type, std::size_t isotope)
Map.hpp
Definition of the class CDPL::Util::Map.
CDPL::Chem::AtomDictionary::begin
ConstEntryIterator begin() const
CDPL::Chem::AtomDictionary::isMetal
static bool isMetal(unsigned int type)
Tells whether the chemical element specified by type is a metal.
CDPL::Chem::AtomDictionary::clear
void clear()
CDPL::Chem::AtomDictionary::Entry::Entry
Entry()
CDPL::Chem::AtomDictionary::SharedPointer
std::shared_ptr< AtomDictionary > SharedPointer
Definition: AtomDictionary.hpp:127
Array.hpp
Definition of the class CDPL::Util::Array.
CDPL::Chem::AtomDictionary::getAtomicWeight
static double getAtomicWeight(unsigned int type, std::size_t isotope=0)
Returns the standard atomic weight or the relative isotopic mass of an isotope of the chemical elemen...
CDPL::Chem::AtomDictionary::Entry::getIsotope
std::size_t getIsotope() const
CDPL::Chem::AtomDictionary::isNonMetal
static bool isNonMetal(unsigned int type)
Tells whether the chemical element specified by type is a non-metal.
CDPL::Chem::AtomDictionary::isTransitionMetal
static bool isTransitionMetal(unsigned int type)
Tells whether the chemical element specified by type is a transition metal.
CDPL::Chem::AtomDictionary::Entry::getAllredRochowElectronegativity
double getAllredRochowElectronegativity() const
CDPL::Chem::AtomDictionary::getName
static const std::string & getName(unsigned int type, std::size_t isotope=0)
Returns the name of the chemical element that is associated with the specified atom type and isotope.
CDPL::Chem::AtomDictionary::Entry::getValenceStates
const Util::STArray & getValenceStates() const
CDPL::Chem::AtomDictionary::Entry::getAverageWeight
double getAverageWeight() const
CDPL::Chem::AtomDictionary::Entry::getVdWRadius
double getVdWRadius() const
CDPL::Chem::AtomDictionary::isChemicalElement
static bool isChemicalElement(unsigned int type)
Tells whether the specified atom type represents a chemical element.
CDPL::Chem::AtomDictionary::getEntriesBegin
ConstEntryIterator getEntriesBegin() const
CDPL::Chem::AtomDictionary::Entry::getCovalentRadius
double getCovalentRadius(std::size_t order) const
CDPL::Chem::AtomDictionary::getMostAbundantIsotope
static std::size_t getMostAbundantIsotope(unsigned int type)
Returns the mass number of the most abundant isotope of the chemical element specified by type.
CDPL::Chem::AtomDictionary::getVdWRadius
static double getVdWRadius(unsigned int type)
Returns the van der Waals radius of the chemical element specified by type.
CDPL::Chem::AtomDictionary::isSemiMetal
static bool isSemiMetal(unsigned int type)
Tells whether the chemical element specified by type is a semi-metal.
CDPL::Chem::AtomDictionary::addEntry
void addEntry(const Entry &entry)
CDPL::Chem::AtomDictionary::getEntriesEnd
ConstEntryIterator getEntriesEnd() const
CDPL::Chem::AtomDictionary::Entry::getType
unsigned int getType() const
CDPL::Chem::AtomDictionary::Entry::IsotopeMassMap
Util::Map< std::size_t, double > IsotopeMassMap
Definition: AtomDictionary.hpp:65
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::AtomDictionary::getSymbol
static const std::string & getSymbol(unsigned int type, std::size_t isotope=0)
Returns the symbol that is associated with the specified atom type and isotope.
CDPL::Chem::AtomDictionary::ConstEntryIterator
boost::transform_iterator< std::function< const Entry &(const EntryLookupTable::value_type &)>, EntryLookupTable::const_iterator > ConstEntryIterator
Definition: AtomDictionary.hpp:131
CDPL::Util::STArray
Array< std::size_t > STArray
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
CDPL::Chem::AtomDictionary::Entry::isNonMetal
bool isNonMetal() const
CDPL::Chem::AtomDictionary::getNumEntries
std::size_t getNumEntries() const
CDPL::Chem::AtomDictionary::getAllredRochowElectronegativity
static double getAllredRochowElectronegativity(unsigned int type)
Returns the Allred-Rochow electronegativity of the chemical element specified by type.
CDPL::Chem::AtomDictionary::Entry
Definition: AtomDictionary.hpp:62
CDPL::Chem::AtomDictionary::getEntry
const Entry & getEntry(unsigned int type, std::size_t isotope) const
CDPL::Chem::AtomDictionary::set
static void set(const SharedPointer &dict)
CDPL::Chem::AtomDictionary::Entry::getMostAbundantIsotope
std::size_t getMostAbundantIsotope() const
CDPL::Chem::AtomDictionary
A global dictionary for the lookup of data associated with the atom types defined in namespace Chem::...
Definition: AtomDictionary.hpp:58
CDPL::Chem::AtomDictionary::getNumValenceElectrons
static std::size_t getNumValenceElectrons(unsigned int type)
Returns the number of valence electrons of the chemical element specified by type.
CDPL::Chem::AtomDictionary::isMainGroupElement
static bool isMainGroupElement(unsigned int type)
Tells whether the chemical element specified by type is a main group element.
CDPL::Chem::AtomDictionary::getValenceStates
static const Util::STArray & getValenceStates(unsigned int type)
Returns an array with the valence states of the chemical element specified by type.
CDPL::Chem::AtomDictionary::Entry::getIsotopeMasses
const IsotopeMassMap & getIsotopeMasses() const
CDPL::Chem::AtomDictionary::getCovalentRadius
static double getCovalentRadius(unsigned int type, std::size_t order=1)
Returns the covalent radius of the chemical element specified by type for the given bond order.
CDPL::Chem::AtomDictionary::getPeriod
static std::size_t getPeriod(unsigned int type)
Returns the period number of the chemical element specified by type.
CDPL::Chem::AtomDictionary::get
static const SharedPointer & get()
CDPL::Chem::AtomDictionary::end
ConstEntryIterator end() const
CDPL::Chem::AtomDictionary::Entry::Entry
Entry(unsigned int atom_type, std::size_t iso, const std::string &sym, const std::string &name, std::size_t most_abdt_iso, double avg_weight, std::size_t iupac_grp, std::size_t period, bool metal, bool non_metal, const Util::STArray &val_states, double vdw_rad, const double cov_radii[3], double ar_eneg, const IsotopeMassMap &iso_masses)