glotzerlab / hoomd-blue

Molecular dynamics and Monte Carlo soft matter simulation on GPUs.
http://glotzerlab.engin.umich.edu/hoomd-blue
BSD 3-Clause "New" or "Revised" License
336 stars 133 forks source link

Random velocity initialization #228

Closed joaander closed 6 years ago

joaander commented 7 years ago

Original report by me.


Some use-cases would be aided by a random velocity initialization built in to hoomd. Suggested API: Add a method to IntegratorTwoStep that draws random gaussian rngs (calling method in HOOMDMath.h) scaled appropriately for the degrees of freedom provided by the integrator (velocity, angular momentum) accounting for 2D/3D simulations, whether or not anisotropic mode is enabled, and the number of rotational degrees of freedom each particle has. This needs to be in the integrator method because no other class in hoomd has all of this information. The average total veloctiy should be removed to prevent the system from having center of mass motion (this requires a reduction in MPI simulations).

Suggested python API:

nvt = integrate.nvt(T = 1.0, group=my_group)
nvt.randomize_velocities() # uses set point T, no arguments required
# post: particles in my_group have random velocities and angular momentum as appropriate
joaander commented 7 years ago

There is a subtle difficulty with the proposed API. The integration methods do not know what the anisotropic mode is until after prepRun is called.

Thus, randomize_velocities() should set a flag to trigger a randomization of the velocities at the start of the next run(). prepRun will call randomizeVelocities for each integration method. Each method will then randomize its velocities if the flag is set and then reset the flag.

It is reasonable to randomize velocities with an NVE integrator. In this case, the user will need to supply a temperature T. This temperature will need to be saved and used when randomizing the velocities. This implementation can be in the base class integration method. At the python level, nvt will determine T from the python method object and set it in C++ where nve will take in T as an argument.

Summary of changes needed:

  1. Add flag and randomization T variable to IntegrationMethodTwoStep
  2. Add randomizeVelocities() method to IntegrationMethodTwoStep
  3. Add call randomizeVelocities for all methods in IntegratorTwoStep::prepRun
  4. Add python API randomize_velocities to integration methods that sets the flags.
joaander commented 7 years ago

@avisekdas How far did you get on your implementation? Will you have time to finish off the last parts next week?

joaander commented 7 years ago

Original comment by Avisek Das (Bitbucket: avisekdas, GitHub: avisekdas).


Hi Josh,

I think it's basically done. I have run some initial tests, but I need to run more tests. I need to test the rigid body part of the code. Do you have suggestion for a suitable test system?

Thanks, Avisek

joaander commented 7 years ago

The rigid rods example in the tutorial notebooks would be a good test system.

http://nbviewer.jupyter.org/github/joaander/hoomd-examples/blob/master/Tutorial%20-%20MD%20-%20Rigid%20rods.ipynb

joaander commented 7 years ago

Let me know what I can do to help move this along. I would like to include this capability in hoomd v2.2 - to be released soon.

joaander commented 7 years ago

Original comment by Avisek Das (Bitbucket: avisekdas, GitHub: avisekdas).


Hi Josh,

I think I did complete the job, but I didn' have time to extensively test it. I won't have time for this in the next month. If you can take over the testing, please do so. Otherwise we have to include this in a 2.2.* release.

Thanks, Avisek

joaander commented 7 years ago

Original comment by Avisek Das (Bitbucket: avisekdas, GitHub: avisekdas).


Come to think of it, I can do some testing in the next hackathon. I did sign up for another project though.

Thanks, Avisek

joaander commented 7 years ago

However and whenever you wish to work on finalizing this is fine with me. I, and other hoomd developers and users will review it only after a pull request is submitted.

v2.2 will be released Sep 8, 2017.

joaander commented 7 years ago

Rescheduling for v2.3.