Skip to content

Commit ce08b5a

Browse files
committed
add new parameter md_nstep for md
1 parent e00ae43 commit ce08b5a

File tree

35 files changed

+78
-49
lines changed

35 files changed

+78
-49
lines changed

doc/examples/md.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ gamma_only 1
1717
calculation md
1818
symmetry 0
1919
20-
relax_nmax 10
2120
out_level m
2221
relax_method cg
2322
@@ -33,6 +32,7 @@ basis_type lcao
3332
mixing_beta 0.4
3433
chg_extrap second-order
3534
35+
md_nstep 10 // md steps
3636
md_type 1 //choose ensemble
3737
md_dt 1 //time step
3838
md_tfirst 700 //the first target temperature

doc/examples/tddft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ smearing_sigma 0.02
2323
basis_type lcao
2424
out_chg 1
2525
gamma_only 0
26-
relax_nmax 2000
26+
md_nstep 2000
2727
scf_thr_rho 1.0e-6
2828
md_type 0
2929
md_dt 0.01

doc/input-main.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
- [Molecular dynamics](#molecular-dynamics)
4141

42-
[md_type](#md-type) | [md_ensolver](#md-ensolver) | [md_restart](#md-restart) | [md_dt](#md-dt) | [md_t](#md-t) | [md_dumpfreq](#md-dumpfreq) | [md_restartfreq](#md-restartfreq) | [md_tfreq](#md-tfreq) | [md_mnhc](#md-mnhc) | [lj_rcut](#lj-rcut) | [lj_epsilon](#lj-epsilon) | [lj_sigma](#lj-sigma) | [msst_direction](#msst-direction) | [msst_vel](#msst-vel) | [msst_vis](#msst-vis) | [msst_tscale](#msst-tscale) | [msst_qmass](#msst-qmass) | [md_damp](#md-damp)
42+
[md_type](#md-type) | [md_nstep](#md_nstep) | [md_ensolver](#md-ensolver) | [md_restart](#md-restart) | [md_dt](#md-dt) | [md_t](#md-t) | [md_dumpfreq](#md-dumpfreq) | [md_restartfreq](#md-restartfreq) | [md_tfreq](#md-tfreq) | [md_mnhc](#md-mnhc) | [lj_rcut](#lj-rcut) | [lj_epsilon](#lj-epsilon) | [lj_sigma](#lj-sigma) | [msst_direction](#msst-direction) | [msst_vel](#msst-vel) | [msst_vis](#msst-vis) | [msst_tscale](#msst-tscale) | [msst_qmass](#msst-qmass) | [md_damp](#md-damp)
4343

4444
- [DFT+U correction](#DFT_U-correction)
4545

@@ -1079,6 +1079,13 @@ This part of variables are used to control the molecular dynamics calculations.
10791079
10801080
[back to top](#input-file)
10811081
1082+
- md_nstep<a id="md_nstep"></a>
1083+
- *Type*: Integer
1084+
- *Description*: the total number of md steps.
1085+
- *Default*: 10
1086+
1087+
[back to top](#input-file)
1088+
10821089
- md_ensolver<a id="md-ensolver"></a>
10831090
- *Type*: String
10841091
- *Description*: choose the energy solver for MD.

examples/03a_Sn64_lcao_md/INPUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gamma_only 1
1010
calculation md
1111
symmetry 0
1212

13-
relax_nmax 10
13+
md_nstep 10
1414
out_level m
1515
relax_method cg
1616

source/input.cpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void Input::Default(void)
213213
//----------------------------------------------------------
214214
scf_thr_rho = 1.0e-9;
215215
scf_nmax = 40;
216-
this->relax_nmax = 0;
216+
relax_nmax = 0;
217217
out_stru = 0;
218218
//----------------------------------------------------------
219219
// occupation
@@ -1033,6 +1033,10 @@ bool Input::Read(const std::string &fn)
10331033
{
10341034
read_value(ifs, mdp.md_type);
10351035
}
1036+
else if (strcmp("md_nstep",word) == 0)
1037+
{
1038+
read_value(ifs, mdp.md_nstep);
1039+
}
10361040
else if (strcmp("md_dt",word) == 0)
10371041
{
10381042
read_value(ifs, mdp.md_dt);
@@ -1894,6 +1898,7 @@ void Input::Bcast()
18941898
*/
18951899
//zheng daye add 2014/5/5
18961900
Parallel_Common::bcast_int(mdp.md_type);
1901+
Parallel_Common::bcast_int(mdp.md_nstep);
18971902
Parallel_Common::bcast_double(mdp.md_dt);
18981903
Parallel_Common::bcast_int(mdp.md_mnhc);
18991904
Parallel_Common::bcast_double(mdp.msst_qmass);
@@ -2177,9 +2182,10 @@ void Input::Check(void)
21772182
GlobalV::CALCULATION = "md";
21782183
symmetry = false;
21792184
cal_force = 1;
2180-
if(this->relax_nmax==0){
2181-
GlobalV::ofs_running<<"relax_nmax should be set. Autoset relax_nmax to 50!"<<endl;
2182-
this->relax_nmax = 50;
2185+
if(mdp.md_nstep == 0)
2186+
{
2187+
GlobalV::ofs_running<<"md_nstep should be set. Autoset md_nstep to 50!"<<endl;
2188+
mdp.md_nstep = 50;
21832189
}
21842190
if(!out_md_control) out_level = "m";//zhengdy add 2019-04-07
21852191

@@ -2188,23 +2194,23 @@ void Input::Check(void)
21882194
if(mdp.md_dt < 0) ModuleBase::WARNING_QUIT("Input::Check","time interval of MD calculation should be set!");
21892195
if(mdp.md_tfirst < 0) ModuleBase::WARNING_QUIT("Input::Check","temperature of MD calculation should be set!");
21902196
if(mdp.md_tlast < 0.0) mdp.md_tlast = mdp.md_tfirst;
2191-
if(mdp.md_tfirst!=mdp.md_tlast)
2192-
{
2193-
std::ifstream file1;
2194-
file1.open("ChangeTemp.dat");
2195-
if(!file1) // Peize Lin fix bug 2016-08-06
2196-
{
2197-
std::ofstream file;
2198-
file.open("ChangeTemp.dat");
2199-
for(int ii=0;ii<30;ii++)
2200-
{
2201-
file<<mdp.md_tfirst+(mdp.md_tlast-mdp.md_tfirst)/double(30)*double(ii+1)<<" ";
2202-
}
2203-
file.close();
2204-
}
2205-
else
2206-
file1.close();
2207-
}
2197+
// if(mdp.md_tfirst!=mdp.md_tlast)
2198+
// {
2199+
// std::ifstream file1;
2200+
// file1.open("ChangeTemp.dat");
2201+
// if(!file1) // Peize Lin fix bug 2016-08-06
2202+
// {
2203+
// std::ofstream file;
2204+
// file.open("ChangeTemp.dat");
2205+
// for(int ii=0;ii<30;ii++)
2206+
// {
2207+
// file<<mdp.md_tfirst+(mdp.md_tlast-mdp.md_tfirst)/double(30)*double(ii+1)<<" ";
2208+
// }
2209+
// file.close();
2210+
// }
2211+
// else
2212+
// file1.close();
2213+
// }
22082214

22092215
}
22102216
else if(calculation == "cell-relax") // mohan add 2011-11-04

source/input_conv.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ void Input_Conv::Convert(void)
423423
//----------------------------------------------------------
424424
GlobalV::SCF_NMAX = INPUT.scf_nmax;
425425
GlobalV::RELAX_NMAX = INPUT.relax_nmax;
426+
GlobalV::MD_NSTEP = INPUT.mdp.md_nstep;
426427

427428
//----------------------------------------------------------
428429
// wavefunction / charge / potential / (2/4)

source/input_update.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ bool Update_input::Read(const std::string &fn)
146146
this->change(GlobalV::ofs_warning,"relax_nmax",GlobalV::RELAX_NMAX,relax_nmax);
147147
GlobalV::RELAX_NMAX = this->relax_nmax;
148148
}
149+
}
150+
else if (strcmp("md_nstep", word) == 0)
151+
{
152+
read_value(ifs, md_nstep);
153+
if(md_nstep!=GlobalV::MD_NSTEP)
154+
{
155+
this->change(GlobalV::ofs_warning, "md_nstep", GlobalV::MD_NSTEP, md_nstep);
156+
GlobalV::MD_NSTEP = this->md_nstep;
157+
}
149158
}
150159
// 7
151160
else if (strcmp("mixing_beta", word) == 0)
@@ -286,7 +295,7 @@ void Update_input::Bcast()
286295
Parallel_Common::bcast_int( GlobalC::en.out_dos );
287296
Parallel_Common::bcast_double( GlobalC::CHR.nelec );
288297

289-
298+
Parallel_Common::bcast_int( GlobalV::MD_NSTEP );
290299
return;
291300
}
292301
#endif

source/input_update.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Update_input
3030
double scf_thr_rho; // \sum |rhog_out - rhog_in |^2
3131
int scf_nmax; // number of max elec iter
3232
int relax_nmax; // number of max ionic iter
33+
int md_nstep; // number of md steps
3334
double mixing_beta; // 0 : no_mixing
3435
int printe;
3536
//int chg_extrap; // mohan add 2011-03-13, xiaohui modify 2015-02-01

source/module_base/global_variable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ double PRESSURE = 0.0;
4444
std::string RELAX_METHOD = "bfgs";
4545
std::string OUT_LEVEL = "ie";
4646
int RELAX_NMAX = 20;
47+
int MD_NSTEP = 20;
4748
int SCF_NMAX = 50;
4849

4950
std::string BASIS_TYPE = "pw"; //xiaohui add 2013-09-01

source/module_base/global_variable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern std::string OUT_LEVEL;
4848

4949
extern int RELAX_NMAX; // 8.3
5050
extern int SCF_NMAX; // 8.4
51+
extern int MD_NSTEP;
5152

5253
extern std::string BASIS_TYPE; //xiaohui add 2013-09-01
5354
extern std::string KS_SOLVER; //xiaohui add 2013-09-01

0 commit comments

Comments
 (0)