Skip to content

pair_style runner: support multiple independent instances - #23

Open
lxknll wants to merge 2 commits into
developfrom
enh-handle-api
Open

pair_style runner: support multiple independent instances#23
lxknll wants to merge 2 commits into
developfrom
enh-handle-api

Conversation

@lxknll

@lxknll lxknll commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

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:

  • pair_runner.cpp/h: handle argument on all library calls; the one-instance-at-a-time restriction and its counter are removed. Requires a RuNNer library with interface API version 3 (checked at startup as before).
  • pair_runner.rst: the "only one instance" restriction paragraph is replaced by a description of the new behavior.
  • New check in the ml-runner example: in.ml-runner.H2O.multi overlays the same water potential twice via hybrid/overlay, and check_multi_instance.sh verifies that the pair energy is exactly twice the single-instance value — a simple invariant that would fail with shared state. Verified against a real build: the energy doubles to the last printed digit.

aknoll 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.
@lxknll

lxknll commented Jul 29, 2026

Copy link
Copy Markdown
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 😊

@lxknll

lxknll commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

pinging @knlausch and @M0M097 for comments.

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