diff --git a/pyscf/ao2mo/__init__.py b/pyscf/ao2mo/__init__.py index 7ea93a4e6c..fbe646eb56 100644 --- a/pyscf/ao2mo/__init__.py +++ b/pyscf/ao2mo/__init__.py @@ -31,6 +31,7 @@ import tempfile import numpy import h5py +from pyscf import gto from pyscf.ao2mo import incore from pyscf.ao2mo import outcore from pyscf.ao2mo import r_outcore @@ -143,7 +144,7 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e', ''' if isinstance(eri_or_mol, numpy.ndarray): return incore.full(eri_or_mol, mo_coeff, *args, **kwargs) - else: + elif isinstance(eri_or_mol, gto.MoleBase): if '_spinor' in intor: mod = r_outcore else: @@ -157,6 +158,11 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e', *args, **kwargs) else: return mod.full_iofree(eri_or_mol, mo_coeff, intor, *args, **kwargs) + else: + raise RuntimeError('ERI is not available. If this is generated by mf._eri, ' + 'the integral tensor is too big to store in memory. ' + 'You should either increase mol.max_memory, or set ' + 'mol.incore_anyway. See issue #2473.') def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e', *args, **kwargs): @@ -293,7 +299,7 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e ''' if isinstance(eri_or_mol, numpy.ndarray): return incore.general(eri_or_mol, mo_coeffs, *args, **kwargs) - else: + elif isinstance(eri_or_mol, gto.MoleBase): if '_spinor' in intor: mod = r_outcore else: @@ -307,6 +313,11 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e *args, **kwargs) else: return mod.general_iofree(eri_or_mol, mo_coeffs, intor, *args, **kwargs) + else: + raise RuntimeError('ERI is not available. If this is generated by mf._eri, ' + 'the integral tensor is too big to store in memory. ' + 'You should either increase mol.max_memory, or set ' + 'mol.incore_anyway. See issue #2473.') def kernel(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e', *args, **kwargs): diff --git a/pyscf/solvent/__init__.py b/pyscf/solvent/__init__.py index eeba899549..c1976117fa 100644 --- a/pyscf/solvent/__init__.py +++ b/pyscf/solvent/__init__.py @@ -13,6 +13,9 @@ # limitations under the License. from pyscf.solvent import ddcosmo +from pyscf.solvent import ddpcm +from pyscf.solvent import pcm +from pyscf.solvent import smd def ddCOSMO(method_or_mol, solvent_obj=None, dm=None): '''Initialize ddCOSMO model. @@ -58,7 +61,6 @@ def ddPCM(method_or_mol, solvent_obj=None, dm=None): from pyscf import gto from pyscf import scf, mcscf from pyscf import tdscf - from pyscf.solvent import ddpcm if isinstance(method_or_mol, gto.mole.Mole): return ddpcm.DDPCM(method_or_mol) @@ -126,7 +128,6 @@ def PCM(method_or_mol, solvent_obj=None, dm=None): from pyscf import gto from pyscf import scf, mcscf from pyscf import tdscf - from pyscf.solvent import pcm if isinstance(method_or_mol, gto.mole.Mole): return pcm.PCM(method_or_mol) @@ -157,7 +158,6 @@ def SMD(method_or_mol, solvent_obj=None, dm=None): ''' from pyscf import gto from pyscf import scf - from pyscf.solvent import smd if isinstance(method_or_mol, gto.mole.Mole): return smd.SMD(method_or_mol)