Skip to content

Commit

Permalink
Improve error message for ao2mo module (fix pyscf#2473)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Oct 20, 2024
1 parent 410d960 commit 5a59d9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 13 additions & 2 deletions pyscf/ao2mo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions pyscf/solvent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5a59d9e

Please sign in to comment.