pair_style runner: support multiple independent instances - #23
Open
lxknll wants to merge 2 commits into
Open
Conversation
added 2 commits
July 29, 2026 09:12
RuNNer's C interface is instance-based now (API_VERSION 3): each pair style instance creates its own interface handle in the constructor (runner_interface_create), passes it as the first argument to every interface call, and destroys it in the destructor. The one-instance-at-a-time restriction and its static counter are gone -- multiple pair_style runner instances (e.g. in hybrid setups) each own an independent potential.
The handle-based RuNNer interface makes every pair_style runner instance an independent potential, so the single-instance restriction is gone. Update the Restrictions section of the pair_runner doc page accordingly and add a regression check to the ml-runner example: in.ml-runner.H2O.multi overlays the same 2G water potential twice via pair_style hybrid/overlay, and check_multi_instance.sh verifies that the overlaid pair energy is exactly twice the single-instance value (in.ml-runner.H2O.single) -- an invariant that shared global state would break. Verified against a LAMMPS build linked with the handle-based libRuNNer: epair doubles to the last printed digit.
Collaborator
Author
|
As discussed in the RuNNer club, I gave this piece of work to Claude. Obviously we can discuss all of this, but I think the result is already pretty nice 😊 |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So far only one pair_style runner could exist per simulation, because the RuNNer library stored its state globally — a second pair style would have overwritten the first one's settings. The pair style even carried a counter to error out in that case.
RuNNer's interface is now instance-based: the pair style creates its own interface instance in the constructor (runner_interface_create() returns an opaque handle), passes the handle to every library call, and releases it in the destructor. Each pair_style runner therefore owns a fully independent potential — including different models in one simulation via pair_style hybrid.
Changes: