Skip to content

ts: keep the shape of triclinic cells across the reversible-scaling turning point - #289

Merged
srmnitc merged 3 commits into
ICAMS:mainfrom
pmrv:remap-box-tilts
Nov 22, 2026
Merged

srmnitc merged 3 commits into
ICAMS:mainfrom
pmrv:remap-box-tilts

Conversation

@pmrv

@pmrv pmrv commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Bug: in mode: ts, a triclinic (tilted) cell runs the backward reversible-scaling sweep in a sheared box. At the turning point the cell is reset to the T0 reference lengths, but the tilt factors keep their hot values. fix npt iso/aniso rescales the tilts with the lengths instead of barostatting them, so the shear persists for the whole sweep.
  • Effect: the averaged free energy is biased low. The bias grows from zero at the anchor to about 1 meV/atom near Tm for strongly tilted cells, and ts_dissipation is inflated. Orthogonal boxes are not affected.
  • Fix: the backward sweep continues from the forward end state, with no reset at the turning point. Every remaining reset to the reference cell now also restores the tilt factors.
  • Tested: tilted and orthogonal cells of the same phases, before and after the fix. The shear and the bias are gone. pytest passes, including the lammps and slow tests and new tests for this.
  • Visible change: avg.dat gains nine columns after the existing seven (xy xz yz pxx pyy pzz pxy pxz pyz), and the equilibration and sweep thermo output prints the cell and the stress tensor. Columns 1–7 are unchanged.

Commits

  1. 2671e72: log the tilt factors and the full stress tensor (thermo and avg.dat). No change in behaviour.
  2. fedffda: the averaging stage stores the mean tilts. remap_box restores them, and an orthogonal box gets the same command as before. The P–V-fit rescale (change_box ... scale) scales the tilts too.
  3. df2d994: no remap_box at the start of the backward sweep (phase.py L1733). It came in with the session split in b286426 (L1895 there). Under NVT the cell never changes, so nothing changes there.

Sketch of the mechanism

mechanism

🤖 Generated with Claude Code

pmrv and others added 3 commits November 17, 2026 13:55
…g.dat

Shear stress and the tilt factors were invisible in every calphy output, so a
sheared cell under pressure_coupling iso/aniso (which barostat neither) could
not be detected from a run (#13).

- avg.dat gains columns xy xz yz pxx pyy pzz pxy pxz pyz, appended after the
  existing seven so that every reader of columns 1-7 keeps working.  The
  variable definitions and the ave/time command now live in helpers
  (define_average_variables, average_fix_command, AVG_COLUMNS) instead of
  being repeated in solid, liquid and alchemy.
- The equilibration and reversible-scaling thermo_style lines also print
  lx ly lz xy xz yz pxx pyy pzz pxy pxz pyz.

No change in behaviour; the golden command streams and the avg.dat fixture
are updated for the new columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every stage after the averaging resets the cell to the averaged reference
box with helpers.remap_box, which ran `change_box x/y/z final` only.  That
leaves xy/xz/yz as they were read.  For the backward reversible-scaling leg,
which reads the hot end of the forward leg, a triclinic cell thus got the hot
tilts on the cold lengths, a shear of ~tilt/l * (l_hot/l_cold - 1).  Under
pressure_coupling iso/aniso fix npt does not barostat the tilts but rescales
them with the lengths (scalexy/xz/yz yes), so that shear is kept for the
whole backward leg and biases the averaged free energy low.

- The pressure convergence also averages xy/xz/yz from avg.dat and stores
  them on the job (Phase.xy/xz/yz, 0.0 for an orthogonal box).
- remap_box takes the tilts and sets them with `xy/xz/yz final` whenever one
  is non-zero.  An orthogonal box gets the identical command as before.
- The isotropic rescale of the P-V fit used `change_box x/y/z scale`, which
  likewise leaves the tilts alone; it now scales them too
  (helpers.scale_box_command, `xy final $(xy*s)`).
- tests/test_remap_box_tilts.py: emitted commands, the stored tilts, the
  backward-leg remap, the P-V rescale, and with a real lmp binary that the new
  command restores the cell while the old one keeps the hot tilts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The backward reversible-scaling sweep reads conf.ts.forward_<i>.data, an
equilibrium sample at (lambda_f, lambda_f*P), and then reset the cell to the
reference box measured at T0:
https://github.com/ICAMS/calphy/blob/0b04e22564029a2111aeac610aef0a698c8dc24d/calphy/phase.py#L1733

That reset arrived with the split of the sweep into two LAMMPS sessions in
b286426 ("switch to stepped ts"), which copied the forward sweep's setup:
https://github.com/ICAMS/calphy/blob/b286426019cb81bfcf9a5c52c78590b8fbe271a1/calphy/phase.py#L1895
In the single-session version (36953b2) the backward sweep simply continued
from the forward end state.

The reset compresses the hot cell to the cold lengths, which the middle
equilibration then has to undo (a +6.5 to +9.5 kbar pressure spike at its
first step in the test runs of #14), and for a triclinic cell it
also shears it: change_box ... final leaves the tilts at their hot values,
and fix npt iso/aniso keeps that shear for the whole sweep (#13).

Drop it.  Under NVT the forward sweep never changes the cell, so nothing
changes there.  The other remap_box calls, which pin an equilibrium sample
at T0 to the averaged reference cell, keep restoring the full cell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@srmnitc
srmnitc merged commit 778a9be into ICAMS:main Nov 22, 2026
6 checks passed
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