def build(self, j_only=False, with_j3c=True): log = logger.Logger(self.stdout, self.verbose) t1 = (time.clock(), time.time()) self.dump_flags() self.auxcell = make_modrho_basis(self.cell, self.auxbasis, self.eta) self._j_only = j_only if j_only: kptij_lst = numpy.hstack((self.kpts,self.kpts)).reshape(-1,2,3) else: kptij_lst = [(ki, self.kpts[j]) for i, ki in enumerate(self.kpts) for j in range(i+1)] kptij_lst = numpy.asarray(kptij_lst) if not isinstance(self._cderi, str): if isinstance(self._cderi_file, str): self._cderi = self._cderi_file else: self._cderi = self._cderi_file.name if with_j3c: if self.approx_sr_level == 0: build_Lpq_pbc(self, self.auxcell, kptij_lst) elif self.approx_sr_level == 1: build_Lpq_pbc(self, self.auxcell, numpy.zeros((1,2,3))) elif self.approx_sr_level == 2: build_Lpq_nonpbc(self, self.auxcell) elif self.approx_sr_level == 3: build_Lpq_1c_approx(self, self.auxcell) t1 = log.timer_debug1('Lpq', *t1) _make_j3c(self, self.cell, self.auxcell, kptij_lst) t1 = log.timer_debug1('j3c', *t1) return self
def build(mydf, j_only=None, with_j3c=True, kpts_band=None): # Unlike DF and AFT class, here MDF objects are synced once if mpi.pool.size == 1: return df.DF.build(mydf, j_only, with_j3c, kpts_band) mydf = _sync_mydf(mydf) cell = mydf.cell log = logger.Logger(mydf.stdout, mydf.verbose) info = rank, platform.node(), platform.os.getpid() log.debug('MPI info (rank, host, pid) %s', comm.gather(info)) t1 = (time.clock(), time.time()) if mydf.kpts_band is not None: mydf.kpts_band = numpy.reshape(mydf.kpts_band, (-1, 3)) if kpts_band is not None: kpts_band = numpy.reshape(kpts_band, (-1, 3)) if mydf.kpts_band is None: mydf.kpts_band = kpts_band else: mydf.kpts_band = unique(numpy.vstack( (mydf.kpts_band, kpts_band)))[0] mydf.dump_flags() mydf.auxcell = make_modrho_basis(cell, mydf.auxbasis, mydf.eta) if mydf.kpts_band is None: kpts = mydf.kpts kband_uniq = numpy.zeros((0, 3)) else: kpts = mydf.kpts kband_uniq = [k for k in mydf.kpts_band if len(member(k, kpts)) == 0] if j_only is None: j_only = mydf._j_only if j_only: kall = numpy.vstack([kpts, kband_uniq]) kptij_lst = numpy.hstack((kall, kall)).reshape(-1, 2, 3) else: kptij_lst = [(ki, kpts[j]) for i, ki in enumerate(kpts) for j in range(i + 1)] kptij_lst.extend([(ki, kj) for ki in kband_uniq for kj in kpts]) kptij_lst.extend([(ki, ki) for ki in kband_uniq]) kptij_lst = numpy.asarray(kptij_lst) if with_j3c: if isinstance(mydf._cderi_to_save, str): cderi = mydf._cderi_to_save else: cderi = mydf._cderi_to_save.name if isinstance(mydf._cderi, str): log.warn( 'Value of _cderi is ignored. DF integrals will be ' 'saved in file %s .', cderi) mydf._cderi = cderi mydf._make_j3c(cell, mydf.auxcell, kptij_lst, cderi) t1 = log.timer_debug1('j3c', *t1) return mydf
def build(mydf, j_only=None, with_j3c=True, kpts_band=None): # Unlike DF and AFT class, here MDF objects are synced once if mpi.pool.size == 1: return df.DF.build(mydf, j_only, with_j3c, kpts_band) mydf = _sync_mydf(mydf) cell = mydf.cell log = logger.Logger(mydf.stdout, mydf.verbose) log.debug('MPI info (rank, host, pid) %s', mpi.platform_info()) t1 = (time.clock(), time.time()) if mydf.kpts_band is not None: mydf.kpts_band = numpy.reshape(mydf.kpts_band, (-1,3)) if kpts_band is not None: kpts_band = numpy.reshape(kpts_band, (-1,3)) if mydf.kpts_band is None: mydf.kpts_band = kpts_band else: mydf.kpts_band = unique(numpy.vstack((mydf.kpts_band,kpts_band)))[0] mydf.dump_flags() mydf.auxcell = make_modrho_basis(cell, mydf.auxbasis, mydf.eta) if mydf.kpts_band is None: kpts = mydf.kpts kband_uniq = numpy.zeros((0,3)) else: kpts = mydf.kpts kband_uniq = [k for k in mydf.kpts_band if len(member(k, kpts))==0] if j_only is None: j_only = mydf._j_only if j_only: kall = numpy.vstack([kpts,kband_uniq]) kptij_lst = numpy.hstack((kall,kall)).reshape(-1,2,3) else: kptij_lst = [(ki, kpts[j]) for i, ki in enumerate(kpts) for j in range(i+1)] kptij_lst.extend([(ki, kj) for ki in kband_uniq for kj in kpts]) kptij_lst.extend([(ki, ki) for ki in kband_uniq]) kptij_lst = numpy.asarray(kptij_lst) if with_j3c: if isinstance(mydf._cderi_to_save, str): cderi = mydf._cderi_to_save else: cderi = mydf._cderi_to_save.name if isinstance(mydf._cderi, str): log.warn('Value of _cderi is ignored. DF integrals will be ' 'saved in file %s .', cderi) mydf._cderi = cderi mydf._make_j3c(cell, mydf.auxcell, kptij_lst, cderi) t1 = log.timer_debug1('j3c', *t1) return mydf
def test_modrho_basis(self): cell = pgto.Cell( atom = 'Li 0 0 0; Li 1.5 1.5 1.5', a = numpy.eye(3) * 3, ) cell.build() cell1 = pgto.Cell( atom = 'Li1 0 0 0; Li2 1.5 1.5 1.5', a = numpy.eye(3) * 3, ) cell1.build() auxcell = df.make_modrho_basis(cell, auxbasis='ccpvdz', drop_eta=.1) auxcell1 = df.make_modrho_basis(cell1, auxbasis='ccpvdz', drop_eta=.1) for ib in range(len(auxcell._bas)): nprim = auxcell.bas_nprim(ib) nc = auxcell.bas_nctr(ib) es = auxcell.bas_exp(ib) es1 = auxcell1.bas_exp(ib) ptr = auxcell._bas[ib, gto.mole.PTR_COEFF] ptr1 = auxcell1._bas[ib, gto.mole.PTR_COEFF] cs = auxcell._env[ptr:ptr+nprim*nc] cs1 = auxcell1._env[ptr1:ptr1+nprim*nc] self.assertAlmostEqual(abs(es - es1).max(), 0, 15) self.assertAlmostEqual(abs(cs - cs1).max(), 0, 15)