diff --git a/my_pyscf/mcscf/lasscf_async/combine.py b/my_pyscf/mcscf/lasscf_async/combine.py index 6c0fc668..421fdc39 100644 --- a/my_pyscf/mcscf/lasscf_async/combine.py +++ b/my_pyscf/mcscf/lasscf_async/combine.py @@ -208,6 +208,10 @@ def combine_pair (las, kf1, kf2, kf_ref=None): '''Combine two keyframes and relax one specific block of active-active orbital rotations between the fragments assigned to each with the inactive and virtual orbitals frozen.''' if kf_ref is None: kf_ref=kf1 + if len (kf1.frags.intersection (kf2.frags)): + errstr = ("Cannot combine keyframes that are responsible for the same fragments " + "({} {})").format (kf1.frags, kf2.frags) + raise RuntimeError (errstr) kf3 = orth_orb (las, [kf1, kf2], kf_ref=kf_ref) i, j = select_aa_block (las, kf1.frags, kf2.frags, kf3.fock1) kf3 = relax (las, kf3, freeze_inactive=True, unfrozen_frags=(i,j)) diff --git a/my_pyscf/mcscf/lasscf_async/keyframe.py b/my_pyscf/mcscf/lasscf_async/keyframe.py index 03119843..d7c96f8e 100644 --- a/my_pyscf/mcscf/lasscf_async/keyframe.py +++ b/my_pyscf/mcscf/lasscf_async/keyframe.py @@ -349,5 +349,24 @@ def democratic_matrix (las, mat, frags, mo_coeff): return u @ mat @ u.conj ().T +# Thought I might need this; realize I don't. Might still be useful later. +def fock_cycle (las, kf1): + '''For the inactive-virtual orbital rotations only, build and diagonalize the fock + matrix once''' + nao, nmo = kf1.mo_coeff.shape + ncore, ncas = las.ncore, las.ncas + nocc = ncore + ncas + nvirt = nmo - nocc + mo = np.append (kf1.mo_coeff[:,:ncore], kf1.mo_coeff[:,nocc:]) + if not mo.shape[1]: return kf1 + kf2 = kf1.copy () + fock = las.get_hcore ()[None,:,:] + kf1.veff + fock = get_roothaan_fock (fock, kf1.dm1s, las._scf.get_ovlp()) + orbsym = None # TODO: symmetry + fock = mo.conj ().T @ fock @ mo + ene, umat = las._eig (fock, 0, 0, orbsym) + if ncore: kf2.mo_coeff[:,:ncore] = mo @ umat[:,:ncore] + if nvirt: kf2.mo_coeff[:,nocc:] = mo @ umat[:,ncore:] + return kf2