| 1 |
gezelter |
1210 |
/********************************************************************** |
| 2 |
|
|
|
| 3 |
|
|
This basic Periodic Table class was originally taken from the data.h |
| 4 |
|
|
file in OpenBabel. The code has been modified to match the OOPSE coding style. |
| 5 |
|
|
|
| 6 |
|
|
We have retained the OpenBabel copyright and GPL license on this class: |
| 7 |
|
|
|
| 8 |
|
|
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. |
| 9 |
|
|
Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison |
| 10 |
|
|
|
| 11 |
|
|
This file is part of the Open Babel project. |
| 12 |
|
|
For more information, see <http://openbabel.sourceforge.net/> |
| 13 |
|
|
|
| 14 |
|
|
This program is free software; you can redistribute it and/or modify |
| 15 |
|
|
it under the terms of the GNU General Public License as published by |
| 16 |
|
|
the Free Software Foundation version 2 of the License. |
| 17 |
|
|
|
| 18 |
|
|
This program is distributed in the hope that it will be useful, |
| 19 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
|
|
GNU General Public License for more details. |
| 22 |
|
|
***********************************************************************/ |
| 23 |
|
|
|
| 24 |
|
|
/** |
| 25 |
|
|
* @file ElementsTable.hpp |
| 26 |
|
|
* @author gezelter |
| 27 |
|
|
* @date 12/21/2007 |
| 28 |
|
|
* @time 11:30am |
| 29 |
|
|
* @version 1.0 |
| 30 |
|
|
*/ |
| 31 |
|
|
|
| 32 |
|
|
#ifndef UTILS_ELEMENTSTABLE_HPP |
| 33 |
|
|
#define UTILS_ELEMENTSTABLE_HPP |
| 34 |
|
|
|
| 35 |
|
|
#include "config.h" |
| 36 |
|
|
#include <vector> |
| 37 |
|
|
#include "primitives/Element.hpp" |
| 38 |
|
|
|
| 39 |
|
|
namespace oopse { |
| 40 |
|
|
|
| 41 |
|
|
/** |
| 42 |
|
|
* @class ElementsTable.hpp "util/ElementsTable.hpp" |
| 43 |
|
|
* @brief Periodic Table of the Elements |
| 44 |
|
|
* Using element data is a place holder when we lack information about |
| 45 |
|
|
* a specific atom type. In particular, the Langevin algorithms must |
| 46 |
|
|
* assume specific atomic radii to predict drag and random forces on those |
| 47 |
|
|
* atoms. For force fields which do not specify Lennard-Jones radii, |
| 48 |
|
|
* the element's van der Waals radius is used instead. |
| 49 |
|
|
* The ElementsTable class (etab) is declared as external in |
| 50 |
|
|
* ElementsTable.cpp. Source files that include the header file |
| 51 |
|
|
* ElementsTable.hpp automatically have an extern definition to etab. |
| 52 |
|
|
* The following code sample demonstrates the use of the ElementsTable class: |
| 53 |
|
|
* @code |
| 54 |
|
|
* cout << "The symbol for element 6 is " << etab.GetSymbol(6) << endl; |
| 55 |
|
|
* cout << "The atomic number for Sulfur is " << etab.GetAtomicNum(16) << endl; |
| 56 |
|
|
* cout << "The van der Waal radius for Nitrogen is " << etab.GetVdwRad(7); |
| 57 |
|
|
* @endcode |
| 58 |
|
|
* Stored information in the OBElementTable includes elemental: |
| 59 |
|
|
* - symbols |
| 60 |
|
|
* - covalent radii |
| 61 |
|
|
* - van der Waal radii |
| 62 |
|
|
* - expected maximum bonding valence |
| 63 |
|
|
* - molar mass (by IUPAC recommended atomic masses) |
| 64 |
|
|
* - electronegativity |
| 65 |
|
|
* - ionization potential |
| 66 |
|
|
* - electron affinity |
| 67 |
|
|
* - RGB colors for visualization programs |
| 68 |
|
|
* - names (by IUPAC recommendation) |
| 69 |
|
|
*/ |
| 70 |
|
|
class ElementsTable { |
| 71 |
|
|
public: |
| 72 |
|
|
/** Constructor */ |
| 73 |
|
|
ElementsTable(); |
| 74 |
|
|
/** Destructor */ |
| 75 |
|
|
~ElementsTable(); |
| 76 |
|
|
|
| 77 |
|
|
/** |
| 78 |
|
|
* Read in the data file. |
| 79 |
|
|
*/ |
| 80 |
|
|
void Init(); |
| 81 |
|
|
/** |
| 82 |
|
|
* Set the directory before calling Init() |
| 83 |
|
|
*/ |
| 84 |
|
|
void SetReadDirectory(char *dir) { dir_ = dir; } |
| 85 |
|
|
/** |
| 86 |
|
|
* Set the environment variable to use before calling Init() |
| 87 |
|
|
*/ |
| 88 |
|
|
void SetEnvironmentVariable(char *var) { envvar_ = var; } |
| 89 |
|
|
/** |
| 90 |
|
|
* Specified by particular table classes (parses an individual data line) |
| 91 |
|
|
* @param line the data line to parse |
| 92 |
|
|
*/ |
| 93 |
|
|
void ParseLine(const char *line); |
| 94 |
|
|
/** |
| 95 |
|
|
* @return the number of elements in the periodic table |
| 96 |
|
|
*/ |
| 97 |
|
|
unsigned int GetNumberOfElements(); |
| 98 |
|
|
unsigned int GetSize() { return GetNumberOfElements(); } |
| 99 |
|
|
/** |
| 100 |
|
|
* @return the atomic number matching the element symbol passed |
| 101 |
|
|
* or 0 if not defined. For 'D' or 'T' hydrogen isotopes, will return |
| 102 |
|
|
* a value in the second argument |
| 103 |
|
|
* @param str the element symbol |
| 104 |
|
|
* @param iso the isotope index for Deuterium or Tritium |
| 105 |
|
|
*/ |
| 106 |
|
|
int GetAtomicNum(const char *str); |
| 107 |
|
|
int GetAtomicNum(const char *str, int &iso); |
| 108 |
|
|
/** |
| 109 |
|
|
* @return the element symbol matching the atomic number passed |
| 110 |
|
|
* @param atomicnum the atomic number of the element |
| 111 |
|
|
*/ |
| 112 |
skuang |
1305 |
const char *GetSymbol(int atomicnum); |
| 113 |
gezelter |
1210 |
/** |
| 114 |
|
|
* @return the van der Waals radius for this atomic number |
| 115 |
|
|
* @param atomicnum the atomic number of the element |
| 116 |
|
|
*/ |
| 117 |
|
|
RealType GetVdwRad(int atomicnum); |
| 118 |
|
|
/** |
| 119 |
|
|
* @return the covalent radius for this atomic number |
| 120 |
|
|
* @param atomicnum the atomic number of the element |
| 121 |
|
|
*/ |
| 122 |
|
|
RealType GetCovalentRad(int atomicnum); |
| 123 |
|
|
/** |
| 124 |
|
|
* @return the average atomic mass for this element. |
| 125 |
|
|
* @param atomicnum the atomic number of the element |
| 126 |
|
|
*/ |
| 127 |
|
|
RealType GetMass(int atomicnum); |
| 128 |
|
|
/** |
| 129 |
|
|
* @return a "corrected" bonding radius based on the hybridization. |
| 130 |
|
|
* Scales the covalent radius by 0.95 for sp2 and 0.90 for sp hybrids |
| 131 |
|
|
* @param atomicnum the atomic number of the element |
| 132 |
|
|
* @param hyb the hybridization of the element |
| 133 |
|
|
*/ |
| 134 |
|
|
RealType CorrectedBondRad(int atomicnum, int hyb = 3); |
| 135 |
|
|
/** |
| 136 |
|
|
* @return a "corrected" vdW radius based on the hybridization. |
| 137 |
|
|
* Scales the van der Waals radius by 0.95 for sp2 and 0.90 for sp hybrids |
| 138 |
|
|
* @param atomicnum the atomic number of the element |
| 139 |
|
|
* @param hyb the hybridization of the element |
| 140 |
|
|
*/ |
| 141 |
|
|
RealType CorrectedVdwRad(int atomicnum, int hyb = 3); |
| 142 |
|
|
/** |
| 143 |
|
|
* @return the maximum expected number of bonds to this element |
| 144 |
|
|
* @param atomicnum the atomic number of the element |
| 145 |
|
|
*/ |
| 146 |
|
|
int GetMaxBonds(int atomicnum); |
| 147 |
|
|
/** |
| 148 |
|
|
* @return the Pauling electronegativity for this element |
| 149 |
|
|
* @param atomicnum the atomic number of the element |
| 150 |
|
|
*/ |
| 151 |
|
|
RealType GetElectroNeg(int atomicnum); |
| 152 |
|
|
/** |
| 153 |
|
|
* @return the ionization potential (in eV) for this element |
| 154 |
|
|
* @param atomicnum the atomic number of the element |
| 155 |
|
|
*/ |
| 156 |
|
|
RealType GetIonization(int atomicnum); |
| 157 |
|
|
/** |
| 158 |
|
|
* @return the electron affinity (in eV) for this element |
| 159 |
|
|
* @param atomicnum the atomic number of the element |
| 160 |
|
|
*/ |
| 161 |
|
|
RealType GetElectronAffinity(int atomicnum); |
| 162 |
|
|
/** |
| 163 |
|
|
* @return a vector with red, green, blue color values for this element |
| 164 |
|
|
* @param atomicnum the atomic number of the element |
| 165 |
|
|
*/ |
| 166 |
|
|
std::vector<RealType> GetRGB(int atomicnum); |
| 167 |
|
|
|
| 168 |
|
|
/** |
| 169 |
|
|
* @return the name of this element |
| 170 |
|
|
* @param atomicnum the atomic number of the element |
| 171 |
|
|
*/ |
| 172 |
|
|
std::string GetName(int atomicnum); |
| 173 |
|
|
|
| 174 |
|
|
protected: |
| 175 |
|
|
bool init_; //!< whether the data been read already |
| 176 |
|
|
std::string filename_; //!< file to search for |
| 177 |
|
|
std::string dir_; //!< data directory for file if _envvar fails |
| 178 |
|
|
std::string subdir_; //!< subdirectory (if using environment variable) |
| 179 |
|
|
std::string envvar_; //!< environment variable to check first |
| 180 |
|
|
std::vector<Element*> elements_; |
| 181 |
|
|
const char *dataptr_; //!< default data table if file is unreadable |
| 182 |
|
|
|
| 183 |
|
|
}; |
| 184 |
|
|
|
| 185 |
|
|
extern ElementsTable etab; |
| 186 |
|
|
} |
| 187 |
|
|
|
| 188 |
|
|
#endif |