@@ -157,8 +157,13 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, Grid_Driver* gd, const int&
157157 if (this ->DMRGint [is] != nullptr ) {
158158 delete this ->DMRGint [is];
159159 }
160+ if (this ->hRGint_tmp [is] != nullptr ) {
161+ delete this ->hRGint_tmp [is];
162+ }
160163 this ->DMRGint [is] = new hamilt::HContainer<double >(ucell_in.nat );
161164 }
165+ this ->hRGint_tmp [0 ]
166+ = new hamilt::HContainer<double >(ucell_in.nat );
162167#ifdef __MPI
163168 if (this ->DMRGint_full != nullptr ) {
164169 delete this ->DMRGint_full ;
@@ -167,132 +172,14 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, Grid_Driver* gd, const int&
167172#endif
168173 }
169174
170- // prepare the row_index and col_index for construct AtomPairs, they are
171- // same, name as orb_index
172- std::vector<int > orb_index (ucell_in.nat + 1 );
173- orb_index[0 ] = 0 ;
174- for (int i = 1 ; i < orb_index.size (); i++) {
175- int type = ucell_in.iat2it [i - 1 ];
176- orb_index[i] = orb_index[i - 1 ] + ucell_in.atoms [type].nw ;
177- }
178- std::vector<int > orb_index_npol;
179- if (npol == 2 ) {
180- orb_index_npol.resize (ucell_in.nat + 1 );
181- orb_index_npol[0 ] = 0 ;
182- for (int i = 1 ; i < orb_index_npol.size (); i++) {
183- int type = ucell_in.iat2it [i - 1 ];
184- orb_index_npol[i]
185- = orb_index_npol[i - 1 ] + ucell_in.atoms [type].nw * npol;
186- }
187- }
188-
189175 if (PARAM.globalv .gamma_only_local && nspin != 4 ) {
190176 this ->hRGint ->fix_gamma ();
191177 }
192- for (int T1 = 0 ; T1 < ucell_in.ntype ; ++T1) {
193- const Atom* atom1 = &(ucell_in.atoms [T1]);
194- for (int I1 = 0 ; I1 < atom1->na ; ++I1) {
195- auto & tau1 = atom1->tau [I1];
196-
197- gd->Find_atom (ucell_in, tau1, T1, I1);
198-
199- const int iat1 = ucell_in.itia2iat (T1, I1);
200-
201- // for grid integration (on FFT box),
202- // we only need to consider <phi_i | phi_j>,
203-
204- // whether this atom is in this processor.
205- if (this ->gridt ->in_this_processor [iat1]) {
206- for (int ad = 0 ; ad < gd->getAdjacentNum () + 1 ; ++ad) {
207- const int T2 = gd->getType (ad);
208- const int I2 = gd->getNatom (ad);
209- const int iat2 = ucell_in.itia2iat (T2, I2);
210- const Atom* atom2 = &(ucell_in.atoms [T2]);
211-
212- // NOTE: hRGint wil save total number of atom pairs,
213- // if only upper triangle is saved, the lower triangle will
214- // be lost in 2D-block parallelization. if the adjacent atom
215- // is in this processor.
216- if (this ->gridt ->in_this_processor [iat2]) {
217- ModuleBase::Vector3<double > dtau
218- = gd->getAdjacentTau (ad) - tau1;
219- double distance = dtau.norm () * ucell_in.lat0 ;
220- double rcut
221- = this ->gridt ->rcuts [T1] + this ->gridt ->rcuts [T2];
222-
223- // if(distance < rcut)
224- // mohan reset this 2013-07-02 in Princeton
225- // we should make absolutely sure that the distance is
226- // smaller than rcuts[it] this should be consistant
227- // with LCAO_nnr::cal_nnrg function typical example : 7
228- // Bohr cutoff Si orbital in 14 Bohr length of cell.
229- // distance = 7.0000000000000000
230- // rcuts[it] = 7.0000000000000008
231- if (distance < rcut - 1.0e-15 ) {
232- // calculate R index
233- auto & R_index = gd->getBox (ad);
234- // insert this atom-pair into this->hRGint
235- if (npol == 1 ) {
236- hamilt::AtomPair<double > tmp_atom_pair (
237- iat1,
238- iat2,
239- R_index.x ,
240- R_index.y ,
241- R_index.z ,
242- orb_index.data (),
243- orb_index.data (),
244- ucell_in.nat );
245- this ->hRGint ->insert_pair (tmp_atom_pair);
246- } else {
247- // HR is complex and size is nw * npol
248- hamilt::AtomPair<std::complex <double >>
249- tmp_atom_pair (iat1,
250- iat2,
251- R_index.x ,
252- R_index.y ,
253- R_index.z ,
254- orb_index_npol.data (),
255- orb_index_npol.data (),
256- ucell_in.nat );
257- this ->hRGintCd ->insert_pair (tmp_atom_pair);
258- // DMR is double now and size is nw
259- hamilt::AtomPair<double > tmp_dmR (
260- iat1,
261- iat2,
262- R_index.x ,
263- R_index.y ,
264- R_index.z ,
265- orb_index.data (),
266- orb_index.data (),
267- ucell_in.nat );
268- for (int is = 0 ; is < this ->DMRGint .size ();
269- is++) {
270- this ->DMRGint [is]->insert_pair (tmp_dmR);
271- }
272- #ifdef __MPI
273- hamilt::AtomPair<double > tmp_dmR_full (
274- iat1,
275- iat2,
276- R_index.x ,
277- R_index.y ,
278- R_index.z ,
279- orb_index_npol.data (),
280- orb_index_npol.data (),
281- ucell_in.nat );
282- // tmp DMR for transfer
283- this ->DMRGint_full ->insert_pair (tmp_dmR_full);
284- #endif
285- }
286- }
287- } // end iat2
288- } // end ad
289- } // end iat
290- } // end I1
291- } // end T1
292178 if (npol == 1 ) {
179+ this ->hRGint ->insert_ijrs (this ->gridt ->get_ijr_info (), ucell_in);
293180 this ->hRGint ->allocate (nullptr , false );
294181 ModuleBase::Memory::record (" Gint::hRGint" ,
295- this ->hRGint ->get_memory_size ());
182+ this ->hRGint ->get_memory_size ());
296183 // initialize DMRGint with hRGint when NSPIN != 4
297184 for (int is = 0 ; is < this ->DMRGint .size (); is++) {
298185 if (this ->DMRGint [is] != nullptr ) {
@@ -304,16 +191,20 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, Grid_Driver* gd, const int&
304191 this ->DMRGint [0 ]->get_memory_size ()
305192 * this ->DMRGint .size ());
306193 } else {
307- this ->hRGintCd ->allocate (nullptr , 0 );
308- ModuleBase::Memory::record (" Gint::hRGintCd" ,
309- this ->hRGintCd ->get_memory_size ());
310- for (int is = 0 ; is < this ->DMRGint .size (); is++) {
194+ this ->hRGintCd ->insert_ijrs (this ->gridt ->get_ijr_info (), ucell_in, npol);
195+ for (int is = 0 ; is < nspin; is++) {
196+ this ->hRGint_tmp [is]->insert_ijrs (this ->gridt ->get_ijr_info (), ucell_in);
197+ this ->DMRGint [is]->insert_ijrs (this ->gridt ->get_ijr_info (), ucell_in);
198+ this ->hRGint_tmp [is]->allocate (nullptr , false );
311199 this ->DMRGint [is]->allocate (nullptr , false );
312200 }
201+ ModuleBase::Memory::record (" Gint::hRGint_tmp" ,
202+ this ->hRGint_tmp [0 ]->get_memory_size ()*nspin);
313203 ModuleBase::Memory::record (" Gint::DMRGint" ,
314- this ->DMRGint [0 ]->get_memory_size ()
315- * this ->DMRGint .size ());
204+ this ->DMRGint [0 ]->get_memory_size ()
205+ * this ->DMRGint .size ()*nspin );
316206#ifdef __MPI
207+ this ->DMRGint_full ->insert_ijrs (this ->gridt ->get_ijr_info (), ucell_in, npol);
317208 this ->DMRGint_full ->allocate (nullptr , false );
318209 ModuleBase::Memory::record (" Gint::DMRGint_full" ,
319210 this ->DMRGint_full ->get_memory_size ());
@@ -397,4 +288,4 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
397288 }
398289 }
399290 ModuleBase::timer::tick (" Gint" , " transfer_DMR" );
400- }
291+ }
0 commit comments