forked from ferchault/APHF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasis.py
319 lines (271 loc) · 9.46 KB
/
basis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
"""
Copyright (C) 2015 Rocco Meli, 2021 Guido Falk von Rudorff
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from HF import *
class Atom:
"""
Class representing an atom.
"""
def __init__(self, name, R, Z, basisZ):
"""
Initializer for ATOM
INPUT:
NAME: Name of the element
R: Position (cartesian coordinates, atomic units)
Z: Atomic charge
ORBITALS: list of orbitals for this atom
"""
self.name = name
self.R = R
self.Z = Z
self.basisZ = basisZ
class Basis:
def __init__(self, basisset, atoms):
self._basis = []
for atom in atoms:
db = bse.get_basis(basisset, int(atom.basisZ))
db = db["elements"][str(int(atom.basisZ))]["electron_shells"]
for shell in db:
if shell["function_type"] != "gto":
raise ValueError("Unknown function type")
a = [mpmath.mpf(_) for _ in shell["exponents"]]
for angmom, coeffs in zip(
shell["angular_momentum"], shell["coefficients"]
):
if angmom > 1:
raise ValueError("Angular momentum not implemented")
d = [mpmath.mpf(_) for _ in coeffs]
if angmom == 0:
self._basis.append(
{
"R": atom.R, #
"lx": 0, #
"ly": 0, #
"lz": 0, #
"a": a, #
"d": d,
}
)
if angmom == 1:
self._basis.append(
{
"R": atom.R, #
"lx": 1, #
"ly": 0, #
"lz": 0, #
"a": a, #
"d": d,
}
)
self._basis.append(
{
"R": atom.R, #
"lx": 0, #
"ly": 1, #
"lz": 0, #
"a": a, #
"d": d,
}
)
self._basis.append(
{
"R": atom.R, #
"lx": 0, #
"ly": 0, #
"lz": 1, #
"a": a, #
"d": d,
}
)
self.K = len(self._basis)
def basis(self):
return self._basis
class STO3G:
"""
STO-3G minimal basis set.
"""
def __init__(self, atoms):
"""
Initializer for STO3G
INPUT:
ATOMS: list of atoms
Source
Modern Quantum Chemistry
Szabo and Ostlund
Dover
1989
"""
# Exponential coefficients for the Gaussian orbitals
self.zeta1 = {
"H": mpmath.mp.mpf("1.24"),
"He": 2.0925,
"Li": 2.69,
"Be": 3.68,
"B": 4.68,
"C": 5.67,
"N": 6.67,
"O": 7.66,
"F": 8.65,
}
self.zeta2 = {
"Li": 0.75,
"Be": 1.10,
"B": 1.45,
"C": 1.72,
"N": 1.95,
"O": 2.25,
"F": 2.55,
}
self.STO3G = []
for a in atoms: # For every atom
for o in a.orbitals: # For every atomic orbital
if o == "1s":
a1 = mpmath.mp.mpf("0.109818") * self.zeta1[
a.name
] ** mpmath.mp.mpf("2")
a2 = mpmath.mp.mpf("0.405771") * self.zeta1[
a.name
] ** mpmath.mp.mpf("2")
a3 = mpmath.mp.mpf("2.22766") * self.zeta1[a.name] ** mpmath.mp.mpf(
"2"
)
d1 = mpmath.mp.mpf("0.444635")
d2 = mpmath.mp.mpf("0.535328")
d3 = mpmath.mp.mpf("0.154329")
self.STO3G.append(
{
"AOn": a.name, #
"AOt": o, #
"R": a.R, #
"lx": 0, #
"ly": 0, #
"lz": 0, #
"a": (a1, a2, a3), #
"d": (d1, d2, d3),
}
)
if o == "2s":
a1 = 0.0751386 * self.zeta2[a.name] ** 2
a2 = 0.231031 * self.zeta2[a.name] ** 2
a3 = 0.994203 * self.zeta2[a.name] ** 2
d1 = 0.700115
d2 = 0.399513
d3 = -0.0999672
self.STO3G.append(
{
"AOn": a.name,
"AOt": o,
"R": a.R,
"lx": 0,
"ly": 0,
"lz": 0,
"a": (a1, a2, a3),
"d": (d1, d2, d3),
}
)
if o == "2p":
a1 = 0.0751386 * self.zeta2[a.name] ** 2
a2 = 0.231031 * self.zeta2[a.name] ** 2
a3 = 0.994203 * self.zeta2[a.name] ** 2
d1 = 0.391957
d2 = 0.607684
d3 = 0.1559163
self.STO3G.append(
{
"AOn": a.name,
"AOt": o,
"R": a.R,
"lx": 1,
"ly": 0,
"lz": 0,
"a": (a1, a2, a3),
"d": (d1, d2, d3),
}
)
self.STO3G.append(
{
"AOn": a.name,
"AOt": o,
"R": a.R,
"lx": 0,
"ly": 1,
"lz": 0,
"a": (a1, a2, a3),
"d": (d1, d2, d3),
}
)
self.STO3G.append(
{
"AOn": a.name,
"AOt": o,
"R": a.R,
"lx": 0,
"ly": 0,
"lz": 1,
"a": (a1, a2, a3),
"d": (d1, d2, d3),
}
)
self.K = len(self.STO3G)
def basis(self):
"""
Return the basis set.
"""
return self.STO3G
def info(self):
"""
Print informations about the bais set.
"""
print("########################")
print("STO-3G MINIMAL BASIS SET")
print("########################\n")
for b in self.STO3G:
print(b["AOn"] + " orbital:")
print(" " + b["AOt"] + ":")
print(" R = ", b["R"])
print(" lx = " + str(b["lx"]))
print(" ly = " + str(b["ly"]))
print(" lz = " + str(b["lz"]))
print(" alpha = ", b["a"])
print(" d = ", b["d"], "\n")
if __name__ == "__main__":
"""
Results compared with
Modern Quantum Chemistry
Szabo and Ostlund
Dover
1989
and
The Mathematica Journal
Evaluation of Gaussian Molecular Integrals
I. Overlap Integrals
Minhhuy Hô and Julio Manuel Hernández-Pérez
2012
"""
# HeH+
atoms = [Atom("H", (0, 0, 0), ["1s"]), Atom("He", (0, 0, 1.4), ["1s"])]
# Create the basis set
sto3g = STO3G(atoms)
# Display informations
sto3g.info()
print("\n\n\n\n\n")
# H2O
atoms = [
Atom("H", (0, +1.43233673, -0.96104039), ["1s"]),
Atom("H", (0, -1.43233673, -0.96104039), ["1s"]),
Atom("O", (0, 0, 0.24026010), ["1s", "2s", "2p"]),
]
# Create the basis set
sto3g = STO3G(atoms)
# Display informations
sto3g.info()