-
-
Notifications
You must be signed in to change notification settings - Fork 688
Expand file tree
/
Copy pathuhf.py
More file actions
64 lines (53 loc) · 1.97 KB
/
uhf.py
File metadata and controls
64 lines (53 loc) · 1.97 KB
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
#!/usr/bin/env python
#
# This code was copied from the data generation program of Tencent Alchemy
# project (https://github.com/tencent-alchemy).
#
#
# Copyright 2019 Tencent America LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Qiming Sun <[email protected]>
#
import numpy
from pyscf import lib
from pyscf.lib import logger
from pyscf.grad import uhf as uhf_grad
from pyscf.df.grad import rhf as df_rhf_grad
class Gradients(uhf_grad.Gradients):
'''Unrestricted density-fitting Hartree-Fock gradients'''
_keys = {'with_df', 'auxbasis_response'}
def __init__(self, mf):
uhf_grad.Gradients.__init__(self, mf)
# Whether to include the response of DF auxiliary basis when computing
# nuclear gradients of J/K matrices
auxbasis_response = True
get_jk = df_rhf_grad.Gradients.get_jk
get_j = df_rhf_grad.Gradients.get_j
get_k = df_rhf_grad.Gradients.get_k
def get_veff(self, mol=None, dm=None):
vj, vk = self.get_jk(mol, dm)
vhf = vj[0]+vj[1] - vk
if self.auxbasis_response:
e1_aux = vj.aux.sum ((0,1))
e1_aux -= numpy.trace (vk.aux, axis1=0, axis2=1)
logger.debug1(self, 'sum(auxbasis response) %s', e1_aux.sum(axis=0))
vhf = lib.tag_array(vhf, aux=e1_aux)
return vhf
def extra_force(self, atom_id, envs):
if self.auxbasis_response:
return envs['vhf'].aux[atom_id]
else:
return 0
Grad = Gradients