def get_hcore(self, mol=None): '''1-component X2c Foldy-Wouthuysen (FW Hamiltonian (spin-free part only) ''' if mol is None: mol = self.mol if mol.has_ecp(): raise NotImplementedError xmol, contr_coeff = self.get_xmol(mol) c = lib.param.LIGHT_SPEED assert ('1E' in self.approx.upper()) t = xmol.intor_symmetric('int1e_kin') v = xmol.intor_symmetric('int1e_nuc') s = xmol.intor_symmetric('int1e_ovlp') w = xmol.intor_symmetric('int1e_pnucp') if 'get_xmat' in self.__dict__: # If the get_xmat method is overwritten by user, build the X # matrix with the external get_xmat method x = self.get_xmat(xmol) h1 = x2c._get_hcore_fw(t, v, w, s, x, c) elif 'ATOM' in self.approx.upper(): atom_slices = xmol.offset_nr_by_atom() nao = xmol.nao_nr() x = numpy.zeros((nao, nao)) for ia in range(xmol.natm): ish0, ish1, p0, p1 = atom_slices[ia] shls_slice = (ish0, ish1, ish0, ish1) t1 = xmol.intor('int1e_kin', shls_slice=shls_slice) s1 = xmol.intor('int1e_ovlp', shls_slice=shls_slice) with xmol.with_rinv_at_nucleus(ia): z = -xmol.atom_charge(ia) v1 = z * xmol.intor('int1e_rinv', shls_slice=shls_slice) w1 = z * xmol.intor('int1e_prinvp', shls_slice=shls_slice) x[p0:p1, p0:p1] = x2c._x2c1e_xmatrix(t1, v1, w1, s1, c) h1 = x2c._get_hcore_fw(t, v, w, s, x, c) else: h1 = x2c._x2c1e_get_hcore(t, v, w, s, c) if self.basis is not None: s22 = xmol.intor_symmetric('int1e_ovlp') s21 = gto.intor_cross('int1e_ovlp', xmol, mol) c = lib.cho_solve(s22, s21) h1 = reduce(numpy.dot, (c.T, h1, c)) if self.xuncontract and contr_coeff is not None: h1 = reduce(numpy.dot, (contr_coeff.T, h1, contr_coeff)) return h1
def get_hcore(self, cell=None, kpts=None): if cell is None: cell = self.cell if kpts is None: kpts_lst = numpy.zeros((1, 3)) else: kpts_lst = numpy.reshape(kpts, (-1, 3)) xcell, contr_coeff = self.get_xmol(cell) with_df = aft.AFTDF(xcell) c = lib.param.LIGHT_SPEED assert ('1E' in self.approx.upper()) if 'ATOM' in self.approx.upper(): atom_slices = xcell.offset_nr_by_atom() nao = xcell.nao_nr() x = numpy.zeros((nao, nao)) vloc = numpy.zeros((nao, nao)) wloc = numpy.zeros((nao, nao)) for ia in range(xcell.natm): ish0, ish1, p0, p1 = atom_slices[ia] shls_slice = (ish0, ish1, ish0, ish1) t1 = xcell.intor('int1e_kin', shls_slice=shls_slice) s1 = xcell.intor('int1e_ovlp', shls_slice=shls_slice) with xcell.with_rinv_at_nucleus(ia): z = -xcell.atom_charge(ia) v1 = z * xcell.intor('int1e_rinv', shls_slice=shls_slice) w1 = z * xcell.intor('int1e_prinvp', shls_slice=shls_slice) vloc[p0:p1, p0:p1] = v1 wloc[p0:p1, p0:p1] = w1 x[p0:p1, p0:p1] = x2c._x2c1e_xmatrix(t1, v1, w1, s1, c) else: raise NotImplementedError t = xcell.pbc_intor('int1e_kin', 1, lib.HERMITIAN, kpts_lst) s = xcell.pbc_intor('int1e_ovlp', 1, lib.HERMITIAN, kpts_lst) v = with_df.get_nuc(kpts_lst) #w = get_pnucp(with_df, kpts_lst) if self.basis is not None: s22 = s s21 = pbcgto.intor_cross('int1e_ovlp', xcell, cell, kpts=kpts_lst) h1_kpts = [] for k in range(len(kpts_lst)): # The treatment of pnucp local part has huge effects to hcore #h1 = x2c._get_hcore_fw(t[k], vloc, wloc, s[k], x, c) - vloc + v[k] #h1 = x2c._get_hcore_fw(t[k], v[k], w[k], s[k], x, c) h1 = x2c._get_hcore_fw(t[k], v[k], wloc, s[k], x, c) if self.basis is not None: c = lib.cho_solve(s22[k], s21[k]) h1 = reduce(numpy.dot, (c.T, h1, c)) if self.xuncontract and contr_coeff is not None: h1 = reduce(numpy.dot, (contr_coeff.T, h1, contr_coeff)) h1_kpts.append(h1) if kpts is None or numpy.shape(kpts) == (3, ): h1_kpts = h1_kpts[0] return lib.asarray(h1_kpts)
def get_hcore(self, cell=None, kpts=None): if cell is None: cell = self.cell if kpts is None: kpts_lst = numpy.zeros((1,3)) else: kpts_lst = numpy.reshape(kpts, (-1,3)) xcell, contr_coeff = self.get_xmol(cell) with_df = aft.AFTDF(xcell) c = lib.param.LIGHT_SPEED assert('1E' in self.approx.upper()) if 'ATOM' in self.approx.upper(): atom_slices = xcell.offset_nr_by_atom() nao = xcell.nao_nr() x = numpy.zeros((nao,nao)) vloc = numpy.zeros((nao,nao)) wloc = numpy.zeros((nao,nao)) for ia in range(xcell.natm): ish0, ish1, p0, p1 = atom_slices[ia] shls_slice = (ish0, ish1, ish0, ish1) t1 = xcell.intor('int1e_kin', shls_slice=shls_slice) s1 = xcell.intor('int1e_ovlp', shls_slice=shls_slice) with xcell.with_rinv_as_nucleus(ia): z = -xcell.atom_charge(ia) v1 = z * xcell.intor('int1e_rinv', shls_slice=shls_slice) w1 = z * xcell.intor('int1e_prinvp', shls_slice=shls_slice) vloc[p0:p1,p0:p1] = v1 wloc[p0:p1,p0:p1] = w1 x[p0:p1,p0:p1] = x2c._x2c1e_xmatrix(t1, v1, w1, s1, c) else: raise NotImplementedError t = xcell.pbc_intor('int1e_kin', 1, lib.HERMITIAN, kpts_lst) s = xcell.pbc_intor('int1e_ovlp', 1, lib.HERMITIAN, kpts_lst) v = with_df.get_nuc(kpts_lst) #w = get_pnucp(with_df, kpts_lst) if self.basis is not None: s22 = s s21 = pbcgto.intor_cross('int1e_ovlp', xcell, cell, kpts=kpts_lst) h1_kpts = [] for k in range(len(kpts_lst)): # The treatment of pnucp local part has huge effects to hcore #h1 = x2c._get_hcore_fw(t[k], vloc, wloc, s[k], x, c) - vloc + v[k] #h1 = x2c._get_hcore_fw(t[k], v[k], w[k], s[k], x, c) h1 = x2c._get_hcore_fw(t[k], v[k], wloc, s[k], x, c) if self.basis is not None: c = lib.cho_solve(s22[k], s21[k]) h1 = reduce(numpy.dot, (c.T, h1, c)) if self.xuncontract and contr_coeff is not None: h1 = reduce(numpy.dot, (contr_coeff.T, h1, contr_coeff)) h1_kpts.append(h1) if kpts is None or numpy.shape(kpts) == (3,): h1_kpts = h1_kpts[0] return lib.asarray(h1_kpts)