Skip to content

Use setParticles() to restrict atoms - #167

Merged
peastman merged 4 commits into
openmm:mainfrom
peastman:particles
Sep 14, 2026
Merged

peastman merged 4 commits into
openmm:mainfrom
peastman:particles

Conversation

@peastman

Copy link
Copy Markdown
Member

When creating a mixed system, this uses the setParticles() method added to PythonForce in OpenMM 8.6. This can make it a lot faster, since it only needs to transfer data for the particles in the ML region, not the whole system. It also makes the code slightly simpler.

Comment thread openmmml/models/fennixpotential.py Outdated
Comment thread openmmml/models/fennixpotential.py Outdated
peastman and others added 2 commits September 14, 2026 09:21
Co-authored-by: Evan Pretti <pretti@stanford.edu>
Co-authored-by: Evan Pretti <pretti@stanford.edu>
@peastman

Copy link
Copy Markdown
Member Author

Thanks.

@peastman
peastman merged commit 5c78d5a into openmm:main Sep 14, 2026
8 checks passed
@peastman
peastman deleted the particles branch September 14, 2026 18:14
CheukHinHoJerry added a commit to CheukHinHoJerry/openmm-ml that referenced this pull request Sep 17, 2026
…rostatic path

Upstream openmm#167 restricts PythonForce to the ML atoms via setParticles(), so the
callback state no longer carries MM coordinates. PolarMACE electrostatic
embedding needs them in the same forward pass (the MM field polarises the ML
density) and returns MM back-reaction forces, so that path keeps the explicit
index slice/scatter and does not call setParticles(). The plain ML path uses
upstream's restriction unchanged; with indices=None and mmInfo=None
_computeMACE is behaviourally identical to upstream.

Same pattern as the EMLE embedding PR (openmm#159): a full-system PythonForce that
indexes ML and MM regions itself.

Verified on OpenMM 8.6.1 (isolated env) with graph_longrange@external_field:
TestPolarMACEElectrostaticEmbedding + TestElectrostaticEmbeddingPME +
TestMechanicalEmbedding: 104 passed, 6 skipped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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