Add FlashMD energy rescaling to fix metatomic#51
Draft
johannes-spies wants to merge 1 commit into
Draft
Conversation
Implements the energy-conservation enforcement from App. C of the FlashMD paper (arXiv:2505.19350): with `rescale_energy on`, the predicted momenta are rescaled after each step by alpha = sqrt(1 - (E'-E)/K') so the total energy matches its pre-step value. The potential energy U is taken from a `pair_style metatomic` energy model on top of the fix, read every step via an internal `compute pe` (mirroring how fix npt obtains the virial). The rescale is applied in post_force, i.e. after the FlashMD map and before the thermostat half-step, matching i-PI's operator splitting. Verified on a 108-atom fcc Al NVE example: total energy drifts ~30 meV/atom without rescaling and is flat to machine precision with it, consistent with an i-PI reference and with an independent recomputation of the energy from dumped frames. Example inputs added under examples/PACKAGES/metatomic. fix metatomic/kk overrides initial_integrate/post_force, so the host-side rescale does not run there; it now errors out instead of silently doing nothing. On-device Kokkos support is left as follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
|
I don't love doing this inside the engine. Would it make sense/be possible to implement this by having the FlashMD model request the energy as an extra input, and do the rescaling internally? |
Author
|
Hm, can the models have state/remember the last energy? Because that's what's needed here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the energy-conservation enforcement from App. C of the FlashMD paper (arXiv:2505.19350): with
rescale_energy on, the predicted momenta are rescaled after each step by alpha = sqrt(1 - (E'-E)/K') so the total energy matches its pre-step value.The potential energy U is taken from a
pair_style metatomicenergy model on top of the fix, read every step via an internalcompute pe(mirroring how fix npt obtains the virial). The rescale is applied in post_force, i.e. after the FlashMD map and before the thermostat half-step, matching i-PI's operator splitting.Verified on a 108-atom fcc Al NVE example: total energy drifts ~30 meV/atom without rescaling and is flat to machine precision with it, consistent with an i-PI reference and with an independent recomputation of the energy from dumped frames. Example inputs added under examples/PACKAGES/metatomic.
fix metatomic/kk overrides initial_integrate/post_force, so the host-side rescale does not run there; it now errors out instead of silently doing nothing. On-device Kokkos support is left as follow-up.