Skip to content

Optionally reset velocities for MD#686

Merged
alinelena merged 3 commits intostfc:mainfrom
ElliottKasoar:fix-velocities
Mar 20, 2026
Merged

Optionally reset velocities for MD#686
alinelena merged 3 commits intostfc:mainfrom
ElliottKasoar:fix-velocities

Conversation

@ElliottKasoar
Copy link
Member

Resolves #666

This is a slightly different fix to the discussion in the issue, to me it also seems like a reasonable solution that makes sense based on our current parameters (rescale_velocities in particular, since this already guarded an effectively duplicated self._reset_velocities() call):

  • If rescale_velocities is True (default is False) then velocities are reset before heating and/or MD (assuming we're not restarting)
  • If rescale_velocities is False, we don't reset the velocities, unless no velocities have been set, in the same way as NVT_CSVR. I'm also happy to leave the velocities at 0 if it makes more sense

I test that reading in a file with velocities (and rescale_velocities is False) keeps these velocities, so I think it addresses the main point of the issue.

There is also scope for debate about the additional resets we perform in between heating steps, and between heating and MD, but that could also be addressed separately.

How does this look/sound, @trdurrant?

@alinelena
Copy link
Member

what I think is needed to have a test where we have an input file that contains velocities and without any rescale_velocities in the input we keep the user velocities

@ElliottKasoar
Copy link
Member Author

what I think is needed to have a test where we have an input file that contains velocities and without any rescale_velocities in the input we keep the user velocities

Is that not what test_no_reset_velocities does?

lj-traj.xyz includes velocities, so I just reused it for the input file, and I check that with rescale_velocities=False (the default, but included to be explicit) the velocities are unchanged.

@ElliottKasoar
Copy link
Member Author

what I think is needed to have a test where we have an input file that contains velocities and without any rescale_velocities in the input we keep the user velocities

Is that not what test_no_reset_velocities does?

lj-traj.xyz includes velocities, so I just reused it for the input file, and I check that with rescale_velocities=False (the default, but included to be explicit) the velocities are unchanged.

Actually the momenta are stored, not velocities, but I don't think this makes a practical difference.

@alinelena
Copy link
Member

what I think is needed to have a test where we have an input file that contains velocities and without any rescale_velocities in the input we keep the user velocities

Is that not what test_no_reset_velocities does?

lj-traj.xyz includes velocities, so I just reused it for the input file, and I check that with rescale_velocities=False (the default, but included to be explicit) the velocities are unchanged.

cool!

Co-authored-by: Jacob Wilkins <46597752+oerc0122@users.noreply.github.com>
@alinelena alinelena merged commit 1c21f04 into stfc:main Mar 20, 2026
3 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initial velocities for MD non-restart simulations

3 participants