Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/34-tdhf-nacv.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
td = mf.TDA().set(nstates=5) # TDHF is OK
td.kernel() # [ 9.21540892 10.99036172 11.83380819 13.62301694 15.06349085]

nac = td.NAC()
nac = td.nac_method()
nac.state=(0,1) # same as (1,0) 0 means ground state, 1 means the first excited state
nac.kernel()
'''
Expand Down
39 changes: 39 additions & 0 deletions gpu4pyscf/df/grad/tdrks_ris.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2021-2025 The PySCF Developers. 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.

from gpu4pyscf.df import int3c2e, df
from gpu4pyscf.df.grad import tdrhf as tdrhf_grad_df
from gpu4pyscf.tdscf import ris
from gpu4pyscf.grad import tdrks_ris as tdrks_ris_grad
from gpu4pyscf import __config__

class Gradients(tdrks_ris_grad.Gradients):
from gpu4pyscf.lib.utils import to_gpu, device

_keys = {'with_df', 'auxbasis_response'}
def __init__(self, td):
# Whether to include the response of DF auxiliary basis when computing
# nuclear gradients of J/K matrices
tdrks_ris_grad.Gradients.__init__(self, td)

auxbasis_response = True
get_jk = tdrhf_grad_df.get_jk

def check_sanity(self):
assert isinstance(self.base._scf, df.df_jk._DFHF)
assert isinstance(self.base, ris.TDDFT) or isinstance(self.base, ris.TDA)

get_veff = tdrhf_grad_df.get_veff

Grad = Gradients
15 changes: 15 additions & 0 deletions gpu4pyscf/df/nac/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021-2024 The PySCF Developers. 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.

from . import tdrhf, tdrks, tdrks_ris
38 changes: 38 additions & 0 deletions gpu4pyscf/df/nac/tdrhf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2021-2024 The PySCF Developers. 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.

from gpu4pyscf.nac import tdrhf as tdrhf_nac
from gpu4pyscf.df.grad.tdrhf import get_jk, get_veff
from gpu4pyscf.tdscf import rhf as tdrhf
from gpu4pyscf.lib import logger
from gpu4pyscf.df import df
from gpu4pyscf.lib.cupy_helper import tag_array


class NAC(tdrhf_nac.NAC):
from gpu4pyscf.lib.utils import to_gpu, device

_keys = {'with_df', 'auxbasis_response'}
def __init__(self, td):
# Whether to include the response of DF auxiliary basis when computing
# nuclear gradients of J/K matrices
tdrhf_nac.NAC.__init__(self, td)

auxbasis_response = True
get_jk = get_jk
get_veff = get_veff

def check_sanity(self):
assert isinstance(self.base._scf, df.df_jk._DFHF)
assert isinstance(self.base, tdrhf.TDHF) or isinstance(self.base, tdrhf.TDA)
36 changes: 36 additions & 0 deletions gpu4pyscf/df/nac/tdrks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2021-2024 The PySCF Developers. 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.

from gpu4pyscf.nac import tdrks as tdrks_nac
from gpu4pyscf.df.nac import tdrhf as tdrhf_nac_df
from gpu4pyscf.df import df
from gpu4pyscf.tdscf import rks as tdrks

class NAC(tdrks_nac.NAC):
from gpu4pyscf.lib.utils import to_gpu, device

_keys = {'with_df', 'auxbasis_response'}
def __init__(self, td):
# Whether to include the response of DF auxiliary basis when computing
# nuclear gradients of J/K matrices
tdrks_nac.NAC.__init__(self, td)

auxbasis_response = True
get_jk = tdrhf_nac_df.get_jk

def check_sanity(self):
assert isinstance(self.base._scf, df.df_jk._DFHF)
assert isinstance(self.base, tdrks.TDDFT) or isinstance(self.base, tdrks.TDA)

get_veff = tdrhf_nac_df.get_veff
35 changes: 35 additions & 0 deletions gpu4pyscf/df/nac/tdrks_ris.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2021-2024 The PySCF Developers. 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.

from gpu4pyscf.nac import tdrks_ris as tdrks_ris_nac
from gpu4pyscf.df.nac import tdrhf as tdrhf_nac_df
from gpu4pyscf.df import df
from gpu4pyscf.tdscf import ris

class NAC(tdrks_ris_nac.NAC):
from gpu4pyscf.lib.utils import to_gpu, device

_keys = {'with_df', 'auxbasis_response'}
def __init__(self, td):
# Whether to include the response of DF auxiliary basis when computing
# nuclear gradients of J/K matrices
tdrks_ris_nac.NAC.__init__(self, td)

auxbasis_response = True
get_veff = tdrhf_nac_df.get_veff
get_jk = tdrhf_nac_df.get_jk

def check_sanity(self):
assert isinstance(self.base._scf, df.df_jk._DFHF)
assert isinstance(self.base, ris.TDDFT) or isinstance(self.base, ris.TDA)
Loading