示例#1
0
    def test_SHCISCF_CASSCF(self):
        """
        Compare SHCI-CASSCF calculation to CASSCF calculation.
        """
        mf = make_o2()
        # Number of orbital and electrons
        ncas = 8
        nelecas = 12

        mc = mcscf.CASSCF(mf, ncas, nelecas)
        e_casscf = mc.kernel()[0]

        mc = shci.SHCISCF(mf, ncas, nelecas)
        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()
示例#2
0
    def test_spin_1RDM(self):
        mol = gto.M(
            atom="""
            C   0.0000     0.0000    0.0000  
            H   -0.9869    0.3895    0.2153  
            H   0.8191     0.6798   -0.1969  
            H   0.1676    -1.0693   -0.0190  
        """,
            spin=1,
        )
        ncas, nelecas = (7, 7)
        mf = scf.ROHF(mol).run()
        mc = shci.SHCISCF(mf, ncas, nelecas)
        mc.davidsonTol = 1e-8
        mc.dE = 1e-12
        mc.kernel()

        #
        # Get our spin 1-RDMs
        #
        dm1 = mc.fcisolver.make_rdm1(0, ncas, nelecas)
        dm_ab = mc.fcisolver.make_rdm1s()  # in MOs
        dm1_check = numpy.linalg.norm(dm1 - numpy.sum(dm_ab, axis=0))
        self.assertLess(dm1_check, 1e-5)
示例#3
0
for el in [element, 'O']:
    mol.ecp[el] = gto.basis.parse_ecp(df[el]['ecp'])
    mol.basis[el] = gto.basis.parse(df[el][basis])
mol.charge = 0
mol.spin = spins[element + 'O']
mol.build(atom="%s 0. 0. 0.; O 0. 0. %g" % (element, re[element + 'O']),
          verbose=4)

m = ROHF(mol)
m.level_shift = 1000.0
dm = m.from_chk("../../../../HF/monoxides/" + element + basis + "0.chk")
hf = m.kernel(dm)
m.analyze()

from pyscf.shciscf import shci
mc = shci.SHCISCF(m, 9, 4 + cas[element])
#mc.fcisolver.conv_tol = 1e-14
mc.fcisolver.mpiprefix = "mpirun -np 28"
mc.fcisolver.num_thrds = 12
mc.verbose = 4
cas = mc.kernel()[0]

from pyscf.icmpspt import icmpspt
pt=icmpspt.icmpspt(mc,rdmM=500, PTM=1000,\
                          pttype="MRLCC",\
                          third_order=True,\
                          fully_ic=True,\
                          do_dm4=True)

datacsv['basis'].append(basis)
datacsv['charge'].append(0)
示例#4
0
mol.basis[el] = gto.basis.parse(df[el][basis])
mol.charge = charge
if el == 'Cr' or el == 'Cu':
    mol.spin = spins[el] - charge
else:
    mol.spin = spins[el] + charge
mol.build(atom="%s 0. 0. 0." % el, verbose=4)

m = ROHF(mol)
m.level_shift = 1000.0
dm = m.from_chk("../../../../HF/atoms/" + el + basis + str(charge) + ".chk")
hf = m.kernel(dm)
m.analyze()

from pyscf.shciscf import shci
mc = shci.SHCISCF(m, 6, cas[el] - charge)
#mc.fcisolver.conv_tol = 1e-14
mc.fcisolver.mpiprefix = "mpirun -np 28"
mc.fcisolver.num_thrds = 12
mc.verbose = 4
cas = mc.kernel()[0]

from pyscf.icmpspt import icmpspt
pt=icmpspt.icmpspt(mc,rdmM=500, PTM=1000,\
                          pttype="MRLCC",\
                          third_order=True,\
                          fully_ic=True,\
                          do_dm4=True)

datacsv['atom'].append(el)
datacsv['charge'].append(charge)
示例#5
0
    "Ag": (25, 24),
    "B3u": (19, 19),
    "B2u": (19, 19),
    "B1g": (15, 14),
    "B1u": (7, 7),
    "B2g": (4, 4),
    "B3g": (3, 3),
    "Au": (2, 2),
}

# Molecule CASSCF Settings
norb = 29
nelec = 32

# Building SHCISCF Object
mch = shci.SHCISCF(mf, norb, nelec)
mch.chkfile = "fe_tz_3B1g_SHCISCF.chk"

mch.fcisolver.sweep_iter = [0, 3, 6]
mch.fcisolver.sweep_epsilon = [1e-3, 5e-4, 1e-4]
mch.fcisolver.stochastic = True
mch.fcisolver.nPTiter = 0  # Turns of PT calculation, i.e. no PTRDM.
mch.fcisolver.mpiprefix = "mpirun -np 28"
mch.fcisolver.prefix = "/rc_scratch/jasm3285/fep/ccpvdz/smallcas/3B1g"
mch.fcisolver.irrep_nelec = {
    "Ag": (2, 1),
    "B3u": (0, 0),
    "B2u": (0, 0),
    "B1g": (1, 0),
    "B1u": (5, 5),
    "B2g": (4, 4),
示例#6
0
mol.ecp = {}
mol.basis = {}
mol.ecp[el] = gto.basis.parse_ecp(df[el]['ecp'])
mol.basis[el] = gto.basis.parse(df[el][basis])
mol.charge = charge
mol.spin = 1
mol.build(atom="%s 0. 0. 0." % el, verbose=4)

m = ROHF(mol)
m.level_shift = 1000.0
#dm=m.from_chk("../../../../HF/atoms/"+el+basis+str(charge)+".chk")
hf = m.kernel()  #dm)
m.analyze()

from pyscf.shciscf import shci
mc = shci.SHCISCF(m, 3, 3)
#mc.fcisolver.conv_tol = 1e-14
mc.fcisolver.mpiprefix = "mpirun -np 28"
mc.fcisolver.num_thrds = 12
mc.verbose = 4
cas = mc.kernel()[0]

from pyscf.icmpspt import icmpspt
pt=icmpspt.icmpspt(mc,rdmM=500, PTM=1000,\
                          pttype="MRLCC",\
                          third_order=True,\
                          fully_ic=True,\
                          do_dm4=True)

datacsv['atom'].append(el)
datacsv['charge'].append(charge)
示例#7
0
    '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),
    'E1uy': (1, 1)
}
solver2.prefix = "solver2"
solver2.epsilon2 = 1.e-7
solver2.stochastic = False

mycas = shci.SHCISCF(myhf, 8, 8)
mcscf.state_average_mix_(mycas, [solver1, solver2], numpy.ones(2) / 2)
mycas.kernel()

print "Total Time:    ", time.time() - t0

# File cleanup
os.system("rm *.bkp")
os.system("rm *.txt")
os.system("rm shci.e")
os.system("rm *.dat")
os.system("rm FCIDUMP")
示例#8
0
              [dimer_atom, (0.000000, 0.000000, -b / 2)],
              [dimer_atom, (0.000000, 0.000000, b / 2)],
          ],
          basis={
              dimer_atom: 'ccpvdz',
          },
          symmetry=1)

# Create HF molecule
mf = scf.RHF(mol)
mf.conv_tol = 1e-9
mf.scf()

# Calculate energy of the molecules with frozen core.
# Active spaces chosen to reflect valence active space.
#mch = shci.SHCISCF( mf, norb, nelec ).state_average_([0.333333, 0.33333, 0.33333])
mch = shci.SHCISCF(mf, norb, nelec).state_average_([0.5, 0.5])
mch.fcisolver.sweep_iter = [0, 3]
mch.fcisolver.sweep_epsilon = [1.e-3, 1.e-4]
mch.kernel()

print "Total Time:    ", time.time() - t0

# File cleanup
os.system("rm *.bkp")
os.system("rm *.txt")
os.system("rm shci.e")
os.system("rm *.dat")
os.system("rm FCIDUMP")
os.system("rm tmp*")
示例#9
0
#
mol = gto.M(verbose=4, atom="O 0 0 0; O 0 0 1.208", basis="ccpvdz")
mf = scf.RHF(mol).run()

#
# Multireference WF
#
ncas = 8
nelecas = 12

mc = mcscf.CASSCF(mf, ncas, nelecas)
e_CASSCF = mc.mc1step()[0]

# Create SHCI molecule for just variational opt.
# Active spaces chosen to reflect valence active space.
mc = shci.SHCISCF(mf, ncas, nelecas)
mc.fcisolver.mpiprefix = "mpirun -np 2"
mc.fcisolver.stochastic = True
mc.fcisolver.nPTiter = 0  # Turn off perturbative calc.
mc.fcisolver.sweep_iter = [0]
# Setting large epsilon1 thresholds highlights improvement from perturbation.
mc.fcisolver.sweep_epsilon = [5e-3]
e_noPT = mc.mc1step()[0]

# Run a single SHCI iteration with perturbative correction.
mc.fcisolver.stochastic = False  # Turns on deterministic PT calc.
mc.fcisolver.epsilon2 = 1e-8
shci.writeSHCIConfFile(mc.fcisolver, [nelecas / 2, nelecas / 2], False)
shci.executeSHCI(mc.fcisolver)
e_PT = shci.readEnergy(mc.fcisolver)
示例#10
0
文件: n2.py 项目: sanshar/VMC
r = 2.0
atomstring = f"N 0 0 {-r/2}; N 0 0 {r/2}"
mol = gto.M(atom=atomstring, basis='6-31g', unit='bohr', symmetry=1)
mf = scf.RHF(mol)
mf.kernel()

# casscf
mc0 = mcscf.CASSCF(mf, 8, 10)
mc0.mc1step()

# dice

# writing input and integrals
print("\nPreparing Dice calculation")
# dummy shciscf object for specifying options
mc = shci.SHCISCF(mf, 8, 10)
mc.mo_coeff = mc0.mo_coeff
mc.fcisolver.sweep_iter = [0]
mc.fcisolver.sweep_epsilon = [1e-5]
mc.fcisolver.davidsonTol = 5.e-5
mc.fcisolver.dE = 1.e-6
mc.fcisolver.maxiter = 6
mc.fcisolver.nPTiter = 0
mc.fcisolver.DoRDM = False
shci.dryrun(mc, mc.mo_coeff)
command = "mv input.dat dice.dat"
os.system(command)
with open("dice.dat", "a") as fh:
    fh.write("writebestdeterminants 1000")

# run dice calculation
示例#11
0
mc0 = mcscf.CASSCF(mf, 8, 4)
mo = mc0.sort_mo_by_irrep({
    'A1g': 2,
    'A1u': 2,
    'E1ux': 2,
    'E1uy': 2
}, {'A1g': 1})
mc0.frozen = 1
mc0.mc1step(mo)

# dice

# writing input and integrals
print("\nPreparing Dice calculation")
# dummy shciscf object for specifying options
mc = shci.SHCISCF(mf, 8, 4)
mc.mo_coeff = mc0.mo_coeff
mc.fcisolver.sweep_iter = [0]
mc.fcisolver.sweep_epsilon = [1e-5]
mc.fcisolver.davidsonTol = 5.e-5
mc.fcisolver.dE = 1.e-6
mc.fcisolver.maxiter = 6
mc.fcisolver.nPTiter = 0
mc.fcisolver.DoRDM = False
shci.dryrun(mc, mc.mo_coeff)
command = "mv input.dat dice.dat"
os.system(command)
with open("dice.dat", "a") as fh:
    fh.write("writebestdeterminants 10000")

# run dice calculation
示例#12
0
from pyscf.shciscf import shci

t0 = time.time()

#
# Mean Field
#
mol = gto.M(verbose=4, atom="C 0 0 0; C 0 0 1.3119", basis="ccpvdz")
mf = scf.RHF(mol).run()

# Create HF molecule
mf = scf.RHF(mol)
mf.conv_tol = 1e-9
mf.scf()

# Calculate energy of the molecules with frozen core.
# Active spaces chosen to reflect valence active space.
# mc = shci.SHCISCF( mf, norb, nelec ).state_average_([0.333333, 0.33333, 0.33333])
ncas = 8
nelecas = 8
mc = shci.SHCISCF(mf, ncas, nelecas).state_average_([0.5, 0.5])
mc.frozen = mc.ncore
mc.fcisolver.sweep_iter = [0, 3]
mc.fcisolver.sweep_epsilon = [1.0e-3, 1.0e-4]
mc.kernel()

print("Total Time:    ", time.time() - t0)

# File cleanup
mc.fcisolver.cleanup_dice_files()
示例#13
0
文件: f2.py 项目: pedersor/pyscf
mol.spin = 0
mol.build()

from pyscf import scf
m = scf.RHF(mol)
m.verbose = 4
ehf = m.scf()
print("EHF", ehf)

from pyscf import cc
mcc = cc.CCSD(m, frozen=0)
mcc.kernel()
etriple = mcc.ccsd_t()
print("ECCSD", ehf + mcc.e_corr)
print("ECCSDT", ehf + mcc.e_corr + etriple)

from pyscf.shciscf import shci
mc = shci.SHCISCF(m, 8, 14, frozen=2)
mc.fcisolver.mpiprefix = "mpirun -np 28"
mc.fcisolver.num_thrds = 12
#mc.fcisolver.sweep_iter    = [   5]
#mc.fcisolver.sweep_epsilon = [1e-5]
#mc.max_cycle_macro=0
mc.verbose = 4
ci_e = mc.kernel()[0]
print("ECAS", ci_e)

from pyscf.icmpspt import icmpspt
energy = icmpspt.mrlcc(mc, nfro=0)
print("ETOT", energy)
示例#14
0
文件: hChain.py 项目: sanshar/VMC
# ccsd
mycc = cc.CCSD(mf)
mycc.frozen = 0
mycc.verbose = 5
mycc.kernel()

et = mycc.ccsd_t()
print('CCSD(T) energy', mycc.e_tot + et)

# dice

# writing input and integrals
print("\nPreparing Dice calculation")
# dummy shciscf object for specifying options
mc = shci.SHCISCF(mf, mol.nao, mol.nelectron)
mc.mo_coeff = mf.mo_coeff
mc.fcisolver.sweep_iter = [ 0 ]
mc.fcisolver.sweep_epsilon = [ 1e-5 ]
mc.fcisolver.davidsonTol = 5.e-5
mc.fcisolver.dE = 1.e-6
mc.fcisolver.maxiter = 6
mc.fcisolver.nPTiter = 0
mc.fcisolver.DoRDM = False
shci.dryrun(mc, mc.mo_coeff)
command = "mv input.dat dice.dat"
os.system(command)
with open("dice.dat", "a") as fh:
  fh.write("writebestdeterminants 10000")

# run dice calculation