Skip to main content

rgpot

img

codecov

rgpot is a potential-energy library and Cap'n Proto RPC server for atomistic simulation codes. It gives clients one geometry carrier, one result carrier, and one extensible backend-configuration carrier:

  • ForceInput: positions, atomic numbers, box, and unit strings
  • PotentialResult: energy plus flat force array
  • PotentialConfig: backend setup, with arms such as none, nwchem, and cpmd

XC response kernels (rgpot::XcKernel, meson -Dwith_xckernel=true) are in-process only. They are not a Potential, and there is no PotentialConfig.xckernel arm: operands are collocation plus named Libxc arrays, not ForceInput. See docs/xckernel.md. pylibxc is not on PyPI (pylibxc2 is an unrelated stub); use the conda-forge libxc package via pixi install -e xckernel.

D3Pot and D4Pot (meson -Dwith_dftd3 / -Dwith_dftd4) are in-process Potential summands: construct them and evaluate ForceInput to energy and forces. There is no PotentialConfig.d3 or PotentialConfig.d4 arm. A DFT host sums XcKernel + VV10 + D4 itself; dispersion is not folded into the XC kernel.

ExprPot (meson -Dwith_expr=true) compiles a Lepton energy string over named child Potential objects. The parser is vendored OpenMM Lepton; there is no pixi muparser feature and no PotentialConfig.expr arm.

In-process LJPot vs pyeonclient Matter on the same LJ fixture is scripts/time_lj_rgpot_vs_pyeonclient.py (rg.terra). On rg.terra (2026-09-04, 1e6 calls) A (LJPot::operator()) was 31-33 ns/call and B (in-process pyeonclient Matter.forces, not potserv) was 687 to 791 ns/call. XcKernel is not a Potential and is not part of that race. See docs/orgmode/howto/exprpot.org.

The public wire schema lives in CppCore/rgpot/rpc/Potentials.capnp and is shared by the C++ server, Python integration tests, and the Rust core crate. Native rgpot units are eV and Angstrom. RPC clients may request compatible units through ForceInput.lengthUnit and ForceInput.energyUnit.

Python (PyPI)

Install the manylinux wheel (nanobind abi3, Python >= 3.12 for the stable ABI extension; requires-python is >= 3.10 for pure metadata):

pip install rgpot
# Metatomic path (engine libs resolve from these packages at runtime):
pip install 'rgpot[metatomic]'
# or: pip install torch metatomic-torch metatensor-torch metatensor-core vesin

The PyPI wheel compiles ExprPot (vendored Lepton), D3Pot, D4Pot, and XcKernel. s-dftd3 / dftd4 are linked and vendored; no conda install is required at pip install time. Lennard-Jones needs only numpy. Metatomic uses dlopen of a bundled engine:

  • layout: rgpot/lib/torch-X.Y/libmetatomic_engine.so
  • picker: installed torch major (same multi-ABI idea as metatomic-torch)
  • supported torch majors: 2.7 and newer (wheels ship 2.7–2.13 engines)
  • torch 2.6 and older are not supported for Metatomic dlopen
import numpy as np
import rgpot

print(rgpot.__version__)
print(rgpot.has_expr, rgpot.has_dftd3, rgpot.has_dftd4, rgpot.has_xckernel)
print(rgpot.available_metatomic_engine_abis())  # e.g. 2.7 .. 2.13
# energy, forces, variance = rgpot.LJPot()(positions, atom_types, box)
# energy, forces, variance = rgpot.D3Pot()(positions, atom_types, box)
# energy, forces, variance = rgpot.ExprPot(
#     "0.5*lj + d3", {"lj": "lj", "d3": "d3"})(positions, atom_types, box)
# print(rgpot.XcKernel.catalog())
# energy, forces, variance = rgpot.evaluate_metatomic(
#     positions, atom_types, box, model_path="model.pt")

See https://pypi.org/project/rgpot/.

Build And Test

Meson is the primary build path. Use the rpctest environment when running the RPC integration scripts because they need pycapnp.

pixi shell -e rpctest
meson setup bbdir -Dwith_tests=true -Dwith_rpc=true --buildtype=debug
meson compile -C bbdir
meson test -C bbdir --print-errorlogs
python tests/rpc_integ.py --server-bin ./bbdir/CppCore/potserv

CMake is supported as well:

cmake -B build \
  -DRGPOT_BUILD_TESTS=ON \
  -DRGPOT_BUILD_EXAMPLES=ON \
  -DRGPOT_WITH_RPC=ON
cmake --build build
ctest --test-dir build --output-on-failure

For client-only consumers that only need the Cap'n Proto schema and generated RPC client types:

cmake -B build_client \
  -DRGPOT_RPC_CLIENT_ONLY=ON \
  -DRGPOT_BUILD_TESTS=ON
cmake --build build_client
ctest --test-dir build_client --output-on-failure

Backends

Backend Server selector Build / runtime notes
LJ LJ Built-in 12-6 Lennard-Jones reference potential
CuH2Pot CuH2 Built-in Cu-H EAM potential
XTBPot XTB, GFNFF, GFN0xTB, GFN1xTB Enable with -Dwith_xtb=true; use pixi env xtbbld or tbbld; linked XTBPot + dlopen libxtb_engine.so (see docs/xtb_backends.md)
TBLitePot TBLite, TBLiteGFN1, TBLiteIPEA1 Enable with -Dwith_tblite=true; use pixi env tblitebld or tbbld
D3Pot D3 In-process Potential summand. Enable with -Dwith_dftd3=true; use pixi env dftd3 or dftd. BJ/zero damping, functional key, explicit ATM flag. No PotentialConfig.d3. Goldens: meson test --suite dftd
D4Pot D4 In-process Potential summand. Enable with -Dwith_dftd4=true; use pixi env dftd4 or dftd. Functional key, charge, explicit ATM/many-body flag. No PotentialConfig.d4. Goldens: meson test --suite dftd
ExprPot in-process Enable with -Dwith_expr=true. Vendored OpenMM Lepton (no pixi muparser). Named Potential children; construct-time fail-closed names. No PotentialConfig.expr.
MetatomicPot Metatomic:<model_path> Enable with -Dwith_metatomic=true; use pixi env metatomicbld. Pip engines: torch 2.7+
UmaPot Uma:<model_path>, Uma:<model_path>:omol Enable with -Dwith_metatomic=true. AOTInductor .pt2 plus vesin neighbor lists; charge/spin are per-call tensor inputs
NWChemPot NWChem Frontend always builds; load libnwchemc from the split nwchemc project at runtime
CPMDPot CPMD Frontend always builds; load libcpmdc from the split cpmdc project at runtime
UmaPot Uma:<model.pt2> UMA / OMol AOTInductor .pt2. Vesin neighbors, one package per composition. See CppCore/rgpot/UmaPot/README.md.
SkalaPot Skala Skala XC on NWChem DFT via libnwchemc.
MOPACPot MOPAC Frontend always builds; load libmopacc from the split mopacc project at runtime (OpenMOPAC). Packed params. Default model AM1.

Copyable construct-and-evaluate (meson -Dwith_expr=true). PotentialHandle::from_impl / rgpot_potential_new_eindir wraps that one ExprPot as one eindir objective for rgmin, rgsaddle, and anneal.

#include "rgpot/ExprPot/ExprPot.hpp"
#include "rgpot/LennardJones/LJPot.hpp"
#include "rgpot/Morse/MorsePot.hpp"
#include "rgpot/types/AtomMatrix.hpp"

#include <array>
#include <memory>
#include <vector>

int main() {
  std::vector<rgpot::ExprPot::Term> terms;
  terms.emplace_back("lj", std::make_unique<rgpot::LJPot>());
  terms.emplace_back("morse", std::make_unique<rgpot::MorsePot>());
  rgpot::ExprPot pot("0.5*lj + morse", std::move(terms));

  rgpot::types::AtomMatrix positions{{1.0, 2.0, 3.0}, {1.5, 2.5, 3.5}};
  std::vector<int> atomTypes{0, 0};
  std::array<std::array<double, 3>, 3> box{{
      {15.0, 0.0, 0.0},
      {0.0, 20.0, 0.0},
      {0.0, 0.0, 30.0},
  }};
  auto [energy, forces, variance] = pot(positions, atomTypes, box);
  (void)forces;
  (void)variance;
  (void)energy;
}

When the build also has -Dwith_dftd3=true, swap the Morse child for D3Pot and the string "0.5*lj + d3".

Example server commands:

./bbdir/CppCore/potserv 12345 LJ
./bbdir/CppCore/potserv 12345 Metatomic:CppCore/tests/data/lj38/lennard-jones.pt
CPMDC_LIBRARY=/path/to/libcpmdc.so ./bbdir/CppCore/potserv 12345 CPMD
NWCHEMC_LIBRARY=/path/to/libnwchemc.so ./bbdir/CppCore/potserv 12345 NWChem

CPMD And NWChem Configuration

CPMD and NWChem do not use ad hoc rgpot config files. They use the PotentialConfig union over RPC:

  • PotentialConfig.cpmd carries CPMDParams for CPMDPot
  • PotentialConfig.nwchem carries NWChemParams for NWChemPot
  • geometry still arrives through ForceInput on every calculate() call

For CPMD, tests/cpmd_params.py contains pycapnp helpers for building CPMDParams and PotentialConfig.cpmd messages. The helper covers scalar fields, raw inputBlocks, and every structured CPMDInputSection arm. See CppCore/rgpot/CPMDPot/README.md for the engine lookup order and schema field mapping.

The CPMD runtime path is:

  1. Build libcpmdc.so in the split cpmdc repository (or use the in-tree libcpmdc_fake_engine.so from a -Dwith_tests=true build for CI).
  2. Start potserv <port> CPMD with CPMDC_LIBRARY, RGPOT_CPMDC_ENGINE, or RGPOT_CPMD_ENGINE pointing at that shared library.
  3. Send configure(PotentialConfig.cpmd) once for method setup.
  4. Send ForceInput on each calculate() call for geometry and requested output units.

For NWChem, tests/nwchem_params.py builds NWChemParams / PotentialConfig.nwchem. Engine lookup order is NWCHEMC_LIBRARY, RGPOT_NWCHEMC_ENGINE, RGPOT_NWCHEM_ENGINE, then enginePath on params. See CppCore/rgpot/NWChemPot/README.md. The NWChem runtime path mirrors CPMD:

  1. Build libnwchemc.so in the split nwchemc repository (or libnwchemc_fake_engine.so from a tests build).
  2. Start potserv <port> NWChem with the library env vars above.
  3. configure(PotentialConfig.nwchem) once, then calculate(ForceInput).

potctl drives the same Potential Cap'n Proto RPC against potserv (bridge stress and CI legs pass the potential name such as NWChem or CPMD).

Developer Tasks

Hooks use prek through prek.toml. Common commands:

pixi r prek-install
pixi r prek
pixi r rust-test
pixi r -e rpctest python tests/test_cpmd_params.py
pixi r -e rpctest python tests/test_nwchem_params.py
pixi r -e rpctest python tests/test_rpc_integ_cpmd.py
pixi r -e rpctest python tests/test_rpc_integ_nwchem.py
# Full RPC + C ABI E2E (point env at built fake engines + potserv)
export RGPOT_POTSERV=/path/to/bbdir/CppCore/potserv
export NWCHEMC_LIBRARY=/path/to/bbdir/CppCore/libnwchemc_fake_engine.so
export RGPOT_CPMD_ENGINE=/path/to/bbdir/CppCore/libcpmdc_fake_engine.so
pixi r -e rpctest python tests/test_rpc_e2e_c_abi.py
pixi r -e rpctest python tests/rpc_integ.py \
  --server-bin ./bbdir/CppCore/potserv \
  --nwchem-smoke \
  --cpmd-smoke

The root README is generated from readme_src.org. Project documentation sources live under docs/orgmode/.

License

MIT, with backend-specific notes: some potentials are adapted from eOn under BSD-3-Clause terms. The unit expression parser in CppCore/rgpot/units.cc is derived from metatomic-torch (BSD-3-Clause, metatensor developers).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rgpot-3.2.0.tar.gz (38.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rgpot-3.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.8 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

rgpot-3.2.0-cp312-abi3-macosx_14_0_arm64.whl (10.1 MB view details)

Uploaded CPython 3.12+macOS 14.0+ ARM64

rgpot-3.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

rgpot-3.2.0-cp311-cp311-macosx_14_0_arm64.whl (10.1 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

rgpot-3.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

rgpot-3.2.0-cp310-cp310-macosx_14_0_arm64.whl (10.1 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file rgpot-3.2.0.tar.gz.

File metadata

  • Download URL: rgpot-3.2.0.tar.gz
  • Upload date:
  • Size: 38.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rgpot-3.2.0.tar.gz
Algorithm Hash digest
SHA256 4d32054904fb5477ecc4310860bc9cf5035569b6fa4aa53d2150eaabded2f336
MD5 f0e62531a32ceb25634c2f4f1d9d7e6b
BLAKE2b-256 51a824e3b1458287f4f0a38644949886fad5fc8807e082e258d8763ede956089

See more details on using hashes here.

File details

Details for the file rgpot-3.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rgpot-3.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cfddad60ca0d9778b705c976a9bf5b88abf61d40e463247b721c943591206778
MD5 ec818c11881ca49ac0f791041a65f15a
BLAKE2b-256 20e036cc62e1a33e145b4255ec10b7c8cdc05af564dfe8da2552dd08e0ad9807

See more details on using hashes here.

File details

Details for the file rgpot-3.2.0-cp312-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rgpot-3.2.0-cp312-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 10389f7a3e65ef7e07f6a4cd44df36ede67d2ed6b65f96390c791c77284c006b
MD5 b8382d5b72495aea8b85d419a43842a2
BLAKE2b-256 0d47f270529bb4f339690a32b0c274e4fefaa5ebebb1b319804257993ef41010

See more details on using hashes here.

File details

Details for the file rgpot-3.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rgpot-3.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f0ac0924d84fb38daf69aa78832a0dde3837994177f3dea6349808a67f2ef7a5
MD5 c205a34a086439885a39f40c54f148e0
BLAKE2b-256 f077a6bdb15084dc39ee676032ca200936f02ef3049b0f41948eae9f3ae8bc2d

See more details on using hashes here.

File details

Details for the file rgpot-3.2.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rgpot-3.2.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0e628a197a93e4496706d190ccaf79c89f1bb6247e65ad9c727a0751c9cf7180
MD5 96a910c64631cc1d6330dbd09dd935a9
BLAKE2b-256 52af7600cfa5d71c15ea8ea43025e7d3998802fc77d0ce99b81bf70961d9fce7

See more details on using hashes here.

File details

Details for the file rgpot-3.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rgpot-3.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ba2c65b853d2fdcc69beddce7e1ee2217341765c1755e22f2ae4871ad2858bf
MD5 36e901d8b57e32cd444c565adeb2ab7e
BLAKE2b-256 28debac2bb81d14268466e9052b49c20f0b16b1df5f3d2f764ce44c8d8f664cc

See more details on using hashes here.

File details

Details for the file rgpot-3.2.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rgpot-3.2.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a21e3d5650df3e9332aabf731a4c8b6e179a924936a6d71aca6f5b5f1445156e
MD5 a4854ca364d5a6c34fb332e006c2e668
BLAKE2b-256 ac40457dd22719a25516fcf2c18e9ac65f56dfdd232fe159d94d5371dea774d9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.2.0 This release

7 files

3.1.2

7 files

3.1.0

7 files

3.0.2

8 files

2.5.4

1 file

2.5.3

1 file

2.5.2

1 file

2.5.1

2 files

2.4.2

2 files

2.4.1

2 files

2.4.0

2 files

2.3.1

2 files

2.3.0

2 files

2.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page