Пример #1
0
    def test_DFCASCI_natorb(self):
        #
        mol = gto.M(atom="C 0 0 0; C 0 0 1;", basis="ccpvdz", spin=2, verbose=0)
        mf = scf.RHF(mol).density_fit().run()
        ncas, nelecas = (8, 12)
        mc = mcscf.CASCI(mf, ncas, nelecas).density_fit()
        mc.fcisolver = shci.SHCI(mf.mol)
        mc.natorb = True
        mc.kernel()

        mc.make_rdm1()
        no_coeff = mc.mo_coeff
        dm1_no = reduce(
            numpy.dot,
            (no_coeff.conj().T, mf.get_ovlp(), mc.make_rdm1(), mf.get_ovlp(), no_coeff),
        )
        numpy.testing.assert_allclose(
            dm1_no.diagonal(), mc.mo_occ, rtol=3e-4, atol=1e-5
        )
Пример #2
0
    def test_SHCI_CASCI(self):
        """
        Compare SHCI-CASCI calculation to CASCI calculation.
        """
        mf = make_o2()
        # Number of orbital and electrons
        ncas = 8
        nelecas = 12

        mc = mcscf.CASCI(mf, ncas, nelecas)
        e_casscf = mc.kernel()[0]
        mc = mcscf.CASCI(mf, ncas, nelecas)
        mc.fcisolver = shci.SHCI(mf.mol)
        mc.fcisolver.stochastic = True
        mc.fcisolver.nPTiter = 0  # Turn off perturbative calc.
        mc.fcisolver.sweep_iter = [0]
        mc.fcisolver.sweep_epsilon = [1e-12]
        e_shciscf = mc.kernel()[0]
        self.assertAlmostEqual(e_shciscf, e_casscf, places=6)
        mc.fcisolver.cleanup_dice_files()
Пример #3
0
import os
from pyscf import gto, scf, ao2mo, mcscf, tools, fci
from pyscf.shciscf import shci, settings

alpha = 0.007297351

mol = gto.M(atom='C 0 0 0; C 0 0 1.3119',
            basis='cc-pvqz',
            verbose=5,
            symmetry=1,
            spin=2)
myhf = scf.RHF(mol)
myhf.kernel()

##USE SHCISCF
solver1 = shci.SHCI(mol)
solver1.irrep_nelec = {
    'A1g': (2, 1),
    'A1u': (1, 1),
    'E1ux': (1, 1),
    'E1uy': (1, 0)
}
solver1.prefix = "solver1"
solver1.epsilon2 = 1.e-7
solver1.stochastic = False

solver2 = shci.SHCI(mol)
solver2.irrep_nelec = {
    'A1g': (2, 1),
    'A1u': (1, 1),
    'E1ux': (1, 0),
Пример #4
0
mf = scf.RHF(mol).run()
ncas, nelecas = (8, 10)

mc = mcscf.CASSCF(mf, ncas, nelecas)
mc.fcisolver.conv_tol = 1e-14
mc.kernel(mc.mo_coeff)
dm1, dm2, dm3 = fci.rdm.make_dm123("FCI3pdm_kern_sf", mc.ci, mc.ci, ncas,
                                   nelecas)
dm1, dm2, dm3 = fci.rdm.reorder_dm123(dm1, dm2, dm3)
np.save("pyscf_1RDM.npy", dm1)
np.save("pyscf_2RDM.npy", dm2)
np.save("pyscf_3RDM.npy", dm3)

#
# Use orbitals for an approx. CASCI and create RDMs
#
mc2 = mcscf.CASCI(mf, ncas, nelecas)
mc2.fcisolver = shci.SHCI(mol)
mc2.fcisolver.sweep_iter = [0]
mc2.fcisolver.sweep_epsilon = [1e-10]
mc2.fcisolver.scratchDirectory = "."
mc2.kernel(mc.mo_coeff)

#
# Helpful Outputs
#
print(mc.ci.shape)
print(dm2.shape)
print(np.einsum("ii", dm1))
print(np.einsum("ii", np.einsum("ikjj", dm2) / (nelecas - 1)))