Skip to content

Commit

Permalink
Update verlet.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Zjhjunhao authored May 28, 2024
1 parent 074bcf5 commit aa0433e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions source/module_md/verlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,7 @@ void Verlet::apply_thermostat(void)
{
if (mdp.my_rank == 0)
{
double deviation;
for (int i = 0; i < ucell.nat; ++i)
{
if (static_cast<double>(std::rand()) / RAND_MAX <= 1.0 / mdp.md_nraise)
{
deviation = sqrt(mdp.md_tlast / allmass[i]);
for (int k = 0; k < 3; ++k)
{
if (ionmbl[i][k])
{
vel[i][k] = deviation * MD_func::gaussrand();
}
}
}
}
anderson_set_vel();
}
#ifdef __MPI
MPI_Bcast(vel, ucell.nat * 3, MPI_DOUBLE, 0, MPI_COMM_WORLD);
Expand Down Expand Up @@ -145,3 +131,22 @@ void Verlet::restart(const std::string& global_readin_dir)
MD_base::restart(global_readin_dir);
return;
}

void Verlert::anderson_set_vel(void)
{
double deviation;
for (int i = 0; i < ucell.nat; ++i)
{
if (static_cast<double>(std::rand()) / RAND_MAX <= 1.0 / mdp.md_nraise)
{
deviation = sqrt(mdp.md_tlast / allmass[i]);
for (int k = 0; k < 3; ++k)
{
if (ionmbl[i][k])
{
vel[i][k] = deviation * MD_func::gaussrand();
}
}
}
}
}

0 comments on commit aa0433e

Please sign in to comment.