@@ -131,14 +131,7 @@ void IState_Charge::begin(Gint_Gamma& gg,
131131 // Use a const vector to store efermi for all spins, replace the original implementation:
132132 // const double ef_tmp = pelec->eferm.get_efval(is);
133133 double ef_spin = ef_all_spin[is];
134- ModuleIO::write_vdata_palgrid (pgrid,
135- rho_save[is].data (),
136- is,
137- nspin,
138- 0 ,
139- ssc.str (),
140- ef_spin,
141- ucell_in);
134+ ModuleIO::write_vdata_palgrid (pgrid, rho_save[is].data (), is, nspin, 0 , ssc.str (), ef_spin, ucell_in);
142135 }
143136
144137 std::cout << " Complete!" << std::endl;
@@ -212,8 +205,11 @@ void IState_Charge::begin(Gint_k& gk,
212205 if (bands_picked_[ib])
213206 {
214207 // Using new density matrix inplementation (multi-k)
215- const int nspin_dm = std::map<int , int >({ {1 ,1 },{2 ,2 },{4 ,1 } })[nspin];
216- elecstate::DensityMatrix<std::complex <double >, double > DM (this ->ParaV , nspin_dm, kv.kvec_d , kv.get_nks () / nspin_dm);
208+ const int nspin_dm = std::map<int , int >({{1 , 1 }, {2 , 2 }, {4 , 1 }})[nspin];
209+ elecstate::DensityMatrix<std::complex <double >, double > DM (this ->ParaV ,
210+ nspin_dm,
211+ kv.kvec_d ,
212+ kv.get_nks () / nspin_dm);
217213
218214#ifdef __MPI
219215 this ->idmatrix (ib, nspin, nelec, nlocal, wg, DM, kv, if_separate_k);
@@ -259,13 +255,13 @@ void IState_Charge::begin(Gint_k& gk,
259255
260256 double ef_spin = ef_all_spin[is];
261257 ModuleIO::write_vdata_palgrid (pgrid,
262- rho_save[is].data (),
263- is,
264- nspin,
265- 0 ,
266- ssc.str (),
267- ef_spin,
268- ucell_in);
258+ rho_save[is].data (),
259+ is,
260+ nspin,
261+ 0 ,
262+ ssc.str (),
263+ ef_spin,
264+ ucell_in);
269265 }
270266
271267 std::cout << " Complete!" << std::endl;
@@ -318,13 +314,13 @@ void IState_Charge::begin(Gint_k& gk,
318314
319315 double ef_spin = ef_all_spin[is];
320316 ModuleIO::write_vdata_palgrid (pgrid,
321- rho_save[is].data (),
322- is,
323- nspin,
324- 0 ,
325- ssc.str (),
326- ef_spin,
327- ucell_in);
317+ rho_save[is].data (),
318+ is,
319+ nspin,
320+ 0 ,
321+ ssc.str (),
322+ ef_spin,
323+ ucell_in);
328324 }
329325
330326 std::cout << " Complete!" << std::endl;
@@ -480,7 +476,7 @@ void IState_Charge::idmatrix(const int& ib,
480476 this ->psi_gamma ->fix_k (is);
481477
482478 // psi::Psi<double> wg_wfc(*this->psi_gamma, 1, this->psi_gamma->get_nbands());
483- psi::Psi<double > wg_wfc (1 ,
479+ psi::Psi<double > wg_wfc (1 ,
484480 this ->psi_gamma ->get_nbands (),
485481 this ->psi_gamma ->get_nbasis (),
486482 this ->psi_gamma ->get_nbasis (),
@@ -547,12 +543,13 @@ void IState_Charge::idmatrix(const int& ib,
547543 }
548544
549545 this ->psi_k ->fix_k (ik);
550-
551- psi::Psi<std::complex <double >> wg_wfc (1 ,
552- this ->psi_k ->get_nbands (),
546+
547+ psi::Psi<std::complex <double >> wg_wfc (1 ,
548+ this ->psi_k ->get_nbands (),
553549 this ->psi_k ->get_nbasis (),
554550 this ->psi_k ->get_nbasis (),
555551 true );
552+ wg_wfc.set_all_psi (this ->psi_k ->get_pointer (), wg_wfc.size ());
556553
557554 for (int ir = 0 ; ir < wg_wfc.get_nbands (); ++ir)
558555 {
0 commit comments