@@ -11,7 +11,7 @@ berryphase::berryphase()
1111}
1212
1313#ifdef __LCAO
14- berryphase::berryphase (Local_Orbital_Charge& loc_in ) : loc(&loc_in )
14+ berryphase::berryphase (const Parallel_Orbitals& paraV_in ) : paraV(paraV_in )
1515{
1616 GDIR = INPUT.gdir ;
1717}
@@ -43,7 +43,7 @@ void berryphase::get_occupation_bands()
4343void berryphase::lcao_init (const K_Vectors& kv, const Grid_Technique& grid_tech)
4444{
4545 ModuleBase::TITLE (" berryphase" , " lcao_init" );
46- lcao_method.init (grid_tech, this -> loc -> wfc_k_grid , kv.get_nkstot ());
46+ lcao_method.init (grid_tech, kv.get_nkstot ());
4747 lcao_method.cal_R_number ();
4848 lcao_method.cal_orb_overlap ();
4949 return ;
@@ -89,8 +89,10 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)
8989 for (int ix = 0 ; ix < mp_x; ix++)
9090 {
9191 k_index[string_index][ix] = ix + iy * mp_x + iz * mp_x * mp_y;
92- if (ix == (mp_x - 1 ))
93- k_index[string_index][ix + 1 ] = k_index[string_index][0 ];
92+ if (ix == (mp_x - 1 )) {
93+ k_index[string_index][ix + 1 ]
94+ = k_index[string_index][0 ];
95+ }
9496 }
9597 }
9698 }
@@ -137,8 +139,10 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)
137139 for (int iy = 0 ; iy < mp_y; iy++)
138140 {
139141 k_index[string_index][iy] = ix + iy * mp_x + iz * mp_x * mp_y;
140- if (iy == (mp_y - 1 ))
141- k_index[string_index][iy + 1 ] = k_index[string_index][0 ];
142+ if (iy == (mp_y - 1 )) {
143+ k_index[string_index][iy + 1 ]
144+ = k_index[string_index][0 ];
145+ }
142146 }
143147 }
144148 }
@@ -185,8 +189,10 @@ void berryphase::set_kpoints(const K_Vectors& kv, const int direction)
185189 for (int iz = 0 ; iz < mp_z; iz++)
186190 {
187191 k_index[string_index][iz] = ix + iy * mp_x + iz * mp_x * mp_y;
188- if (iz == (mp_z - 1 ))
189- k_index[string_index][iz + 1 ] = k_index[string_index][0 ];
192+ if (iz == (mp_z - 1 )) {
193+ k_index[string_index][iz + 1 ]
194+ = k_index[string_index][0 ];
195+ }
190196 }
191197 }
192198 }
@@ -303,9 +309,15 @@ double berryphase::stringPhase(int index_str,
303309 }
304310
305311 mat (nb, mb) = pw_method.unkdotp_soc_G0 (rhopw, wfcpw, ik_1, ik_2, nb, mb, psi_in, G);
312+ } else {
313+ mat (nb, mb) = pw_method.unkdotp_soc_G (wfcpw,
314+ ik_1,
315+ ik_2,
316+ nb,
317+ mb,
318+ npwx,
319+ psi_in);
306320 }
307- else
308- mat (nb, mb) = pw_method.unkdotp_soc_G (wfcpw, ik_1, ik_2, nb, mb, npwx, psi_in);
309321 }
310322
311323 } // nb
@@ -318,10 +330,11 @@ double berryphase::stringPhase(int index_str,
318330 LapackConnector::zgetrf (nbands, nbands, mat, nbands, ipiv.data (), &info);
319331 for (int ib = 0 ; ib < nbands; ib++)
320332 {
321- if (ipiv[ib] != (ib + 1 ))
333+ if (ipiv[ib] != (ib + 1 )) {
322334 det = -det * mat (ib, ib);
323- else
335+ } else {
324336 det = det * mat (ib, ib);
337+ }
325338 }
326339
327340 zeta = zeta * det;
@@ -334,7 +347,7 @@ double berryphase::stringPhase(int index_str,
334347 if (GlobalV::NSPIN != 4 )
335348 {
336349 // std::complex<double> my_det = lcao_method.det_berryphase(ik_1,ik_2,dk,nbands);
337- zeta = zeta * lcao_method.det_berryphase (ik_1, ik_2, dk, nbands, * this ->loc -> ParaV , psi_in, kv);
350+ zeta = zeta * lcao_method.det_berryphase (ik_1, ik_2, dk, nbands, this ->paraV , psi_in, kv);
338351 // test by jingan
339352 // GlobalV::ofs_running << "methon 1: det = " << my_det << std::endl;
340353 // test by jingan
@@ -401,8 +414,9 @@ void berryphase::Berry_Phase(int nbands,
401414 for (int istring = 0 ; istring < total_string; istring++)
402415 {
403416 wistring[istring] = 1.0 / total_string;
404- if (GlobalV::NSPIN == 2 )
417+ if (GlobalV::NSPIN == 2 ) {
405418 wistring[istring] = wistring[istring] * 2 ;
419+ }
406420 }
407421
408422 for (int istring = 0 ; istring < total_string; istring++)
@@ -561,10 +575,11 @@ void berryphase::Macroscopic_polarization(const int npwx,
561575
562576 // calculate Macroscopic polarization modulus because berry phase
563577 int modulus = 0 ;
564- if ((!lodd) && (GlobalV::NSPIN == 1 ))
578+ if ((!lodd) && (GlobalV::NSPIN == 1 )) {
565579 modulus = 2 ;
566- else
580+ } else {
567581 modulus = 1 ;
582+ }
568583
569584 // test by jingan
570585 // GlobalV::ofs_running << "ion polarization end" << std::endl;
0 commit comments