Exemplo n.º 1
0
def setUpModule():
    global mol, mf, myadc
    r = 1.098
    mol = gto.Mole()
    mol.atom = [
        ['N', ( 0., 0.    , -r/2   )],
        ['N', ( 0., 0.    ,  r/2)],]
    mol.basis = {'N':'cc-pvdz'}
    mol.verbose = 0
    mol.build()
    mf = scf.RHF(mol).density_fit(auxbasis='cc-pvdz-jkfit')
    mf.kernel()
    myadc = adc.ADC(mf)
    myadc = adc.ADC(mf).density_fit(auxbasis='cc-pvdz-ri')
Exemplo n.º 2
0
    def test_hf_dfgs(self):

        mf = scf.UHF(mol).run()
        myadc = adc.ADC(mf)
        myadc.with_df = df.DF(mol, auxbasis='cc-pvdz-ri')
        e, t_amp1, t_amp2 = myadc.kernel_gs()
        self.assertAlmostEqual(e, -0.150979874, 6)
Exemplo n.º 3
0
def setUpModule():
    global mol, mf, myadc
    r = 1.098
    mol = gto.Mole()
    mol.atom = [
        ['N', ( 0., 0.    , -r/2   )],
        ['N', ( 0., 0.    ,  r/2)],]
    mol.basis = {'N':'aug-cc-pvdz'}
    mol.verbose = 0
    mol.build()
    mf = scf.UHF(mol)
    mf.conv_tol = 1e-12
    mf.kernel()
    myadc = adc.ADC(mf)
Exemplo n.º 4
0
def setUpModule():
    global mol, mf, myadc
    mol = gto.Mole()
    mol.atom = [
        ['P', ( 0., 0.    , 0.)],]
    mol.basis = {'P':'aug-cc-pvqz'}
    mol.verbose = 0
    mol.spin = 3
    mol.build()

    mf = scf.UHF(mol)
    mf.conv_tol = 1e-12
    mf.irrep_nelec = {'A1g':(3,3),'E1ux':(2,1),'E1uy':(2,1),'A1u':(2,1)}
    mf.kernel()
    myadc = adc.ADC(mf)
Exemplo n.º 5
0
def setUpModule():
    global mol, mf, myadc
    r = 0.969286393
    mol = gto.Mole()
    mol.atom = [
        ['O', (0., 0., -r / 2)],
        ['H', (0., 0., r / 2)],
    ]
    mol.basis = {'O': 'aug-cc-pvdz', 'H': 'aug-cc-pvdz'}
    mol.verbose = 0
    mol.symmetry = False
    mol.spin = 1
    mol.build()
    mf = scf.UHF(mol)
    mf.conv_tol = 1e-12
    mf.kernel()
    myadc = adc.ADC(mf)
Exemplo n.º 6
0
    def test_hf_dfadc3_ip(self):

        mf = scf.UHF(mol).run()
        myadc = adc.ADC(mf)
        myadc.with_df = df.DF(mol, auxbasis='aug-cc-pvdz-ri')
        myadc.method = "adc(3)"

        e, v, p = myadc.kernel(nroots=3)
        e_corr = myadc.e_corr

        self.assertAlmostEqual(e_corr, -0.1633223874, 6)

        self.assertAlmostEqual(e[0], 0.45707376, 6)
        self.assertAlmostEqual(e[1], 0.46818480, 6)
        self.assertAlmostEqual(e[2], 0.55652975, 6)

        self.assertAlmostEqual(p[0], 0.93868596, 6)
        self.assertAlmostEqual(p[1], 0.58692425, 6)
        self.assertAlmostEqual(p[2], 0.35110754, 6)
Exemplo n.º 7
0
    def test_dfhf_dfadc2_ea(self):

        mf = scf.RHF(mol).density_fit(auxbasis='cc-pvdz-jkfit').run()
        myadc = adc.ADC(mf).density_fit(auxbasis='cc-pvdz-ri')
        myadc.max_memory = 20
        myadc.method = "adc(2)"
        myadc.method_type = "ea"

        e, v, p = myadc.kernel(nroots=4)

        self.assertAlmostEqual(e[0], 0.14260766, 6)
        self.assertAlmostEqual(e[1], 0.14260766, 6)
        self.assertAlmostEqual(e[2], 0.55083845, 6)
        self.assertAlmostEqual(e[3], 0.76736577, 6)

        self.assertAlmostEqual(p[0], 1.86603796, 6)
        self.assertAlmostEqual(p[1], 1.86603796, 6)
        self.assertAlmostEqual(p[2], 1.92699634, 6)
        self.assertAlmostEqual(p[3], 1.88366005, 6)
Exemplo n.º 8
0
def setUpModule():
    global mol, mf, myadc
    mol = gto.Mole()
    r = 0.957492
    x = r * math.sin(104.468205 * math.pi/(2 * 180.0))
    y = r * math.cos(104.468205* math.pi/(2 * 180.0))
    mol.atom = [
        ['O', ( 0., 0.    , 0)],
        ['H', ( 0., -x, y)],
        ['H', ( 0., x , y)],]
    mol.basis = {'H': 'cc-pVDZ',
                 'O': 'cc-pVDZ',}
    mol.verbose = 0
    mol.build()

    mf = scf.RHF(mol)
    mf.conv_tol = 1e-12
    mf.kernel()
    myadc = adc.ADC(mf)
Exemplo n.º 9
0
    def test_hf_dfadc2_ea(self):

        mf = scf.RHF(mol).run()
        myadc = adc.ADC(mf).density_fit(auxbasis='cc-pvdz-ri')
        myadc.max_memory = 20
        myadc.method = "adc(2)"
        myadc.method_type = "ea"

        e, v, p, x = myadc.kernel(nroots=4)

        self.assertAlmostEqual(e[0], 0.14265314, 6)
        self.assertAlmostEqual(e[1], 0.14265314, 6)
        self.assertAlmostEqual(e[2], 0.55092042, 6)
        self.assertAlmostEqual(e[3], 0.76714415, 6)

        self.assertAlmostEqual(p[0], 1.86604908, 6)
        self.assertAlmostEqual(p[1], 1.86604908, 6)
        self.assertAlmostEqual(p[2], 1.92697854, 6)
        self.assertAlmostEqual(p[3], 1.88386011, 6)
Exemplo n.º 10
0
    def test_dfadc3_ip(self):

        myadc = adc.ADC(mf).density_fit(auxbasis='cc-pvdz-ri')
        myadc.max_memory = 2
        myadc.method = "adc(3)"
        myadc.method_type = "ip"

        e, v, p, x = myadc.kernel(nroots=3)
        e_corr = myadc.e_corr

        self.assertAlmostEqual(e_corr, -0.3061165912, 6)

        self.assertAlmostEqual(e[0], 0.55609388, 6)
        self.assertAlmostEqual(e[1], 0.60109239, 6)
        self.assertAlmostEqual(e[2], 0.60109239, 6)

        self.assertAlmostEqual(p[0], 1.83255357, 6)
        self.assertAlmostEqual(p[1], 1.86389642, 6)
        self.assertAlmostEqual(p[2], 1.86389642, 6)
Exemplo n.º 11
0
    def test_check_mp2_high_cost(self):
        mol = gto.Mole()
        mol.atom = [
            ['C', (0.0, 0.0, 0.0)],
            ['O', (0.0, r_CO, 0.0)],
            ['H', (0.0, -x, y)],
            ['H', (0.0, -x, -y)],
        ]
        mol.basis = {
            'H': 'aug-cc-pVQZ',
            'C': 'aug-cc-pVQZ',
            'O': 'aug-cc-pVQZ',
        }
        mol.verbose = 7
        mol.output = '/dev/null'
        mol.build()

        mf = scf.RHF(mol)
        mf.conv_tol = 1e-12
        mf.kernel()
        # Ensure phase
        mf.mo_coeff[:, mf.mo_coeff.sum(axis=0) < 0] *= -1

        mp2 = mp.MP2(mf)
        e_mp2 = mp2.kernel()[0]

        myadc = adc.ADC(mf)
        myadc.max_memory = 20
        e_adc_mp2, t_amp1, t_amp2 = myadc.kernel_gs()

        diff_mp2 = e_adc_mp2 - e_mp2

        self.assertAlmostEqual(diff_mp2, 0.0000000000000, 6)

        t_amp1_n = numpy.linalg.norm(t_amp1[0])
        t_amp2_n = numpy.linalg.norm(t_amp2[0])

        self.assertAlmostEqual(t_amp1_n, 0.0456504320024, 6)
        self.assertAlmostEqual(t_amp2_n, 0.2977897530749, 6)

        self.assertAlmostEqual(lib.fp(t_amp1[0]), -0.008983054536, 6)
        self.assertAlmostEqual(lib.fp(t_amp2[0]), -0.639727653133, 6)
Exemplo n.º 12
0
    def test_check_mp2(self):
        mol = gto.Mole()
        mol.atom = [
            ['C', (0.0, 0.0, 0.0)],
            ['O', (0.0, r_CO, 0.0)],
            ['H', (0.0, -x, y)],
            ['H', (0.0, -x, -y)],
        ]
        mol.basis = '3-21g'
        mol.verbose = 7
        mol.output = '/dev/null'
        mol.build()

        mf = scf.RHF(mol)
        mf.conv_tol = 1e-12
        mf.kernel()
        # Ensure phase
        mf.mo_coeff[:, mf.mo_coeff.sum(axis=0) < 0] *= -1

        mp2 = mp.MP2(mf)
        e_mp2 = mp2.kernel()[0]

        myadc = adc.ADC(mf)
        myadc.max_memory = 1
        e_adc_mp2, t_amp1, t_amp2 = myadc.kernel_gs()

        diff_mp2 = e_adc_mp2 - e_mp2

        self.assertAlmostEqual(diff_mp2, 0.0000000000000, 6)

        t_amp1_n = numpy.linalg.norm(t_amp1[0])
        t_amp2_n = numpy.linalg.norm(t_amp2[0])

        self.assertAlmostEqual(t_amp1_n, 0.0430170343900, 6)
        self.assertAlmostEqual(t_amp2_n, 0.2427924473992, 6)

        self.assertAlmostEqual(lib.fp(t_amp1[0]), 0.0196348032865, 6)
        self.assertAlmostEqual(lib.fp(t_amp2[0]), 0.1119036046756, 6)
Exemplo n.º 13
0
from pyscf import gto, scf, adc, df

mol = gto.Mole()
r = 1.098
mol.atom = [
    ['N', (0., 0., -r / 2)],
    ['N', (0., 0., r / 2)],
]
mol.basis = {'N': 'aug-cc-pvdz'}
mol.build()

# Running conventional SCF followed by DF-ADC

mf = scf.RHF(mol).run()
myadc = adc.ADC(mf).density_fit('aug-cc-pvdz-ri')
myadc.kernel_gs()

# Running DF-SCF followed by DF-ADC

mf = scf.RHF(mol).density_fit().run()
myadc = adc.ADC(mf)
myadc.kernel_gs()

# Using different auxiliary basis for DF-SCF and DF-ADC

mf = scf.RHF(mol).density_fit('aug-cc-pvdz-jkfit').run()
myadc = adc.ADC(mf).density_fit('aug-cc-pvdz-ri')
myadc.verbose = 6
eip, vip, pip, xip = myadc.kernel()
Exemplo n.º 14
0
mf = scf.RHF(mol)
mf.conv_tol = 1e-12
mf.run()

# We can build the compressed ADC(2) self-energy as the zeroth iteration
# of AGF2, taking only the space corresponding to 1p coupling to 2p1h
gf2 = agf2.AGF2(mf)
se = gf2.build_se()
se = se.get_occupied()  # 2p1h/1p2h -> 2p1h
se.coupling = se.coupling[:gf2.nocc]  # 1p/1h -> 1p

# Use the adc module to get the 1p space from ADC(2). In AGF2, this is the
# bare Fock matrix, and is relaxed through the self-consistency. We can use
# the ADC 1p space instead.
adc2 = adc.radc.RADCIP(adc.ADC(mf).run())
h_1p = adc2.get_imds()

# Find the eigenvalues of the self-energy in the 'extended Fock matrix'
# format, which are the ionization potentials:
e_ip = se.eig(h_1p)[0]
print('IP-ADC(2) using the AGF2 solver (with renormalization):')
print(-e_ip[-1])

# Compare to ADC(2) values - note that these will not be the same, since
# AGF2 performs a compression/renormalization of the 2p1h space to allow
# full diagonalisation of the Hamiltonian instead of using an iterative solver:
e_ip = adc2.kernel(nroots=1)[0]
print('IP-ADC(2) using the pyscf solver:')
print(e_ip[-1])
Exemplo n.º 15
0
    def test_dfhf_dfadc_gs(self):

        mf = scf.RHF(mol).density_fit(auxbasis='cc-pvdz-jkfit').run()
        myadc = adc.ADC(mf).density_fit(auxbasis='cc-pvdz-ri')
        e, t_amp1, t_amp2 = myadc.kernel_gs()
        self.assertAlmostEqual(e, -0.3108102956, 6)
Exemplo n.º 16
0
 def __init__(self, hf, **kwargs):
     self.hf = hf
     self._pyscf = adc.ADC(self.hf._pyscf, **kwargs)
Exemplo n.º 17
0
        if rank == 0:
            print(ip)

        t1 = time.time()
        if rank == 0:
            print(t1-t0, '\n')

        rhf = hf.RHF(rhf.mol, with_df=False).run()

        t0 = time.time()

        adc2 = adc.RADC2(rhf, nroots=1, wtol=0, verbose=False).run()
        if rank == 0:
            print(adc2.ip[0][0])

        t1 = time.time()
        if rank == 0:
            print(t1-t0, '\n')

        t0 = time.time()

        adc2 = pyscf_adc.ADC(rhf._pyscf).run()
        if rank == 0:
            print(pyscf_adc.uadc.UADCIP(adc2).kernel()[0])

        t1 = time.time()
        if rank == 0:
            print(t1-t0, '\n')


Exemplo n.º 18
0
r = 0.969286393
mol = gto.Mole()
mol.atom = [
    ['O', (0., 0., -r / 2)],
    ['H', (0., 0., r / 2)],
]
mol.basis = {'O': 'aug-cc-pvdz', 'H': 'aug-cc-pvdz'}
mol.verbose = 0
mol.symmetry = False
mol.spin = 1
mol.build()
mf = scf.UHF(mol)
mf.conv_tol = 1e-12
mf.kernel()
myadc = adc.ADC(mf)


def tearDownModule():
    global mol, mf
    del mol, mf


class KnownValues(unittest.TestCase):
    def test_ea_adc2(self):

        e, t_amp1, t_amp2 = myadc.kernel()
        self.assertAlmostEqual(e, -0.16402828164387806, 6)

        e, v, p = myadc.ea_adc(nroots=3)
Exemplo n.º 19
0
from pyscf import scf
from pyscf import adc
from pyscf import df

r = 1.098
mol = gto.Mole()
mol.atom = [
    ['N', (0., 0., -r / 2)],
    ['N', (0., 0., r / 2)],
]
mol.basis = {'N': 'cc-pvdz'}
mol.verbose = 0
mol.build()
mf = scf.RHF(mol).density_fit(auxbasis='cc-pvdz-jkfit')
mf.kernel()
myadc = adc.ADC(mf)
myadc = adc.ADC(mf).density_fit(auxbasis='cc-pvdz-ri')


def tearDownModule():
    global mol, mf
    del mol, mf


class KnownValues(unittest.TestCase):
    def test_df_gs(self):

        mf = scf.RHF(mol).run()
        myadc.with_df = df.DF(mol, auxbasis='cc-pvdz-ri')
        e, t_amp1, t_amp2 = myadc.kernel_gs()
        self.assertAlmostEqual(e, -0.31081009625, 6)