Example #1
0
def run(b, dm, mo):
    mol = gto.Mole()
    mol.verbose = 5
    mol.output = 'out_hf-%2.1f' % b
    mol.atom = [
        ["F", (0., 0., 0.)],
        ["H", (0., 0., b)],
    ]

    mol.basis = {
        'F': 'cc-pvdz',
        'H': 'cc-pvdz',
    }
    mol.build()
    mf = scf.RHF(mol)
    ehf.append(mf.scf(dm))

    mc = mcscf.CASSCF(mf, 6, 6)
    if mo is None:
        # initial guess for b = 0.7
        mo = mcscf.sort_mo(mc, mf.mo_coeff, [3, 4, 5, 6, 8, 9])
    else:
        mo = mcscf.project_init_guess(mc, mo)
    e1 = mc.mc1step(mo)[0]
    emc.append(e1)
    return mf.make_rdm1(), mc.mo_coeff
Example #2
0
def run(b, mo0=None, dm0=None):
    mol = gto.Mole()
    mol.build(
        verbose = 5,
        output = 'o2rhf-%3.2f.out' % b,
        atom = [
            ['O', (0, 0,  b/2)],
            ['O', (0, 0, -b/2)],],
        basis = 'cc-pvdz',
        spin = 2,
        symmetry = 1,
    )

    mf = scf.RHF(mol)
    mf.scf(dm0)

    mc = mcscf.CASSCF(mf, 12, 8)
    if mo0 is not None:
        mo0 = lo.orth.vec_lowdin(mo0, mf.get_ovlp())
    else:
        mo0 = mcscf.sort_mo(mc, mf.mo_coeff, [5,6,7,8,9,11,12,13,14,15,16,17])
        mc.max_orb_stepsize = .02
    mc.kernel(mo0)
    mc.analyze()
    return mf, mc
Example #3
0
def run(b, mo0=None, dm0=None):
    mol = gto.Mole()
    mol.build(
        verbose = 5,
        output = 'o2rhf-%3.2f.out' % b,
        atom = [
            ['O', (0, 0,  b/2)],
            ['O', (0, 0, -b/2)],],
        basis = 'cc-pvdz',
        spin = 2,
        symmetry = 1,
    )

    mf = scf.RHF(mol)
    mf.scf(dm0)

    mc = mcscf.CASSCF(mf, 12, 8)
    if mo0 is not None:
        #from pyscf import lo
        #mo0 = lo.orth.vec_lowdin(mo0, mf.get_ovlp())
        mo0 = mcscf.project_init_guess(mc, mo0)
    else:
        mo0 = mcscf.sort_mo(mc, mf.mo_coeff, [5,6,7,8,9,11,12,13,14,15,16,17])
        mc.max_orb_stepsize = .02
    mc.kernel(mo0)
    mc.analyze()
    return mf, mc
Example #4
0
def run(b, dm, mo):
    mol = gto.Mole()
    mol.verbose = 5
    mol.output = 'out_hf-%2.1f' % b
    mol.atom = [
        ["F", (0., 0., 0.)],
        ["H", (0., 0., b)],]
    mol.spin = 2
    mol.basis = {'F': 'cc-pvdz',
                 'H': 'cc-pvdz',}
    mol.build()
    m = scf.RHF(mol)
    ehf.append(m.scf(dm))

    mc = mcscf.CASSCF(m, 6, 6)
    if mo is None:
        mo = mcscf.sort_mo(mc, m.mo_coeff, [3,4,5,6,8,9])
    else:
        mo = mcscf.project_init_guess(mc, mo)
    e1 = mc.mc1step(mo)[0]
    emc.append(e1)
    return m.make_rdm1(), mc.mo_coeff
Example #5
0
#
# Load MF orbitals
#
chkname = "_chk/pp_dianion_dz_b3lyp.chk"
mol = chkfile.load_mol(chkname)
mol.verbose = 5
mf = dft.RKS(mol)
mf.__dict__.update(chkfile.load(chkname, "scf"))

#
# SA-MCSCF
#
nelecas, ncas = (4, 4)
n_states = 3
weights = np.ones(n_states) / n_states

mc = mcscf.CASSCF(mf, ncas, nelecas).state_average_(weights)
mc.fix_spin(ss=0)
mc.natorb = True
mc.chkfile = "_chk/pp_dianion_dz_cas_4e_4o.chk"
cas_list = [142, 143, 150, 151]
mo = mcscf.sort_mo(mc, mf.mo_coeff, cas_list)
mc.mc1step(mo)

#
# Analysis and processing
#
mc.analyze()
molden.from_mcscf(mc, "_molden/pp_dianion_dz_cas_4e_4o.molden")
molden.from_mo(mol, "_molden/pp_dianion_dz_cas_4e_4o_alt.molden", mc.mo_coeff)
cect = numpy.dot(HF_MOcoeff, numpy.dot(e_d, HF_MOcoeff.T))
f = numpy.dot(ova, numpy.dot(cect, ova))
en = numpy.diag(numpy.dot(coeff.T, numpy.dot(f, coeff)))
fname = 'generated_AS_beforeCAS'
from pyscf.tools import molden
with open(fname + '.molden', 'w') as thefile:
    molden.header(mol, thefile)
    molden.orbital_coeff(mol, thefile, coeff, ene=en, occ=mf.mo_occ)
#==========================================================

mycas = mcscf.CASSCF(mf, norb, [nalpha, nbeta])
AS = range(N_Core, N_Core + N_Act)
mycas.chkfile = 'cas_FeCp2.chk'  # it is useful to keep the chk file for CASSCF in case you want to run some subsequent CASCI and NEVPT2 calculations
mycas.fcisolver.nroots = 1
mycas.fix_spin_(
    ss=0
)  # in newer PYSCF it is better to specify ss which is usually your mol.spin
activeMO = mcscf.sort_mo(mycas, coeff, AS, base=0)
mycas.verbose = 5
mycas.max_cycle_macro = 150
mycas.kernel(activeMO)

mc = mcscf.CASCI(mf, norb, [nalpha, nbeta])
mc.__dict__.update(scf.chkfile.load('cas_FeCp2.chk', 'mcscf'))
mc.fcisolver.nroots = 1
mc.fix_spin_(ss=0)
mc.verbose = 6
mc.kernel()

ci_nevpt_e1 = mrpt.NEVPT(mc, root=0).kernel()
Example #7
0
# Checkpoint File Name
chkName = '5cene_HF.chk'

mol = lib.chkfile.load_mol(chkName)
mol.max_memory = 40000
mf = scf.RHF(mol)
mf.__dict__.update(lib.chkfile.load(chkName, 'scf'))

# Molecule CASSCF Settings
norb = 22
nelec = 22

# Building SHCISCF Object
mch = shci.SHCISCF(mf, norb, nelec)
mo = mcscf.sort_mo(mch, mf.mo_coeff, [
    57, 59, 62, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 83, 92,
    96, 98, 100
])

mch.chkfile = 'singlet_1Ag_shciscf.chk'
#mo = lib.chkfile.load( mch.chkfile , 'mcscf/mo_coeff')

mch.fcisolver.nPTiter = 0  # No perturbative.
mch.fcisolver.sweep_iter = [0, 3, 6, 9]
mch.fcisolver.sweep_epsilon = [1e-3, 5e-4, 1e-4, 8.5e-5]
mch.fcisolver.stochastic = True
mch.fcisolver.mpiprefix = 'mpirun -np 28'
mch.fcisolver.prefix = "/rc_scratch/jasm3285"

# Run SHCISCF
emc = mch.mc2step(mo)[0]
os.system("rm *.bkp")
Example #8
0
solver3.spin = 3
solver3.wfnsym = 'B3'
solver3.nroots = 1
solver4 = fci.direct_spin1.FCI(mol)
solver4 = fci.addons.fix_spin(solver2, ss=3 / 2 * (3 / 2 + 1))
solver4.spin = 3
solver4.wfnsym = 'B4'
solver4.nroots = 1
solver5 = fci.direct_spin1.FCI(mol)
solver5 = fci.addons.fix_spin(solver2, ss=5 / 2 * (5 / 2 + 1))
solver5.spin = 3
solver5.wfnsym = 'A'
solver5.nroots = 1

# We use the MP2 nat orbs as the entanglement is calculated for them.

mc = mcscf.CASSCF(mf, len(act_mos), act_ele)
mo = mcscf.sort_mo(mc, no, np.array(act_mos) + 1)
mcscf.state_average_mix_(mc, [solver1, solver2, solver3, solver4, solver5],
                         weights)
ener = mc.kernel(mo)

print('Excitation from A to B2: ', (solver1.e_tot - solver2.e_tot) * 27.2114,
      'eV')
print('Excitation from A to B3: ', (solver1.e_tot - solver3.e_tot) * 27.2114,
      'eV')
print('Excitation from A to B4: ', (solver1.e_tot - solver4.e_tot) * 27.2114,
      'eV')
print('Excitation from spin 3 to 5: ',
      (solver1.e_tot - solver5.e_tot) * 27.2114, 'eV')
Example #9
0
          len(mos[i]), ": ", mos[i], color.END)
print("")

# If state average calculations are done Check the active spaces
mos = ASF.select_mroot_AS(mos)
ele = asf.orbs_el_n(mf.mo_occ, mos)

print(color.BOLD + 'Selected active space' + color.END, color.RED, ele,
      color.END, color.BOLD + 'electrons in these MOs:' + color.END, color.RED,
      len(mos), ": ", mos, color.END)
print("")

# CASSCF on DMRG nat orbs
print(color.BOLD + "State average CASSCF calculations" + color.END)
mc = mcscf.CASSCF(mf, len(mos), ele)
mo = mcscf.sort_mo(mc, ASF.init_nat, np.array(mos) + 1)

mc = mc.state_average([0.5, 0.5])
mc.fcisolver.spin = final_spin
mc.fix_spin(ss=final_spin)
mc.kernel(mo)

# Save info
cas_orbs = mc.mo_coeff

mc = mcscf.CASCI(mf, len(mos), ele)
mc.fcisolver.nroots = 2
mc.fix_spin(ss=final_spin)

ener = mc.kernel(cas_orbs)
print(color.BOLD + 'Root [0]:' + color.END, color.RED, ener[0][0], color.END,
Example #10
0
symmetry = True,
)
mf = scf.RHF(mol)
mf.kernel()
#mf.analyze()

#
# 1. State-average CASSCF to get optimal orbitals
#
mc = mcscf.CASSCF(mf, 6, 6)
solver_ag = fci.direct_spin0_symm.FCI(mol)
solver_b2u = fci.direct_spin0_symm.FCI(mol)
solver_b2u.wfnsym = 'B2u'
mc.fcisolver = mcscf.state_average_mix(mc, [solver_ag,solver_b2u], [.5,.5])
cas_list = [17,20,21,22,23,30]  # 2pz orbitals
mo = mcscf.sort_mo(mc, mf.mo_coeff, cas_list)
mc.kernel(mo)
#mc.analyze()
mc_mo = mc.mo_coeff

#
# 2. Ground state wavefunction.  This step can be passed you approximate it
# with the state-averaged CASSCF wavefunction
#
mc = mcscf.CASCI(mf, 6, 6)
mc.fcisolver.wfnsym = 'Ag'
mc.kernel(mc_mo)
ground_state = mc.ci

#
# 3. Exited states.  In this example, B2u are bright states.