Skip to content

Add support for flexible barostats in i-PI - #47

Merged
johannes-spies merged 6 commits into
mainfrom
mtk-barostat
Sep 7, 2026
Merged

johannes-spies merged 6 commits into
mainfrom
mtk-barostat

Conversation

@johannes-spies

@johannes-spies johannes-spies commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

get_npt_stepper only worked with isotropic (BZP) barostats, because _qbaro and _pbaro had the logic of BaroBZP baked in. An MTK barostat still passed the NPTIntegrator type check. flexible runs with NPTIntegrator and then silently produced wrong dynamics through broadcasting.

We can't call BaroMTK.qcstep/pstep directly. Similar to BaroBZP, 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 the sinh drift term and the pc·fc force corrections have to be left out. These are the same two omissions the existing isotropic branch already makes compared to BaroBZP. Everything else follows BaroMTK: the matrix exponentials for the cell scaling, the full np.triu stress and the kb*T*L term for the cell momentum, and the hmask/vol_constraint projection with its ethermo bookkeeping.

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.

`_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
johannes-spies changed the base branch from main to remove-pin September 3, 2026 14:50
@johannes-spies
johannes-spies changed the base branch from remove-pin to update-maintainers September 3, 2026 15:34
Base automatically changed from update-maintainers to main September 3, 2026 15:48
Comment thread src/flashmd/ipi.py Outdated
Comment thread src/flashmd/ipi.py Outdated
Comment thread src/flashmd/ipi.py
Comment thread src/flashmd/ipi.py Outdated
@johannes-spies
johannes-spies marked this pull request as ready for review September 5, 2026 12:44
@johannes-spies johannes-spies changed the title Add support for flexible barostats Add support for flexible barostats in i-PI Sep 5, 2026
@johannes-spies
johannes-spies merged commit e368313 into main Sep 7, 2026
4 checks passed
@johannes-spies
johannes-spies deleted the mtk-barostat branch September 7, 2026 06:20
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