コード例 #1
0
    def test_pp_int(self):
        L = 2.
        n = 20
        cell = pbcgto.Cell()
        cell.atom = 'He  1.  .1  .3; He  .0  .8  1.1'
        cell.a = np.eye(3) * L
        cell.mesh = [n] * 3
        cell.basis = {'He': [[0, (0.8, 1.0)], [1, (1.2, 1.0)]]}
        cell.pseudo = {
            'He':
            pbcgto.pseudo.parse('''
He
    2
     0.40000000    3    -1.98934751    -0.75604821    0.95604821
    2
     0.29482550    3     1.23870466    .855         .3
                                       .71         -1.1
                                                    .9
     0.32235865    2     2.25670239    -0.39677748
                                        0.93894690
                                                 ''')
        }
        cell.build()
        np.random.seed(9)
        kpt = np.random.random(3)

        ref = get_pp_nl(cell)
        dat = pp_int.get_pp_nl(cell)
        self.assertTrue(dat.dtype == np.double)
        self.assertAlmostEqual(np.linalg.norm(ref - dat), 0, 11)

        ref = get_pp_nl(cell, kpt)
        dat = pp_int.get_pp_nl(cell, (kpt, kpt))
        self.assertTrue(dat.dtype == np.complex128)
        self.assertAlmostEqual(np.linalg.norm(ref - dat[0]), 0, 11)
        self.assertAlmostEqual(np.linalg.norm(ref - dat[1]), 0, 11)

        ref = get_pp_loc_part2(cell)
        dat = pp_int.get_pp_loc_part2(cell)
        self.assertAlmostEqual(np.linalg.norm(ref - dat), 0, 11)

        ref = get_pp_loc_part2(cell, kpt)
        dat = pp_int.get_pp_loc_part2(cell, kpt)
        self.assertAlmostEqual(np.linalg.norm(ref - dat), 0, 11)
コード例 #2
0
ファイル: test_pp.py プロジェクト: berquist/pyscf
    def test_pp_loc_part2(self):
        cell = pbcgto.Cell()
        cell.atom = 'He 1. .5 .5; C .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))],
                      'C' :'gth-szv',}
        cell.pseudo = {'C':'gth-pade'}
        cell.h = np.eye(3) * 2.5
        cell.gs = [15] * 3
        cell.build()
        np.random.seed(1)
        kpt = np.random.random(3)

        ref = get_pp_loc_part2(cell)
        dat = pp_int.get_pp_loc_part2(cell)
        self.assertAlmostEqual(np.linalg.norm(ref-dat), 0, 12)

        ref = get_pp_loc_part2(cell, kpt)
        dat = pp_int.get_pp_loc_part2(cell, kpt)
        self.assertAlmostEqual(np.linalg.norm(ref-dat), 0, 12)
コード例 #3
0
ファイル: test_pp.py プロジェクト: chrinide/pyscf
    def test_pp_int(self):
        L = 2.
        n = 20
        cell = pbcgto.Cell()
        cell.atom = 'He  1.  .1  .3; He  .0  .8  1.1'
        cell.a = np.eye(3) * L
        cell.mesh = [n] * 3
        cell.basis = { 'He': [[0, (0.8, 1.0)],
                              [1, (1.2, 1.0)]
                             ]}
        cell.pseudo = {'He': pbcgto.pseudo.parse('''
He
    2
     0.40000000    3    -1.98934751    -0.75604821    0.95604821
    2
     0.29482550    3     1.23870466    .855         .3
                                       .71         -1.1
                                                    .9
     0.32235865    2     2.25670239    -0.39677748
                                        0.93894690
                                                 ''')}
        cell.build()
        np.random.seed(9)
        kpt = np.random.random(3)

        ref = get_pp_nl(cell)
        dat = pp_int.get_pp_nl(cell)
        self.assertTrue(dat.dtype == np.double)
        self.assertAlmostEqual(np.linalg.norm(ref-dat), 0, 11)

        ref = get_pp_nl(cell, kpt)
        dat = pp_int.get_pp_nl(cell, (kpt,kpt))
        self.assertTrue(dat.dtype == np.complex128)
        self.assertAlmostEqual(np.linalg.norm(ref-dat[0]), 0, 11)
        self.assertAlmostEqual(np.linalg.norm(ref-dat[1]), 0, 11)

        ref = get_pp_loc_part2(cell)
        dat = pp_int.get_pp_loc_part2(cell)
        self.assertAlmostEqual(np.linalg.norm(ref-dat), 0, 11)

        ref = get_pp_loc_part2(cell, kpt)
        dat = pp_int.get_pp_loc_part2(cell, kpt)
        self.assertAlmostEqual(np.linalg.norm(ref-dat), 0, 11)
コード例 #4
0
ファイル: test_pp.py プロジェクト: xlzan/pyscf
    def test_pp_loc_part2(self):
        cell = pbcgto.Cell()
        cell.atom = 'He 1. .5 .5; C .1 1.3 2.1'
        cell.basis = {'He': [(0, (2.5, 1)), (0, (1., 1))],
                      'C' :'gth-szv',}
        cell.pseudo = {'C':'gth-pade'}
        cell.a = np.eye(3) * 2.5
        cell.gs = [15] * 3
        cell.build()
        np.random.seed(1)
        kpt = np.random.random(3)

        ref = get_pp_loc_part2(cell)
        dat = pp_int.get_pp_loc_part2(cell)
        self.assertAlmostEqual(np.linalg.norm(ref-dat), 0, 12)

        ref = get_pp_loc_part2(cell, kpt)
        dat = pp_int.get_pp_loc_part2(cell, kpt)
        self.assertAlmostEqual(np.linalg.norm(ref-dat), 0, 12)
コード例 #5
0
def get_gth_pp(mol):
    from pyscf.gto import ATOM_OF
    from pyscf.pbc.gto import Cell
    from pyscf.pbc.gto.pseudo import pp_int
    from pyscf.df import incore

    # Analytical integration for get_pp_loc_part1(cell).
    fakemol = pp_int.fake_cell_vloc(mol, 0)
    vpploc = 0
    if fakemol.nbas > 0:
        charges = fakemol.atom_charges()
        atmlst = fakemol._bas[:, ATOM_OF]
        v = incore.aux_e2(mol, fakemol, 'int3c2e', aosym='s2', comp=1)
        v = numpy.einsum('...i,i->...', v, -charges[atmlst])
        vpploc += lib.unpack_tril(v)

    # To compute the rest part of GTH PP, mimic the mol with a 0D cell.
    cell_0D = mol.view(Cell)
    cell_0D.dimension = 0
    cell_0D.a = numpy.eye(3)
    vpploc += pp_int.get_pp_loc_part2(cell_0D).real
    vpploc += pp_int.get_pp_nl(cell_0D).real
    return vpploc
コード例 #6
0
ファイル: pp_int.py プロジェクト: chrinide/pyscf
def get_gth_pp(mol):
    from pyscf.gto import ATOM_OF
    from pyscf.pbc.gto import Cell
    from pyscf.pbc.gto.pseudo import pp_int
    from pyscf.df import incore

    # Analytical integration for get_pp_loc_part1(cell).
    fakemol = pp_int.fake_cell_vloc(mol, 0)
    vpploc = 0
    if fakemol.nbas > 0:
        charges = fakemol.atom_charges()
        atmlst = fakemol._bas[:,ATOM_OF]
        v = incore.aux_e2(mol, fakemol, 'int3c2e', aosym='s2', comp=1)
        v = numpy.einsum('...i,i->...', v, -charges[atmlst])
        vpploc += lib.unpack_tril(v)

    # To compute the rest part of GTH PP, mimic the mol with a 0D cell.
    cell_0D = mol.view(Cell)
    cell_0D.dimension = 0
    cell_0D.a = numpy.eye(3)
    vpploc += pp_int.get_pp_loc_part2(cell_0D).real
    vpploc += pp_int.get_pp_nl(cell_0D).real
    return vpploc