def canonicalize(mf, mo_coeff, mo_occ, fock=None): '''Canonicalization diagonalizes the Fock matrix in occupied, open, virtual subspaces separatedly (without change occupancy). ''' if not mf.mol.symmetry: return hf.canonicalize(mf, mo_coeff, mo_occ, fock) if fock is None: dm = mf.make_rdm1(mo_coeff, mo_occ) fock = mf.get_hcore() + mf.get_jk(mol, dm) coreidx = mo_occ == 2 viridx = mo_occ == 0 openidx = ~(coreidx | viridx) mo = numpy.empty_like(mo_coeff) mo_e = numpy.empty(mo_occ.size) s = mf.get_ovlp() for idx in (coreidx, openidx, viridx): if numpy.count_nonzero(idx) > 0: orb = mo_coeff[:, idx] f1 = reduce(numpy.dot, (orb.T.conj(), fock, orb)) e, c = scipy.linalg.eigh(f1) c = numpy.dot(mo_coeff[:, idx], c) mo[:, idx] = _symmetrize_canonicalization_(mf.mol, e, c, s) mo_e[idx] = e return mo_e, mo
def canonicalize(mf, mo_coeff, mo_occ, fock=None): '''Canonicalization diagonalizes the Fock matrix in occupied, open, virtual subspaces separatedly (without change occupancy). ''' if not mf.mol.symmetry: return hf.canonicalize(mf, mo_coeff, mo_occ, fock) if fock is None: dm = mf.make_rdm1(mo_coeff, mo_occ) fock = mf.get_hcore() + mf.get_jk(mol, dm) coreidx = mo_occ == 2 viridx = mo_occ == 0 openidx = ~(coreidx | viridx) mo = numpy.empty_like(mo_coeff) mo_e = numpy.empty(mo_occ.size) s = mf.get_ovlp() for idx in (coreidx, openidx, viridx): if numpy.count_nonzero(idx) > 0: orb = mo_coeff[:,idx] f1 = reduce(numpy.dot, (orb.T.conj(), fock, orb)) e, c = scipy.linalg.eigh(f1) c = numpy.dot(mo_coeff[:,idx], c) mo[:,idx] = _symmetrize_canonicalization_(mf.mol, e, c, s) mo_e[idx] = e return mo_e, mo
def canonicalize(mf, mo_coeff, mo_occ, fock=None): '''Canonicalization diagonalizes the Fock matrix within occupied, open, virtual subspaces separatedly (without change occupancy). ''' dm = mf.make_rdm1(mo_coeff, mo_occ) if fock is None: fock = mf.get_hcore() + mf.get_jk(mol, dm) if isinstance(fock, numpy.ndarray) and fock.ndim == 3: fock = get_roothaan_fock(fock, dm, mf.get_ovlp()) return hf.canonicalize(mf, mo_coeff, mo_occ, fock)
def canonicalize(mf, mo_coeff, mo_occ, fock=None): '''Canonicalization diagonalizes the Fock matrix within occupied, open, virtual subspaces separatedly (without change occupancy). ''' if not hasattr(fock, 'focka'): dm = mf.make_rdm1(mo_coeff, mo_occ) fock = mf.get_fock(dm=dm) mo_e, mo_coeff = hf.canonicalize(mf, mo_coeff, mo_occ, fock) mo_ea = numpy.einsum('pi,pi->i', mo_coeff, fock.focka.dot(mo_coeff)) mo_eb = numpy.einsum('pi,pi->i', mo_coeff, fock.fockb.dot(mo_coeff)) mo_e = lib.tag_array(mo_e, mo_ea=mo_ea, mo_eb=mo_eb) return mo_e, mo_coeff
def canonicalize(mf, mo_coeff, mo_occ, fock=None): '''Canonicalization diagonalizes the Fock matrix within occupied, open, virtual subspaces separatedly (without change occupancy). ''' if getattr(fock, 'focka', None) is None: dm = mf.make_rdm1(mo_coeff, mo_occ) fock = mf.get_fock(dm=dm) mo_e, mo_coeff = hf.canonicalize(mf, mo_coeff, mo_occ, fock) fa, fb = fock.focka, fock.fockb mo_ea = numpy.einsum('pi,pi->i', mo_coeff.conj(), fa.dot(mo_coeff)).real mo_eb = numpy.einsum('pi,pi->i', mo_coeff.conj(), fb.dot(mo_coeff)).real mo_e = lib.tag_array(mo_e, mo_ea=mo_ea, mo_eb=mo_eb) return mo_e, mo_coeff
def canonicalize(mf, mo_coeff, mo_occ, fock=None): '''Canonicalization diagonalizes the Fock matrix in occupied, open, virtual subspaces separatedly (without change occupancy). ''' mol = mf.mol if not mol.symmetry: return hf.canonicalize(mf, mo_coeff, mo_occ, fock) if fock is None: dm = mf.make_rdm1(mo_coeff, mo_occ) fock = mf.get_hcore() + mf.get_veff(mf.mol, dm) coreidx = mo_occ == 2 viridx = mo_occ == 0 openidx = ~(coreidx | viridx) mo = numpy.empty_like(mo_coeff) mo_e = numpy.empty(mo_occ.size) if hasattr(mo_coeff, 'orbsym'): orbsym = mo_coeff.orbsym irreps = set(orbsym) for ir in irreps: idx0 = orbsym == ir for idx1 in (coreidx, openidx, viridx): idx = idx0 & idx1 if numpy.count_nonzero(idx) > 0: orb = mo_coeff[:, idx] f1 = reduce(numpy.dot, (orb.T.conj(), fock, orb)) e, c = scipy.linalg.eigh(f1) mo[:, idx] = numpy.dot(mo_coeff[:, idx], c) mo_e[idx] = e else: s = mf.get_ovlp() for idx in (coreidx, openidx, viridx): if numpy.count_nonzero(idx) > 0: orb = mo_coeff[:, idx] f1 = reduce(numpy.dot, (orb.T.conj(), fock, orb)) e, c = scipy.linalg.eigh(f1) c = numpy.dot(mo_coeff[:, idx], c) mo[:, idx] = _symmetrize_canonicalization_(mf, e, c, s) mo_e[idx] = e orbsym = get_orbsym(mol, mo, s, False) mo = lib.tag_array(mo, orbsym=orbsym) return mo_e, mo