From 940e4ac16f02eeef3fc944eae190d7f0609a60e7 Mon Sep 17 00:00:00 2001 From: Xiaojie Wu Date: Fri, 3 May 2024 23:42:36 -0700 Subject: [PATCH] move auxbasis_response out of __init__ (#2192) * move auxbasis_response out of __init__ * relax unit test in test_c_agf2 * import hessian * Update __init__.py --- pyscf/df/grad/rhf.py | 7 ++++--- pyscf/df/grad/rks.py | 7 ++++--- pyscf/df/grad/uhf.py | 7 ++++--- pyscf/df/grad/uks.py | 6 +++--- pyscf/df/hessian/rhf.py | 2 +- pyscf/df/hessian/rks.py | 2 +- pyscf/df/hessian/uhf.py | 2 +- pyscf/df/hessian/uks.py | 2 +- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/pyscf/df/grad/rhf.py b/pyscf/df/grad/rhf.py index cfa31375eb..94aad0be24 100644 --- a/pyscf/df/grad/rhf.py +++ b/pyscf/df/grad/rhf.py @@ -482,11 +482,12 @@ class Gradients(rhf_grad.Gradients): _keys = {'with_df', 'auxbasis_response'} def __init__(self, mf): - # Whether to include the response of DF auxiliary basis when computing - # nuclear gradients of J/K matrices - self.auxbasis_response = True rhf_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 + def check_sanity(self): assert isinstance(self.base, df.df_jk._DFHF) diff --git a/pyscf/df/grad/rks.py b/pyscf/df/grad/rks.py index adfc7b7080..1802299b68 100644 --- a/pyscf/df/grad/rks.py +++ b/pyscf/df/grad/rks.py @@ -107,11 +107,12 @@ class Gradients(rks_grad.Gradients): _keys = {'with_df', 'auxbasis_response'} def __init__(self, mf): - # Whether to include the response of DF auxiliary basis when computing - # nuclear gradients of J/K matrices - self.auxbasis_response = True rks_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 diff --git a/pyscf/df/grad/uhf.py b/pyscf/df/grad/uhf.py index 0eec773b0d..6295633ede 100644 --- a/pyscf/df/grad/uhf.py +++ b/pyscf/df/grad/uhf.py @@ -35,11 +35,12 @@ class Gradients(uhf_grad.Gradients): _keys = {'with_df', 'auxbasis_response'} def __init__(self, mf): - # Whether to include the response of DF auxiliary basis when computing - # nuclear gradients of J/K matrices - self.auxbasis_response = True 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 diff --git a/pyscf/df/grad/uks.py b/pyscf/df/grad/uks.py index e6de663a95..30fe60b361 100644 --- a/pyscf/df/grad/uks.py +++ b/pyscf/df/grad/uks.py @@ -108,11 +108,11 @@ class Gradients(uks_grad.Gradients): _keys = {'with_df', 'auxbasis_response'} def __init__(self, mf): - # Whether to include the response of DF auxiliary basis when computing - # nuclear gradients of J/K matrices - self.auxbasis_response = True uks_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 diff --git a/pyscf/df/hessian/rhf.py b/pyscf/df/hessian/rhf.py index d06fa9f473..6c4cd691e5 100644 --- a/pyscf/df/hessian/rhf.py +++ b/pyscf/df/hessian/rhf.py @@ -475,9 +475,9 @@ def _load_dim0(dat, p0, p1): class Hessian(rhf_hess.Hessian): '''Non-relativistic restricted Hartree-Fock hessian''' def __init__(self, mf): - self.auxbasis_response = 1 rhf_hess.Hessian.__init__(self, mf) + auxbasis_response = 1 partial_hess_elec = partial_hess_elec make_h1 = make_h1 diff --git a/pyscf/df/hessian/rks.py b/pyscf/df/hessian/rks.py index 74c1bdd6c9..1d1073d657 100644 --- a/pyscf/df/hessian/rks.py +++ b/pyscf/df/hessian/rks.py @@ -121,9 +121,9 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None): class Hessian(rks_hess.Hessian): '''Non-relativistic RKS hessian''' def __init__(self, mf): - self.auxbasis_response = 1 rks_hess.Hessian.__init__(self, mf) + auxbasis_response = 1 partial_hess_elec = partial_hess_elec make_h1 = make_h1 diff --git a/pyscf/df/hessian/uhf.py b/pyscf/df/hessian/uhf.py index 5cb20240f8..be863e87ec 100644 --- a/pyscf/df/hessian/uhf.py +++ b/pyscf/df/hessian/uhf.py @@ -526,9 +526,9 @@ def _gen_jk(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, class Hessian(uhf_hess.Hessian): '''Non-relativistic UHF hessian''' def __init__(self, mf): - self.auxbasis_response = 1 uhf_hess.Hessian.__init__(self, mf) + auxbasis_response = 1 partial_hess_elec = partial_hess_elec make_h1 = make_h1 diff --git a/pyscf/df/hessian/uks.py b/pyscf/df/hessian/uks.py index 1afa995973..3c86207f36 100644 --- a/pyscf/df/hessian/uks.py +++ b/pyscf/df/hessian/uks.py @@ -134,9 +134,9 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None): class Hessian(uks_hess.Hessian): '''Non-relativistic RKS hessian''' def __init__(self, mf): - self.auxbasis_response = 1 uks_hess.Hessian.__init__(self, mf) + auxbasis_response = 1 partial_hess_elec = partial_hess_elec make_h1 = make_h1