Skip to content

IMDv2 generic support implementation with tests - #141

Merged
orbeckst merged 49 commits into
mainfrom
imdv2-support
Nov 24, 2026
Merged

orbeckst merged 49 commits into
mainfrom
imdv2-support

Conversation

@amruthesht

@amruthesht amruthesht commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

This PR provides generic IMDv2 support for handling various v2 streaming scenarios in imdclient

Fixes #140 , #143

Changes made in this Pull Request:

Note: IMDv2 in GROMACS seems to expects transmission rate from the user via the client, as discussed in #143
It ignores IMD-nst in the *.mdp file. Thus the IMDClient object was modified to send IMD_TRATE right after IMD_GO as set in the object initiation when using v2.

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@codecov

codecov Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.41%. Comparing base (901b297) to head (02b94a5).

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends imdclient to handle more IMDv2 streaming patterns (notably variable energy-packet ordering) and adds/updates integration tests and simulation inputs to validate IMDv2 behavior across supported engines.

Changes:

  • Update IMDv2 frame parsing to tolerate multiple leading energy packets before coordinates and to reuse cached energies when energies are omitted.
  • Add IMDv2 integration test coverage alongside existing IMDv3 tests for NAMD, GROMACS, and LAMMPS.
  • Add new IMDv2 engine input/config files and rename/refactor test datafile constants to separate v2/v3 variants.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
imdclient/IMDClient.py Adjust IMDv2 producer parsing to handle multiple/optional energy packets before coordinates.
imdclient/tests/base.py Refactor integration test base class and add an IMDv2-specific integration test class.
imdclient/tests/test_namd.py Split shared NAMD fixtures and add IMDv2 + IMDv3 integration test classes with version-specific inputs.
imdclient/tests/test_lammps.py Split shared LAMMPS fixtures and add IMDv2 + IMDv3 integration test classes with version-specific inputs.
imdclient/tests/test_gromacs.py Split shared GROMACS fixtures and add IMDv2 + IMDv3 integration test classes with version-specific inputs.
imdclient/tests/minimalreader.py Handle missing box data when converting to MDAnalysis dimensions during stream processing.
imdclient/tests/datafiles.py Rename/split datafile constants to explicitly distinguish v2 vs v3 simulation inputs.
imdclient/data/namd/md/namd_v2_nst_1.namd Add NAMD IMDv2 test configuration (NST=1).
imdclient/data/namd/md/namd_v2_nst_8.namd Add NAMD IMDv2 test configuration (NST=8).
imdclient/data/lammps/md/lammps_v2_nst_1.in Add LAMMPS IMDv2 test input (NST=1).
imdclient/data/lammps/md/lammps_v2_nst_8.in Add LAMMPS IMDv2 test input (NST=8).
imdclient/data/lammps/md/lammps_v3_nst_1.in Expand LAMMPS IMDv3 fix options to explicitly enable time/box/coords/vel/forces.
imdclient/data/lammps/md/lammps_v3_nst_8.in Expand LAMMPS IMDv3 fix options to explicitly enable time/box/coords/vel/forces.
imdclient/data/gromacs/md/gromacs_v2_nst1.mdp Add GROMACS IMDv2 test MDP (NST=1).
imdclient/data/gromacs/md/gromacs_v2_nst8.mdp Add GROMACS IMDv2 test MDP (NST=8).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread imdclient/IMDClient.py Resolved
Comment thread imdclient/tests/test_lammps.py Resolved
Comment thread imdclient/tests/base.py Resolved
Comment thread imdclient/tests/minimalreader.py Resolved
Comment thread imdclient/IMDClient.py Resolved
@amruthesht
amruthesht force-pushed the imdv2-support branch 2 times, most recently from fca1842 to bd67a88 Compare June 5, 2026 19:35

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in meeting, wrap the GROMACS streamed coordinates into the unit cell by

  1. extracting the ts.dimensions from the saved trajectory
  2. create two on-the-fly transformations
  3. use the transformations with the in-memory universe that you build with the numpy array of the IMD data

This should generate an in-memory trajectory of wrapped coordinates.

Comment thread imdclient/tests/base.py
container.reload()
if container.attrs.get("State", {}).get("Status") == "running":
container.stop(timeout=30)
except docker.errors.NotFound:
- modify gmx v2 based requirement of sending trate via client
@pytest.fixture()
def first_frame(self):
return 0
def imd_nst(self, mdp):
@orbeckst

Copy link
Copy Markdown
Member

As discussed, we will fall back to the NAMD CPU code from the main branch.

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With tests passing, I think this looks good to 🚢 .

There's a lot of additional work to make v2 useable, including the tests. Well done, @amruthesht

@orbeckst

Copy link
Copy Markdown
Member

@ljwoods2 can you please have a quick look and let us know if we can merge?

@orbeckst orbeckst left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry – code is good but we're still missing

  • docs: section on using v2 (separate from the v3 section), include short discussion on shortcomings
  • CHANGELOG

@amruthesht
amruthesht requested a review from orbeckst November 20, 2026 19:42
@amruthesht

Copy link
Copy Markdown
Contributor Author

Sorry – code is good but we're still missing

  • docs: section on using v2 (separate from the v3 section), include short discussion on shortcomings
  • CHANGELOG

@orbeckst - requested changes were made!
CHANGELOG was updated, and documentation for v2 was added. It notes the discrepancy in IMDv2 units across MD engines as noted in #158 .
However, overall documentation must be revamped later to match the language in the JCTC paper (#157).

@orbeckst

orbeckst commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

(The commit message here is wrong: should have been "0.2.5 unpublished into 0.3.0")

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some docs changes, please

Comment thread docs/source/usage_v2.rst Resolved
Comment thread docs/source/usage_v2.rst Resolved
Comment thread docs/source/usage_v2.rst Resolved
Comment thread docs/source/usage_v2.rst Resolved
Comment thread docs/source/index.rst Resolved
Comment thread docs/source/index.rst Resolved
Comment thread docs/source/usage_v2.rst Resolved
Comment thread docs/source/usage_v2.rst Resolved
Comment thread CHANGELOG.md Resolved
- made limitations clearer
- noted unit issues in v3 changes
- reordered v3 before v2
- name v2 "legacy"
in analysis code instead.

.. note::
Not all simulation engines send energy packets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amruthesht does LAMMPS v3 send energy packets??

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the docs and I am happy with it to be merged.

@orbeckst

Copy link
Copy Markdown
Member

@ljwoods2 if you have time to review please let me know how long you'll need. Otherwise I'll dismiss your review tomorrow and merge as-is. Thanks!

@ljwoods2

Copy link
Copy Markdown
Collaborator

@orbeckst Feel free to move forward without me, otherwise I have time to review the weekend of December 4th.

@orbeckst
orbeckst dismissed ljwoods2’s stale review November 23, 2026 23:57

Earlier comments seem to be addressed and Lawson said he doesn't have time to review until Dec.

@orbeckst
orbeckst merged commit 894c1d8 into main Nov 24, 2026
22 checks passed
@orbeckst
orbeckst deleted the imdv2-support branch November 24, 2026 00:19
@orbeckst

Copy link
Copy Markdown
Member

@amruthesht @ljwoods2 @HeydenLabASU — IMDv2 support is merged! 🎉

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.

IMDv2 in GROMACS requires client to set trate IMDv2 support and tests for receiving positions Add tests for IMDv2 streams

4 participants