11#include " get_wf_lcao.h"
22
3- #include " module_parameter/parameter.h"
43#include " module_base/global_function.h"
54#include " module_base/global_variable.h"
65#include " module_base/memory.h"
98#include " module_io/cube_io.h"
109#include " module_io/write_wfc_pw.h"
1110#include " module_io/write_wfc_r.h"
11+ #include " module_parameter/parameter.h"
1212IState_Envelope::IState_Envelope (const elecstate::ElecState* pes)
1313{
1414 pes_ = pes;
@@ -124,13 +124,13 @@ void IState_Envelope::begin(const UnitCell& ucell,
124124
125125 const double ef_tmp = this ->pes_ ->eferm .get_efval (is);
126126 ModuleIO::write_vdata_palgrid (pgrid,
127- pes_->charge ->rho_save [is],
128- is,
129- nspin,
130- 0 ,
131- ss.str (),
132- ef_tmp,
133- &(ucell));
127+ pes_->charge ->rho_save [is],
128+ is,
129+ nspin,
130+ 0 ,
131+ ss.str (),
132+ ef_tmp,
133+ &(ucell));
134134 }
135135 }
136136 }
@@ -150,81 +150,84 @@ void IState_Envelope::begin(const UnitCell& ucell,
150150 // Set this->bands_picked_ according to the mode
151151 select_bands (nbands_istate, out_wfc_re_im, nbands, nelec, mode_re_im, fermi_band);
152152
153- // Calculate out_wfc_re_im
154- for (int ib = 0 ; ib < nbands; ++ib)
153+ if (out_wfc_pw || out_wfc_r)
155154 {
156- if (bands_picked_[ib])
155+ // Calculate out_wfc_re_im
156+ for (int ib = 0 ; ib < nbands; ++ib)
157157 {
158- std::cout << " Performing grid integral over real space grid for band " << ib + 1 << " ..." << std::endl;
159-
160- for (int is = 0 ; is < nspin; ++is)
158+ if (bands_picked_[ib])
161159 {
162- ModuleBase::GlobalFunc::ZEROS (pes_-> charge -> rho [is], pw_wfc-> nrxx ) ;
160+ std::cout << " Performing grid integral over real space grid for band " << ib + 1 << " ... " << std::endl ;
163161
164- psid->fix_k (is);
162+ for (int is = 0 ; is < nspin; ++is)
163+ {
164+ ModuleBase::GlobalFunc::ZEROS (pes_->charge ->rho [is], pw_wfc->nrxx );
165+
166+ psid->fix_k (is);
165167#ifdef __MPI
166- wfc_2d_to_grid (psid->get_pointer (), para_orb, wfc_gamma_grid[is], gg.gridt ->trace_lo );
168+ wfc_2d_to_grid (psid->get_pointer (), para_orb, wfc_gamma_grid[is], gg.gridt ->trace_lo );
167169#else
168- // if not MPI enabled, it is the case psid holds a global matrix. use fix_k to switch between different
169- // spin channels (actually kpoints, because now the same kpoint in different spin channels are treated
170- // as distinct kpoints)
170+ // if not MPI enabled, it is the case psid holds a global matrix. use fix_k to switch between
171+ // different spin channels (actually kpoints, because now the same kpoint in different spin channels
172+ // are treated as distinct kpoints)
171173
172- for (int i = 0 ; i < nbands; ++i)
173- {
174- for (int j = 0 ; j < nlocal; ++j)
174+ for (int i = 0 ; i < nbands; ++i)
175175 {
176- wfc_gamma_grid[is][i][j] = psid[0 ](i, j);
176+ for (int j = 0 ; j < nlocal; ++j)
177+ {
178+ wfc_gamma_grid[is][i][j] = psid[0 ](i, j);
179+ }
177180 }
178- }
179181#endif
180182
181- gg.cal_env (wfc_gamma_grid[is][ib], pes_->charge ->rho [is], ucell);
183+ gg.cal_env (wfc_gamma_grid[is][ib], pes_->charge ->rho [is], ucell);
182184
183- pes_->charge ->save_rho_before_sum_band ();
185+ pes_->charge ->save_rho_before_sum_band ();
184186
185- const double ef_tmp = this ->pes_ ->eferm .get_efval (is);
187+ const double ef_tmp = this ->pes_ ->eferm .get_efval (is);
186188
187- // only for gamma_only now
188- psi_g.fix_k (is);
189- this ->set_pw_wfc (pw_wfc, is, ib, nspin, pes_->charge ->rho , psi_g);
189+ // only for gamma_only now
190+ psi_g.fix_k (is);
191+ this ->set_pw_wfc (pw_wfc, is, ib, nspin, pes_->charge ->rho , psi_g);
190192
191- // Calculate real-space wave functions
192- psi_g.fix_k (is);
193- std::vector<std::complex <double >> wfc_r (pw_wfc->nrxx );
194- pw_wfc->recip2real (&psi_g (ib, 0 ), wfc_r.data (), is);
193+ // Calculate real-space wave functions
194+ psi_g.fix_k (is);
195+ std::vector<std::complex <double >> wfc_r (pw_wfc->nrxx );
196+ pw_wfc->recip2real (&psi_g (ib, 0 ), wfc_r.data (), is);
195197
196- // Extract real and imaginary parts
197- std::vector<double > wfc_real (pw_wfc->nrxx );
198- std::vector<double > wfc_imag (pw_wfc->nrxx );
199- for (int ir = 0 ; ir < pw_wfc->nrxx ; ++ir)
200- {
201- wfc_real[ir] = wfc_r[ir].real ();
202- wfc_imag[ir] = wfc_r[ir].imag ();
203- }
198+ // Extract real and imaginary parts
199+ std::vector<double > wfc_real (pw_wfc->nrxx );
200+ std::vector<double > wfc_imag (pw_wfc->nrxx );
201+ for (int ir = 0 ; ir < pw_wfc->nrxx ; ++ir)
202+ {
203+ wfc_real[ir] = wfc_r[ir].real ();
204+ wfc_imag[ir] = wfc_r[ir].imag ();
205+ }
204206
205- // Output real part
206- std::stringstream ss_real;
207- ss_real << global_out_dir << " BAND" << ib + 1 << " _GAMMA" << " _SPIN" << is + 1 << " _REAL.cube" ;
208- ModuleIO::write_vdata_palgrid (pgrid,
209- wfc_real.data (),
210- is,
211- nspin,
212- 0 ,
213- ss_real.str (),
214- ef_tmp,
215- &(ucell));
216-
217- // Output imaginary part
218- std::stringstream ss_imag;
219- ss_imag << global_out_dir << " BAND" << ib + 1 << " _GAMMA" << " _SPIN" << is + 1 << " _IMAG.cube" ;
220- ModuleIO::write_vdata_palgrid (pgrid,
221- wfc_imag.data (),
222- is,
223- nspin,
224- 0 ,
225- ss_imag.str (),
226- ef_tmp,
227- &(ucell));
207+ // Output real part
208+ std::stringstream ss_real;
209+ ss_real << global_out_dir << " BAND" << ib + 1 << " _GAMMA" << " _SPIN" << is + 1 << " _REAL.cube" ;
210+ ModuleIO::write_vdata_palgrid (pgrid,
211+ wfc_real.data (),
212+ is,
213+ nspin,
214+ 0 ,
215+ ss_real.str (),
216+ ef_tmp,
217+ &(ucell));
218+
219+ // Output imaginary part
220+ std::stringstream ss_imag;
221+ ss_imag << global_out_dir << " BAND" << ib + 1 << " _GAMMA" << " _SPIN" << is + 1 << " _IMAG.cube" ;
222+ ModuleIO::write_vdata_palgrid (pgrid,
223+ wfc_imag.data (),
224+ is,
225+ nspin,
226+ 0 ,
227+ ss_imag.str (),
228+ ef_tmp,
229+ &(ucell));
230+ }
228231 }
229232 }
230233 }
@@ -240,7 +243,7 @@ void IState_Envelope::begin(const UnitCell& ucell,
240243
241244 if (out_wfc_r)
242245 {
243- ModuleIO::write_psi_r_1 (ucell,psi_g, pw_wfc, " wfc_realspace" , false , kv);
246+ ModuleIO::write_psi_r_1 (ucell, psi_g, pw_wfc, " wfc_realspace" , false , kv);
244247 }
245248
246249 for (int is = 0 ; is < nspin; ++is)
@@ -359,15 +362,15 @@ void IState_Envelope::begin(const UnitCell& ucell,
359362 const double ef_tmp = this ->pes_ ->eferm .get_efval (ispin);
360363
361364 ModuleIO::write_vdata_palgrid (pgrid,
362- pes_->charge ->rho [ispin],
363- ispin,
364- nspin,
365- 0 ,
366- ss.str (),
367- ef_tmp,
368- &(ucell),
369- 3 ,
370- 1 );
365+ pes_->charge ->rho [ispin],
366+ ispin,
367+ nspin,
368+ 0 ,
369+ ss.str (),
370+ ef_tmp,
371+ &(ucell),
372+ 3 ,
373+ 1 );
371374
372375 if (out_wf || out_wf_r)
373376 {
@@ -390,7 +393,7 @@ void IState_Envelope::begin(const UnitCell& ucell,
390393 }
391394 if (out_wf_r)
392395 {
393- ModuleIO::write_psi_r_1 (ucell,psi_g, pw_wfc, " wfc_realspace" , false , kv);
396+ ModuleIO::write_psi_r_1 (ucell, psi_g, pw_wfc, " wfc_realspace" , false , kv);
394397 }
395398
396399 std::cout << " Outputting real-space wave functions in cube format..." << std::endl;
@@ -427,26 +430,26 @@ void IState_Envelope::begin(const UnitCell& ucell,
427430 << " _REAL.cube" ;
428431 const double ef_tmp = this ->pes_ ->eferm .get_efval (ispin);
429432 ModuleIO::write_vdata_palgrid (pgrid,
430- wfc_real.data (),
431- ispin,
432- nspin,
433- 0 ,
434- ss_real.str (),
435- ef_tmp,
436- &(ucell));
433+ wfc_real.data (),
434+ ispin,
435+ nspin,
436+ 0 ,
437+ ss_real.str (),
438+ ef_tmp,
439+ &(ucell));
437440
438441 // Output imaginary part
439442 std::stringstream ss_imag;
440443 ss_imag << global_out_dir << " BAND" << ib + 1 << " _k_" << ik + 1 << " _s_" << ispin + 1
441444 << " _IMAG.cube" ;
442445 ModuleIO::write_vdata_palgrid (pgrid,
443- wfc_imag.data (),
444- ispin,
445- nspin,
446- 0 ,
447- ss_imag.str (),
448- ef_tmp,
449- &(ucell));
446+ wfc_imag.data (),
447+ ispin,
448+ nspin,
449+ 0 ,
450+ ss_imag.str (),
451+ ef_tmp,
452+ &(ucell));
450453 }
451454 }
452455 }
0 commit comments