Skip to content

Commit cf6cd98

Browse files
committed
update pw readin wf, found 2 places that read in wave functions, need to be refactored in near future
1 parent 11e4bb4 commit cf6cd98

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

source/module_io/read_wf2rho_pw.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "module_elecstate/module_charge/symmetry_rho.h"
77
#include "module_parameter/parameter.h"
88
#include "module_elecstate/kernels/elecstate_op.h"
9+
#include "module_io/filename.h"
910

1011
void ModuleIO::read_wf2rho_pw(const ModulePW::PW_Basis_K* pw_wfc,
1112
ModuleSymmetry::Symmetry& symm,
@@ -103,10 +104,22 @@ void ModuleIO::read_wf2rho_pw(const ModulePW::PW_Basis_K* pw_wfc,
103104
{
104105
is = isk[ik];
105106
}
106-
std::stringstream filename;
107107
const int ikstot = ik2iktot[ik];
108-
filename << PARAM.globalv.global_readin_dir << "WAVEFUNC" << ikstot + 1 << ".dat";
109-
ModuleIO::read_wfc_pw(filename.str(), pw_wfc, ik, ikstot, nkstot, wfc_tmp);
108+
109+
// mohan add 2025-05-17
110+
// .dat file
111+
const int out_type = 2;
112+
const bool out_app_flag = false;
113+
const bool gamma_only = false;
114+
const int istep = -1;
115+
116+
std::string fn = filename_output(PARAM.globalv.global_readin_dir,"wf","pw",ik,ik2iktot,nspin,nkstot,
117+
out_type,out_app_flag,gamma_only,istep);
118+
119+
ofs_running << " Wave function file name is " << fn << std::endl;
120+
121+
ModuleIO::read_wfc_pw(fn, pw_wfc, ik, ikstot, nkstot, wfc_tmp);
122+
110123
if (nspin == 4)
111124
{
112125
std::vector<std::complex<double>> rho_tmp2(nrxx);
@@ -143,8 +156,9 @@ void ModuleIO::read_wf2rho_pw(const ModulePW::PW_Basis_K* pw_wfc,
143156

144157
if (w1 != 0.0)
145158
{
146-
base_device::DEVICE_CPU* ctx = nullptr;
147-
elecstate::elecstate_pw_op<double, base_device::DEVICE_CPU>()(ctx, is, nrxx, w1, chg.rho, rho_tmp.data());
159+
base_device::DEVICE_CPU* ctx = nullptr;
160+
elecstate::elecstate_pw_op<double, base_device::DEVICE_CPU>()(ctx, is, nrxx,
161+
w1, chg.rho, rho_tmp.data());
148162
}
149163
}
150164
}

source/module_io/read_wfc_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,4 @@ void ModuleIO::read_wfc_pw(const std::string& filename,
329329

330330
ModuleBase::timer::tick("ModuleIO", "read_wfc_pw");
331331
return;
332-
}
332+
}

source/module_psi/psi_initializer_file.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "module_base/timer.h"
44
#include "module_cell/klist.h"
55
#include "module_io/read_wfc_pw.h"
6+
#include "module_io/filename.h"
67
#include "module_parameter/parameter.h"
78
template <typename T>
89
void psi_initializer_file<T>::initialize(const Structure_Factor* sf,
@@ -29,7 +30,19 @@ void psi_initializer_file<T>::init_psig(T* psig, const int& ik)
2930
std::stringstream filename;
3031
int ik_tot = this->p_kv->ik2iktot[ik];
3132
filename << PARAM.globalv.global_readin_dir << "WAVEFUNC" << ik_tot + 1 << ".dat";
32-
ModuleIO::read_wfc_pw(filename.str(), this->pw_wfc_, ik, ik_tot, nkstot, wfcatom);
33+
34+
35+
// mohan update, this is for plane wave, 2025-05-17
36+
const int out_type = 2;
37+
const bool out_app_flag = false;
38+
const bool gamma_only = false;
39+
const int istep = -1;
40+
41+
std::string fn = ModuleIO::filename_output(PARAM.globalv.global_readin_dir,"wf","pw",
42+
ik,this->p_kv->ik2iktot,PARAM.inp.nspin,nkstot,
43+
out_type,out_app_flag,gamma_only,istep);
44+
45+
ModuleIO::read_wfc_pw(fn, this->pw_wfc_, ik, ik_tot, nkstot, wfcatom);
3346

3447
assert(this->nbands_start_ <= wfcatom.nr);
3548
for (int ib = 0; ib < this->nbands_start_; ib++)

tests/integrate/tools/catch_properties.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ fi
421421
# echo "$has_wfc_pw" ## test out_wfc_pw > 0
422422
#--------------------------------------------
423423
if ! test -z "$has_wfc_pw" && [ $has_wfc_pw == 1 ]; then
424-
if [[ ! -f OUT.autotest/WAVEFUNC1.txt ]];then
425-
echo "Can't find file OUT.autotest/WAVEFUNC1.txt"
424+
if [[ ! -f OUT.autotest/wfs1k1_pw.txt ]];then
425+
echo "Can't find file OUT.autotest/wfs1k1_pw.txt"
426426
exit 1
427427
fi
428428
awk 'BEGIN {max=0;read=0;band=1}
@@ -437,7 +437,7 @@ if ! test -z "$has_wfc_pw" && [ $has_wfc_pw == 1 ]; then
437437
if(sqrt($i*$i)>max) {max=sqrt($i*$i)}
438438
}
439439
}
440-
}' OUT.autotest/WAVEFUNC1.txt >> $1
440+
}' OUT.autotest/wfs1k1_pw.txt >> $1
441441
fi
442442

443443

0 commit comments

Comments
 (0)