def test_eval_ao(self): cell = pbcgto.Cell() cell.verbose = 5 cell.output = '/dev/null' cell.a = np.eye(3) * 2.5 cell.gs = [10] * 3 cell.atom = [ ['C', (1., .8, 1.9)], ['C', (.1, .2, .3)], ] cell.basis = 'ccpvdz' cell.build(False, False) grids = gen_grid.UniformGrids(cell) grids.build() ni = numint._NumInt() ao0 = eval_ao(cell, grids.coords) ao1 = ni.eval_ao(cell, grids.coords) self.assertTrue(numpy.allclose(ao0, ao1, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(ao1), -0.54069672246407219, 8) ao0 = eval_ao(cell, grids.coords, deriv=1) ao1 = ni.eval_ao(cell, grids.coords, deriv=1) self.assertTrue(numpy.allclose(ao0, ao1, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(ao1), 8.8004405892746433, 8)
def __init__(self, cell, kpt=None): pyscf.pbc.scf.hf.RHF.__init__(self, cell, kpt) self.xc = 'LDA,VWN' self._ecoul = 0 self._exc = 0 #FIXME (Q): lazy create self._numint, since self.kpt might be changed # self.kpt is set in RHF.__init__() self._numint = numint._NumInt(self.kpt) self._keys = self._keys.union(['xc', 'grids'])
def __init__(self, cell, kpt=numpy.zeros(3)): pbcuhf.UHF.__init__(self, cell, kpt) self.xc = 'LDA,VWN' self.grids = gen_grid.UniformGrids(cell) self.small_rho_cutoff = 1e-7 # Use rho to filter grids ################################################## # don't modify the following attributes, they are not input options self._numint = numint._NumInt() self._keys = self._keys.union(['xc', 'grids', 'small_rho_cutoff'])
def __init__(self, cell, kpt=numpy.zeros(3)): pbcuhf.UHF.__init__(self, cell, kpt) self.xc = 'LDA,VWN' self.grids = gen_grid.UniformGrids(cell) self.small_rho_cutoff = 1e-7 # Use rho to filter grids ################################################## # don't modify the following attributes, they are not input options self._ecoul = 0 self._exc = 0 self._numint = numint._NumInt() self._keys = self._keys.union(['xc', 'grids', 'small_rho_cutoff'])
def test_nr_rks(self): cell = pbcgto.Cell() cell.verbose = 5 cell.output = '/dev/null' cell.a = np.eye(3) * 2.5 cell.gs = [10] * 3 cell.atom = [ ['He', (1., .8, 1.9)], ['He', (.1, .2, .3)], ] cell.basis = 'ccpvdz' cell.build(False, False) grids = gen_grid.UniformGrids(cell) grids.build() nao = cell.nao_nr() np.random.seed(1) kpts = np.random.random((2, 3)) dms = np.random.random((2, nao, nao)) dms = (dms + dms.transpose(0, 2, 1)) * .5 ni = numint._NumInt() ne, exc, vmat = ni.nr_rks(cell, grids, 'blyp', dms[0], 0, kpts[0]) self.assertAlmostEqual(ne, 5.0499199224525153, 8) self.assertAlmostEqual(exc, -3.8870579114663886, 8) self.assertAlmostEqual(finger(vmat), 0.42538491159934377 + 0.14139753327162483j, 8) ni = numint._KNumInt() ne, exc, vmat = ni.nr_rks(cell, grids, 'blyp', dms, 0, kpts) self.assertAlmostEqual(ne, 6.0923292346269742, 8) self.assertAlmostEqual(exc, -3.9899423803106466, 8) self.assertAlmostEqual(finger(vmat[0]), -2348.9577179701278 - 60.733087913116719j, 7) self.assertAlmostEqual(finger(vmat[1]), -2353.0350086740673 - 117.74811536967495j, 7) ne, exc, vmat = ni.nr_rks(cell, grids, 'blyp', [dms, dms], 0, kpts) self.assertAlmostEqual(ne[1], 6.0923292346269742, 8) self.assertAlmostEqual(exc[1], -3.9899423803106466, 8) self.assertAlmostEqual(finger(vmat[1][0]), -2348.9577179701278 - 60.733087913116719j, 7) self.assertAlmostEqual(finger(vmat[1][1]), -2353.0350086740673 - 117.74811536967495j, 7)
def test_eval_ao_kpt(self): cell = pbcgto.Cell() cell.verbose = 5 cell.output = '/dev/null' cell.h = np.eye(3) * 2.5 cell.gs = [10]*3 cell.atom = [['He', (1., .8, 1.9)], ['He', (.1, .2, .3)],] cell.basis = 'ccpvdz' cell.build(False, False) grids = gen_grid.UniformGrids(cell) grids.build() np.random.seed(1) kpt = np.random.random(3) ni = numint._NumInt() ao0 = eval_ao(cell, grids.coords, kpt) ao1 = ni.eval_ao(cell, grids.coords, kpt) self.assertTrue(numpy.allclose(ao0, ao1, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(ao1), (-2.4066959390326477-0.98044994099240701j), 8)
def test_eval_ao_kpt(self): cell = pbcgto.Cell() cell.verbose = 5 cell.output = '/dev/null' cell.a = np.eye(3) * 2.5 cell.gs = [10]*3 cell.atom = [['He', (1., .8, 1.9)], ['He', (.1, .2, .3)],] cell.basis = 'ccpvdz' cell.build(False, False) grids = gen_grid.UniformGrids(cell) grids.build() np.random.seed(1) kpt = np.random.random(3) ni = numint._NumInt() ao0 = eval_ao(cell, grids.coords, kpt) ao1 = ni.eval_ao(cell, grids.coords, kpt) self.assertTrue(numpy.allclose(ao0, ao1, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(ao1), (-2.4066959390326477-0.98044994099240701j), 8)
def test_eval_ao(self): cell = pbcgto.Cell() cell.verbose = 5 cell.output = '/dev/null' cell.h = np.eye(3) * 2.5 cell.gs = [10]*3 cell.atom = [['C', (1., .8, 1.9)], ['C', (.1, .2, .3)],] cell.basis = 'ccpvdz' cell.build(False, False) grids = gen_grid.UniformGrids(cell) grids.build() ni = numint._NumInt() ao0 = eval_ao(cell, grids.coords) ao1 = ni.eval_ao(cell, grids.coords) self.assertTrue(numpy.allclose(ao0, ao1, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(ao1), -0.54069672246407219, 8) ao0 = eval_ao(cell, grids.coords, deriv=1) ao1 = ni.eval_ao(cell, grids.coords, deriv=1) self.assertTrue(numpy.allclose(ao0, ao1, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(ao1), 8.8004405892746433, 8)
def test_nr_rks(self): cell = pbcgto.Cell() cell.verbose = 5 cell.output = '/dev/null' cell.h = np.eye(3) * 2.5 cell.gs = [10]*3 cell.atom = [['He', (1., .8, 1.9)], ['He', (.1, .2, .3)],] cell.basis = 'ccpvdz' cell.build(False, False) grids = gen_grid.UniformGrids(cell) grids.build() nao = cell.nao_nr() np.random.seed(1) kpts = np.random.random((2,3)) dms = np.random.random((2,nao,nao)) dms = (dms + dms.transpose(0,2,1)) * .5 ni = numint._NumInt() ne, exc, vmat = ni.nr_rks(cell, grids, 'blyp', dms[0], 0, kpts[0]) self.assertAlmostEqual(ne, 5.0499199224525153, 8) self.assertAlmostEqual(exc, -3.8870579114663886, 8) self.assertAlmostEqual(finger(vmat), 0.42538491159934377+0.14139753327162483j, 8) ni = numint._KNumInt() ne, exc, vmat = ni.nr_rks(cell, grids, 'blyp', dms, 0, kpts) self.assertAlmostEqual(ne, 6.0923292346269742, 8) self.assertAlmostEqual(exc, -3.9899423803106466, 8) self.assertAlmostEqual(finger(vmat[0]), -2348.9577179701278-60.733087913116719j, 8) self.assertAlmostEqual(finger(vmat[1]), -2353.0350086740673-117.74811536967495j, 8) ne, exc, vmat = ni.nr_rks(cell, grids, 'blyp', [dms,dms], 0, kpts) self.assertAlmostEqual(ne[1], 6.0923292346269742, 8) self.assertAlmostEqual(exc[1], -3.9899423803106466, 8) self.assertAlmostEqual(finger(vmat[1][0]), -2348.9577179701278-60.733087913116719j, 8) self.assertAlmostEqual(finger(vmat[1][1]), -2353.0350086740673-117.74811536967495j, 8)