Skip to content

Commit 11d9427

Browse files
committed
change setup_parameters to print_parameters
1 parent 3cc238d commit 11d9427

File tree

7 files changed

+53
-34
lines changed

7 files changed

+53
-34
lines changed

source/source_esolver/esolver_gets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& inp)
4343
this->kv.set(ucell, ucell.symm, inp.kpoint_file, inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running);
4444
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS");
4545

46-
ModuleIO::setup_parameters(ucell, this->kv);
46+
ModuleIO::print_parameters(ucell, this->kv, inp);
4747

4848
// 2) init ElecState
4949
// autoset nbands in ElecState, it should before basis_init (for Psi 2d division)

source/source_esolver/esolver_ks.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
5959
classname = "ESolver_KS";
6060
basisname = "";
6161

62-
scf_thr = inp.scf_thr;
63-
scf_ene_thr = inp.scf_ene_thr;
64-
maxniter = inp.scf_nmax;
65-
niter = maxniter;
66-
drho = 0.0;
62+
this->scf_thr = inp.scf_thr;
63+
this->scf_ene_thr = inp.scf_ene_thr;
64+
this->maxniter = inp.scf_nmax;
65+
this->niter = maxniter;
66+
this->drho = 0.0;
6767

6868
std::string fft_device = inp.device;
6969

@@ -82,8 +82,9 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
8282
#endif
8383

8484
pw_wfc = new ModulePW::PW_Basis_K_Big(fft_device, fft_precision);
85-
ModulePW::PW_Basis_K_Big* tmp = static_cast<ModulePW::PW_Basis_K_Big*>(pw_wfc);
8685

86+
// for LCAO calculations, we need to set bx, by, and bz
87+
ModulePW::PW_Basis_K_Big* tmp = static_cast<ModulePW::PW_Basis_K_Big*>(pw_wfc);
8788
tmp->setbxyz(inp.bx, inp.by, inp.bz);
8889

8990
//! 4) setup charge mixing
@@ -117,7 +118,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
117118
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS");
118119

119120
//! 9) print information
120-
ModuleIO::setup_parameters(ucell, this->kv);
121+
ModuleIO::print_parameters(ucell, this->kv, inp);
121122

122123
//! 10) setup plane wave for electronic wave functions
123124
ModuleESolver::pw_setup(inp, ucell, *this->pw_rho, this->kv, *this->pw_wfc);

source/source_esolver/esolver_of.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void ESolver_OF::before_all_runners(UnitCell& ucell, const Input_para& inp)
9393

9494
// print information
9595
// mohan add 2021-01-30
96-
ModuleIO::setup_parameters(ucell, kv);
96+
ModuleIO::print_parameters(ucell, kv, inp);
9797

9898
// initialize the real-space uniform grid for FFT and parallel
9999
// distribution of plane waves

source/source_estate/module_charge/charge_mixing.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,23 @@
88

99
Charge_Mixing::Charge_Mixing()
1010
{
11+
this->mixing = nullptr;
12+
this->mixing_highf = nullptr;
1113
}
1214

1315
Charge_Mixing::~Charge_Mixing()
1416
{
15-
delete this->mixing;
16-
delete this->mixing_highf;
17+
if(this->mixing != nullptr)
18+
{
19+
delete this->mixing;
20+
this->mixing = nullptr;
21+
}
22+
23+
if(this->mixing_highf != nullptr)
24+
{
25+
delete this->mixing_highf;
26+
this->mixing_highf = nullptr;
27+
}
1728
}
1829

1930
void Charge_Mixing::set_mixing(const std::string& mixing_mode_in,

source/source_io/print_info.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,39 @@
77
namespace ModuleIO
88
{
99

10-
void setup_parameters(UnitCell& ucell, K_Vectors& kv)
10+
void print_parameters(
11+
const UnitCell& ucell,
12+
K_Vectors& kv,
13+
const Input_para& inp)
1114
{
12-
ModuleBase::TITLE("ModuleIO", "setup_parameters");
13-
14-
if(PARAM.inp.calculation=="scf"
15-
|| PARAM.inp.calculation=="relax"
16-
|| PARAM.inp.calculation=="cell-relax"
17-
|| PARAM.inp.calculation=="nscf"
18-
|| PARAM.inp.calculation=="get_pchg"
19-
|| PARAM.inp.calculation=="get_wf"
20-
|| PARAM.inp.calculation=="md")
15+
ModuleBase::TITLE("ModuleIO", "print_parameters");
16+
17+
if(inp.calculation=="scf"
18+
|| inp.calculation=="relax"
19+
|| inp.calculation=="cell-relax"
20+
|| inp.calculation=="nscf"
21+
|| inp.calculation=="get_pchg"
22+
|| inp.calculation=="get_wf"
23+
|| inp.calculation=="md")
2124
{
2225
std::cout << " ---------------------------------------------------------" << std::endl;
23-
if(PARAM.inp.calculation=="scf")
26+
if(inp.calculation=="scf")
2427
{
2528
std::cout << " Self-consistent calculations for electrons" << std::endl;
2629
}
27-
else if(PARAM.inp.calculation=="test")
30+
else if(inp.calculation=="test")
2831
{
2932
std::cout << " Test run" << std::endl;
3033
}
31-
if(PARAM.inp.calculation=="relax")
34+
if(inp.calculation=="relax")
3235
{
3336
std::cout << " Ion relaxation calculations" << std::endl;
3437
}
35-
if(PARAM.inp.calculation=="cell-relax")
38+
if(inp.calculation=="cell-relax")
3639
{
3740
std::cout << " Cell relaxation calculations" << std::endl;
3841
}
39-
if(PARAM.inp.calculation=="md")
42+
if(inp.calculation=="md")
4043
{
4144
std::cout << " Molecular Dynamics simulations" << std::endl;
4245

@@ -79,12 +82,12 @@ void setup_parameters(UnitCell& ucell, K_Vectors& kv)
7982
<< std::setw(12) << "PROCESSORS"
8083
<< std::setw(12) << "THREADS";
8184

82-
const bool orbinfo = (PARAM.inp.basis_type=="lcao" || PARAM.inp.basis_type=="lcao_in_pw"
83-
|| (PARAM.inp.basis_type=="pw" && PARAM.inp.init_wfc.substr(0, 3) == "nao"));
85+
const bool orbinfo = (inp.basis_type=="lcao" || inp.basis_type=="lcao_in_pw"
86+
|| (inp.basis_type=="pw" && inp.init_wfc.substr(0, 3) == "nao"));
8487
if (orbinfo) { std::cout << std::setw(12) << "NBASE"; }
8588

8689
std::cout << std::endl;
87-
std::cout << " " << std::setw(8) << PARAM.inp.nspin;
90+
std::cout << " " << std::setw(8) << inp.nspin;
8891

8992
if(PARAM.globalv.gamma_only_local)
9093
{
@@ -105,15 +108,15 @@ void setup_parameters(UnitCell& ucell, K_Vectors& kv)
105108

106109

107110
std::cout << " ---------------------------------------------------------" << std::endl;
108-
if(PARAM.inp.basis_type == "lcao")
111+
if(inp.basis_type == "lcao")
109112
{
110113
std::cout << " Use Systematically Improvable Atomic bases" << std::endl;
111114
}
112-
else if(PARAM.inp.basis_type == "lcao_in_pw")
115+
else if(inp.basis_type == "lcao_in_pw")
113116
{
114117
std::cout << " Expand Atomic bases into plane waves" << std::endl;
115118
}
116-
else if(PARAM.inp.basis_type == "pw")
119+
else if(inp.basis_type == "pw")
117120
{
118121
std::cout << " Use plane wave basis" << std::endl;
119122
}

source/source_io/print_info.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ namespace ModuleIO
1515
{
1616

1717
// print out to screen about the readin parameters
18-
void setup_parameters(UnitCell& ucell, K_Vectors& kv);
18+
void print_parameters(
19+
const UnitCell& ucell,
20+
K_Vectors& kv,
21+
const Input_para& inp);
22+
1923
void print_time(time_t& time_start, time_t& time_finish);
2024
void print_screen(const int& stress_step, const int& force_step, const int& istep);
2125
//! Print charge density using FFT

source/source_lcao/module_lr/esolver_lrtd_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ LR::ESolver_LR<T, TR>::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu
319319
}
320320
this->kv.set(ucell,ucell.symm, PARAM.inp.kpoint_file, PARAM.inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running);
321321
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS");
322-
ModuleIO::setup_parameters(ucell, this->kv);
322+
ModuleIO::print_parameters(ucell, this->kv, inp);
323323

324324
this->parameter_check();
325325

0 commit comments

Comments
 (0)