SparkyTruck / deepmd-jax

A lightweight DeepPotentialMD with JAX backend, and more than that! Built for both performance and flexibility in pure Python.
MIT License
17 stars 5 forks source link

MD_simulation_setup #4

Open Wangfeiteng1 opened 1 week ago

Wangfeiteng1 commented 1 week ago

Hi Ruiqi,

I tried to do molecular dynamics simulations using your simulation.py example. I have several questions and I will appreciate it if you can show me the example input.

  1. How to restart the simulations? I tried to restart the simulation by reading the coord.npy and velocity.npy files, but the force.npy has not been wrapped out. Can we produce the force file based on the last snapshot of the coord.npy file?
  2. How to control the wrap/unwrap of atoms? It seems that during the simulation, all the atoms will be wrapped into the original box.
  3. How to control the maximum accepted velocity of the center of mass?

Thank you in advance for your suggestions

Best,

Fei-Teng

SparkyTruck commented 1 week ago

Hi,

Please check out the new staging branch for simulation. Should be much simpler to control simulation and restarting. I'm still finalizing things this week so expect some changes but it should work more or less. I'll make it return the unwrapped coords, thanks for the advice. With DP model being translational invariant, the center of mass shouldn't really move if the initial velocity of zero. Numerical error may accumulate with a very long run though, and I'll try to add the remove-center-of-mass velocity feature real quick.

Wangfeiteng1 commented 1 week ago

Hi

Thank you for your quick answer and I am expecting your progresses. If it is possible and not a tedious work, I hope that more thermostats can be included in the simulation options.

Best,

Fei-Teng

SparkyTruck commented 1 week ago

I am weighing my priorities here but what specific thermostat do you need? Cause I would expect Nose-Hoover to be a good thermostat in most cases.

Wangfeiteng1 commented 1 week ago

Sorry, I do not mean Nose-Hoover is not good enough. I mean for different systems, the thermostats play an important role in faithfully restoring the structural evolution dynamics. If it does not take lots of efforts, I hope that you could leave us with the possibility to test their capability in describing the dynamics. Thank you.

SparkyTruck commented 1 week ago

I still think Nose Hoover should generally (?) be better than Langevin, Anderson, etc. in faithfully restoring the dynamics. Or there are different use cases where those thermostats are required, but an example would be helpful for me to tailor to the need. Anyway, It shouldn't be too hard to customize different thermostats by referencing jax_md/simulate.py for different routines and customizing md.py where you basically only need to change the line that generates init_fn and apply_fn.

Wangfeiteng1 commented 1 week ago

For example, in this JCP paper "Further cautionary tales on thermostatting in molecular dynamics: Energy equipartitioning and non-equilibrium processes in gas-phase simulations" The author stated that "Within the standard scheme for preparing a gas-phase system of flexible many-atom monomers, the Langevin thermostat is found to be very efficient, whereas the NH and CSVR thermostats are unable to produce the correct kinetic energy partitioning in an acceptable amount of equilibration time. Our test simulations for NH and CSVR thermostats show that without actual collisions, monomers are overexcited with respect to their translational and rotational modes at the expense of vibrational energy. In the context of barrierless ion–dipole dimerization, where rotational temperature plays a key role, this hidden bias significantly reduces the dimerization rate coefficient. Effects arising from erroneous equipartition of reactants can be even more drastic for systems with stronger temperature dependencies, e.g., bimolecular reaction complexes involving finite activation barriers." I do not have any preference to these thermostats. Since your are developing the machine learning strategy for molecular dynamics with focus on machine learning part, I think it would be better to be open-minded to the choice of thermostats instead of assuming that one is superior over another. So, leave this test to the users with different background.

SparkyTruck commented 1 week ago

Thanks for the suggestion! I was just weighing the priorities, and you convinced me that I will add Langevin for now. (Though still I would be generally cautious with running NN force fields with highly excited states unless you're confident it is trained on these data -- and maybe equilibrating with an empirical force field first is a option one might consider)