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