1 | //
|
---|
2 | // atominfo.h
|
---|
3 | //
|
---|
4 | // Copyright (C) 1996 Limit Point Systems, Inc.
|
---|
5 | //
|
---|
6 | // Author: Curtis Janssen <cljanss@limitpt.com>
|
---|
7 | // Maintainer: LPS
|
---|
8 | //
|
---|
9 | // This file is part of the SC Toolkit.
|
---|
10 | //
|
---|
11 | // The SC Toolkit is free software; you can redistribute it and/or modify
|
---|
12 | // it under the terms of the GNU Library General Public License as published by
|
---|
13 | // the Free Software Foundation; either version 2, or (at your option)
|
---|
14 | // any later version.
|
---|
15 | //
|
---|
16 | // The SC Toolkit is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU Library General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU Library General Public License
|
---|
22 | // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
|
---|
23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
24 | //
|
---|
25 | // The U.S. Government is granted a limited license as per AL 91-7.
|
---|
26 | //
|
---|
27 |
|
---|
28 | #ifndef _chemistry_molecule_atominfo_h
|
---|
29 | #define _chemistry_molecule_atominfo_h
|
---|
30 |
|
---|
31 | #include <string>
|
---|
32 | #include <map>
|
---|
33 | #include <vector>
|
---|
34 |
|
---|
35 | #include <util/class/class.h>
|
---|
36 | #include <util/keyval/keyval.h>
|
---|
37 |
|
---|
38 | namespace sc {
|
---|
39 |
|
---|
40 | class Units;
|
---|
41 |
|
---|
42 | /** The AtomInfo class provides information about atoms. The information
|
---|
43 | is kept in a file named atominfo.kv in the SC library directory. That
|
---|
44 | information can be overridden by the user. */
|
---|
45 | class AtomInfo: public SavableState {
|
---|
46 | private:
|
---|
47 | enum { Nelement = 118, DefaultZ = 0 };
|
---|
48 |
|
---|
49 | struct atom
|
---|
50 | {
|
---|
51 | int Z;
|
---|
52 | char *name;
|
---|
53 | char *symbol;
|
---|
54 | };
|
---|
55 |
|
---|
56 | static struct atom elements_[Nelement];
|
---|
57 |
|
---|
58 | std::map<std::string,int> name_to_Z_;
|
---|
59 | std::map<std::string,int> symbol_to_Z_;
|
---|
60 | std::map<int,std::string> Z_to_names_;
|
---|
61 | std::map<int,std::string> Z_to_symbols_;
|
---|
62 | std::map<int,double> Z_to_mass_;
|
---|
63 | std::map<int,double> Z_to_atomic_radius_;
|
---|
64 | std::map<int,double> Z_to_vdw_radius_;
|
---|
65 | std::map<int,double> Z_to_bragg_radius_;
|
---|
66 | std::map<int,double> Z_to_maxprob_radius_;
|
---|
67 | std::map<int,std::vector<double> > Z_to_rgb_;
|
---|
68 | std::map<int,double> Z_to_ip_;
|
---|
69 | double atomic_radius_scale_;
|
---|
70 | double vdw_radius_scale_;
|
---|
71 | double bragg_radius_scale_;
|
---|
72 | double maxprob_radius_scale_;
|
---|
73 |
|
---|
74 | char *overridden_values_;
|
---|
75 |
|
---|
76 | void load_library_values();
|
---|
77 | void override_library_values(const Ref<KeyVal> &keyval);
|
---|
78 | void load_values(const Ref<KeyVal>& keyval, int override);
|
---|
79 | void load_values(std::map<int,double>&,
|
---|
80 | double *scale, const char *keyword,
|
---|
81 | const Ref<KeyVal> &keyval, int override,
|
---|
82 | const Ref<Units> &);
|
---|
83 | void load_values(std::map<int,std::vector<double> >&,
|
---|
84 | const char *keyword,
|
---|
85 | const Ref<KeyVal> &keyval, int override);
|
---|
86 | void add_overridden_value(const char *assignment);
|
---|
87 | void initialize_names();
|
---|
88 | double lookup_value(const std::map<int,double>& values, int Z) const;
|
---|
89 | double lookup_array_value(const std::map<int,std::vector<double> >& values,
|
---|
90 | int Z, int i) const;
|
---|
91 | public:
|
---|
92 | AtomInfo();
|
---|
93 |
|
---|
94 | /** The AtomInfo KeyVal constructor is used to generate a AtomInfo
|
---|
95 | object from the input. Default values will be read in from the
|
---|
96 | <tt>atominfo.kv</tt> file in library directory. These can be
|
---|
97 | overridden by specifying the keyword below. The library file is
|
---|
98 | also read using a KeyVal constructor syntax, so consult that file
|
---|
99 | for an example.
|
---|
100 |
|
---|
101 | <table border="1">
|
---|
102 |
|
---|
103 | <tr><td>Keyword<td>Type<td>Default<td>Description
|
---|
104 |
|
---|
105 | <tr><td><tt>mass:unit</tt><td>string<td><tt>amu</tt><td>The unit to
|
---|
106 | be used for masses. See the Units class for more information about
|
---|
107 | units.
|
---|
108 |
|
---|
109 | <tr><td><tt>mass:</tt><em>symbol</em><td>double<td>library
|
---|
110 | value<td>The mass associated with the given atomic symbol.
|
---|
111 |
|
---|
112 | <tr><td><tt>vdw_radius:unit</tt><td>string<td><tt>bohr</tt><td>The
|
---|
113 | unit to be used for van der Waals radii. See the Units class for
|
---|
114 | more information about units.
|
---|
115 |
|
---|
116 | <tr><td><tt>vdw_radius:scaling_factor</tt><td>double<td>1.0<td>The
|
---|
117 | scaling factor to be used for all van der Waals radii, including
|
---|
118 | library values.
|
---|
119 |
|
---|
120 | <tr><td><tt>vdw_radius:</tt><em>symbol</em><td>double<td>library
|
---|
121 | value <td>The van der Waals radius associated with the given atomic
|
---|
122 | symbol.
|
---|
123 |
|
---|
124 | <tr><td><tt>atomic_radius:unit</tt><td>string<td><tt>bohr</tt><td>The
|
---|
125 | unit to be used for atomic radii. See the Units class for more
|
---|
126 | information about units.
|
---|
127 |
|
---|
128 | <tr><td><tt>atomic_radius:scaling_factor</tt><td>double<td>1.0<td>The
|
---|
129 | scaling factor to be used for all atomic radii, including library
|
---|
130 | values.
|
---|
131 |
|
---|
132 | <tr><td><tt>atomic_radius:</tt><em>symbol</em><td>double<td>library
|
---|
133 | value <td>The atomic radius associated with the given atomic
|
---|
134 | symbol.
|
---|
135 |
|
---|
136 | <tr><td><tt>bragg_radius:unit</tt><td>string<td><tt>bohr</tt><td>The
|
---|
137 | unit to be used for Bragg radii. See the Units class for more
|
---|
138 | information about units.
|
---|
139 |
|
---|
140 | <tr><td><tt>bragg_radius:scaling_factor</tt><td>double<td>1.0<td>The
|
---|
141 | scaling factor to be used for all Bragg radii, including library
|
---|
142 | values.
|
---|
143 |
|
---|
144 | <tr><td><tt>bragg_radius:</tt><em>symbol</em><td>double<td>library
|
---|
145 | value <td>The Bragg radius associated with the given atomic symbol.
|
---|
146 |
|
---|
147 | <tr><td><tt>maxprob_radius:unit</tt><td>string<td><tt>bohr</tt><td>The
|
---|
148 | unit to be used for maximum probability radii. See the Units class
|
---|
149 | for more information about units.
|
---|
150 |
|
---|
151 | <tr><td><tt>maxprob_radius:scaling_factor</tt><td>double<td>1.0<td>The
|
---|
152 | scaling factor to be used for all maximum probability radii,
|
---|
153 | including library values.
|
---|
154 |
|
---|
155 | <tr><td><tt>maxprob_radius:</tt><em>symbol</em><td>double<td>library
|
---|
156 | value<td>The maximum probability radius associated with the given
|
---|
157 | atomic symbol.
|
---|
158 |
|
---|
159 | <tr><td><tt>ip:unit</tt><td>string<td><tt>Hartree</tt><td>The unit
|
---|
160 | to be used for ionization potentials. See the Units class for more
|
---|
161 | information about units.
|
---|
162 |
|
---|
163 | <tr><td><tt>ip:</tt><em>symbol</em><td>double<td>library
|
---|
164 | value<td>The ionization potential for the given atom.
|
---|
165 |
|
---|
166 | <tr><td><tt>rgb:</tt><em>symbol</em><td>double[3]<td>library
|
---|
167 | value<td>A vector with the red, green, and blue values used to
|
---|
168 | color each atom. Each element is between 0 (off) and 1 (on).
|
---|
169 |
|
---|
170 | </table>
|
---|
171 | */
|
---|
172 |
|
---|
173 | AtomInfo(const Ref<KeyVal>&);
|
---|
174 | AtomInfo(StateIn&);
|
---|
175 | ~AtomInfo();
|
---|
176 | void save_data_state(StateOut& s);
|
---|
177 |
|
---|
178 | /// These return various measures of the atom's radius.
|
---|
179 | double vdw_radius(int Z) const;
|
---|
180 | double bragg_radius(int Z) const;
|
---|
181 | double atomic_radius(int Z) const;
|
---|
182 | double maxprob_radius(int Z) const;
|
---|
183 |
|
---|
184 | /// Returns the atomization potential for atomic number Z.
|
---|
185 | double ip(int Z) const;
|
---|
186 |
|
---|
187 | /// Return the scale factor for the VdW radii.
|
---|
188 | double vdw_radius_scale() const { return vdw_radius_scale_; }
|
---|
189 | /// Return the scale factor for the Bragg radii.
|
---|
190 | double bragg_radius_scale() const { return bragg_radius_scale_; }
|
---|
191 | /// Return the scale factor for the atomic radii.
|
---|
192 | double atomic_radius_scale() const { return atomic_radius_scale_; }
|
---|
193 | /// Return the scale factor for the maximum probability radii.
|
---|
194 | double maxprob_radius_scale() const { return maxprob_radius_scale_; }
|
---|
195 |
|
---|
196 | /** These return information about the color of the atom
|
---|
197 | for visualization programs. */
|
---|
198 | double rgb(int Z, int color) const;
|
---|
199 | double red(int Z) const;
|
---|
200 | double green(int Z) const;
|
---|
201 | double blue(int Z) const;
|
---|
202 |
|
---|
203 | /// This returns the mass of the most abundant isotope.
|
---|
204 | double mass(int Z) const;
|
---|
205 |
|
---|
206 | /// This returns the full name of the element.
|
---|
207 | std::string name(int Z);
|
---|
208 | /// This returns the symbol for the element.
|
---|
209 | std::string symbol(int Z);
|
---|
210 |
|
---|
211 | /// This converts a name or symbol to the atomic number.
|
---|
212 | int string_to_Z(const std::string &, int allow_exceptions = 1);
|
---|
213 | };
|
---|
214 |
|
---|
215 | }
|
---|
216 |
|
---|
217 | #endif
|
---|
218 |
|
---|
219 | // Local Variables:
|
---|
220 | // mode: c++
|
---|
221 | // c-file-style: "CLJ"
|
---|
222 | // End:
|
---|