Skip to content

Commit

Permalink
Merge pull request brucefan1983#653 from brucefan1983/default_velocity
Browse files Browse the repository at this point in the history
Default velocity
  • Loading branch information
brucefan1983 committed Jun 24, 2024
2 parents c7cb37a + 2a0ca44 commit c0d856a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/gpumd/input_parameters/velocity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ Caveats
This is, however, not a problem since during the MD simulation, the Maxwell distribution will be achieved automatically within a short time.
* The total linear and angular momenta are set to zero.
* If there are already velocity data in the :ref:`simulation model file <model_xyz>`, the initial temperature will not be used and the velocities will be initialized as those in the simulation model file.
**Important:** In this case, you still need to write this keyword, otherwise the velocities will not be initialized at all (and will hence be undefined).
* If there are not velocity data in the :ref:`simulation model file <model_xyz>`, and this keyword is missing, velocities will be initialized with a default temperature of 300 K.
18 changes: 18 additions & 0 deletions src/main_gpumd/run.cu
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ Run::Run()

allocate_memory_gpu(group, atom, thermo);

velocity.initialize(
has_velocity_in_xyz,
300,
atom.cpu_mass,
atom.cpu_position_per_atom,
atom.cpu_velocity_per_atom,
atom.velocity_per_atom,
true,
123);
if (has_velocity_in_xyz) {
printf("Initialized velocities with data in model.xyz.\n");
} else {
printf("Initialized velocities with default T = 300 K.\n");
}

print_line_1();
printf("Finished initializing positions and related parameters.\n");
fflush(stdout);
Expand Down Expand Up @@ -487,6 +502,9 @@ void Run::parse_velocity(const char** param, int num_param)
atom.velocity_per_atom,
use_seed,
seed);
if (!has_velocity_in_xyz) {
printf("Initialized velocities with input T = %g K.\n", initial_temperature);
}
}

void Run::parse_correct_velocity(const char** param, int num_param)
Expand Down
2 changes: 0 additions & 2 deletions src/main_gpumd/velocity.cu
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,6 @@ void Velocity::initialize(
}

velocity_per_atom.copy_from_host(cpu_velocity_per_atom.data());

printf("Initialized velocities with T = %g K.\n", initial_temperature);
}

void Velocity::finalize() { do_velocity_correction = false; }

0 comments on commit c0d856a

Please sign in to comment.