1 |
/********************************************************************** |
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 OpenMD 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 |
* @version 1.0 |
29 |
*/ |
30 |
|
31 |
#ifndef UTILS_ELEMENTSTABLE_HPP |
32 |
#define UTILS_ELEMENTSTABLE_HPP |
33 |
|
34 |
#include "config.h" |
35 |
#include <vector> |
36 |
#include "primitives/Element.hpp" |
37 |
|
38 |
namespace OpenMD { |
39 |
|
40 |
/** |
41 |
* @class ElementsTable |
42 |
* @brief Periodic Table of the Elements |
43 |
* Using element data is a place holder when we lack information about |
44 |
* a specific atom type. In particular, the Langevin algorithms must |
45 |
* assume specific atomic radii to predict drag and random forces on those |
46 |
* atoms. For force fields which do not specify Lennard-Jones radii, |
47 |
* the element's van der Waals radius is used instead. |
48 |
* The ElementsTable class (etab) is declared as external in |
49 |
* ElementsTable.cpp. Source files that include the header file |
50 |
* ElementsTable.hpp automatically have an extern definition to etab. |
51 |
* The following code sample demonstrates the use of the ElementsTable class: |
52 |
* @code |
53 |
* cout << "The symbol for element 6 is " << etab.GetSymbol(6) << endl; |
54 |
* cout << "The atomic number for Sulfur is " << etab.GetAtomicNum(16) << endl; |
55 |
* cout << "The van der Waal radius for Nitrogen is " << etab.GetVdwRad(7); |
56 |
* @endcode |
57 |
* Stored information in the OBElementTable includes elemental: |
58 |
* - symbols |
59 |
* - covalent radii |
60 |
* - van der Waal radii |
61 |
* - expected maximum bonding valence |
62 |
* - molar mass (by IUPAC recommended atomic masses) |
63 |
* - electronegativity |
64 |
* - ionization potential |
65 |
* - electron affinity |
66 |
* - RGB colors for visualization programs |
67 |
* - names (by IUPAC recommendation) |
68 |
*/ |
69 |
class ElementsTable { |
70 |
public: |
71 |
/** Constructor */ |
72 |
ElementsTable(); |
73 |
/** Destructor */ |
74 |
~ElementsTable(); |
75 |
|
76 |
/** |
77 |
* Read in the data file. |
78 |
*/ |
79 |
void Init(); |
80 |
/** |
81 |
* Set the directory before calling Init() |
82 |
*/ |
83 |
void SetReadDirectory(char *dir) { dir_ = dir; } |
84 |
/** |
85 |
* Set the environment variable to use before calling Init() |
86 |
*/ |
87 |
void SetEnvironmentVariable(char *var) { envvar_ = var; } |
88 |
/** |
89 |
* Specified by particular table classes (parses an individual data line) |
90 |
* @param line the data line to parse |
91 |
*/ |
92 |
void ParseLine(const char *line); |
93 |
/** |
94 |
* @return the number of elements in the periodic table |
95 |
*/ |
96 |
unsigned int GetNumberOfElements(); |
97 |
unsigned int GetSize() { return GetNumberOfElements(); } |
98 |
/** |
99 |
* @return the atomic number matching the element symbol passed |
100 |
* or 0 if not defined. |
101 |
* @param str the element symbol |
102 |
*/ |
103 |
int GetAtomicNum(const char *str); |
104 |
/** |
105 |
* @return the atomic number matching the element symbol passed |
106 |
* or 0 if not defined. For 'D' or 'T' hydrogen isotopes, will return |
107 |
* a value in the second argument |
108 |
* @param str the element symbol |
109 |
* @param iso the isotope index for Deuterium or Tritium |
110 |
*/ |
111 |
int GetAtomicNum(const char *str, int &iso); |
112 |
/** |
113 |
* @return the element symbol matching the atomic number passed |
114 |
* @param atomicnum the atomic number of the element |
115 |
*/ |
116 |
const char *GetSymbol(int atomicnum); |
117 |
/** |
118 |
* @return the van der Waals radius for this atomic number |
119 |
* @param atomicnum the atomic number of the element |
120 |
*/ |
121 |
RealType GetVdwRad(int atomicnum); |
122 |
/** |
123 |
* @return the covalent radius for this atomic number |
124 |
* @param atomicnum the atomic number of the element |
125 |
*/ |
126 |
RealType GetCovalentRad(int atomicnum); |
127 |
/** |
128 |
* @return the average atomic mass for this element. |
129 |
* @param atomicnum the atomic number of the element |
130 |
*/ |
131 |
RealType GetMass(int atomicnum); |
132 |
/** |
133 |
* @return a "corrected" bonding radius based on the hybridization. |
134 |
* Scales the covalent radius by 0.95 for sp2 and 0.90 for sp hybrids |
135 |
* @param atomicnum the atomic number of the element |
136 |
* @param hyb the hybridization of the element |
137 |
*/ |
138 |
RealType CorrectedBondRad(int atomicnum, int hyb = 3); |
139 |
/** |
140 |
* @return a "corrected" vdW radius based on the hybridization. |
141 |
* Scales the van der Waals radius by 0.95 for sp2 and 0.90 for sp hybrids |
142 |
* @param atomicnum the atomic number of the element |
143 |
* @param hyb the hybridization of the element |
144 |
*/ |
145 |
RealType CorrectedVdwRad(int atomicnum, int hyb = 3); |
146 |
/** |
147 |
* @return the maximum expected number of bonds to this element |
148 |
* @param atomicnum the atomic number of the element |
149 |
*/ |
150 |
int GetMaxBonds(int atomicnum); |
151 |
/** |
152 |
* @return the Pauling electronegativity for this element |
153 |
* @param atomicnum the atomic number of the element |
154 |
*/ |
155 |
RealType GetElectroNeg(int atomicnum); |
156 |
/** |
157 |
* @return the ionization potential (in eV) for this element |
158 |
* @param atomicnum the atomic number of the element |
159 |
*/ |
160 |
RealType GetIonization(int atomicnum); |
161 |
/** |
162 |
* @return the electron affinity (in eV) for this element |
163 |
* @param atomicnum the atomic number of the element |
164 |
*/ |
165 |
RealType GetElectronAffinity(int atomicnum); |
166 |
/** |
167 |
* @return a vector with red, green, blue color values for this element |
168 |
* @param atomicnum the atomic number of the element |
169 |
*/ |
170 |
std::vector<RealType> GetRGB(int atomicnum); |
171 |
|
172 |
/** |
173 |
* @return the name of this element |
174 |
* @param atomicnum the atomic number of the element |
175 |
*/ |
176 |
std::string GetName(int atomicnum); |
177 |
|
178 |
protected: |
179 |
bool init_; //!< whether the data been read already |
180 |
std::string filename_; //!< file to search for |
181 |
std::string dir_; //!< data directory for file if _envvar fails |
182 |
std::string subdir_; //!< subdirectory (if using environment variable) |
183 |
std::string envvar_; //!< environment variable to check first |
184 |
std::vector<Element*> elements_; |
185 |
const char *dataptr_; //!< default data table if file is unreadable |
186 |
|
187 |
}; |
188 |
|
189 |
extern ElementsTable etab; |
190 |
} |
191 |
|
192 |
#endif |