@@ -81,6 +81,7 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
8181 int mg = hR->get_paraV ()->get_global_row_size ()/2 ;
8282 int ng = hR->get_paraV ()->get_global_col_size ()/2 ;
8383 int nb = hR->get_paraV ()->get_block_size ()/2 ;
84+ hR->set_zero ();
8485#ifdef __MPI
8586 int blacs_ctxt = hR->get_paraV ()->blacs_ctxt ;
8687 int *iat2iwt = new int [ucell_in->nat ];
@@ -98,8 +99,11 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
9899 // 0,3;1,2;1,2;0,3
99100 std::vector<int > first = {0 , 1 , 1 , 0 };
100101 std::vector<int > second= {3 , 2 , 2 , 3 };
102+ std::vector<int > row_set = {0 , 0 , 1 , 1 };
103+ std::vector<int > col_set = {0 , 1 , 0 , 1 };
104+ std::vector<int > clx_i = {1 , 0 , 0 , -1 };
105+ std::vector<int > clx_j = {0 , 1 , -1 , 0 };
101106 for (int is = 0 ; is < 4 ; is++){
102- this ->hR_tmp ->set_zero ();
103107 hamilt::HContainer<std::complex <double >>* hRGint_tmpCd = new hamilt::HContainer<std::complex <double >>(this ->ucell ->nat );
104108 hRGint_tmpCd->insert_ijrs (this ->gridt ->get_ijr_info (), *(this ->ucell ));
105109 hRGint_tmpCd->allocate (nullptr , true );
@@ -128,23 +132,8 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
128132 {
129133 for (int icol = 0 ; icol < mat_nspin1->get_col_size (); ++icol)
130134 {
131- switch (is)
132- {
133- case 0 :
134- upper_mat->get_value (irow, icol) = mat_nspin1->get_value (irow, icol) + mat_nspin2->get_value (irow, icol);
135- break ;
136- case 1 :
137- upper_mat->get_value (irow, icol) = mat_nspin1->get_value (irow, icol) +
138- std::complex <double >(0.0 , 1.0 ) * mat_nspin2->get_value (irow, icol);
139- break ;
140- case 2 :
141- upper_mat->get_value (irow, icol) = mat_nspin1->get_value (irow, icol) -
142- std::complex <double >(0.0 , 1.0 ) * mat_nspin2->get_value (irow, icol);
143- break ;
144- case 3 :
145- upper_mat->get_value (irow, icol) = mat_nspin1->get_value (irow, icol) - mat_nspin2->get_value (irow, icol);
146- break ;
147- }
135+ upper_mat->get_value (irow, icol) = mat_nspin1->get_value (irow, icol)
136+ + std::complex <double >(clx_i[is], clx_j[is]) * mat_nspin2->get_value (irow, icol);
148137 }
149138 }
150139 // fill the lower triangle matrix
@@ -166,7 +155,7 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
166155 }
167156
168157 // std::cout<<"success"<<std::endl;
169-
158+ this -> hR_tmp -> set_zero ();
170159 hamilt::transferSerials2Parallels ( *hRGint_tmpCd, this ->hR_tmp );
171160 for (int iap = 0 ; iap < hR->size_atom_pairs (); iap++)
172161 {
@@ -186,48 +175,19 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
186175 {
187176 for (int icol = 0 ; icol < mat_nspin->get_col_size (); ++icol)
188177 {
189- switch (is)
190- {
191- case 0 :
192- upper_mat->get_value (2 *irow, 2 *icol) += mat_nspin->get_value (irow, icol);
193- break ;
194- case 1 :
195- upper_mat->get_value (2 *irow, 2 *icol+1 ) += mat_nspin->get_value (irow, icol);
196- break ;
197- case 2 :
198- upper_mat->get_value (2 *irow+1 , 2 *icol) += mat_nspin->get_value (irow, icol);
199- break ;
200- case 3 :
201- upper_mat->get_value (2 *irow+1 , 2 *icol+1 ) += mat_nspin->get_value (irow, icol);
202- break ;
203- }
178+ upper_mat->get_value (2 *irow+row_set[is], 2 *icol+col_set[is]) =
179+ mat_nspin->get_value (irow, icol);
204180 }
205181 }
206182 }
207183 }
184+ delete hRGint_tmpCd;
208185 }
209186 delete[] iat2iwt;
210187#else
211188
212189#endif
213190
214- // ===================================
215- // transfer HR from Gint to Veff<OperatorLCAO<std::complex<double>, std::complex<double>>>
216- // ===================================
217- // #ifdef __MPI
218- // int size;
219- // MPI_Comm_size(MPI_COMM_WORLD, &size);
220- // if (size == 1)
221- // {
222- // hR->add(*this->hRGintCd);
223- // }
224- // else
225- // {
226- // hamilt::transferSerials2Parallels<std::complex<double>>(*this->hRGintCd, hR);
227- // }
228- // #else
229- // hR->add(*this->hRGintCd);
230- // #endif
231191 ModuleBase::timer::tick (" Gint_k" , " transfer_pvpR" );
232192 return ;
233193}
0 commit comments