Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/lmp/plugin/deepmdplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#endif
#include "pair_deepmd.h"
#include "pair_deepspin.h"
#include "pair_dpa4spin.h"
#include "version.h"
#if LAMMPS_VERSION_NUMBER >= 20220328
#include "pppm_dplr.h"
Expand All @@ -22,6 +23,7 @@ using namespace LAMMPS_NS;

static Pair* pairdeepmd(LAMMPS* lmp) { return new PairDeepMD(lmp); }
static Pair* pairdeepspin(LAMMPS* lmp) { return new PairDeepSpin(lmp); }
static Pair* pairdpa4spin(LAMMPS* lmp) { return new PairDPA4Spin(lmp); }

#ifdef LMP_KOKKOS
// Runtime plugins do not consume the PairStyle declarations used by LAMMPS'
Expand Down Expand Up @@ -109,6 +111,13 @@ extern "C" void lammpsplugin_init(void* lmp, void* handle, void* regfunc) {
plugin.handle = handle;
(*register_plugin)(&plugin, lmp);

plugin.style = "pair";
plugin.name = "dpa4spin";
plugin.info = "dpa4spin pair style " STR_GIT_SUMM;
plugin.author = "Tiancheng Li";
plugin.creator.v1 = (lammpsplugin_factory1*)&pairdpa4spin;
(*register_plugin)(&plugin, lmp);

plugin.style = "compute";
plugin.name = "deeptensor/atom";
plugin.info = "compute deeptensor/atom " STR_GIT_SUMM;
Expand Down
26 changes: 26 additions & 0 deletions source/lmp/tests/test_lammps_dpa4spin_registration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
"""Native-spin host registration does not require a model artifact."""

import os

import pytest
from lammps import (
lammps,
)


def test_native_spin_host_style_is_registered() -> None:
"""The runtime plugin, rather than the host binary, must expose dpa4spin."""
plugin = os.environ.get("DEEPMD_TEST_PLUGIN")
if not plugin:
pytest.skip("DEEPMD_TEST_PLUGIN is required to validate plugin registration")

lmp = lammps(cmdargs=["-log", "none", "-screen", "none"])
try:
assert not lmp.has_style("pair", "dpa4spin"), (
"host LAMMPS already provides dpa4spin; plugin provenance is ambiguous"
)
lmp.command(f"plugin load {plugin}")
assert lmp.has_style("pair", "dpa4spin")
finally:
lmp.close()
Loading