Ejemplo n.º 1
0
def get_mc_ref(mol, ri=False, sa2=False):
    mf = scf.RHF(mol)
    if ri: mf = mf.density_fit(auxbasis=df.aug_etb(mol))
    mc = mcpdft.CASSCF(mf.run(), 'tPBE', 6, 6, grids_level=6)
    if sa2:
        fcisolvers = [csf_solver(mol, smult=((2 * i) + 1)) for i in (0, 1)]
        if mol.symmetry:
            fcisolvers[0].wfnsym = 'A1'
            fcisolvers[1].wfnsym = 'A2'
        mc = mc.state_average_mix_(fcisolvers, [0.5, 0.5])
        ref = np.load('h2co_sa2_tpbe66_631g_grad_num.npy').reshape(2, 2, 4,
                                                                   3)[int(ri)]
    else:
        ref = np.load('h2co_tpbe66_631g_grad_num.npy')[int(ri)]
    return mc.run(), ref
Ejemplo n.º 2
0
O -0.676110  0.000000  0.000000
H  1.102430  0.000000  0.920125
H  1.102430  0.000000 -0.920125'''
mol = gto.M(atom=h2co_casscf66_631g_xyz,
            basis='6-31g',
            symmetry=False,
            verbose=lib.logger.INFO,
            output='h2co_sa2_casscf66_631g_grad.log')
mf_conv = scf.RHF(mol).run()
mc_conv = mcscf.CASSCF(mf_conv, 6, 6)
mc_conv.fcisolver = csf_solver(mol, smult=1)
mc_conv = mc_conv.state_average_([0.5, 0.5])
mc_conv.conv_tol = 1e-10
mc_conv.kernel()

mf = scf.RHF(mol).density_fit(auxbasis=df.aug_etb(mol)).run()
mc = mcscf.CASSCF(mf, 6, 6)
mc.fcisolver = csf_solver(mol, smult=1)
mc = mc.state_average_([0.5, 0.5])
mc.conv_tol = 1e-10
mc.kernel()

numgrad_conv = numeric_grad.Gradients(mc_conv).run()
print("First state")
de_conv = mc_conv.nuc_grad_method().kernel(state=0)
print("Conventional ERI analytic:\n", de_conv)
de_conv_num = numgrad_conv.de_states[0]
#de_conv_num = np.array ([[-6.29268207e-02,  1.76592986e-04, -7.39246008e-06],
# [ 6.86265793e-02, -1.74918975e-04, -1.91981128e-06],
# [-2.70814282e-03, -1.13363633e-05, -5.35862378e-04],
# [-2.70418672e-03, -5.80733661e-06,  5.42638644e-04]])
Ejemplo n.º 3
0
from pyscf import gto, scf, lib, df
from c2h4n4_struct import structure as struct
from mrh.my_pyscf.mcscf.lasscf_o0 import LASSCF

lib.logger.TIMER_LEVEL = lib.logger.INFO
mol = struct(3.0, 3.0, 'cc-pvtz', symmetry=False)
mol.verbose = lib.logger.INFO
mol.output = 'debug_tz_df_o0.log'
mol.build()
my_aux = df.aug_etb(mol)
mf = scf.RHF(mol).density_fit(auxbasis=my_aux).run()

# 1. Diamagnetic singlet
''' The constructor arguments are
    1) SCF object
    2) List or tuple of ncas for each fragment
    3) List or tuple of nelec for each fragment
    A list or tuple of total-spin multiplicity is supplied
    in "spin_sub".'''
las = LASSCF(mf, (4, 4), (4, 4), spin_sub=(1, 1))
''' The class doesn't know anything about "fragments" at all.
    The active space is only "localized" provided one offers an
    initial guess for the active orbitals that is localized.
    That is the purpose of the localize_init_guess function.
    It requires a sequence of sequence of atom numbers, and it
    projects the orbitals in the ncore:nocc columns into the
    space of those atoms' AOs. The orbitals in the range
    ncore:ncore+ncas_sub[0] are the first active subspace,
    those in the range ncore+ncas_sub[0]:ncore+sum(ncas_sub[:2])
    are the second active subspace, and so on.'''
frag_atom_list = (list(range(3)), list(range(7, 10)))
Ejemplo n.º 4
0
                                        confine_guess=(not active_first))

    # Calculation
    # --------------------------------------------------------------------------------------------------------------------
    e = c2h4n4_dmet.doselfconsistent()
    c2h4n4_dmet.lasci_log.close()
    return e


dr_nn = 3.0
mol = struct(dr_nn, dr_nn, '6-31g', symmetry='Cs')
mol.verbose = lib.logger.DEBUG
mol.output = '/dev/null'
mol.build()
mf = scf.RHF(mol).run()
mf_df = mf.density_fit(auxbasis=df.aug_etb(mol)).run()


def tearDownModule():
    global mol, mf, mf_df
    mol.stdout.close()
    del mol, mf, mf_df


class KnownValues(unittest.TestCase):
    def test_symm(self):
        self.assertAlmostEqual(run(mf, calcname='symm'), -295.44779578419946,
                               7)

    def test_symm_df(self):
        self.assertAlmostEqual(run(mf_df, calcname='symm_df'),
Ejemplo n.º 5
0
#
mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis='ccpvdz')
mf = scf.RHF(mol).density_fit(auxbasis='weigend')
mf.kernel()

#
# The DF basis can be assigned to with_df.auxbasis attribute.
# Like the AO basis input, DF basis can be specified separately for each element.
#
mf = scf.RHF(mol).density_fit()
mf.with_df.auxbasis = {'default': 'weigend', 'N2': 'ahlrichs'}
mf.kernel()

#
# Combined basis set is also supported in DF basis input.
#
mf = scf.RHF(mol).density_fit()
mf.with_df.auxbasis = ('weigend','sto3g')
mf.kernel()

#
# Even-tempered Gaussian DF basis can be generated based on the AO basis.
# In the following example, the exponents of auxbasis are
#    alpha = a * 1.7^i   i = 0..N
# where a and N are determined by the smallest and largest exponets of AO basis.
#
mf = scf.RHF(mol).density_fit()
mf.with_df.auxbasis = df.aug_etb(mol, beta=1.7)
mf.kernel()

Ejemplo n.º 6
0
# This auxbasis will be used for all elements in the system.
#
mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis='ccpvdz')
mf = scf.RHF(mol).density_fit(auxbasis='weigend')
mf.kernel()

#
# The DF basis can be assigned to with_df.auxbasis attribute.
# Like the AO basis input, DF basis can be specified separately for each element.
#
mf = scf.RHF(mol).density_fit()
mf.with_df.auxbasis = {'default': 'weigend', 'N2': 'ahlrichs'}
mf.kernel()

#
# Combined basis set is also supported in DF basis input.
#
mf = scf.RHF(mol).density_fit()
mf.with_df.auxbasis = ('weigend', 'sto3g')
mf.kernel()

#
# Even-tempered Gaussian DF basis can be generated based on the AO basis.
# In the following example, the exponents of auxbasis are
#    alpha = a * 1.7^i   i = 0..N
# where a and N are determined by the smallest and largest exponets of AO basis.
#
mf = scf.RHF(mol).density_fit()
mf.with_df.auxbasis = df.aug_etb(mol, beta=1.7)
mf.kernel()
Ejemplo n.º 7
0
mol = gto.Mole()
mol.basis = 'dzp-dk'
mol.atom = '''
At 0.0 0.0  0.000
At 0.0 0.0  3.100
'''
mol.charge = 0
mol.spin = 0
mol.symmetry = 0
mol.verbose = 4
mol.nucmod = 0
mol.build()

mf = x2c.RHF(mol).density_fit()
auxbasis = df.aug_etb(mol, beta=1.6)
mf.with_df.auxbais = auxbasis
mf.with_x2c.basis = 'unc-ano'
mf.chkfile = name + '.chk'
#mf.__dict__.update(scf.chkfile.load(name+'.chk', 'scf'))
#dm = mf.make_rdm1()
mf.kernel()

ncore = 100

pt = x2c.MP2(mf)
pt.frozen = ncore
pt.kernel()
rdm1 = pt.make_rdm1()
rdm2 = pt.make_rdm2()