예제 #1
0
    def test_tdhf_gamma_point(self):
        mf = RHF(cell).run()
        mf.exxdiv = None
        td_model = tdscf.TDHF(mf)
        td_model.conv_tol = 1e-4
        td_model.kernel()
        e1 = td_model.e

        kmf = KRHF(cell, cell.make_kpts([1, 1, 1])).run()
        kmf.exxdiv = None
        td_model = tdscf.KTDHF(kmf)
        td_model.conv_tol = 1e-4
        td_model.kernel()
        e2 = td_model.e
        self.assertAlmostEqual(abs(e1 - e2).max(), 0, 4)
예제 #2
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1], scaled_center=cls.k_c)

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.kernel()

        cls.td_model_krhf = td_model_krhf = KTDHF(model_krhf)
        td_model_krhf.kernel()

        cls.ref_m = retrieve_m(td_model_krhf)
        cls.ref_e = td_model_krhf.e
예제 #3
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = 'sto-3g'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1], scaled_center=cls.k_c)

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        # model_krhf.with_df._cderi_to_save = cls.df_file
        model_krhf.with_df._cderi = cls.df_file
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()

        cls.td_model_krhf = model_ktd = ktd.TDRHF(model_krhf)
        model_ktd.nroots = 5
        model_ktd.kernel()
예제 #4
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1], scaled_center=cls.k_c)

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.kernel()

        # Gamma
        cls.td_model_rhf_gamma = gtd.TDRHF(model_krhf)
        cls.td_model_rhf_gamma.kernel()
        cls.ref_m_gamma = cls.td_model_rhf_gamma.eri.tdhf_full_form()

        # Supercell
        cls.td_model_rhf_supercell = std.TDRHF(model_krhf)
        cls.td_model_rhf_supercell.kernel()
        cls.ref_m_supercell = cls.td_model_rhf_supercell.eri.tdhf_full_form()
예제 #5
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        cls.model_rhf = model_rhf = KRHF(cell).density_fit()
        model_rhf.kernel()

        cls.td_model_rhf = td_model_rhf = KTDHF(model_rhf)
        td_model_rhf.nroots = 5
        td_model_rhf.kernel()

        cls.ref_m = retrieve_m(td_model_rhf)
예제 #6
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)],
                            [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1])

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()

        # The slow supercell KTDHF
        cls.td_model_krhf = td_model_krhf = krhf_slow.TDRHF(model_krhf)
        td_model_krhf.kernel()
        cls.ref_m = tuple(td_model_krhf.eri.tdhf_full_form(i) for i in range(cls.k))
예제 #7
0
def density_fitting_hf(x):
    """
    Constructs density-fitting (Gamma-point) Hartree-Fock objects.
    Args:
        x (Cell): the supercell;

    Returns:
        The DF-HF object.
    """
    return KRHF(x).density_fit()
예제 #8
0
    def test_tdhf_gamma_point(self):
        mf = RHF(cell).run()
        td_model = tdscf.TDHF(mf)
        td_model.kernel()
        e1 = td_model.e

        kmf = KRHF(cell, cell.make_kpts([1, 1, 1])).run()
        td_model = tdscf.KTDHF(kmf)
        td_model.kernel()
        e2 = td_model.e
        self.assertAlmostEqual(abs(e1-e2).max(), 0, 6)
        self.assertAlmostEqual(abs(e1 - 1.0301736485136344).max(), 0, 6)
예제 #9
0
    def test_tda_gamma_point(self):
        mf = RHF(cell).run()
        td_model = tdscf.TDA(mf)
        td_model.kernel()
        e1 = td_model.e

        kmf = KRHF(cell, cell.make_kpts([1, 1, 1])).run()
        td_model = tdscf.KTDA(kmf)
        td_model.kernel()
        e2 = td_model.e
        self.assertAlmostEqual(abs(e1-e2).max(), 0, 6)
        self.assertAlmostEqual(abs(e1 - 1.0329858545904074).max(), 0, 6)
예제 #10
0
    def test_tdhf_gamma_point(self):
        mf = RHF(cell).run()
        td_model = tdscf.TDHF(mf)
        td_model.conv_tol = 1e-4
        td_model.kernel()
        e1 = td_model.e

        kmf = KRHF(cell, cell.make_kpts([1, 1, 1])).run()
        td_model = tdscf.KTDHF(kmf)
        td_model.conv_tol = 1e-4
        td_model.kernel()
        e2 = td_model.e
        self.assertAlmostEqual(abs(e1 - e2).max(), 0, 4)
        self.assertAlmostEqual(lib.finger(e1), 1.1580752883710259, 5)
예제 #11
0
    def test_tda_gamma_point(self):
        mf = RHF(cell).run()
        td_model = tdscf.TDA(mf)
        td_model.conv_tol = 1e-4
        td_model.kernel()
        e1 = td_model.e

        kmf = KRHF(cell, cell.make_kpts([1, 1, 1])).run()
        td_model = tdscf.KTDA(kmf)
        td_model.conv_tol = 1e-4
        td_model.kernel()
        e2 = td_model.e
        self.assertAlmostEqual(abs(e1 - e2).max(), 0, 4)
        self.assertAlmostEqual(lib.finger(e1), 1.1612366465054151, 5)
예제 #12
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1], scaled_center=cls.k_c)

        # The Gamma-point reference
        cls.model_rhf = model_rhf = RHF(super_cell(cell, [cls.k, 1, 1]),
                                        kpt=k[0]).density_fit()
        model_rhf.conv_tol = 1e-14
        model_rhf.kernel()

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()

        adjust_mf_phase(model_rhf, model_krhf)

        ke = numpy.concatenate(model_krhf.mo_energy)
        ke.sort()

        # Make sure mo energies are the same
        testing.assert_allclose(model_rhf.mo_energy, ke)

        # Make sure no degeneracies are present
        testing.assert_array_less(1e-4, ke[1:] - ke[:-1])

        cls.ov_order = ov_order(model_krhf)

        # The Gamma-point TD
        cls.td_model_rhf = td_model_rhf = td.TDRHF(model_rhf)
        td_model_rhf.kernel()
        cls.ref_m = td_model_rhf.eri.tdhf_full_form()
예제 #13
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1], scaled_center=cls.k_c)

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()

        ke = numpy.concatenate(model_krhf.mo_energy)
        ke.sort()

        # Make sure no degeneracies are present
        testing.assert_array_less(1e-4, ke[1:] - ke[:-1])

        # TD
        cls.td_model_srhf = td_model_srhf = std.TDRHF(model_krhf)
        td_model_srhf.kernel()

        cls.td_model_krhf = td_model_krhf = ktd.TDRHF(model_krhf)
        td_model_krhf.kernel()

        # adjust_td_phase(td_model_srhf, td_model_krhf)

        # GW
        cls.gw = sgw.GW(td_model_srhf)
        cls.kgw = kgw.GW(td_model_krhf)
예제 #14
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.get_abs_kpts((.1, .2, .3))

        # The Gamma-point reference
        cls.model_rhf = model_rhf = RHF(cell, k).density_fit()
        model_rhf.conv_tol = 1e-14
        model_rhf.kernel()

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()

        adjust_mf_phase(model_rhf, model_krhf)

        testing.assert_allclose(model_rhf.mo_energy, model_krhf.mo_energy[0])
        testing.assert_allclose(model_rhf.mo_coeff, model_krhf.mo_coeff[0])

        # The Gamma-point TD
        cls.td_model_rhf = td_model_rhf = td.TDRHF(model_rhf)
        td_model_rhf.kernel()
        cls.ref_m = td_model_rhf.eri.tdhf_full_form()
예제 #15
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'sto-3g'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1])

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()
예제 #16
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1])

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()

        # Add random phases
        numpy.random.seed(0)
        for i in model_krhf.mo_coeff:
            i *= numpy.exp(2.j * numpy.pi *
                           numpy.random.rand(i.shape[1]))[numpy.newaxis, :]

        # The slow supercell KTDHF
        cls.td_model_krhf = td_model_krhf = krhf_slow_supercell.TDRHF(
            model_krhf)
        td_model_krhf.kernel()
        cls.ref_m = td_model_krhf.eri.tdhf_full_form()
예제 #17
0
    def setUpClass(cls):
        cls.cell = cell = Cell()
        # Lift some degeneracies
        cell.atom = '''
        C 0.000000000000   0.000000000000   0.000000000000
        C 1.67   1.68   1.69
        '''
        cell.basis = {'C': [[0, (0.8, 1.0)],
                            [1, (1.0, 1.0)]]}
        # cell.basis = 'gth-dzvp'
        cell.pseudo = 'gth-pade'
        cell.a = '''
        0.000000000, 3.370137329, 3.370137329
        3.370137329, 0.000000000, 3.370137329
        3.370137329, 3.370137329, 0.000000000'''
        cell.unit = 'B'
        cell.verbose = 5
        cell.build()

        k = cell.make_kpts([cls.k, 1, 1], scaled_center=cls.k_c)

        # The Gamma-point reference
        cls.model_rhf = model_rhf = RHF(super_cell(cell, [cls.k, 1, 1]), kpt=k[0]).density_fit()
        model_rhf.conv_tol = 1e-14
        model_rhf.kernel()

        # K-points
        cls.model_krhf = model_krhf = KRHF(cell, k).density_fit()
        model_krhf.conv_tol = 1e-14
        model_krhf.kernel()

        adjust_mf_phase(model_rhf, model_krhf)

        ke = numpy.concatenate(model_krhf.mo_energy)
        ke.sort()

        # Make sure mo energies are the same
        testing.assert_allclose(model_rhf.mo_energy, ke)

        # Make sure no degeneracies are present
        testing.assert_array_less(1e-4, ke[1:] - ke[:-1])

        # TD
        cls.td_model_rhf = td_model_rhf = td.TDRHF(model_rhf)
        td_model_rhf.kernel()

        cls.td_model_krhf = td_model_krhf = ktd.TDRHF(model_krhf)
        td_model_krhf.kernel()

        adjust_td_phase(td_model_rhf, td_model_krhf)

        # GW
        cls.gw = gw.GW(td_model_rhf)
        cls.kgw = kgw.GW(td_model_krhf)

        cls.order_k, cls.order_p, cls.order = ov_order_supercell(cls.kgw.imds)

        orbs = []
        for k in range(cls.k):
            for o in numpy.arange(2, 6):
                orbs.append(numpy.where(numpy.logical_and(cls.order_k == k, cls.order_p == o))[0][0])
        cls.gw.orbs = numpy.array(orbs)
        cls.kgw.orbs = numpy.arange(2, 6)
예제 #18
0
파일: 00_pbc.py 프로젝트: zzy2014/pyscf
from pyscf.pbc.gto import Cell
from pyscf.pbc.scf import KRHF
from pyscf.pbc.tdscf.krhf_slow import TDRHF
from pyscf.pbc.gw import KRGW

cell = Cell()
cell.atom = '''
C 0.000000000000   0.000000000000   0.000000000000
C 1.67   1.68   1.69
'''
cell.basis = {'C': [[0, (0.8, 1.0)], [1, (1.0, 1.0)]]}
cell.pseudo = 'gth-pade'
cell.a = '''
0.000000000, 3.370137329, 3.370137329
3.370137329, 0.000000000, 3.370137329
3.370137329, 3.370137329, 0.000000000'''
cell.unit = 'B'
cell.verbose = 7
cell.build()

model = KRHF(cell, cell.make_kpts([2, 1, 1]))
model.kernel()

model_td = TDRHF(model)
model_td.kernel()

model_gw = KRGW(model_td)
model_gw.kernel()

print(model_gw.mo_energy)