def test_hcore(self): h1ref = pbchf.get_hcore(cell) h1 = pbchf.RHF(cell).get_hcore() self.assertAlmostEqual(abs(h1-h1ref).max(), 0, 9) self.assertAlmostEqual(lib.finger(h1), 0.14116483012673137, 9) cell1 = cell.copy() cell1.ecp = {'He': (2, ((-1, (((7.2, .3),),)),))} cell1.build(0, 0) kpt = numpy.ones(3) * .5 h1ref = pbchf.get_hcore(cell1, kpt) h1 = pbchf.RHF(cell1).get_hcore(kpt=kpt) self.assertAlmostEqual(abs(h1-h1ref).max(), 0, 9) self.assertAlmostEqual(lib.finger(h1), -2.708431894877279-0.395390980665125j, 9) h1 = pscf.KRHF(cell1).get_hcore(kpts=[kpt]) self.assertEqual(h1.ndim, 3) self.assertAlmostEqual(abs(h1[0]-h1ref).max(), 0, 9)
def get_hcore(mf, cell=None, kpts=None): '''Get the core Hamiltonian AO matrices at sampled k-points. Args: kpts : (nkpts, 3) ndarray Returns: hcore : (nkpts, nao, nao) ndarray ''' if cell is None: cell = mf.cell if kpts is None: kpts = mf.kpts return lib.asarray([pbchf.get_hcore(cell, k) for k in kpts])
def get_bands(self, kpt_band, cell=None, dm_kpts=None, kpts=None): '''Get energy bands at a given (arbitrary) 'band' k-point. Returns: mo_energy : (nao,) ndarray Bands energies E_n(k) mo_coeff : (nao, nao) ndarray Band orbitals psi_n(k) ''' if cell is None: cell = self.cell if dm_kpts is None: dm_kpts = self.make_rdm1() if kpts is None: kpts = self.kpts fock = pbchf.get_hcore(cell, kpt_band) \ + self.get_veff(kpts=kpts, kpt_band=kpt_band) s1e = pbchf.get_ovlp(cell, kpt_band) mo_energy, mo_coeff = pyscf.scf.hf.eig(fock, s1e) return mo_energy, mo_coeff
def get_hcore(mf, cell, kpts): '''Get the core Hamiltonian AO matrices at sampled k-points. Args: kpts : (nkpts, 3) ndarray Returns: hcore : (nkpts, nao, nao) ndarray ''' nao = cell.nao_nr() nkpts = len(kpts) hcore = np.zeros((nkpts,nao,nao), np.complex128) for k in range(nkpts): kpt = kpts[k,:] if mf.analytic_int: hcore[k,:,:] = scfint.get_hcore(cell, kpt) else: hcore[k,:,:] = pbchf.get_hcore(cell, kpt) return hcore
def test_hcore(self): h1ref = pbchf.get_hcore(cell) h1 = pbchf.RHF(cell).get_hcore() self.assertAlmostEqual(abs(h1 - h1ref).max(), 0, 9)