Skip to content

Commit

Permalink
Update the treatment of _keys
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Sep 7, 2023
1 parent 74d7eff commit ae7c637
Show file tree
Hide file tree
Showing 107 changed files with 498 additions and 326 deletions.
17 changes: 10 additions & 7 deletions pyscf/adc/radc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ class RADC(lib.StreamObject):
blkmin = getattr(__config__, 'adc_radc_RADC_blkmin', 4)
memorymin = getattr(__config__, 'adc_radc_RADC_memorymin', 2000)

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mol', 'mo_energy', 'incore_complete',
'scf_energy', 'e_tot', 't1', 'frozen', 'chkfile',
'max_space', 't2', 'mo_occ', 'max_cycle',
'imds', 'method', 'method_type', 'with_df', 'compute_properties',
'approx_trans_moments', 'evec_print_tol', 'spec_factor_print_tol',
'ncvs', 'E', 'U', 'P', 'X',
))

def __init__(self, mf, frozen=0, mo_coeff=None, mo_occ=None):
from pyscf import gto

Expand Down Expand Up @@ -162,13 +172,6 @@ def __init__(self, mf, frozen=0, mo_coeff=None, mo_occ=None):
self.P = None
self.X = None

keys = set(('tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mol', 'mo_energy', 'max_memory', 'incore_complete',
'scf_energy', 'e_tot', 't1', 'frozen', 'chkfile',
'max_space', 't2', 'mo_occ', 'max_cycle'))

self._keys = set(self.__dict__.keys()).union(keys)

compute_amplitudes = radc_amplitudes.compute_amplitudes
compute_energy = radc_amplitudes.compute_energy
transform_integrals = radc_ao2mo.transform_integrals_incore
Expand Down
14 changes: 8 additions & 6 deletions pyscf/adc/radc_ea.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,14 @@ class RADCEA(radc.RADC):
Spectroscopic amplitudes for each EA transition.
'''

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mo_energy', 't1', 'max_space', 't2', 'max_cycle',
'nmo', 'transform_integrals', 'with_df', 'compute_properties',
'approx_trans_moments', 'E', 'U', 'P', 'X',
'evec_print_tol', 'spec_factor_print_tol',
))

def __init__(self, adc):
self.mol = adc.mol
self.verbose = adc.verbose
Expand Down Expand Up @@ -999,12 +1007,6 @@ def __init__(self, adc):
self.evec_print_tol = adc.evec_print_tol
self.spec_factor_print_tol = adc.spec_factor_print_tol

keys = set(('tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mo_energy', 'max_memory', 't1', 'max_space', 't2',
'max_cycle'))

self._keys = set(self.__dict__.keys()).union(keys)

kernel = radc.kernel
get_imds = get_imds
matvec = matvec
Expand Down
14 changes: 9 additions & 5 deletions pyscf/adc/radc_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,15 @@ class RADCIP(radc.RADC):
Spectroscopic amplitudes for each IP transition.
'''

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mo_energy_b', 't1', 'mo_energy_a',
'max_space', 't2', 'max_cycle',
'nmo', 'transform_integrals', 'with_df', 'compute_properties',
'approx_trans_moments', 'E', 'U', 'P', 'X',
'evec_print_tol', 'spec_factor_print_tol',
))

def __init__(self, adc):
self.mol = adc.mol
self.verbose = adc.verbose
Expand Down Expand Up @@ -954,11 +963,6 @@ def __init__(self, adc):
self.evec_print_tol = adc.evec_print_tol
self.spec_factor_print_tol = adc.spec_factor_print_tol

keys = set(('tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mo_energy_b', 'max_memory', 't1', 'mo_energy_a',
'max_space', 't2', 'max_cycle'))
self._keys = set(self.__dict__.keys()).union(keys)

kernel = radc.kernel
get_imds = get_imds
get_diag = get_diag
Expand Down
14 changes: 9 additions & 5 deletions pyscf/adc/radc_ip_cvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,15 @@ class RADCIPCVS(radc.RADC):
Spectroscopic amplitudes for each IP transition.
'''

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mo_energy_b', 't1', 'mo_energy_a',
'max_space', 't2', 'max_cycle',
'nmo', 'transform_integrals', 'with_df', 'compute_properties',
'approx_trans_moments', 'E', 'U', 'P', 'X',
'evec_print_tol', 'spec_factor_print_tol', 'ncvs',
))

def __init__(self, adc):
self.mol = adc.mol
self.verbose = adc.verbose
Expand Down Expand Up @@ -972,11 +981,6 @@ def __init__(self, adc):
self.spec_factor_print_tol = adc.spec_factor_print_tol
self.ncvs = adc.ncvs

keys = set(('tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
'mo_energy_b', 'max_memory', 't1', 'mo_energy_a',
'max_space', 't2', 'max_cycle'))
self._keys = set(self.__dict__.keys()).union(keys)

kernel = radc.kernel
get_imds = get_imds
get_diag = get_diag
Expand Down
19 changes: 11 additions & 8 deletions pyscf/adc/uadc.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ class UADC(lib.StreamObject):
'''
incore_complete = getattr(__config__, 'adc_uadc_UADC_incore_complete', False)

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mol', 'mo_energy_b',
'scf_energy', 'e_tot', 't1', 'frozen',
'mo_energy_a', 'chkfile', 'max_space', 't2', 'mo_occ', 'max_cycle',
'incore_complete', 'mo_energy_a', 'mo_energy_b', 'with_df',
'compute_mpn_energy', 'compute_spec', 'compute_properties',
'approx_trans_moments', 'evec_print_tol', 'spec_factor_print_tol',
'E', 'U', 'P', 'X', 'ncvs',
))

def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
from pyscf import gto

Expand Down Expand Up @@ -166,14 +177,6 @@ def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
self.X = (None,)
self.ncvs = None

keys = set(('tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mol', 'mo_energy_b',
'max_memory', 'scf_energy', 'e_tot', 't1', 'frozen',
'mo_energy_a', 'chkfile', 'max_space', 't2', 'mo_occ',
'max_cycle'))

self._keys = set(self.__dict__.keys()).union(keys)

compute_amplitudes = uadc_amplitudes.compute_amplitudes
compute_energy = uadc_amplitudes.compute_energy
transform_integrals = uadc_ao2mo.transform_integrals_incore
Expand Down
16 changes: 10 additions & 6 deletions pyscf/adc/uadc_ea.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,16 @@ class UADCEA(uadc.UADC):
Spectroscopic amplitudes for each EA transition.
'''

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory',
't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle',
'nocc_a', 'nocc_b', 'nvir_a', 'nvir_b', 'mo_coeff', 'mo_energy_a',
'mo_energy_b', 'nmo_a', 'nmo_b', 'mol', 'transform_integrals',
'with_df', 'spec_factor_print_tol', 'evec_print_tol',
'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X',
))

def __init__(self, adc):
self.verbose = adc.verbose
self.stdout = adc.stdout
Expand Down Expand Up @@ -1999,12 +2009,6 @@ def __init__(self, adc):
self.P = adc.P
self.X = adc.X

keys = set(('tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory',
't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle'))

self._keys = set(self.__dict__.keys()).union(keys)

kernel = uadc.kernel
get_imds = get_imds
matvec = matvec
Expand Down
16 changes: 10 additions & 6 deletions pyscf/adc/uadc_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,16 @@ class UADCIP(uadc.UADC):
Spectroscopic amplitudes for each IP transition.
'''

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory',
't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle',
'nocc_a', 'nocc_b', 'nvir_a', 'nvir_b', 'mo_coeff', 'mo_energy_a',
'mo_energy_b', 'nmo_a', 'nmo_b', 'mol', 'transform_integrals',
'with_df', 'spec_factor_print_tol', 'evec_print_tol',
'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X',
))

def __init__(self, adc):
self.verbose = adc.verbose
self.stdout = adc.stdout
Expand Down Expand Up @@ -1877,12 +1887,6 @@ def __init__(self, adc):
self.P = adc.P
self.X = adc.X

keys = set(('tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory',
't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle'))

self._keys = set(self.__dict__.keys()).union(keys)

kernel = uadc.kernel
get_imds = get_imds
get_diag = get_diag
Expand Down
16 changes: 10 additions & 6 deletions pyscf/adc/uadc_ip_cvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,16 @@ class UADCIPCVS(uadc.UADC):
Spectroscopic amplitudes for each IP transition.
'''

_keys = set((
'tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory',
't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle',
'nocc_a', 'nocc_b', 'nvir_a', 'nvir_b', 'mo_coeff', 'mo_energy_a',
'mo_energy_b', 'nmo_a', 'nmo_b', 'mol', 'transform_integrals',
'with_df', 'spec_factor_print_tol', 'evec_print_tol', 'ncvs',
'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X',
))

def __init__(self, adc):
self.verbose = adc.verbose
self.stdout = adc.stdout
Expand Down Expand Up @@ -2075,12 +2085,6 @@ def __init__(self, adc):
self.P = adc.P
self.X = adc.X

keys = set(('tol_residual','conv_tol', 'e_corr', 'method',
'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory',
't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle'))

self._keys = set(self.__dict__.keys()).union(keys)

kernel = uadc.kernel
get_imds = get_imds
get_diag = get_diag
Expand Down
4 changes: 2 additions & 2 deletions pyscf/agf2/dfragf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ class DFRAGF2(ragf2.RAGF2):
Auxiliaries of the Green's function
'''

_keys = set(['_with_df', 'allow_lowmem_build'])

def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):
ragf2.RAGF2.__init__(self, mf, frozen=frozen, mo_energy=mo_energy,
mo_coeff=mo_coeff, mo_occ=mo_occ)
Expand All @@ -270,8 +272,6 @@ def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):

self.allow_lowmem_build = True

self._keys.update(['_with_df', 'allow_lowmem_build'])

build_se_part = build_se_part
get_jk = get_jk

Expand Down
4 changes: 2 additions & 2 deletions pyscf/agf2/dfuagf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class DFUAGF2(uagf2.UAGF2):
Auxiliaries of the Green's function for each spin
'''

_keys = set(['_with_df', 'allow_lowmem_build'])

def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):
uagf2.UAGF2.__init__(self, mf, frozen=frozen, mo_energy=mo_energy,
mo_coeff=mo_coeff, mo_occ=mo_occ)
Expand All @@ -221,8 +223,6 @@ def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):

self.allow_lowmem_build = True

self._keys.update(['_with_df', 'allow_lowmem_build'])

build_se_part = build_se_part
get_jk = dfragf2.get_jk

Expand Down
11 changes: 10 additions & 1 deletion pyscf/agf2/ragf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,16 @@ class RAGF2(lib.StreamObject):
async_io = getattr(__config__, 'agf2_async_io', True)
incore_complete = getattr(__config__, 'agf2_incore_complete', False)

_keys = set((
'async_io', 'mol', 'incore_complete',
'conv_tol', 'conv_tol_rdm1', 'conv_tol_nelec', 'max_cycle',
'max_cycle_outer', 'max_cycle_inner', 'weight_tol', 'fock_diis_space',
'fock_diis_min_space', 'diis', 'diis_space', 'diis_min_space',
'os_factor', 'ss_factor', 'damping',
'mo_energy', 'mo_coeff', 'mo_occ', 'se', 'gf', 'e_1b', 'e_2b', 'e_init',
'frozen', 'converged', 'chkfile',
))

def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):

if mo_energy is None: mo_energy = mpi_helper.bcast(mf.mo_energy)
Expand Down Expand Up @@ -549,7 +559,6 @@ def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):
self._nocc = None
self.converged = False
self.chkfile = mf.chkfile
self._keys = set(self.__dict__.keys())

energy_1body = energy_1body
energy_2body = energy_2body
Expand Down
4 changes: 2 additions & 2 deletions pyscf/agf2/ragf2_slow.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ class RAGF2(ragf2.RAGF2):
Auxiliaries of the Green's function
'''

_keys = set(['nmom'])

def __init__(self, mf, nmom=(None,0), frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):

ragf2.RAGF2.__init__(self, mf, frozen=frozen, mo_energy=mo_energy,
mo_coeff=mo_coeff, mo_occ=mo_occ)

self.nmom = nmom

self._keys.update(['nmom'])

build_se_part = build_se_part

def build_se(self, eri=None, gf=None, os_factor=None, ss_factor=None, se_prev=None):
Expand Down
4 changes: 2 additions & 2 deletions pyscf/agf2/uagf2_slow.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ class UAGF2(uagf2.UAGF2):
Auxiliaries of the Green's function for each spin
'''

_keys = set(['nmom'])

def __init__(self, mf, nmom=(None,0), frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None):

uagf2.UAGF2.__init__(self, mf, frozen=frozen, mo_energy=mo_energy,
mo_coeff=mo_coeff, mo_occ=mo_occ)

self.nmom = nmom

self._keys.update(['nmom'])

build_se_part = build_se_part

def build_se(self, eri=None, gf=None, os_factor=None, ss_factor=None, se_prev=None):
Expand Down
16 changes: 10 additions & 6 deletions pyscf/cc/ccsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,16 @@ class CCSD(lib.StreamObject):
incore_complete = getattr(__config__, 'cc_ccsd_CCSD_incore_complete', False)
cc2 = getattr(__config__, 'cc_ccsd_CCSD_cc2', False)

_keys = set((
'max_cycle', 'conv_tol', 'iterative_damping',
'conv_tol_normt', 'diis', 'diis_space', 'diis_file',
'diis_start_cycle', 'diis_start_energy_diff', 'direct',
'async_io', 'incore_complete', 'cc2', 'callback',
'mol', 'verbose', 'stdout', 'frozen', 'level_shift',
'mo_coeff', 'mo_occ', 'converged', 'converged_lambda', 'emp2', 'e_hf',
'e_corr', 't1', 't2', 'l1', 'l2', 'chkfile', 'callback',
))

def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
if isinstance(mf, gto.Mole):
raise RuntimeError('''
Expand Down Expand Up @@ -969,12 +979,6 @@ def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
self.chkfile = mf.chkfile
self.callback = None

keys = set(('max_cycle', 'conv_tol', 'iterative_damping',
'conv_tol_normt', 'diis', 'diis_space', 'diis_file',
'diis_start_cycle', 'diis_start_energy_diff', 'direct',
'async_io', 'incore_complete', 'cc2'))
self._keys = set(self.__dict__.keys()).union(keys)

@property
def ecc(self):
return self.e_corr
Expand Down
3 changes: 2 additions & 1 deletion pyscf/cc/dfccsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
MEMORYMIN = getattr(__config__, 'cc_ccsd_memorymin', 2000)

class RCCSD(ccsd.CCSD):
_keys = set(['with_df'])

def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
ccsd.CCSD.__init__(self, mf, frozen, mo_coeff, mo_occ)
if getattr(mf, 'with_df', None):
self.with_df = mf.with_df
else:
self.with_df = df.DF(mf.mol)
self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True)
self._keys.update(['with_df'])

def reset(self, mol=None):
self.with_df.reset(mol)
Expand Down
Loading

0 comments on commit ae7c637

Please sign in to comment.