Chemical Data Processing Library C++ API - Version 1.4.0
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:
65  {
66 
67  public:
72 
76  Entry();
77 
96  Entry(unsigned int atom_type, std::size_t iso, const std::string& sym,
97  const std::string& name, std::size_t most_abdt_iso, double avg_weight,
98  std::size_t iupac_grp, std::size_t period, bool metal, bool non_metal, const Util::STArray& val_states,
99  double vdw_rad, const double cov_radii[3], double ar_eneg, const IsotopeMassMap& iso_masses);
100 
105  unsigned int getType() const;
106 
111  std::size_t getIsotope() const;
112 
117  const std::string& getSymbol() const;
118 
123  const std::string& getName() const;
124 
129  std::size_t getMostAbundantIsotope() const;
130 
135  double getAverageWeight() const;
136 
141  std::size_t getIUPACGroup() const;
142 
147  std::size_t getPeriod() const;
148 
153  bool isMetal() const;
154 
159  bool isNonMetal() const;
160 
166 
171  double getVdWRadius() const;
172 
178  double getCovalentRadius(std::size_t order) const;
179 
185 
191 
192  private:
193  unsigned int atomType;
194  std::size_t isotope;
195  std::string symbol;
196  std::string name;
197  std::size_t mostAbundantIso;
198  double avgWeight;
199  std::size_t iupacGroup;
200  std::size_t period;
201  bool isMet;
202  bool isNonMet;
203  Util::STArray valenceStates;
204  double vdwRadius;
205  double covalentRadii[3];
206  double allredRochowEneg;
207  IsotopeMassMap isoMassMap;
208  };
209 
210  private:
211  typedef std::unordered_map<std::pair<unsigned int, std::size_t>, Entry, boost::hash<std::pair<unsigned int, std::size_t> > > EntryLookupTable;
212  typedef std::unordered_map<std::string, unsigned int> SymbolToTypeLookupTable;
213 
214  public:
218  typedef std::shared_ptr<AtomDictionary> SharedPointer;
219 
223  typedef boost::transform_iterator<std::function<const Entry&(const EntryLookupTable::value_type&)>,
224  EntryLookupTable::const_iterator>
226 
231  void addEntry(const Entry& entry);
232 
239  bool containsEntry(unsigned int type, std::size_t isotope) const;
240 
246  void removeEntry(unsigned int type, std::size_t isotope);
247 
255  const Entry& getEntry(unsigned int type, std::size_t isotope) const;
256 
260  void clear();
261 
266  std::size_t getNumEntries() const;
267 
273 
279 
285 
291 
295  void loadDefaults();
296 
301  static void set(const SharedPointer& dict);
302 
307  static const SharedPointer& get();
308 
320  static const std::string& getSymbol(unsigned int type, std::size_t isotope = 0);
321 
334  static const std::string& getName(unsigned int type, std::size_t isotope = 0);
335 
344  static unsigned int getType(const std::string& symbol, bool strict = false);
345 
353  static std::size_t getMostAbundantIsotope(unsigned int type);
354 
361  static std::size_t getIUPACGroup(unsigned int type);
362 
369  static std::size_t getPeriod(unsigned int type);
370 
377  static std::size_t getNumValenceElectrons(unsigned int type);
378 
393  static double getAtomicWeight(unsigned int type, std::size_t isotope = 0);
394 
401  static double getVdWRadius(unsigned int type);
402 
410  static double getCovalentRadius(unsigned int type, std::size_t order = 1);
411 
419  static double getAllredRochowElectronegativity(unsigned int type);
420 
426  static const Util::STArray& getValenceStates(unsigned int type);
427 
433  static bool isChemicalElement(unsigned int type);
434 
440  static bool isMainGroupElement(unsigned int type);
441 
447  static bool isTransitionMetal(unsigned int type);
448 
454  static bool isMetal(unsigned int type);
455 
461  static bool isSemiMetal(unsigned int type);
462 
468  static bool isNonMetal(unsigned int type);
469 
475  static bool isHalogen(unsigned int type);
476 
482  static bool isNobleGas(unsigned int type);
483 
484  private:
485  static SharedPointer defaultDict;
486  EntryLookupTable entries;
487  SymbolToTypeLookupTable strictSymToTypeTable;
488  SymbolToTypeLookupTable nonstrictSymToTypeTable;
489  };
490  }; // namespace Chem
491 } // namespace CDPL
492 
493 #endif // CDPL_CHEM_ATOMDICTIONARY_HPP
Definition of class CDPL::Util::Array.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Util::Map.
A single dictionary entry describing the properties of an (atom type, isotope) pair.
Definition: AtomDictionary.hpp:65
const IsotopeMassMap & getIsotopeMasses() const
Returns the map from isotope mass number to its relative isotopic mass for the element.
double getAverageWeight() const
Returns the standard (average) atomic weight of the element.
double getCovalentRadius(std::size_t order) const
Returns the covalent radius of the element for the given bond order.
bool isNonMetal() const
Tells whether the element is a non-metal.
double getVdWRadius() const
Returns the Van der Waals radius of the element.
std::size_t getIUPACGroup() const
Returns the IUPAC group number of the element.
const Util::STArray & getValenceStates() const
Returns the valence states of the element.
std::size_t getPeriod() const
Returns the period of the element.
bool isMetal() const
Tells whether the element is a metal.
unsigned int getType() const
Returns the atom type of the entry.
const std::string & getName() const
Returns the element name of the entry.
std::size_t getMostAbundantIsotope() const
Returns the mass number of the most abundant isotope of the element.
Util::Map< std::size_t, double > IsotopeMassMap
A map from isotope mass number to its relative isotopic mass.
Definition: AtomDictionary.hpp:71
const std::string & getSymbol() const
Returns the element symbol of the 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)
Constructs an entry with the given properties.
std::size_t getIsotope() const
Returns the mass number of the isotope of the entry.
double getAllredRochowElectronegativity() const
Returns the Allred-Rochow electronegativity of the element.
Entry()
Constructs an empty entry.
A global dictionary for the lookup of data associated with the atom types defined in namespace Chem::...
Definition: AtomDictionary.hpp:58
static std::size_t getPeriod(unsigned int type)
Returns the period number of the chemical element specified by type.
void clear()
Removes all entries from the dictionary.
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.
static const SharedPointer & get()
Returns the process-wide default atom dictionary.
static bool isMetal(unsigned int type)
Tells whether the chemical element specified by type is a metal.
ConstEntryIterator begin() const
Returns a constant iterator pointing to the first entry (range-based for support).
static bool isNobleGas(unsigned int type)
Tells whether the chemical element specified by type is a noble gas.
const Entry & getEntry(unsigned int type, std::size_t isotope) const
Returns the entry for the given (type, isotope) pair.
std::size_t getNumEntries() const
Returns the number of entries stored in the dictionary.
std::shared_ptr< AtomDictionary > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated AtomDictionary instances.
Definition: AtomDictionary.hpp:218
static double getAllredRochowElectronegativity(unsigned int type)
Returns the Allred-Rochow electronegativity of the chemical element specified by type.
static std::size_t getMostAbundantIsotope(unsigned int type)
Returns the mass number of the most abundant isotope of the chemical element specified by type.
static bool isHalogen(unsigned int type)
Tells whether the chemical element specified by type is a halogen.
void loadDefaults()
Loads the default atom dictionary bundled with CDPKit.
static bool isSemiMetal(unsigned int type)
Tells whether the chemical element specified by type is a semi-metal.
static const Util::STArray & getValenceStates(unsigned int type)
Returns an array with the valence states of the chemical element specified by type.
void addEntry(const Entry &entry)
Adds the given entry to the dictionary. Any pre-existing entry for the same (type,...
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.
static void set(const SharedPointer &dict)
Sets the process-wide default atom dictionary used by the static accessor methods.
boost::transform_iterator< std::function< const Entry &(const EntryLookupTable::value_type &)>, EntryLookupTable::const_iterator > ConstEntryIterator
A constant iterator over the entries of the dictionary.
Definition: AtomDictionary.hpp:225
ConstEntryIterator end() const
Returns a constant iterator pointing one past the last entry (range-based for support).
static bool isChemicalElement(unsigned int type)
Tells whether the specified atom type represents a chemical element.
static double getVdWRadius(unsigned int type)
Returns the Van der Waals radius of the chemical element specified by type.
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing one past the last entry.
bool containsEntry(unsigned int type, std::size_t isotope) const
Tells whether the dictionary contains an entry for the given (type, isotope) pair.
static bool isNonMetal(unsigned int type)
Tells whether the chemical element specified by type is a non-metal.
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.
static bool isTransitionMetal(unsigned int type)
Tells whether the chemical element specified by type is a transition metal.
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the first entry.
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.
static std::size_t getIUPACGroup(unsigned int type)
Returns the IUPAC group of the chemical element specified by type.
static bool isMainGroupElement(unsigned int type)
Tells whether the chemical element specified by type is a main group element.
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...
void removeEntry(unsigned int type, std::size_t isotope)
Removes the entry for the given (type, isotope) pair, if present.
static std::size_t getNumValenceElectrons(unsigned int type)
Returns the number of valence electrons of the chemical element specified by type.
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:575
The namespace of the Chemical Data Processing Library.