Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions pyscf/csf_fci/csf.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ def get_init_guess(self, norb, nelec, nroots, hdiag_csf, **kwargs):
return get_init_guess (norb, nelec, nroots, hdiag_csf, self.transformer)

def kernel(self, h1e, eri, norb, nelec, ci0=None, **kwargs):
# Assume we are passed "remaining memory" if max_memory is a kwarg
if 'max_memory' in kwargs:
kwargs['max_memory'] += lib.current_memory ()[0]
self.norb = norb
self.nelec = nelec
if 'smult' in kwargs:
Expand Down
6 changes: 5 additions & 1 deletion pyscf/csf_fci/csf_symm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import scipy
from pyscf import symm, __config__
from pyscf import symm, __config__, lib
from pyscf.lib import logger, davidson1
from pyscf.fci import direct_spin1_symm, cistring, direct_uhf
from pyscf.lib.numpy_helper import tag_array
Expand Down Expand Up @@ -34,6 +34,10 @@ def kernel(self, h1e, eri, norb, nelec, ci0=None, **kwargs):
''' Over the top of the existing kernel, I just need to set the parameters and cache values related to spin.

...and electron configuration point group '''

# Assume we are passed "remaining memory" if max_memory is a kwarg
if 'max_memory' in kwargs:
kwargs['max_memory'] += lib.current_memory ()[0]
log = logger.new_logger (self, self.verbose)
gpname = getattr (self.mol, 'groupname', None)
if gpname in ('Dooh', 'Coov'):
Expand Down
5 changes: 4 additions & 1 deletion pyscf/csf_fci/csfstring.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import sys, os, time
import ctypes
import warnings
from pyscf.csf_fci import csdstring
from pyscf.fci import cistring
from pyscf.fci.spin_op import spin_square0
Expand Down Expand Up @@ -935,7 +936,9 @@ def get_spin_evecs (nspin, neleca, nelecb, smult, max_memory=param.MAX_MEMORY):
mem_current = lib.current_memory ()[0]
mem_rem = max_memory - mem_current
mem_reqd = ndet * ncsf * np.dtype (np.float64).itemsize / 1e6
if mem_reqd > mem_rem:
if max_memory < 0:
warnings.warn ("Negative max_memory ({} MB)".format (max_memory), RuntimeWarning)
elif mem_reqd > mem_rem:
memstr = ('CSF unitary matrix for {} unpaired of {} total electrons w/ s={:.1f} is too big'
" ({} MB req'd of {} MB remaining; {} MB total available)").format (
nspin, neleca+nelecb, s, mem_reqd, mem_rem, max_memory)
Expand Down
1 change: 1 addition & 0 deletions pyscf/csf_fci/test/test_csfstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
from scipy import special
from pyscf.csf_fci.csfstring import *
from pyscf import lib

def case_spin_evecs (ks, nspin, ms):
neleca = int (round (nspin/2 + ms))
Expand Down
8 changes: 5 additions & 3 deletions pyscf/occri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,17 @@ def get_jk(
dm_shape = dm.shape
nk = self.kpts.shape[0]
nao = cell.nao
ndm = dm.reshape (-1, nk, nao, nao).shape[0]
if with_k:
if self.scf_iter == 0:
dm = numpy.asarray(dm)
if getattr(dm, 'mo_coeff', None) is None:
dm = self.make_natural_orbitals(dm.reshape(-1, nk, nao, nao))
else:
mo_coeff = numpy.asarray(dm.mo_coeff).reshape(-1, nk, nao, nao)
mo_occ = numpy.asarray(dm.mo_occ).reshape(-1, nk, nao)
dm = lib.tag_array(dm.reshape(-1, nk, nao, nao), mo_coeff=mo_coeff, mo_occ=mo_occ)
mo_occ = numpy.asarray(dm.mo_occ).reshape(ndm, nk, -1)
nmo = mo_occ.shape[2]
mo_coeff = numpy.asarray(dm.mo_coeff).reshape(ndm, nk, nao, nmo)
dm = lib.tag_array(dm.reshape(ndm, nk, nao, nao), mo_coeff=mo_coeff, mo_occ=mo_occ)

if with_j:
vj = self.get_j(self, dm, kpts=self.kpts)
Expand Down
2 changes: 1 addition & 1 deletion pyscf/occri/test/test_isdfx_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setUp(self):
self.cell_h2.basis = "gth-szv"
self.cell_h2.pseudo = "gth-pbe"
self.cell_h2.a = numpy.eye(3) * 6.0
self.cell_h2.mesh = [11] * 3
self.cell_h2.mesh = [21] * 3
self.cell_h2.verbose = 0
self.cell_h2.build()

Expand Down
2 changes: 1 addition & 1 deletion pyscf/occri/test/test_occri.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUpModule():
cell.basis = "gth-szv"
cell.pseudo = "gth-pbe"
cell.a = numpy.eye(3) * 3.5607
cell.mesh = [17] * 3
cell.mesh = [21] * 3
cell.build()

# Setup proper k-point mesh
Expand Down
15 changes: 9 additions & 6 deletions pyscf/pbc/lno/test/test_makeklnordm1.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,29 +232,32 @@ def test_make_lno_complex(self):
verbose=cell.verbose,stdout=cell.stdout)
eris.build()

occ_ref = -0.06419439687135728+4.973277156424204e-05j
vir_ref = -0.010792752484758372-0.014791758114215927j

arr = make_lo_rdm1_occ_1h_complex(eris, moeocc, moevir, uocc_loc)
fp = lib.fp(arr)
self.assertAlmostEqual(fp, -0.06422719794290856+2.5105071595401036e-05j, 7)
self.assertAlmostEqual(fp, occ_ref, 7)

arr = make_lo_rdm1_occ_1p_complex(eris, moeocc, moevir, uvir_loc)
fp = lib.fp(arr)
self.assertAlmostEqual(fp, -0.06422719794290856+2.5105071595401036e-05j, 7)
self.assertAlmostEqual(fp, occ_ref, 7)

arr = make_lo_rdm1_occ_2p_complex(eris, moeocc, moevir, uvir_loc)
fp = lib.fp(arr)
self.assertAlmostEqual(fp, -0.06422719794290856+2.5105071595401036e-05j, 7)
self.assertAlmostEqual(fp, occ_ref, 7)

arr = make_lo_rdm1_vir_1h_complex(eris, moeocc, moevir, uocc_loc)
fp = lib.fp(arr)
self.assertAlmostEqual(fp, -0.002766848360192287-0.034349212190162834j, 7)
self.assertAlmostEqual(fp, vir_ref, 7)

arr = make_lo_rdm1_vir_1p_complex(eris, moeocc, moevir, uvir_loc)
fp = lib.fp(arr)
self.assertAlmostEqual(fp, -0.002766848360192287-0.034349212190162834j, 7)
self.assertAlmostEqual(fp, vir_ref, 7)

arr = make_lo_rdm1_vir_2h_complex(eris, moeocc, moevir, uocc_loc)
fp = lib.fp(arr)
self.assertAlmostEqual(fp, -0.002766848360192287-0.034349212190162834j, 7)
self.assertAlmostEqual(fp, vir_ref, 7)



Expand Down
2 changes: 1 addition & 1 deletion pyscf/tools/trexio.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def _scf_to_trexio(mf, trexio_file):
if _trexio_is_uhf_uks_mf(mf):
mo_type = "UHF"
# Check for split structure (common in KUKS/KDF): ([up...], [dn...])
is_split_spin = isinstance(mf.mo_coeff, tuple) and len(mf.mo_coeff) == 2
is_split_spin = (mf.mo_coeff.ndim==4) and (mf.mo_coeff.shape[0]==2)

for i_k, _ in enumerate(kpts):
if is_split_spin:
Expand Down
Loading