Beispiel #1
0
    def test_boys(self):
        idx = numpy.array([17,20,21,22,23,30,36,41,42,47,48,49])-1
        loc = boys.Boys(mol)
        mo = loc.kernel(mf.mo_coeff[:,idx])
        dip = boys.dipole_integral(mol, mo)
        z = numpy.einsum('xii,xii->', dip, dip)
        self.assertAlmostEqual(z, 98.670988758151907, 4)

        mo = loc.kernel(mf.mo_coeff[:,idx+1])
        dip = boys.dipole_integral(mol, mo)
        z = numpy.einsum('xii,xii->', dip, dip)
        self.assertAlmostEqual(z, 27.481320331665497, 4)
Beispiel #2
0
    def test_boys(self):
        idx = numpy.array([17,20,21,22,23,30,36,41,42,47,48,49])-1
        loc = boys.Boys(mol)
        mo = loc.kernel(mf.mo_coeff[:,idx])
        dip = boys.dipole_integral(mol, mo)
        z = numpy.einsum('xii,xii->', dip, dip)
        self.assertAlmostEqual(z, 98.670988758151907, 9)

        mo = loc.kernel(mf.mo_coeff[:,idx+1])
        dip = boys.dipole_integral(mol, mo)
        z = numpy.einsum('xii,xii->', dip, dip)
        self.assertAlmostEqual(z, 27.481320331665497, 9)
Beispiel #3
0
 def test_edmiston(self):
     idx = range(1, 5)
     loc = edmiston.EdmistonRuedenberg(h2o)
     mo = loc.kernel(mf_h2o.mo_coeff[:, idx])
     dip = boys.dipole_integral(h2o, mo)
     z = numpy.einsum('xii,xii->', dip, dip)
     self.assertAlmostEqual(z, 17.96309963411759, 4)
Beispiel #4
0
 def test_edmiston(self):
     idx = range(1, 5)
     loc = edmiston.EdmistonRuedenberg(h2o)
     mo = loc.kernel(mf_h2o.mo_coeff[:,idx])
     dip = boys.dipole_integral(h2o, mo)
     z = numpy.einsum('xii,xii->', dip, dip)
     self.assertAlmostEqual(z, 17.96309963411759, 4)
Beispiel #5
0
 def test_boys(self):
     idx = numpy.array([17,20,21,22,23,30,36,41,42,47,48,49])-1
     loc = boys.Boys(mol, mf.mo_coeff[:,idx])
     loc.max_cycle = 100
     mo = loc.kernel()
     dip = boys.dipole_integral(mol, mo)
     z = numpy.einsum('xii,xii->', dip, dip)
     self.assertAlmostEqual(z, 98.670988758151907, 4)
Beispiel #6
0
def get_locorb(mf, localize='pm', pair=True):
    mol = mf.mol
    mo = mf.mo_coeff
    nbf = mf.mo_coeff.shape[0]
    nif = mf.mo_coeff.shape[1]
    mol2 = mf.mol.copy()
    mol2.basis = 'sto-6g'
    mol2.build()
    mf2 = scf.RHF(mol2)
    mf2.max_cycle = 150
    #dm = mf2.from_chk('loc_rhf_proj.chk')
    mf2.kernel()
    mo2 = mf2.mo_coeff
    #nbf2 = mf2.mo_coeff.shape[0]
    #nif2 = mf2.mo_coeff.shape[1]
    idx = np.count_nonzero(mf.mo_occ)
    cross_S = gto.intor_cross('int1e_ovlp', mol, mol2)
    print(idx, mo.shape, mo2.shape, cross_S.shape)
    vir_cross = einsum('ji,jk,kl->il', mo[:, idx:], cross_S, mo2[:, idx:])

    u, s, v = scipy.linalg.svd(vir_cross)
    print('SVD', s)
    projmo = np.dot(mo[:, idx:], u)
    mf.mo_coeff[:, idx:] = projmo

    npair = np.sum(mf2.mo_occ == 0)
    print('npair', npair)
    idx2 = np.count_nonzero(mf.mo_occ)
    ncore = chemcore(mol)
    idx1 = min(idx2 - npair, ncore)
    idx3 = idx2 + npair
    print('MOs after projection')
    dump_mat.dump_mo(mf.mol, mf.mo_coeff[:, idx1:idx3], ncol=10)
    occ_idx = slice(idx1, idx2)
    vir_idx = slice(idx2, idx3)
    if localize:
        mf = loc(mf, occ_idx, vir_idx, localize)
    if pair:
        mo_dipole = dipole_integral(mol, mf.mo_coeff)
        #ncore = idx1
        nopen = np.sum(mf.mo_occ == 1)
        nalpha = idx2
        #nvir_lmo = npair
        alpha_coeff = pair_by_tdm(ncore, npair, nopen, nalpha, npair, nbf, nif,
                                  mf.mo_coeff, mo_dipole)
        mf.mo_coeff = alpha_coeff.copy()
        print('MOs after pairing')
        ncore = idx2 - npair
        dump_mat.dump_mo(mf.mol, mf.mo_coeff[:, idx1:idx3], ncol=10)
    return mf, mf.mo_coeff, npair, ncore