Skip to content

Commit 8896f65

Browse files
committed
Fix: UT for ElecStatePW
1 parent 562c522 commit 8896f65

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

source/module_elecstate/test/updaterhok_pw_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MockElecStatePW : public ElecStatePW
5252
/******************************
5353
* read wavefunction
5454
******************************/
55-
void read_wfc2(const std::string& fn, ModuleBase::ComplexMatrix* psi, ModuleBase::Vector3<double>* gkk)
55+
void read_wfc2(const std::string& fn, psi::Psi<std::complex<double>> &psi, ModuleBase::Vector3<double>* gkk)
5656
{
5757
std::string* wfilename;
5858
wfilename = new std::string[GlobalC::kv.nkstot];
@@ -94,7 +94,7 @@ void read_wfc2(const std::string& fn, ModuleBase::ComplexMatrix* psi, ModuleBase
9494
double realpart;
9595
double imagpart;
9696
ifs >> realpart >> imagpart;
97-
psi[ik](ib, ig) = std::complex<double>(realpart, imagpart);
97+
psi(ik, ib, ig) = std::complex<double>(realpart, imagpart);
9898
}
9999
getline(ifs, tmpstring);
100100
getline(ifs, tmpstring);
@@ -307,7 +307,7 @@ TEST_F(EState,RhoPW)
307307
std::stringstream ssw;
308308
ssw <<GlobalV::global_out_dir<< "WAVEFUNC";
309309
// we need to supply out_wfc_pw here
310-
read_wfc2(ssw.str(), GlobalC::wf.evc, GlobalC::pw.gcar);
310+
read_wfc2(ssw.str(), GlobalC::wf.psi[0], GlobalC::pw.gcar);
311311

312312
// copy data from old wf.evc to new evc(an object of Psi)
313313
evc.resize(GlobalC::kv.nks,GlobalV::NBANDS,GlobalC::wf.npwx);
@@ -316,7 +316,7 @@ TEST_F(EState,RhoPW)
316316
{
317317
for(int j=0;j<GlobalC::wf.npwx;j++)
318318
{
319-
evc(i,j)=GlobalC::wf.evc[0](i,j);
319+
evc(i,j)=GlobalC::wf.psi[0](i,j);
320320
}
321321
}
322322
// using class ElecStatePW to calculate rho

source/module_elecstate/test/updaterhok_pw_test.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,11 @@ void wavefunc::allocate(const int nks)
136136
{
137137
this->npwx = GlobalC::pw.setupIndGk(this->igk, GlobalC::kv.ngk);
138138
this->wg.create(nks,GlobalV::NBANDS);
139-
this->evc=new ModuleBase::ComplexMatrix[nks];
140139
this->ekb = new double*[nks];
140+
this->psi = new psi::Psi<std::complex<double>>(nks, GlobalV::NBANDS,npwx, nullptr);
141141
for (int ik=0;ik<nks;ik++)
142142
{
143143
this->ekb[ik] = new double[GlobalV::NBANDS];
144-
this->evc[ik].create(GlobalV::NBANDS,npwx);
145144
}
146145
return;
147146
}

0 commit comments

Comments
 (0)