Repository navigation
Add support for flexible barostats in i-PI - #47
Merged
Merged
Conversation
`_qbaro` and `_pbaro` were transcriptions of `BaroBZP.qcstep`/`pstep` with the scalar algebra baked in, so they only worked for the isotropic (BZP) barostat. An MTK barostat, whose `p` is a 3x3 upper-triangular matrix, passed the integrator type check (i-PI restricts the `nst` ensemble to the RGB barostat, so `flexible` runs with `NPTIntegrator`) and then propagated silently wrong dynamics through broadcasting. Both helpers now take a `mode` argument using i-PI's barostat mode names, with the flexible branch following `BaroMTK` -- matrix exponentials for the cell scaling, the full `np.triu` stress for the cell momentum, and the `hmask`/`vol_constraint` projection with its `ethermo` bookkeeping. As in the isotropic branch, the terms that the plain velocity Verlet splitting needs but `OAbBbBABbAbPO` does not (the `sinh` drift term and the `pc.fc` force corrections) are left out. The mode is derived from `type(motion.barostat)`, so it cannot disagree with the input file, and unsupported barostats (SC-BZP, RGB, dummy) now raise instead of being silently mishandled. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
johannes-spies
force-pushed
the
mtk-barostat
branch
from
September 3, 2026 14:50
f5a2a2c to
2f22a4d
Compare
johannes-spies
changed the base branch from
remove-pin
to
update-maintainers
September 3, 2026 15:34
zyxwwxyz
reviewed
Sep 3, 2026
johannes-spies
marked this pull request as ready for review
September 5, 2026 12:44
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.
get_npt_stepperonly worked with isotropic (BZP) barostats, because_qbaroand_pbarohad the logic ofBaroBZPbaked in. An MTK barostat still passed theNPTIntegratortype check.flexibleruns withNPTIntegratorand then silently produced wrong dynamics through broadcasting.We can't call
BaroMTK.qcstep/pstepdirectly. Similar toBaroBZP, they assume a plain velocity Verlet splitting in which the position propagation is interleaved with the barostat steps. FlashMD's splitting does the position propagation entirely inside the ML step, so thesinhdrift term and thepc·fcforce corrections have to be left out. These are the same two omissions the existing isotropic branch already makes compared toBaroBZP. Everything else followsBaroMTK: the matrix exponentials for the cell scaling, the fullnp.triustress and thekb*T*Lterm for the cell momentum, and thehmask/vol_constraintprojection with itsethermobookkeeping.The mode is determined automatically from
type(motion.barostat)instead of being passed in, so it can't disagree with the input file, and unsupported barostats (SC-BZP, RGB, dummy) now raise instead of being mishandled.