Skip to content

Commit 31eddbf

Browse files
authored
Merge pull request #1004 from YuLiu98/develop
refactor: update docs and check for MD parameters
2 parents 063ebdd + dfef0d9 commit 31eddbf

File tree

11 files changed

+41
-28
lines changed

11 files changed

+41
-28
lines changed

docs/input-main.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ This part of variables are used to control the molecular dynamics calculations.
11141114
11151115
- **Type**: Double
11161116
- **Description**: This is the time step(fs) used in md simulation .
1117-
- **Default**: 1
1117+
- **Default**: 1.0
11181118
11191119
#### md_tfirst & md_tlast
11201120
@@ -1178,31 +1178,31 @@ temperature will fluctuate violently; if it is too small, the temperature will t
11781178
11791179
- **Type**: Real
11801180
- **Description**: the velocity of shock wave ($\AA$/fs) for MSST.
1181-
- **Default**: 0
1181+
- **Default**: 0.0
11821182
11831183
#### msst_vis
11841184
11851185
- **Type**: Real
11861186
- **Description**: artificial viscosity (mass/length/time) for MSST.
1187-
- **Default**: 0
1187+
- **Default**: 0.0
11881188
11891189
#### msst_tscale
11901190
11911191
- **Type**: Real
11921192
- **Description**: reduction in initial temperature (0~1) used to compress volume in MSST.
1193-
- **Default**: 0
1193+
- **Default**: 0.01
11941194
11951195
#### msst_qmass
11961196
1197-
- **Type**: Double
1197+
- **Type**: Real
11981198
- **Description**: Inertia of extended system variable. Used only when md_type is 4, you should set a number which is larger than 0. Note that Qmass of NHC is set by md_tfreq.
11991199
- **Default**: No default
12001200
12011201
#### md_damp
12021202
12031203
- **Type**: Real
12041204
- **Description**: damping parameter (fs) used to add force in Langevin method.
1205-
- **Default**: 1
1205+
- **Default**: 1.0
12061206
12071207
### DFT+U correction
12081208

source/input.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,26 @@ void Input::Check(void)
23582358
ModuleBase::WARNING_QUIT("Input::Check", "temperature of MD calculation should be set!");
23592359
if (mdp.md_tlast < 0.0)
23602360
mdp.md_tlast = mdp.md_tfirst;
2361+
2362+
if(mdp.md_tfreq == 0)
2363+
{
2364+
mdp.md_tfreq = 1.0/40.0/mdp.md_dt;
2365+
}
2366+
if(mdp.md_restart)
2367+
{
2368+
init_vel = 1;
2369+
}
2370+
if(mdp.md_ensolver == "LJ" || mdp.md_ensolver == "DP" || mdp.md_type == 4)
2371+
{
2372+
cal_stress = 1;
2373+
}
2374+
if(mdp.md_type == 4)
2375+
{
2376+
if(mdp.msst_qmass <= 0)
2377+
{
2378+
ModuleBase::WARNING_QUIT("Input::Check", "msst_qmass must be greater than 0!");
2379+
}
2380+
}
23612381
// if(mdp.md_tfirst!=mdp.md_tlast)
23622382
// {
23632383
// std::ifstream file1;

source/module_md/MD_func.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ void MD_func::force_virial(
242242

243243
if(mdp.md_ensolver == "LJ")
244244
{
245-
GlobalV::CAL_STRESS = 1;
246245
bool which_method = unit_in.judge_big_cell();
247246
if(which_method)
248247
{
@@ -276,7 +275,6 @@ void MD_func::force_virial(
276275
}
277276
else if(mdp.md_ensolver == "DP")
278277
{
279-
GlobalV::CAL_STRESS = 1;
280278
DP_potential::DP_pot(unit_in, potential, force, stress);
281279
}
282280
#ifndef __CMD

source/module_md/MD_parameters.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class MD_parameters
1111
md_restart = 0;
1212
md_type = 1;
1313
md_nstep = 10;
14-
md_dt = 1;
15-
md_tfirst = 0;
16-
md_tlast = -1;
14+
md_dt = 1.0;
15+
md_tfirst = -1.0;
16+
md_tlast = -1.0;
1717
md_dumpfreq = 1;
18-
md_restartfreq = 1;
18+
md_restartfreq = 5;
1919

2020
// Classic MD
2121
md_ensolver = "FP";
@@ -25,17 +25,17 @@ class MD_parameters
2525

2626
// MSST
2727
msst_direction = 2;
28-
msst_qmass = 1;
29-
msst_vel = 0;
30-
msst_vis = 0;
28+
msst_qmass = -1.0;
29+
msst_vel = 0.0;
30+
msst_vis = 0.0;
3131
msst_tscale = 0.01;
3232

3333
// NHC
34-
md_tfreq = 0;
34+
md_tfreq = 0.0;
3535
md_mnhc = 4;
3636

3737
// Langevin
38-
md_damp = 1;
38+
md_damp = 1.0;
3939
};
4040
~MD_parameters(){};
4141

source/module_md/MSST.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ MSST::MSST(MD_parameters& MD_para_in, UnitCell_pseudo &unit_in) : Verlet(MD_para
1010
{
1111
std::cout << "MSST" << std::endl;
1212

13-
GlobalV::CAL_STRESS = 1;
1413
mdp.msst_qmass = mdp.msst_qmass / pow(ModuleBase::ANGSTROM_AU, 4) / pow(ModuleBase::AU_to_MASS, 2);
1514
mdp.msst_vel = mdp.msst_vel * ModuleBase::ANGSTROM_AU * ModuleBase::AU_to_FS;
1615
mdp.msst_vis = mdp.msst_vis / ModuleBase::AU_to_MASS / ModuleBase::ANGSTROM_AU * ModuleBase::AU_to_FS;

source/module_md/verlet.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,7 @@ Verlet::Verlet(MD_parameters& MD_para_in, UnitCell_pseudo &unit_in):
2525
mdp.md_dt /= ModuleBase::AU_to_FS;
2626
mdp.md_tfirst /= ModuleBase::Hartree_to_K;
2727
mdp.md_tlast /= ModuleBase::Hartree_to_K;
28-
29-
if(mdp.md_tfreq == 0)
30-
{
31-
mdp.md_tfreq = 1.0/40.0/mdp.md_dt;
32-
}
33-
else
34-
{
35-
mdp.md_tfreq *= ModuleBase::AU_to_FS;
36-
}
28+
mdp.md_tfreq *= ModuleBase::AU_to_FS;
3729

3830
// LJ parameters
3931
mdp.lj_rcut *= ModuleBase::ANGSTROM_AU;
@@ -42,7 +34,6 @@ Verlet::Verlet(MD_parameters& MD_para_in, UnitCell_pseudo &unit_in):
4234

4335
step_ = 0;
4436
step_rst_ = 0;
45-
if(mdp.md_restart) unit_in.init_vel = 1;
4637

4738
MD_func::InitPos(ucell, pos);
4839
MD_func::InitVel(ucell, mdp.md_tfirst, allmass, frozen_freedom_, ionmbl, vel);

tests/integrate/120_PW_KP_MD_NVE/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ mixing_beta 0.7
2424

2525
md_type 0
2626
md_restart 0
27+
md_tfirst 0
2728

2829
read_file_dir ./

tests/integrate/220_NO_KP_MD_NVE/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ mixing_beta 0.7
2424

2525
md_type 0
2626
md_restart 0
27+
md_tfirst 0
2728

2829
read_file_dir ./

tests/integrate/320_NO_GO_MD_NVE/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ mixing_beta 0.7
2525

2626
md_type 0
2727
md_restart 0
28+
md_tfirst 0
2829

2930
read_file_dir ./
3031

tests/integrate/601_NO_TDDFT_N2_occ/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ scf_thr 1.0e-6
2929
tddft 1
3030

3131
md_type 0
32+
md_tfirst 0
3233
md_dt 0.01
3334
ocp 1
3435
ocp_set 5*2 2*0 1*2 4*0

0 commit comments

Comments
 (0)