Skip to content

Commit 3372a54

Browse files
authored
Merge pull request #967 from Qianruipku/hotfix
fix a bug that different cores have different scale that make MD stuck
2 parents 9fe5879 + 0a76c78 commit 3372a54

File tree

4 files changed

+3
-10
lines changed

4 files changed

+3
-10
lines changed

source/module_md/FIRE.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ void FIRE::first_half()
6464
}
6565
#ifdef __MPI
6666
MPI_Bcast(pos , ucell.nat*3,MPI_DOUBLE,0,MPI_COMM_WORLD);
67+
MPI_Bcast(vel , ucell.nat*3,MPI_DOUBLE,0,MPI_COMM_WORLD);
6768
#endif
6869

6970
ucell.update_pos_tau(pos);

source/module_md/MD_func.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ void MD_func::kinetic_stress(
7575
// This function calculates the classical kinetic energy of atoms
7676
// and its contribution to stress.
7777
//----------------------------------------------------------------------------
78-
if(GlobalV::MY_RANK==0) //only first rank do md
79-
{
8078
kinetic = MD_func::GetAtomKE(unit_in.nat, vel, allmass);
8179

8280
ModuleBase::matrix temp;
@@ -107,7 +105,6 @@ void MD_func::kinetic_stress(
107105
}
108106
}
109107
}
110-
}
111108
}
112109

113110
// Read Velocity from STRU liuyu 2021-09-24

source/module_md/MSST.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ void MSST::first_half()
7878
const int sd = mdp.msst_direction;
7979
const double dthalf = 0.5 * mdp.md_dt;
8080
double vol;
81-
if( GlobalV::MY_RANK == 0 )
82-
{
8381
energy_ = potential + kinetic;
8482

8583
// propagate the time derivative of volume 1/2 step
@@ -118,9 +116,9 @@ void MSST::first_half()
118116
{
119117
pos[i] += vel[i] * mdp.md_dt;
120118
}
121-
}
122119
#ifdef __MPI
123120
MPI_Bcast(pos , ucell.nat*3,MPI_DOUBLE,0,MPI_COMM_WORLD);
121+
MPI_Bcast(vel , ucell.nat*3,MPI_DOUBLE,0,MPI_COMM_WORLD);
124122
#endif
125123

126124
ucell.update_pos_tau(pos);
@@ -142,8 +140,6 @@ void MSST::second_half()
142140

143141
const int sd = mdp.msst_direction;
144142
const double dthalf = 0.5 * mdp.md_dt;
145-
if( GlobalV::MY_RANK == 0 )
146-
{
147143
energy_ = potential + kinetic;
148144

149145
// propagate velocities 1/2 step
@@ -158,7 +154,6 @@ void MSST::second_half()
158154

159155
// calculate Lagrangian position
160156
lag_pos -= mdp.msst_vel * ucell.omega / v0 * mdp.md_dt;
161-
}
162157

163158
ModuleBase::timer::tick("MSST", "second_half");
164159
}

source/module_md/verlet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void Verlet::first_half()
8989
}
9090
#ifdef __MPI
9191
MPI_Bcast(pos , ucell.nat*3,MPI_DOUBLE,0,MPI_COMM_WORLD);
92+
MPI_Bcast(vel , ucell.nat*3,MPI_DOUBLE,0,MPI_COMM_WORLD);
9293
#endif
9394

9495
ucell.update_pos_tau(pos);
@@ -98,7 +99,6 @@ void Verlet::first_half()
9899

99100
void Verlet::second_half()
100101
{
101-
if(GlobalV::MY_RANK==0) //only first rank do md
102102
for(int i=0; i<ucell.nat; ++i)
103103
{
104104
for(int k=0; k<3; ++k)

0 commit comments

Comments
 (0)