# NOTE the DMRG-NEVPT2 is expensive, it requires about 8 GB memory per processor
#
#from pyscf.dmrgscf import settings
#settings.MPIPREFIX = 'srun'
#settings.BLOCKSCRATCHDIR = '/scratch'

from pyscf.dmrgscf import DMRGCI, DMRGSCF
from pyscf import mrpt

#
# Redirect output to another file
#
mol.build(verbose=7, output = 'hs_dmrg.out')

mf = scf.RHF(mol).x2c()
mc = DMRGSCF(mf, norb, [nalpha,nbeta])
mc.chkfile = 'hs_mc.chk'
mc.max_memory = 30000
mc.fcisolver.maxM = 1000
mc.fcisolver.tol = 1e-6
orbs = mc.sort_mo(caslst, coeff, base=0)
mc.mc1step(orbs)


#
# CASCI-NEVPT2
#
# If DMRG-CASSCF was finished without any problems (eg convergence, wall time
# limits on cluster etc),  one can simply continue with DMRG-NEVPT2
#       mrpt.NEVPT(mc).kernel()
#
Example #2
0
'''

b = 1.2
mol = gto.M(
    verbose=4,
    atom='N 0 0 %f; N 0 0 %f' % (-b * .5, b * .5),
    basis='cc-pvdz',
    symmetry=True,
)
m = scf.RHF(mol)
m.kernel()

#
# Simple state-average calculation
#
mc = DMRGSCF(m, 8, 8)
mc.state_average_([0.5, 0.5])
mc.kernel()
print(mc.e_tot)

#
# More general and/or complicated state-average calculations:
#
# Block code does not allow state average over different spin symmetry or
# spatial symmetry.  Mixing different spin or different irreducible
# representations requires multiple passes of DMRG calculations.
# See also pyscf/examples/mcscf/41-hack_state_average.py
#

#
# state-average over different spin states.
                           level_shift=0.5)
#
# Note: stream operations are used here.  This one line code is equivalent to
# the following serial statements.
#
#m = scf.sfx2c1e(scf.RHF(mol))
#m.conv_tol = 1e-9
#m.chkfile = 'hf_chk-%s'%b
#m.level_shift = 0.5
#m.kernel()

dm = m.make_rdm1()
m.level_shift = 0
m.scf(dm)

mc = DMRGSCF(m, 20, 28)  # 20o, 28e
mc.fcisolver.maxM = 1000
mc.fcisolver.tol = 1e-6

mc.chkfile = 'mc_chk_18o-%s' % b
cas_occ = {
    'A1g': 4,
    'A1u': 4,
    'E1ux': 2,
    'E1uy': 2,
    'E1gx': 2,
    'E1gy': 2,
    'E2ux': 1,
    'E2uy': 1,
    'E2gx': 1,
    'E2gy': 1
Example #4
0
# NOTE the DMRG-NEVPT2 is expensive, it requires about 8 GB memory per processor
#
#from pyscf.dmrgscf import settings
#settings.MPIPREFIX = 'srun'
#settings.BLOCKSCRATCHDIR = '/scratch'

from pyscf.dmrgscf import DMRGCI, DMRGSCF
from pyscf import mrpt

#
# Redirect output to another file
#
mol.build(verbose=7, output='hs_dmrg.out')

mf = scf.sfx2c1e(scf.RHF(mol))
mc = DMRGSCF(mf, norb, [nalpha, nbeta])
mc.chkfile = 'hs_mc.chk'
mc.max_memory = 30000
mc.fcisolver.maxM = 1000
mc.fcisolver.tol = 1e-6
orbs = mc.sort_mo(caslst, coeff, base=0)
mc.mc1step(orbs)

#
# CASCI-NEVPT2
#
# If DMRG-CASSCF was finished without any problems (eg convergence, wall time
# limits on cluster etc),  one can simply continue with DMRG-NEVPT2
#       mrpt.NEVPT(mc).kernel()
#
# But it's highly possible that one needs to restore the calculation from
m = scf.sfx2c1e(scf.RHF(mol)).run(conv_tol=1e-9, chkfile='hf_chk-%s'%b, level_shift=0.5)
#
# Note: stream operations are used here.  This one line code is equivalent to
# the following serial statements.
#
#m = scf.sfx2c1e(scf.RHF(mol))
#m.conv_tol = 1e-9
#m.chkfile = 'hf_chk-%s'%b
#m.level_shift = 0.5
#m.kernel()

dm = m.make_rdm1()
m.level_shift = 0
m.scf(dm)

mc = DMRGSCF(m, 20, 28)  # 20o, 28e
mc.fcisolver.maxM = 1000
mc.fcisolver.tol = 1e-6

mc.chkfile = 'mc_chk_18o-%s'%b
cas_occ = {'A1g':4, 'A1u':4,
           'E1ux':2, 'E1uy':2, 'E1gx':2, 'E1gy':2,
           'E2ux':1, 'E2uy':1, 'E2gx':1, 'E2gy':1}
mo = mc.sort_mo_by_irrep(cas_occ)
mc.kernel(mo)

#
# DMRG-NEVPT2
#
mrpt.NEVPT(mc).kernel()
Example #6
0
def run(b, dm_guess, mo_guess, ci=None):
    mol = gto.Mole()
    mol.verbose = 5
    mol.output = 'cr2-%3.2f.out' % b
    mol.atom = [
        ['Cr',(  0.,  0., -b/2)],
        ['Cr',(  0.,  0.,  b/2)],
    ]
    mol.basis = 'ccpvdzdk'
    mol.symmetry = True
    mol.build()

    mf = scf.RHF(mol).x2c()
    mf.max_cycle = 100
    mf.conv_tol = 1e-9
    mf.kernel(dm_guess)

#---------------------
# CAS(12,12)
#
# The active space of CAS(12,42) can be generated by function sort_mo_by_irrep,
# or AVAS, dmet_cas methods.  Here we first run a CAS(12,12) calculation and
# using the lowest CASSCF canonicalized orbitals in the CAS(12,42) calculation
# as the core and valence orbitals.
    mc = mcscf.CASSCF(mf, 12, 12)
    if mo_guess is None:
# the initial guess for first calculation
        ncas = {'A1g' : 2, 'E1gx' : 1, 'E1gy' : 1, 'E2gx' : 1, 'E2gy' : 1,
                'A1u' : 2, 'E1ux' : 1, 'E1uy' : 1, 'E2ux' : 1, 'E2uy' : 1}
        mo_guess = mc.sort_mo_by_irrep(ncas)
    else:
        mo_guess = mcscf.project_init_guess(mc, mo_guess)

# Projection may destroy the spatial symmetry of the MCSCF orbitals.
        try:
            print('Irreps of the projected CAS(12,12) orbitals',
                  symm.label_orb_symm(mol, mol.irrep_id, mol.symm_orb, mo_guess))
        except:
            print('Projected CAS(12,12) orbitals does not have right symmetry')

# FCI solver with multi-threads is not stable enough for this sytem
    mc.fcisolver.threads = 1
# To avoid spin contamination
    mc.fix_spin_()
# By default, canonicalization as well as the CASSCF optimization do not
# change the orbital symmetry labels. "Orbital energy" mc.mo_energy, the
# diagonal elements of the general fock matrix, may have wrong ordering.
# To use the lowest CASSCF orbitals as the core + active orbitals in the next
# step, we have to sort the orbitals based on the "orbital energy". This
# operation will change the orbital symmetry labels.
    mc.sorting_mo_energy = True
# "mc.natorb = True" will transform the active space, to its natural orbital
# representation.  By default, the active space orbitals are NOT reordered
# even the option sorting_mo_energy is enabled.  Transforming the active space
# orbitals is a dangerous operation because it needs also to update the CI
# wavefunction. For DMRG solver (or other approximate FCI solver), the CI
# wavefunction may not be able to consistently converged and it leads to
# inconsistency between the orbital space and the CI wavefunction
# representations.  Unless required by the following CAS calculation, setting
# mc.natorb=True should be avoided
#    mc.natorb = True

    mc.kernel(mo_guess, ci)
    mc.analyze()

#---------------------
# CAS(12,42)
#
# Using the lowest CASSCF canonicalized orbitals in the CAS(12,42) DMRG-CASSCF
# calculation.
    norb = 42
    nelec = 12
    mc1 = DMRGSCF(mf, norb, nelec)
    mc1.fcisolver.maxM = 4000

# Enable internal rotation since the bond dimension of DMRG calculation is
# small, the active space energy can be optimized wrt to the orbital rotation
# within the active space.
    mc1.internal_rotation = True
# Sorting the orbital energy is not a step of must here.
#    mc1.sorting_mo_energy = True
#    mc1.natorb = True

    mc1.kernel(mc.mo_coeff)

# Passing the results as an initial guess to the next point.
    return mf.make_rdm1(), mc.mo_coeff, mc.ci
Example #7
0
'''

b = 1.2
mol = gto.M(
    verbose = 4,
    atom = 'N 0 0 %f; N 0 0 %f'%(-b*.5,b*.5),
    basis = 'cc-pvdz',
    symmetry = True,
)
m = scf.RHF(mol)
m.kernel()

#
# Simple state-average calculation
#
mc = DMRGSCF(m, 8, 8)
mc.state_average_([0.5, 0.5])
mc.kernel()
print(mc.e_tot)


#
# More general and/or complicated state-average calculations:
#
# Block code does not allow state average over different spin symmetry or
# spatial symmetry.  Mixing different spin or different irreducible
# representations requires multiple passes of DMRG calculations.
# See also pyscf/examples/mcscf/41-hack_state_average.py
#

#
'''

b = 1.2
mol = gto.M(
    verbose=4,
    atom='N 0 0 %f; N 0 0 %f' % (-b * .5, b * .5),
    basis='cc-pvdz',
    symmetry=True,
)
m = scf.RHF(mol)
m.kernel()

#
# Simple state-average calculation
#
mc = DMRGSCF(m, 8, 8)
mc.state_average_([0.5, 0.5])
mc.kernel()
print(mc.e_tot)

#
# More general and/or complicated state-average calculations:
#
# Block code does not allow state average over different spin symmetry or
# spatial symmetry.  Mixing different spin or different irreducible
# representations requires multiple passes of DMRG calculations.
# See also pyscf/examples/mcscf/41-hack_state_average.py
#

#
# state-average over different spin states.
Example #9
0
'''

b = 1.2
mol = gto.M(
    verbose = 4,
    atom = 'N 0 0 %f; N 0 0 %f'%(-b*.5,b*.5),
    basis = 'cc-pvdz',
    symmetry = True,
)
m = scf.RHF(mol)
m.kernel()

#
# Simple state-average calculation
#
mc = DMRGSCF(m, 8, 8)
mc.state_average_([0.5, 0.5])
mc.kernel()
print(mc.e_tot)


#
# More general and/or complicated state-average calculations:
#
# Block code does not allow state average over different spin symmetry or
# spatial symmetry.  Mixing different spin or different irreducible
# representations requires multiple passes of DMRG calculations.
# See also pyscf/examples/mcscf/41-hack_state_average.py
#

#