Skip to content

Fix Bussi thermostat DOF count and add zero-KE guard - #57

Open
zyxwwxyz wants to merge 1 commit into
mainfrom
bussi
Open

Fix Bussi thermostat DOF count and add zero-KE guard#57
zyxwwxyz wants to merge 1 commit into
mainfrom
bussi

Conversation

@zyxwwxyz

@zyxwwxyz zyxwwxyz commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • n_degrees_of_freedom used a hardcoded 3 * len(atoms), biasing the target temperature upward whenever DOF-removing constraints (e.g. FixCom) are attached. Now uses atoms.get_number_of_degrees_of_freedom(), matching ASE's own reference ase.md.bussi.Bussi implementation.
  • Added a guard in __init__ that raises ValueError if the initial kinetic energy is ~0, to avoid a silent divide-by-zero/NaN when velocities haven't been set yet. Also matches ASE's reference implementation.

Test plan

  • Run the README quickstart example and confirm temperature is unaffected (no constraints attached, so DOF count is unchanged at 3N)
  • Attach a FixCom constraint and confirm the reported/sampled temperature matches target (previously biased ~1-33% high depending on system size)
  • Confirm instantiating Bussi with zero-velocity atoms raises ValueError

🤖 Generated with Claude Code

n_degrees_of_freedom was hardcoded to 3*len(atoms), which biases the
target temperature upward when constraints (e.g. FixCom) remove DOF,
and silently divides by zero if velocities haven't been set yet.
Both fixes mirror ASE's own reference ase.md.bussi.Bussi implementation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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