Skip to content

Commit a5cf8aa

Browse files
committed
update the readin wave function information
1 parent dcbeb06 commit a5cf8aa

File tree

10 files changed

+58
-29
lines changed

10 files changed

+58
-29
lines changed

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
247247
const K_Vectors* kv = reinterpret_cast<const K_Vectors*>(klist);
248248
const int nkstot = kv->get_nkstot();
249249
const std::vector<int>& isk = kv->isk;
250-
ModuleIO::read_wf2rho_pw(pw_wfc, symm, kv->ik2iktot.data(), nkstot, isk, *this);
250+
ModuleIO::read_wf2rho_pw(pw_wfc, symm, kv->ik2iktot,
251+
nkstot, isk, *this, GlobalV::ofs_running);
251252
}
252253
}
253254

source/module_esolver/esolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ std::string determine_type()
9696
ModuleBase::WARNING_QUIT("ESolver", "No such esolver_type combined with basis_type");
9797
}
9898

99-
GlobalV::ofs_running << "\n The esolver type: " << esolver_type << std::endl;
99+
GlobalV::ofs_running << "\n Energy Solver:" << esolver_type << std::endl;
100100

101101
auto device_info = PARAM.inp.device;
102102

source/module_esolver/esolver_ks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
5858
ESolver_FP::before_all_runners(ucell, inp);
5959

6060
classname = "ESolver_KS";
61-
basisname = "PLEASE ADD BASISNAME FOR CURRENT ESOLVER.";
61+
basisname = "";
6262

6363
scf_thr = PARAM.inp.scf_thr;
6464
scf_ene_thr = PARAM.inp.scf_ene_thr;

source/module_io/cal_dos.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ void ModuleIO::prepare_dos(std::ofstream& ofs_running,
1717
double &emin)
1818
{
1919
ofs_running << " DOS CALCULATIONS BEGINS" << std::endl;
20-
2120
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
2221
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
2322
ofs_running << " | "

source/module_io/read_wf2rho_pw.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,27 @@
99

1010
void ModuleIO::read_wf2rho_pw(const ModulePW::PW_Basis_K* pw_wfc,
1111
ModuleSymmetry::Symmetry& symm,
12-
const int* ik2iktot,
12+
const std::vector<int> &ik2iktot,
1313
const int nkstot,
14-
const std::vector<int>& isk,
15-
Charge& chg)
14+
const std::vector<int> &isk,
15+
Charge& chg,
16+
std::ofstream &ofs_running)
1617
{
1718
ModuleBase::TITLE("ModuleIO", "read_wf2rho_pw");
1819
ModuleBase::timer::tick("ModuleIO", "read_wf2rho_pw");
1920

21+
ofs_running << " READING WAVE FUNCTIONS" << std::endl;
22+
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
23+
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
24+
ofs_running << " | "
25+
" |" << std::endl;
26+
ofs_running << " | Reading electronic wave functions in plane wave basis set and |" << std::endl;
27+
ofs_running << " | evaluate charge density based on these wave functions |" << std::endl;
28+
ofs_running << " | "
29+
" |" << std::endl;
30+
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
31+
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
32+
2033
const int kpar = GlobalV::KPAR;
2134
const int my_pool = GlobalV::MY_POOL;
2235
const int my_rank = GlobalV::MY_RANK;
@@ -39,8 +52,20 @@ void ModuleIO::read_wf2rho_pw(const ModulePW::PW_Basis_K* pw_wfc,
3952
{
4053
std::string filename = PARAM.globalv.global_readin_dir + "istate.info";
4154
std::ifstream ifs(filename);
55+
56+
if(!ifs)
57+
{
58+
std::stringstream sss;
59+
sss << "Cannot find file " << filename;
60+
ModuleBase::WARNING_QUIT("ModuleIO::read_wf2rho_pw", sss.str());
61+
}
62+
else
63+
{
64+
ofs_running << " Find file containing weights of wave function: " << filename << std::endl;
65+
}
66+
4267
std::string useless;
43-
if (PARAM.inp.nspin == 2)
68+
if (nspin == 2)
4469
{
4570
const int nkstot_np = nkstot / 2;
4671
for (int iktot_np = 0; iktot_np < nkstot_np; ++iktot_np)
@@ -82,7 +107,7 @@ void ModuleIO::read_wf2rho_pw(const ModulePW::PW_Basis_K* pw_wfc,
82107
const int ikstot = ik2iktot[ik];
83108
filename << PARAM.globalv.global_readin_dir << "WAVEFUNC" << ikstot + 1 << ".dat";
84109
ModuleIO::read_wfc_pw(filename.str(), pw_wfc, ik, ikstot, nkstot, wfc_tmp);
85-
if (PARAM.inp.nspin == 4)
110+
if (nspin == 4)
86111
{
87112
std::vector<std::complex<double>> rho_tmp2(nrxx);
88113
for (int ib = 0; ib < nbands; ++ib)

source/module_io/read_wf2rho_pw.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "module_elecstate/module_charge/charge.h"
66

77
#include <string>
8+
#include <fstream>
89

910
namespace ModuleIO
1011
{
@@ -19,10 +20,11 @@ namespace ModuleIO
1920
*/
2021
void read_wf2rho_pw(const ModulePW::PW_Basis_K* pw_wfc,
2122
ModuleSymmetry::Symmetry& symm,
22-
const int* ik2iktot,
23+
const std::vector<int> &ik2iktot,
2324
const int nkstot,
24-
const std::vector<int>& isk,
25-
Charge& chg);
25+
const std::vector<int> &isk,
26+
Charge& chg,
27+
std::ofstream &ofs_running);
2628

2729
} // namespace ModuleIO
2830

source/module_io/test/read_wf2rho_pw_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ TEST_F(ReadWfcRhoTest, ReadWfcRho)
222222
ModuleIO::write_wfc_pw("WAVEFUNC", *psi, *kv, wfcpw);
223223

224224
// Read the wave functions to charge density
225-
ModuleIO::read_wf2rho_pw(wfcpw, symm, kv->ik2iktot.data(), nkstot, kv->isk, chg);
225+
std::ofstream running_log("running_log.txt");
226+
ModuleIO::read_wf2rho_pw(wfcpw, symm, kv->ik2iktot, nkstot, kv->isk, chg, running_log);
226227

227228
// compare the charge density
228229
for (int ir = 0; ir < rhopw->nrxx; ++ir)
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
INPUT_PARAMETERS
2-
#Parameters (General)
3-
suffix autotest
4-
pseudo_dir ../../PP_ORB
5-
2+
# general commands
63
calculation scf
7-
4+
#noncolin 1
5+
lspinorb 1
86
gamma_only 0
97
symmetry 0
108

11-
#out_wfc_pw 2
9+
# directories to read wave functions
10+
suffix autotest
11+
pseudo_dir ../../PP_ORB
12+
read_file_dir ./
13+
#out_wfc_pw 2
1214
init_chg wfc
1315
init_wfc file
1416

15-
smearing_method gaussian
16-
smearing_sigma 0.001
17-
18-
ecutwfc 20
19-
scf_thr 1e-6
20-
scf_nmax 2
21-
22-
#noncolin 1
23-
lspinorb 1
24-
17+
# plane wave basis and scf
2518
basis_type pw
19+
ecutwfc 20
20+
scf_thr 1e-6
21+
scf_nmax 2
2622
ks_solver dav
2723
pw_diag_thr 0.00001
2824

25+
# charge mixing
2926
mixing_type broyden
3027
mixing_beta 0.4
3128
mixing_gg0 1.5
29+
30+
# smearing method
31+
smearing_method gaussian
32+
smearing_sigma 0.001

0 commit comments

Comments
 (0)