11#include " elecstate.h"
2- # include " src_pw/occupy.h "
2+
33#include " module_base/global_variable.h"
44#include " module_base/tool_title.h"
5- #include " src_pw/global.h"
65#include " src_parallel/parallel_reduce.h"
6+ #include " src_pw/global.h"
7+ #include " src_pw/occupy.h"
78
89namespace elecstate
910{
1011
1112const double * ElecState::getRho (int spin) const
1213{
13- // hamilt::MatrixBlock<double> temp{&(this->charge->rho[spin][0]), 1, this->charge->nrxx}; // this->chr->get_nspin(), this->chr->get_nrxx()};
14+ // hamilt::MatrixBlock<double> temp{&(this->charge->rho[spin][0]), 1, this->charge->nrxx}; //
15+ // this->chr->get_nspin(), this->chr->get_nrxx()};
1416 return &(this ->charge ->rho [spin][0 ]);
1517}
1618
@@ -23,7 +25,7 @@ void ElecState::calculate_weights(void)
2325 // std::cout << " tetrahedron_method = " << use_tetrahedron_method << std::endl;
2426 // std::cout << " fixed_occupations = " << fixed_occupations << std::endl;
2527 double ** ekb_tmp = new double *[this ->ekb .nr ];
26- for (int i= 0 ; i< this ->ekb .nr ; ++i)
28+ for (int i = 0 ; i < this ->ekb .nr ; ++i)
2729 {
2830 ekb_tmp[i] = &(this ->ekb (i, 0 ));
2931 }
@@ -40,37 +42,37 @@ void ElecState::calculate_weights(void)
4042 if (GlobalV::TWO_EFERMI)
4143 {
4244 Occupy::iweights (GlobalC::kv.nks ,
43- GlobalC::kv.wk ,
44- nbands,
45- GlobalC::ucell.magnet .get_nelup (),
46- ekb_tmp,
47- GlobalC::en.ef_up ,
48- this ->wg ,
49- 0 ,
50- GlobalC::kv.isk );
45+ GlobalC::kv.wk ,
46+ nbands,
47+ GlobalC::ucell.magnet .get_nelup (),
48+ ekb_tmp,
49+ GlobalC::en.ef_up ,
50+ this ->wg ,
51+ 0 ,
52+ GlobalC::kv.isk );
5153 Occupy::iweights (GlobalC::kv.nks ,
52- GlobalC::kv.wk ,
53- nbands,
54- GlobalC::ucell.magnet .get_neldw (),
55- ekb_tmp,
56- GlobalC::en.ef_dw ,
57- this ->wg ,
58- 1 ,
59- GlobalC::kv.isk );
54+ GlobalC::kv.wk ,
55+ nbands,
56+ GlobalC::ucell.magnet .get_neldw (),
57+ ekb_tmp,
58+ GlobalC::en.ef_dw ,
59+ this ->wg ,
60+ 1 ,
61+ GlobalC::kv.isk );
6062 // ef = ( ef_up + ef_dw ) / 2.0_dp need??? mohan add 2012-04-16
6163 }
6264 else
6365 {
6466 // -1 means don't need to consider spin.
6567 Occupy::iweights (GlobalC::kv.nks ,
66- GlobalC::kv.wk ,
67- nbands,
68- GlobalC::CHR.nelec ,
69- ekb_tmp,
70- this ->ef ,
71- this ->wg ,
72- -1 ,
73- GlobalC::kv.isk );
68+ GlobalC::kv.wk ,
69+ nbands,
70+ GlobalC::CHR.nelec ,
71+ ekb_tmp,
72+ this ->ef ,
73+ this ->wg ,
74+ -1 ,
75+ GlobalC::kv.isk );
7476 }
7577 }
7678 else if (Occupy::use_tetrahedron_method)
@@ -79,7 +81,7 @@ void ElecState::calculate_weights(void)
7981 // if(my_rank == 0)
8082 // {
8183 // tweights(GlobalC::kv.nkstot, nspin, nbands, GlobalC::CHR.nelec, ntetra,tetra, GlobalC::wf.et,
82- // this->ef, this->wg);
84+ // this->ef, this->wg);
8385 // }
8486 }
8587 else if (Occupy::use_gaussian_broadening)
@@ -188,63 +190,63 @@ void ElecState::calculate_weights(void)
188190
189191double ElecState::eBandK (const int & ik)
190192{
191- ModuleBase::TITLE (" ElecStatePW" ," eBandK" );
193+ ModuleBase::TITLE (" ElecStatePW" , " eBandK" );
192194 double eband_k = 0.0 ;
193- for (int ibnd = 0 ;ibnd < this ->ekb .nc ; ibnd++)
194- {
195+ for (int ibnd = 0 ; ibnd < this ->ekb .nc ; ibnd++)
196+ {
195197 eband_k += this ->ekb (ik, ibnd) * this ->wg (ik, ibnd);
196198 }
197199 return eband_k;
198200}
199201
200- void ElecState::print_band (const int & ik, const int & printe, const int & iter)
202+ void ElecState::print_band (const int & ik, const int & printe, const int & iter)
201203{
202- // check the band energy.
204+ // check the band energy.
203205 bool wrong = false ;
204206 int nbands = this ->ekb .nc ;
205- for (int ib=0 ; ib<nbands; ++ib)
206- {
207- if ( abs ( this ->ekb (ik, ib) ) > 1.0e10 )
208- {
209- GlobalV::ofs_warning << " ik=" << ik+1 << " ib=" << ib+1 << " " << this ->ekb (ik, ib) << " Ry" << std::endl;
210- wrong = true ;
211- }
212- }
213- if (wrong)
207+ for (int ib = 0 ; ib < nbands; ++ib)
214208 {
215- ModuleBase::WARNING_QUIT (" Threshold_Elec::print_eigenvalue" ," Eigenvalues are too large!" );
209+ if (abs (this ->ekb (ik, ib)) > 1.0e10 )
210+ {
211+ GlobalV::ofs_warning << " ik=" << ik + 1 << " ib=" << ib + 1 << " " << this ->ekb (ik, ib) << " Ry"
212+ << std::endl;
213+ wrong = true ;
214+ }
215+ }
216+ if (wrong)
217+ {
218+ ModuleBase::WARNING_QUIT (" Threshold_Elec::print_eigenvalue" , " Eigenvalues are too large!" );
216219 }
217220
218-
219-
220- if (GlobalV::MY_RANK==0 )
221- {
222- // if( GlobalV::DIAGO_TYPE == "selinv" ) xiaohui modify 2013-09-02
223- if (GlobalV::KS_SOLVER==" selinv" ) // xiaohui add 2013-09-02
224- {
225- GlobalV::ofs_running << " No eigenvalues are available for selected inversion methods." << std::endl;
226- }
227- else
228- {
229- if ( printe>0 && ((iter+1 ) % printe == 0 ))
230- {
231- // NEW_PART("ENERGY BANDS (Rydberg), (eV)");
232- GlobalV::ofs_running << std::setprecision (6 );
233- GlobalV::ofs_running << " Energy (eV) & Occupations for spin=" << GlobalV::CURRENT_SPIN+1 << " K-point=" << ik+1 << std::endl;
234- GlobalV::ofs_running << std::setiosflags (ios::showpoint);
235- for (int ib=0 ;ib<nbands;ib++)
236- {
237- GlobalV::ofs_running << " " << std::setw (6 ) << ib+1
238- << std::setw (15 ) << this ->ekb (ik, ib) * ModuleBase::Ry_to_eV;
239- // for the first electron iteration, we don't have the energy
240- // spectrum, so we can't get the occupations.
241- GlobalV::ofs_running << std::setw (15 ) << this ->wg (ik,ib);
242- GlobalV::ofs_running << std::endl;
243- }
244- }
245- }
246- }
247- return ;
221+ if (GlobalV::MY_RANK == 0 )
222+ {
223+ // if( GlobalV::DIAGO_TYPE == "selinv" ) xiaohui modify 2013-09-02
224+ if (GlobalV::KS_SOLVER == " selinv" ) // xiaohui add 2013-09-02
225+ {
226+ GlobalV::ofs_running << " No eigenvalues are available for selected inversion methods." << std::endl;
227+ }
228+ else
229+ {
230+ if (printe > 0 && ((iter + 1 ) % printe == 0 ))
231+ {
232+ // NEW_PART("ENERGY BANDS (Rydberg), (eV)");
233+ GlobalV::ofs_running << std::setprecision (6 );
234+ GlobalV::ofs_running << " Energy (eV) & Occupations for spin=" << GlobalV::CURRENT_SPIN + 1
235+ << " K-point=" << ik + 1 << std::endl;
236+ GlobalV::ofs_running << std::setiosflags (ios::showpoint);
237+ for (int ib = 0 ; ib < nbands; ib++)
238+ {
239+ GlobalV::ofs_running << " " << std::setw (6 ) << ib + 1 << std::setw (15 )
240+ << this ->ekb (ik, ib) * ModuleBase::Ry_to_eV;
241+ // for the first electron iteration, we don't have the energy
242+ // spectrum, so we can't get the occupations.
243+ GlobalV::ofs_running << std::setw (15 ) << this ->wg (ik, ib);
244+ GlobalV::ofs_running << std::endl;
245+ }
246+ }
247+ }
248+ }
249+ return ;
248250}
249251
250252} // namespace elecstate
0 commit comments