Skip to content

Add EquipartitionMonitor to catch per-group temperature drift - #53

Draft
zyxwwxyz wants to merge 14 commits into
mainfrom
equipart
Draft

Add EquipartitionMonitor to catch per-group temperature drift#53
zyxwwxyz wants to merge 14 commits into
mainfrom
equipart

Conversation

@zyxwwxyz

@zyxwwxyz zyxwwxyz commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add EquipartitionMonitor, an ASE dynamics observer that reports instantaneous kinetic temperature for the whole system, and for one group per chemical species
  • Exact energy conservation (rescale_energy=True) only fixes the total energy by rescaling all momenta by a single global factor each step — it says nothing about how kinetic energy is distributed, so a model that systematically mispredicts a subset of degrees of freedom can leave some atoms hotter or colder than others without tripping any energy-conservation check
  • Add docs/equipartition.md explaining the issue and how to use the monitor, and link to it from the README energy-conservation section
  • Add unit tests covering default per-species grouping, custom groups, name-clash validation, logfile output, and attaching to a real VelocityVerlet run

Test plan

  • pytest tests/test_equipartition.py -k "not attaches_as_a_dynamics_observer" passes locally
  • test_attaches_as_a_dynamics_observer (downloads a pretrained model) should be run in CI

🤖 Generated with Claude Code

zyxwwxyz and others added 14 commits September 4, 2026 09:40
Exact energy conservation only fixes the total energy, so a model that
systematically mispredicts a subset of degrees of freedom can keep
some atoms hotter or colder than others without it showing up as an
energy-conservation violation. The monitor tracks per-species (and
custom-group) kinetic temperature as an ASE dynamics observer so this
kind of bias is easy to catch.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Clarify the impact of global rescaling on temperature distribution among atoms.
Removed redundant explanation about energy conservation and restructured the description of the EquipartitionMonitor.
Refactor comment for clarity and conciseness.
The logfile "step" column was actually a call counter (len(self.history)),
which only matches the true dynamics step when attached with interval=1.
With interval=10 (the documented example), a "step 3" entry was really
step 30, silently corrupting any downstream time axis.

EquipartitionMonitor now takes the dynamics object itself instead of
atoms, reading dyn.atoms for momenta and dyn.nsteps for the real step
count, mirroring how ase.md.MDLogger accesses dyn. Also switch the
logfile from append to write mode, since silently appending to a stale
file from an earlier/unrelated run produced a malformed, doubly-headered
log.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Removed redundant phrase about diagnostic availability for i-PI and LAMMPS users.
Custom groups added API surface (name-clash validation, extra
constructor arg) for a use case (arbitrary spatial regions) that isn't
core to the diagnostic; per-species grouping alone covers the main
failure mode this monitor targets. Also document that "system" and the
per-species entries use different degrees-of-freedom conventions (many
MD codes subtract 3 DOF from the global temperature for the conserved
center-of-mass motion, which can't be meaningfully attributed to an
arbitrary subgroup), so users don't mistake the resulting small,
systematic offset for a real equipartition violation.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The previous wording cited LAMMPS/i-PI conventions, but this monitor
only involves ASE. Reframe the note around ase.Atoms.constraints
directly: with no constraints, "system" and per-species entries agree
on the 3N convention; the mismatch only appears once you impose a
constraint that removes degrees of freedom (e.g. FixCom), since that
correction can't be meaningfully attributed to an arbitrary subgroup.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Remove redundant explanation about convention mismatch in equipartition.
Removed redundant explanation regarding convention mismatch in equipartition.
Added note about fluctuations in per-group temperatures and clarified degrees-of-freedom conventions.
Added note about fluctuations in instantaneous per-group temperatures for small cells.
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.

1 participant