예제 #1
0
def h1e_for_cas(casci, mo_coeff=None, ncas=None, ncore=None):
    '''CAS sapce one-electron hamiltonian for UHF-CASCI or UHF-CASSCF

    Args:
        casci : a U-CASSCF/U-CASCI object or UHF object

    '''
    if mo_coeff is None: mo_coeff = casci.mo_coeff
    if ncas is None: ncas = casci.ncas
    if ncore is None: ncore = casci.ncore
    mo_core = (mo_coeff[0][:, :ncore[0]], mo_coeff[1][:, :ncore[1]])
    mo_cas = (mo_coeff[0][:, ncore[0]:ncore[0] + ncas],
              mo_coeff[1][:, ncore[1]:ncore[1] + ncas])

    hcore = casci.get_hcore()
    energy_core = casci.energy_nuc()
    if mo_core[0].size == 0 and mo_core[1].size == 0:
        corevhf = (0, 0)
    else:
        core_dm = (numpy.dot(mo_core[0],
                             mo_core[0].T), numpy.dot(mo_core[1],
                                                      mo_core[1].T))
        corevhf = casci.get_veff(casci.mol, core_dm)
        energy_core += numpy.einsum('ij,ji', core_dm[0], hcore[0])
        energy_core += numpy.einsum('ij,ji', core_dm[1], hcore[1])
        energy_core += numpy.einsum('ij,ji', core_dm[0], corevhf[0]) * .5
        energy_core += numpy.einsum('ij,ji', core_dm[1], corevhf[1]) * .5
    h1eff = (reduce(numpy.dot,
                    (mo_cas[0].T, hcore[0] + corevhf[0], mo_cas[0])),
             reduce(numpy.dot,
                    (mo_cas[1].T, hcore[1] + corevhf[1], mo_cas[1])))
    return h1eff, energy_core
예제 #2
0
파일: ucasci.py 프로젝트: chrinide/pyscf
def h1e_for_cas(casci, mo_coeff=None, ncas=None, ncore=None):
    '''CAS sapce one-electron hamiltonian for UHF-CASCI or UHF-CASSCF

    Args:
        casci : a U-CASSCF/U-CASCI object or UHF object

    '''
    if mo_coeff is None: mo_coeff = casci.mo_coeff
    if ncas is None: ncas = casci.ncas
    if ncore is None: ncore = casci.ncore
    mo_core =(mo_coeff[0][:,:ncore[0]], mo_coeff[1][:,:ncore[1]])
    mo_cas = (mo_coeff[0][:,ncore[0]:ncore[0]+ncas],
              mo_coeff[1][:,ncore[1]:ncore[1]+ncas])

    hcore = casci.get_hcore()
    energy_core = casci.energy_nuc()
    if mo_core[0].size == 0 and mo_core[1].size == 0:
        corevhf = (0,0)
    else:
        core_dm = (numpy.dot(mo_core[0], mo_core[0].T),
                   numpy.dot(mo_core[1], mo_core[1].T))
        corevhf = casci.get_veff(casci.mol, core_dm)
        energy_core += numpy.einsum('ij,ji', core_dm[0], hcore[0])
        energy_core += numpy.einsum('ij,ji', core_dm[1], hcore[1])
        energy_core += numpy.einsum('ij,ji', core_dm[0], corevhf[0]) * .5
        energy_core += numpy.einsum('ij,ji', core_dm[1], corevhf[1]) * .5
    h1eff = (reduce(numpy.dot, (mo_cas[0].T, hcore[0]+corevhf[0], mo_cas[0])),
             reduce(numpy.dot, (mo_cas[1].T, hcore[1]+corevhf[1], mo_cas[1])))
    return h1eff, energy_core