Skip to content

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

Merged
johannes-spies merged 1 commit into
mainfrom
bussi
Sep 22, 2026
Merged

johannes-spies merged 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>

@johannes-spies johannes-spies left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johannes-spies
johannes-spies merged commit 1a7cb0e into main Sep 22, 2026
4 checks passed
@johannes-spies
johannes-spies deleted the bussi branch September 22, 2026 07:57
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.

2 participants