|
8 | 8 | namespace elecstate |
9 | 9 | { |
10 | 10 | int ElecStateLCAO::out_wfc_lcao = 0; |
| 11 | +bool ElecStateLCAO::need_psi_grid = 1; |
11 | 12 |
|
12 | 13 | // multi-k case |
13 | 14 | void ElecStateLCAO::psiToRho(const psi::Psi<std::complex<double>>& psi) |
@@ -38,25 +39,7 @@ void ElecStateLCAO::psiToRho(const psi::Psi<std::complex<double>>& psi) |
38 | 39 | for (int ik = 0; ik < psi.get_nk(); ik++) |
39 | 40 | { |
40 | 41 | psi.fix_k(ik); |
41 | | - this->lowf->wfc_2d_to_grid(ElecStateLCAO::out_wfc_lcao, psi.get_pointer(), this->lowf->wfc_k_grid[ik], ik, this->ekb, this->wg); |
42 | | - //added by zhengdy-soc, rearrange the wfc_k_grid from [up,down,up,down...] to [up,up...down,down...], |
43 | | - if(GlobalV::NSPIN==4) |
44 | | - { |
45 | | - int row = GlobalC::GridT.lgd; |
46 | | - std::vector<std::complex<double>> tmp(row); |
47 | | - for(int ib=0; ib<GlobalV::NBANDS; ib++) |
48 | | - { |
49 | | - for(int iw=0; iw<row / GlobalV::NPOL; iw++) |
50 | | - { |
51 | | - tmp[iw] = this->lowf->wfc_k_grid[ik][ib][iw * GlobalV::NPOL]; |
52 | | - tmp[iw + row / GlobalV::NPOL] = this->lowf->wfc_k_grid[ik][ib][iw * GlobalV::NPOL + 1]; |
53 | | - } |
54 | | - for(int iw=0; iw<row; iw++) |
55 | | - { |
56 | | - this->lowf->wfc_k_grid[ik][ib][iw] = tmp[iw]; |
57 | | - } |
58 | | - } |
59 | | - } |
| 42 | + this->print_psi(psi); |
60 | 43 | } |
61 | 44 | } |
62 | 45 |
|
@@ -112,8 +95,7 @@ void ElecStateLCAO::psiToRho(const psi::Psi<double>& psi) |
112 | 95 | if (GlobalV::KS_SOLVER == "genelpa" || GlobalV::KS_SOLVER == "scalapack_gvx") |
113 | 96 | { |
114 | 97 | psi.fix_k(ik); |
115 | | - double** wfc_grid = nullptr; // output but not do "2d-to-grid" conversion |
116 | | - this->lowf->wfc_2d_to_grid(ElecStateLCAO::out_wfc_lcao, psi.get_pointer(), wfc_grid, this->ekb, this->wg); |
| 98 | + this->print_psi(psi); |
117 | 99 | } |
118 | 100 | //this->loc->dm2dToGrid(this->loc->dm_gamma[ik], this->loc->DM[ik]); // transform dm_gamma[is].c to this->loc->DM[is] |
119 | 101 | this->loc->cal_dk_gamma_from_2D_pub(); |
@@ -158,11 +140,36 @@ void ElecStateLCAO::print_psi(const psi::Psi<double>& psi_in) |
158 | 140 | } |
159 | 141 | void ElecStateLCAO::print_psi(const psi::Psi<std::complex<double>>& psi_in) |
160 | 142 | { |
161 | | - if(!ElecStateLCAO::out_wfc_lcao) return; |
| 143 | + if(!ElecStateLCAO::out_wfc_lcao && !ElecStateLCAO::need_psi_grid) return; |
162 | 144 |
|
163 | 145 | // output but not do "2d-to-grid" conversion |
164 | | - std::complex<double>** wfc_grid = nullptr; |
165 | | - this->lowf->wfc_2d_to_grid(ElecStateLCAO::out_wfc_lcao, psi_in.get_pointer(), wfc_grid, psi_in.get_current_k(), this->ekb, this->wg); |
| 146 | + std::complex<double>** wfc_grid = nullptr; |
| 147 | + int ik = psi_in.get_current_k(); |
| 148 | + if(ElecStateLCAO::need_psi_grid) |
| 149 | + { |
| 150 | + wfc_grid = this->lowf->wfc_k_grid[ik]; |
| 151 | + } |
| 152 | + this->lowf->wfc_2d_to_grid(ElecStateLCAO::out_wfc_lcao, psi_in.get_pointer(), wfc_grid, ik, this->ekb, this->wg); |
| 153 | + |
| 154 | + //added by zhengdy-soc, rearrange the wfc_k_grid from [up,down,up,down...] to [up,up...down,down...], |
| 155 | + if(ElecStateLCAO::need_psi_grid && GlobalV::NSPIN==4) |
| 156 | + { |
| 157 | + int row = GlobalC::GridT.lgd; |
| 158 | + std::vector<std::complex<double>> tmp(row); |
| 159 | + for(int ib=0; ib<GlobalV::NBANDS; ib++) |
| 160 | + { |
| 161 | + for(int iw=0; iw<row / GlobalV::NPOL; iw++) |
| 162 | + { |
| 163 | + tmp[iw] = this->lowf->wfc_k_grid[ik][ib][iw * GlobalV::NPOL]; |
| 164 | + tmp[iw + row / GlobalV::NPOL] = this->lowf->wfc_k_grid[ik][ib][iw * GlobalV::NPOL + 1]; |
| 165 | + } |
| 166 | + for(int iw=0; iw<row; iw++) |
| 167 | + { |
| 168 | + this->lowf->wfc_k_grid[ik][ib][iw] = tmp[iw]; |
| 169 | + } |
| 170 | + } |
| 171 | + } |
| 172 | + |
166 | 173 | return; |
167 | 174 | } |
168 | 175 |
|
|
0 commit comments