@@ -42,8 +42,9 @@ void toQO::initialize(const std::string& out_dir,
4242 init_info += " qo_basis: " + qo_basis_ + " \n " ;
4343 init_info += " qo_thr: " + std::to_string (qo_thr_) + " \n " ;
4444 init_info += " qo_strategies: " ;
45- for (auto s: strategies_)
45+ for (auto s: strategies_) {
4646 init_info += s + " " ;
47+ }
4748 init_info += " \n " ;
4849 init_info += " Output directory: " + out_dir + " \n " ;
4950 init_info += " Pseudopotential directory: " + pseudo_dir + " \n " ;
@@ -159,33 +160,36 @@ bool toQO::orbital_filter_out(const int& itype, const int& l, const int& izeta)
159160 // means for the first atom type, use s and p orbitals, for the second, use
160161 // s, p, d, and f orbitals
161162 // default is `all` for all types, and for each type, all orbitals are used
162- if (strategies_[itype] == " all" )
163+ if (strategies_[itype] == " all" ) {
163164 return false ;
164- else if (l >= l2symbol.size ())
165+ } else if (l >= l2symbol.size ()) {
165166 return true ;
166- else if (strategies_[itype].find_first_of (l2symbol[l]) != std::string::npos)
167+ } else if (strategies_[itype].find_first_of (l2symbol[l]) != std::string::npos) {
167168 return false ;
168- else
169+ } else {
169170 return true ;
171+ }
170172 }
171173 else if (qo_basis_ == " szv" )
172174 {
173175 // use two individual logic branch allows them have different orbital filtering logic,
174176 // although presently they are almost the same
175- if (izeta != 0 )
177+ if (izeta != 0 ) {
176178 return true ; // filter out
177- else if (strategies_[itype] == " all" )
179+ } else if (strategies_[itype] == " all" ) {
178180 return false ; // keep
179- else if (l >= l2symbol.size ())
181+ } else if (l >= l2symbol.size ()) {
180182 return true ; // filter out
181- else if (strategies_[itype].find_first_of (l2symbol[l]) != std::string::npos)
183+ } else if (strategies_[itype].find_first_of (l2symbol[l]) != std::string::npos) {
182184 return false ; // keep
183- else
185+ } else {
184186 return true ; // filter out
187+ }
185188 }
186- else
189+ else {
187190 return false ;
188191}
192+ }
189193
190194void toQO::build_hydrogen (const int ntype,
191195 const double * const charges,
@@ -283,8 +287,9 @@ void toQO::build_ao(const int ntype,
283287 qo_thr, // / qo_thr
284288 rank); // / rank
285289 }
286- else if (qo_basis_ == " szv" )
290+ else if (qo_basis_ == " szv" ) {
287291 build_szv ();
292+ }
288293 if (rank == 0 )
289294 {
290295 std::string ao_build_info = " toQO::build_ao: built atomic orbitals for calculating QO overlap integrals\n " ;
@@ -370,10 +375,12 @@ void toQO::calculate_ovlpk(int ik)
370375 MPI_Barrier (MPI_COMM_WORLD);
371376#endif
372377 // ik == -1 corresponds to the case of those processes with less kpoints than others
373- if (ik != -1 )
378+ if (ik != -1 ) {
374379 read_ovlp (out_dir_, nchi_, nphi_, true , barrier_iR);
375- if (ik != -1 )
380+ }
381+ if (ik != -1 ) {
376382 append_ovlpR_eiRk (ik, barrier_iR);
383+ }
377384 }
378385}
379386
@@ -390,8 +397,9 @@ void toQO::calculate()
390397 // while for zero_out overlap, it can be not so strictly synchronized
391398 zero_out_ovlps (false );
392399 calculate_ovlpk (ik);
393- if (ik != -1 )
400+ if (ik != -1 ) {
394401 write_ovlp<std::complex <double >>(out_dir_, ovlpk_, nchi_, nphi_, false , ik);
402+ }
395403 }
396404#ifdef __MPI
397405 // once the calculation of S(k) is finished, prone to delete all QO_ovlpR_*.dat files. But the most
@@ -420,17 +428,19 @@ void toQO::append_ovlpR_eiRk(int ik, int iR)
420428 ModuleBase::libm::sincos (arg, &sinp, &cosp);
421429 std::complex <double > phase = std::complex <double >(cosp, sinp);
422430 // add all values of ovlpR_ to ovlpk_ with multiplication of phase
423- for (int i = 0 ; i < nchi_ * nphi_; i++)
431+ for (int i = 0 ; i < nchi_ * nphi_; i++) {
424432 ovlpk_[i] += ovlpR_[i] * phase;
425433}
434+ }
426435
427436void toQO::allocate_ovlp (const bool & is_R)
428437{
429- if (is_R)
438+ if (is_R) {
430439 ovlpR_.resize (nchi_ * nphi_, 0.0 );
431- else
440+ } else {
432441 ovlpk_.resize (nchi_ * nphi_, std::complex <double >(0.0 , 0.0 ));
433442}
443+ }
434444
435445void toQO::deallocate_ovlp (const bool & is_R)
436446{
@@ -448,11 +458,12 @@ void toQO::deallocate_ovlp(const bool& is_R)
448458
449459void toQO::zero_out_ovlps (const bool & is_R)
450460{
451- if (is_R)
461+ if (is_R) {
452462 std::fill (ovlpR_.begin (), ovlpR_.end (), 0.0 );
453- else
463+ } else {
454464 std::fill (ovlpk_.begin (), ovlpk_.end (), std::complex <double >(0.0 , 0.0 ));
455465}
466+ }
456467
457468void toQO::radialcollection_indexing (const RadialCollection& radcol,
458469 const std::vector<int >& natoms,
@@ -475,15 +486,17 @@ void toQO::radialcollection_indexing(const RadialCollection& radcol,
475486 for (int m_abs = 0 ; m_abs <= l; m_abs++)
476487 {
477488 ms.push_back (m_abs);
478- if (m_abs != 0 )
489+ if (m_abs != 0 ) {
479490 ms.push_back (-m_abs);
491+ }
480492 }
481493 for (int izeta = 0 ; izeta < radcol.nzeta (itype, l); izeta++)
482494 {
483495 // usually, the orbital is distinguished by it, l and zeta, the ia and m are not
484496 // commonly used.
485- if (orbital_filter_out (itype, l, izeta) && with_filter)
497+ if (orbital_filter_out (itype, l, izeta) && with_filter) {
486498 continue ;
499+ }
487500 for (int m: ms)
488501 {
489502 index_map[std::make_tuple (itype, iatom, l, izeta, m)] = index;
@@ -554,12 +567,14 @@ std::complex<double> str2complex(const std::string& str)
554567{
555568 std::string real_str, imag_str;
556569 int i = 1 ; // skip '('
557- while (str[i] != ' ,' )
570+ while (str[i] != ' ,' ) {
558571 real_str += str[i];
572+ }
559573 i++;
560574 i++; // skip ','
561- while (str[i] != ' )' )
575+ while (str[i] != ' )' ) {
562576 imag_str += str[i];
577+ }
563578 i++;
564579 return std::complex <double >(std::stod (real_str), std::stod (imag_str));
565580}
@@ -586,20 +601,22 @@ void toQO::read_ovlp(const std::string& dir, const int& nrows, const int& ncols,
586601 double val;
587602 ifs >> val;
588603 inum++;
589- if (inum <= nchi_ * nphi_)
604+ if (inum <= nchi_ * nphi_) {
590605 ovlpR_[inum - 1 ] = val;
591- else
606+ } else {
592607 break ;
608+ }
593609 }
594610 else
595611 {
596612 std::string val_str;
597613 ifs >> val_str;
598614 inum++;
599- if (inum <= nchi_ * nphi_)
615+ if (inum <= nchi_ * nphi_) {
600616 ovlpk_[inum - 1 ] = str2complex (val_str);
601- else
617+ } else {
602618 break ;
619+ }
603620 }
604621 }
605622}
0 commit comments