Skip to content

Commit c43c3e4

Browse files
authored
Merge pull request #892 from Qianruipku/hotfix
refactor: modify input-main.md and add const for parameters
2 parents 3c80d55 + 53547b2 commit c43c3e4

File tree

12 files changed

+56
-59
lines changed

12 files changed

+56
-59
lines changed

docs/input-main.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
- [Variables related to output information](#variables-related-to-output-information)
3434

35-
[out_force](#out_force) | [out_mul](#out_mul) | [out_chg](#out_chg) | [out_pot](#out_pot) | [out_dm](#out-dm) | [out_wfc_pw](#out_wfc_pw) | [out_wfc_r](#out_wfc_r) | [out_wfc_lcao](#out_wfc_lcao) | [out_dos](#out-dos) | [out_band](#out-band) | [out_stru](#out-stru) | [out_level](#out_level) | [out_alllog](#out-alllog) | [out_mat_hs](#out_mat_hs) | [out_mat_r](#out_mat_r) | [out_mat_hs2](#out_mat_hs2) | [out_element_info](#out-element-info) | [restart_save](#restart_save) | [restart_load](#restart_load)
35+
[out_force](#out_force) | [out_mul](#out_mul) | [out_freq_elec](#out_freq_elec) | [out_freq_ion](#out_freq_ion) | [out_chg](#out_chg) | [out_pot](#out_pot) | [out_dm](#out-dm) | [out_wfc_pw](#out_wfc_pw) | [out_wfc_r](#out_wfc_r) | [out_wfc_lcao](#out_wfc_lcao) | [out_dos](#out-dos) | [out_band](#out-band) | [out_stru](#out-stru) | [out_level](#out_level) | [out_alllog](#out-alllog) | [out_mat_hs](#out_mat_hs) | [out_mat_r](#out_mat_r) | [out_mat_hs2](#out_mat_hs2) | [out_element_info](#out-element-info) | [restart_save](#restart_save) | [restart_load](#restart_load)
3636

3737
- [Density of states](#density-of-states)
3838

@@ -675,6 +675,18 @@ This part of variables are used to control the output of properties.
675675
- **Description**: If set to 1, ABACUS will output the Mulliken population analysis result. The name of the output file is mulliken.txt
676676
- **Default**: 0
677677
678+
#### out_freq_elec
679+
680+
- **Type**: Integer
681+
- **Description**: If set to >1, it represents the frequency of electronic iters to output charge density (if [out_chg](#out_chg) is turned on) and wavefunction (if [out_wfc_pw](#out_wf_pw) or [out_wfc_r](#out_wfc_r) is turned on). If set to 0, ABACUS will output them only when converged in SCF. Used for the restart of SCF.
682+
- **Default**: 0
683+
684+
#### out_freq_ion
685+
686+
- **Type**: Integer
687+
- **Description**: If set to >1, it represents the frequency of ionic steps to output charge density (if [out_chg](#out_chg) is turned on) and wavefunction (if [out_wfc_pw](#out_wf_pw) or [out_wfc_r](#out_wfc_r) is turned on). If set to 0, ABACUS will output them only when ionic steps reach its maximum step. Used for the restart of MD or Relax.
688+
- **Default**: 0
689+
678690
#### out_chg
679691
680692
- **Type**: Integer

source/module_esolver/esolver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ESolver
3636

3737
/// These two virtual `Run` will be merged in the future.
3838
//virtual void Run(int istep, Atom &atom) = 0;
39-
virtual void Run(int istep, UnitCell_pseudo& cell) = 0;
39+
virtual void Run(const int istep, UnitCell_pseudo& cell) = 0;
4040
virtual void Run(int istep,
4141
Record_adj& ra /**< would be a 2nd-module of Cell*/,
4242
Local_Orbital_Charge& loc /**< EState*/,

source/module_esolver/esolver_dp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void ESolver_DP::Init(Input &inp, UnitCell_pseudo &ucell)
4343
assert(ucell.nat == iat);
4444
}
4545

46-
void ESolver_DP::Run(int istep, UnitCell_pseudo &ucell)
46+
void ESolver_DP::Run(const int istep, UnitCell_pseudo &ucell)
4747
{
4848
#ifdef __DPMD
4949
if(access("graph.pb", 0) == -1)

source/module_esolver/esolver_dp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ESolver_DP: public ESolver
1515
}
1616

1717
void Init(Input &inp, UnitCell_pseudo &cell) override;
18-
void Run(int istep, UnitCell_pseudo& cell) override;
18+
void Run(const int istep, UnitCell_pseudo& cell) override;
1919
void cal_Energy(energy& en) override;
2020
void cal_Force(ModuleBase::matrix &force) override;
2121
void cal_Stress(ModuleBase::matrix &stress) override;

source/module_esolver/esolver_ks.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ESolver_KS::ESolver_KS()
2525
out_freq_elec = GlobalV::OUT_FREQ_ELEC;
2626
}
2727

28-
void ESolver_KS:: hamilt2density(int istep, int iter, double ethr)
28+
void ESolver_KS:: hamilt2density(const int istep, const int iter, const double ethr)
2929
{
3030
ModuleBase::timer:: tick(this->classname,"hamilt2density");
3131
//Temporarily, before HSolver is constructed, it should be overrided by
@@ -37,7 +37,7 @@ void ESolver_KS:: hamilt2density(int istep, int iter, double ethr)
3737
}
3838

3939

40-
void ESolver_KS:: Run(int istep, UnitCell_pseudo& cell)
40+
void ESolver_KS:: Run(const int istep, UnitCell_pseudo& cell)
4141
{
4242
ModuleBase::timer:: tick(this->classname,"Run");
4343

@@ -109,7 +109,7 @@ void ESolver_KS:: Run(int istep, UnitCell_pseudo& cell)
109109
};
110110

111111
//<Temporary> It should be a function of Diag_H class in the future.
112-
void ESolver_KS:: set_ethr(int istep, int iter)
112+
void ESolver_KS:: set_ethr(const int istep, const int iter)
113113
{
114114
//It is too complex now and should be modified.
115115
if(iter == 1)
@@ -148,24 +148,13 @@ void ESolver_KS:: set_ethr(int istep, int iter)
148148
{
149149
this->diag_ethr = 1.e-2;
150150
}
151-
152-
//----------------------------
153-
// this->diag_ethr changes in CG Method.
154-
// mohan update 2012-03-26
155-
// mohan update 2012-02-08
156-
//----------------------------
157-
if(GlobalV::BASIS_TYPE=="lcao")
158-
{
159-
this->diag_ethr = std::min( this->diag_ethr, 0.01*this->drho/ std::max(1.0, GlobalC::CHR.nelec));
160-
}
161-
// mohan update 2009-09-04
162-
else
163-
{
164-
this->diag_ethr = std::min( this->diag_ethr, 0.1*this->drho/ std::max(1.0, GlobalC::CHR.nelec));
165-
//std::cout << " new this->diag_ethr = " << this->diag_ethr << std::endl;
166-
}
151+
this->diag_ethr = std::min( this->diag_ethr, 0.1*this->drho/ std::max(1.0, GlobalC::CHR.nelec));
167152

168153
}
154+
// if(GlobalV::BASIS_TYPE=="lcao" || GlobalV::BASIS_TYPE=="lcao_in_pw")
155+
// {
156+
// this->diag_ethr = 0.0;
157+
// }
169158
}
170159

171160
void ESolver_KS:: printhead()
@@ -182,12 +171,12 @@ void ESolver_KS:: printhead()
182171
std::cout << std::setw(11) << "TIME(s)" << std::endl;
183172
}
184173

185-
void ESolver_KS::printiter(bool conv_elec, int iter, double drho, double duration, double ethr)
174+
void ESolver_KS::printiter(const bool conv_elec, const int iter, const double drho, const double duration, const double ethr)
186175
{
187176
GlobalC::en.print_etot(conv_elec, iter, drho, duration, ethr);
188177
}
189178

190-
void ESolver_KS:: writehead(std::ofstream &ofs_running, int istep, int iter)
179+
void ESolver_KS:: writehead(std::ofstream &ofs_running, const int istep, const int iter)
191180
{
192181
ofs_running
193182
<< "\n "
@@ -197,7 +186,7 @@ void ESolver_KS:: writehead(std::ofstream &ofs_running, int istep, int iter)
197186
<< "--------------------------------\n";
198187
}
199188

200-
void ESolver_KS:: reset_diagethr(std::ofstream &ofs_running, double hsover_error)
189+
void ESolver_KS:: reset_diagethr(std::ofstream &ofs_running, const double hsover_error)
201190
{
202191
ofs_running << " Notice: Threshold on eigenvalues was too large.\n";
203192
ModuleBase::WARNING("scf","Threshold on eigenvalues was too large.");

source/module_esolver/esolver_ks.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,40 @@ class ESolver_KS: public ESolver_FP
2020
int niter; // iter steps actually used in scf
2121
int out_freq_elec;// frequency for output
2222

23-
virtual void Run(int istep, UnitCell_pseudo& cell) override;
23+
virtual void Run(const int istep, UnitCell_pseudo& cell) override;
2424

2525
// calculate electron density from a specific Hamiltonian
26-
virtual void hamilt2density(int istep, int iter, double ethr);
26+
virtual void hamilt2density(const int istep, const int iter, const double ethr);
2727
// get
2828
virtual int getniter() override;
2929

3030
protected:
3131
// Something to do before SCF iterations.
3232
virtual void beforescf(){};
3333
// Something to do before hamilt2density function in each iter loop.
34-
virtual void eachiterinit(int iter){};
34+
virtual void eachiterinit(const int iter){};
3535
// Something to do after hamilt2density function in each iter loop.
36-
virtual void eachiterfinish(int iter, bool conv){};
36+
virtual void eachiterfinish(const int iter, const bool conv){};
3737
// Something to do after SCF iterations when SCF is converged or comes to the max iter step.
38-
virtual void afterscf(bool conv){};
38+
virtual void afterscf(const bool conv){};
3939
// <Temporary> It should be replaced by a function in Hamilt Class
40-
virtual void updatepot(bool conv){};
40+
virtual void updatepot(const bool conv){};
4141

4242

4343
//TOOLS:
4444
protected:
4545
// Set ethr for hsolver
46-
void set_ethr(int istep, int iter);
46+
void set_ethr(const int istep, const int iter);
4747
// Print the headline on the screen:
4848
// ITER ETOT(eV) EDIFF(eV) DRHO TIME(s)
4949
void printhead();
5050
// Print inforamtion in each iter
5151
// G1 -3.435545e+03 0.000000e+00 3.607e-01 2.862e-01
52-
void printiter(bool conv, int iter, double drho, double duration, double ethr);
52+
void printiter(const bool conv, const int iter, const double drho, const double duration, const double ethr);
5353
// Write the headline in the running_log file
5454
// "PW/LCAO" ALGORITHM --------------- ION= 1 ELEC= 1--------------------------------
55-
void writehead(std::ofstream &ofs_running,int istep, int iter);
56-
void reset_diagethr(std::ofstream &ofs_running, double hsover_error);
55+
void writehead(std::ofstream &ofs_running, const int istep, const int iter);
56+
void reset_diagethr(std::ofstream &ofs_running, const double hsover_error);
5757

5858

5959

source/module_esolver/esolver_ks_lcao.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ESolver_KS_LCAO: public ESolver_KS
2121
Local_Orbital_Charge& loc,
2222
Local_Orbital_wfc& lowf,
2323
LCAO_Hamilt& uhm) override;
24-
void Run(int istep, UnitCell_pseudo& cell) override {};
24+
void Run(const int istep, UnitCell_pseudo& cell) override {};
2525

2626
void cal_Energy(energy& en) override;
2727
void cal_Force(ModuleBase::matrix &force) override;

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void ESolver_KS_PW:: beforescf()
192192
}
193193
}
194194

195-
void ESolver_KS_PW:: eachiterinit(int iter)
195+
void ESolver_KS_PW:: eachiterinit(const int iter)
196196
{
197197
// mohan add 2010-07-16
198198
if(iter==1) GlobalC::CHR.set_new_e_iteration(true);
@@ -215,15 +215,11 @@ void ESolver_KS_PW:: eachiterinit(int iter)
215215
}
216216

217217
//Temporary, it should be replaced by hsolver later.
218-
void ESolver_KS_PW:: hamilt2density(int istep, int iter, double ethr)
218+
void ESolver_KS_PW:: hamilt2density(const int istep, const int iter, const double ethr)
219219
{
220220
GlobalV::PW_DIAG_THR = ethr;
221221
this->c_bands(istep,iter);
222-
ethr = GlobalV::PW_DIAG_THR;
223-
if(GlobalV::BASIS_TYPE=="lcao" || GlobalV::BASIS_TYPE=="lcao_in_pw")
224-
{
225-
ethr = 0.0;
226-
}
222+
227223
GlobalC::en.eband = 0.0;
228224
GlobalC::en.demet = 0.0;
229225
GlobalC::en.ef = 0.0;
@@ -265,15 +261,15 @@ void ESolver_KS_PW:: hamilt2density(int istep, int iter, double ethr)
265261
}
266262

267263
//Temporary:
268-
void ESolver_KS_PW:: c_bands(int istep, int iter)
264+
void ESolver_KS_PW:: c_bands(const int istep, const int iter)
269265
{
270266
Electrons elec;
271267
elec.iter = iter;
272268
elec.c_bands(istep);
273269
}
274270

275271
//Temporary, it should be rewritten with Hamilt class.
276-
void ESolver_KS_PW:: updatepot(bool conv_elec)
272+
void ESolver_KS_PW:: updatepot(const bool conv_elec)
277273
{
278274
if (!conv_elec)
279275
{
@@ -305,7 +301,7 @@ void ESolver_KS_PW:: updatepot(bool conv_elec)
305301
GlobalC::pot.set_vr_eff();
306302
}
307303

308-
void ESolver_KS_PW:: eachiterfinish(int iter, bool conv_elec)
304+
void ESolver_KS_PW:: eachiterfinish(const int iter, const bool conv_elec)
309305
{
310306
//print_eigenvalue(GlobalV::ofs_running);
311307
GlobalC::en.calculate_etot();
@@ -352,7 +348,7 @@ void ESolver_KS_PW:: eachiterfinish(int iter, bool conv_elec)
352348
}
353349

354350

355-
void ESolver_KS_PW::afterscf(bool conv_elec)
351+
void ESolver_KS_PW::afterscf(const bool conv_elec)
356352
{
357353
#ifdef __LCAO
358354
if(GlobalC::chi0_hilbert.epsilon) // pengfei 2016-11-23

source/module_esolver/esolver_ks_pw.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class ESolver_KS_PW: public ESolver_KS
2121

2222
protected:
2323
virtual void beforescf() override;
24-
virtual void eachiterinit(int iter) override;
25-
virtual void hamilt2density(int istep, int iter, double ethr) override;
26-
virtual void updatepot(bool conv) override;
27-
virtual void eachiterfinish(int iter, bool conv) override;
28-
virtual void afterscf(bool) override;
24+
virtual void eachiterinit(const int iter) override;
25+
virtual void hamilt2density(const int istep, const int iter, const double ethr) override;
26+
virtual void updatepot(const bool conv) override;
27+
virtual void eachiterfinish(const int iter, const bool conv) override;
28+
virtual void afterscf(const bool) override;
2929

3030
// <Temporary> Get wavefunctions and eigen energies.
3131
// It should be replaced by diag class in HSolver module in the future
32-
void c_bands(int istep, int iter);
32+
void c_bands(const int istep, const int iter);
3333

3434
// It copies the function in Threshold_Elec class.
3535
// After all ESolver, HSolver are constructed, Class Electrons and Threshold_Elec should be deleted.

source/module_esolver/esolver_lj.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void ESolver_LJ::Init(Input &inp, UnitCell_pseudo &ucell)
2626
inp.test_just_neighbor);
2727
}
2828

29-
void ESolver_LJ::Run(int istep, UnitCell_pseudo &ucell)
29+
void ESolver_LJ::Run(const int istep, UnitCell_pseudo &ucell)
3030
{
3131
double distance;
3232
int index = 0;

0 commit comments

Comments
 (0)