Skip to content

Bug fixes in MD, cell optimizers, Ewald stress and elastic tensors - #626

Merged
CompRhys merged 3 commits into
mainfrom
fix/high-severity-bugs
Oct 26, 2026
Merged

CompRhys merged 3 commits into
mainfrom
fix/high-severity-bugs

Conversation

@abhijeetgangan

@abhijeetgangan abhijeetgangan commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Unseeded states seed rng from torch's global generator instead of torch.Generator()'s fixed default seed, so unseeded runs differ and torch.manual_seed() makes them reproducible. Nosé-Hoover and NVE draw their starting momenta from rng too, so their unseeded runs now differ as well. The reproducibility docs are updated to match, and their Nosé-Hoover example now seeds the state.
  • BinningAutoBatcher gives each batch after the first its own seed drawn from the state's generator, so replicas in different batches no longer get identical noise, seeded or not.
  • The Nosé-Hoover chain, thermostat and barostat are now per-system attributes, so slicing, splitting and concatenating keep each system's own chain, and .to() converts it.
  • Triclinic C-rescale updates the cell as mu @ h to match the position update, so atoms keep their fractional coordinates. The old update heated a 60 K run to 88 K. mu is now the upper-triangular R of the deformation's QR decomposition instead of R^T, because R^T @ h would slowly rotate upper-triangular cells such as ASE's.
  • The triclinic deviatoric correction uses the same column-vector convention, so the same crystal described in two lattice bases now deforms identically. In an MD check, cubic and primitive fcc Ar cells under the same anisotropic pressure now strain the same to 1e-5, where they differed by 7%.
  • BFGS with a cell filter now moves the cell of smaller systems in a mixed-size batch, which were reading padded atom DOFs instead of their cell DOFs.
  • concatenate_states pads the BFGS Hessian and L-BFGS history before the cell block instead of after it, so cell-optimizer states of different sizes keep their cell DOFs in place when merged. It also pads a shorter L-BFGS history at the front instead of the end, so the newest pair stays last. Before, the last pair of a merged system with a shorter history was zero padding, so its step lost the usual initial Hessian scaling and differed from the step it would take alone.
  • BFGS with a cell filter updates the cell through set_constrained_cell and scales atoms with the cell, as L-BFGS does, so FixSymmetry now holds.
  • vv_fire with a cell filter now moves the cell; it only ever moved the atoms.
  • vv_fire mixes velocities with the current alpha before decaying it, the vv_fire counterpart of ase_fire departs from ASE's FIRE: alpha decayed before mixing, and dt halved for structures joining a running batch #611.
  • EwaldModel recomputes a system's stress on its own when the batch's shared k-space grid gives it a 0/0 virial, instead of returning NaN.
  • A rhombohedral cell whose 3-fold axis isn't along z, such as ASE's primitive FCC or BCC, now gets a triclinic elastic fit instead of trigonal constraints that assume that axis. make_sb_sim_state now rotates its axis onto z.
  • A hexagonal lattice with a trigonal space group, such as R-3m Sb in the hexagonal setting, now gets a trigonal elastic fit when moyopy is available.
  • Every fix extends an existing test that fails on main.
  • Each test now starts from torch.manual_seed(0). test_optimizer_sym_converges uses noise that FixSymmetry cancels exactly, because before it passed for only about 1 seed in 10. Its LJ now has σ = 2.5 Å, near the hcp neighbor distance, so the strained cell starts well above the force tolerance instead of already converged, and it gets twice MAX_STEPS.

Checklist

Before a pull request can be merged, the following items must be checked:

  • Doc strings have been added in the Google docstring format.
  • Run ruff on your code.
  • Tests have been added for any new functionality or bug fixes.

@CompRhys
CompRhys merged commit 978a857 into main Oct 26, 2026
62 of 64 checks passed
@CompRhys
CompRhys deleted the fix/high-severity-bugs branch October 26, 2026 07:29
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