Skip to content

Multiple improvments and fixes for path and simulation modules. - #1378

Merged
chrisjonesBSU merged 31 commits into
mosdef-hub:developfrom
chrisjonesBSU:fix-azimuthal-sampling
Oct 20, 2026
Merged

chrisjonesBSU merged 31 commits into
mosdef-hub:developfrom
chrisjonesBSU:fix-azimuthal-sampling

Conversation

@chrisjonesBSU

Copy link
Copy Markdown
Contributor

PR Summary:

Fix azimuthal sampling in random walks, plus PBC, backmapping and HOOMD updates

This started as a fix for biased azimuthal sampling in hard_sphere_random_walk. A few related fixes ended up on the branch along the way, so it's a bit of a grab bag.

Random walks

  • Trial vectors are now drawn from a normal distribution instead of a uniform cube. The cube favored its diagonals, so the azimuth around the chain wasn't uniform. Heads up: the same seed gives different walks than develop now. Seeding is still reproducible on this branch, and the existing seed tests pass.
  • PBC fixes:
    • The previous site gets unwrapped (minimum image) before the next step is built, so bond angles come out right across the boundary. This includes the first angle of a link-linear walk.
    • get_second_point wraps its candidates into the box.
    • All the overlap checks in points.py now get pbc and box_lengths.
  • TargetCoordinate takes an optional capture_radius. Inside it, the bias weight ramps up to 1 as the walk gets close to termination_radius. That radius can come from a WithinCoordinate terminator, and capture_radius="auto" uses 10x the bond length. If that isn't larger than termination_radius, the walk raises an error before it starts and says to pass a float.
  • When include_compound is used, biases now see the chain tip as coordinates[-1]. Before, the second step saw a compound particle there instead. This also fixes TargetDirection and AvoidDirection, which had the same bug on develop.
  • The small-angle overlap warning respects choice sampler weights, skips zero-weight angles, and stays quiet below 0.5%.

Backmapping

  • New box argument. For a Compound it defaults to system.box. Bonds across the boundary are oriented using the minimum image, so fragments point through the boundary instead of across the box.
  • Children are added in lists instead of one at a time. That's roughly 2x faster on large systems.
  • Not in this PR: atoms near a face can still end up a little outside the box, and the output doesn't get a box set. That's part of a separate issue about consolidating PBC wrapping around freud.

HoomdSimulation

  • Frame handling:
    • Coordinates are matched to a centered or a corner box layout, per axis.
    • Systems that fit neither layout, or that only have a bounding box, are shifted in as one rigid piece instead of being wrapped atom by atom. Before this, a molecule far from the origin could get moved and split.
    • The frame is cached with the snapshot, so a reused snapshot round-trips correctly even if the coordinates now look like the other layout. A cached snapshot is only reused if its box still matches the requested box, so a new simulation after box_update doesn't shift the system.
  • nvt and box_update accept kT=[start, finish] and ramp between the two values. A list or array that isn't exactly two values raises a ValueError.
  • ForcesHandler scales tabulated angle and dihedral potentials. Before, they were dropped whenever a handler was used.
  • New speedup_by_moltag option made accessible from mBuild simulation model. It is passed through to gmso.
  • The path forcefield now leaves angle partners out of the WCA when the angle table covers every angle type. Develop only left out bonded pairs. Dihedral partners are left out when the dihedral table covers every type and angle partners are already left out. Without tables, only bonded pairs are left out, as before. The ForcesHandler docstring notes that scaling a table down, or the default scale_periodic=0, lets those beads overlap.
  • A few print calls are now logger.info. The GPU fallback message is a logger.warning.

PR Checklist


  • Includes appropriate unit test(s)
  • Appropriate docstring(s) are added/updated
  • Code is (approximately) PEP8 compliant
  • Issue(s) raised/addressed?

chrisjonesBSU and others added 25 commits August 26, 2026 10:04
… set default box values. All of this information is available by RandomWalkState, add a test to make sure wrapping is being done outside the main RW loop (i.e., in points.py second point)
… prevents over-sampling box corners/diagonals
…y handle table potentials in HOOMD's simulation class
…age convention ensures bonds crossing the periodic boundaries are correctly oriented
… one-at-a-time. Roughly 2x speed up when backmapping large compounds
Resolve conflicts in TargetCoordinate.__call__ by combining the adaptive
capture-radius weight with the PBC-aware distance calculation. The
capture-radius ramp now also uses minimum-image distance when attached
to a walk, consistent with WithinCoordinate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt, rather than always using the default, which could allow for paricle overlaps when angles and/or dihedrals aren't in the path FF
…nge info to warning when no GPU is found in HoomdSimulation and run_on_gpu is True
@chrisjonesBSU chrisjonesBSU added the 2.0 Additions for mBuild 2.0 label Oct 19, 2026
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.22034% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.67%. Comparing base (b3a8db1) to head (6cdeb9f).

Files with missing lines Patch % Lines
mbuild/simulation.py 92.39% 7 Missing ⚠️
mbuild/path/path_utils.py 66.66% 6 Missing ⚠️
mbuild/coarse_graining/backmap.py 95.23% 1 Missing ⚠️
mbuild/path/bias.py 98.43% 1 Missing ⚠️
mbuild/utils/simulation/path_forces.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1378      +/-   ##
===========================================
+ Coverage    82.39%   82.67%   +0.28%     
===========================================
  Files           72       72              
  Lines         8604     8747     +143     
===========================================
+ Hits          7089     7232     +143     
  Misses        1515     1515              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

chrisjonesBSU added 3 commits October 19, 2026 11:51
…more robust. Before, scaled forces were cached, so recreating a Simulation class instance on the same compound would carry the last-used ForcesHandler scaling. This perserves the original params throughout, including the cached forces
@chrisjonesBSU
chrisjonesBSU merged commit 54f3075 into mosdef-hub:develop Oct 20, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.0 Additions for mBuild 2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant