Skip to main content

graphatoms

Conda Version Conda Downloads PyPI version PyPI Downloads

The chemical core classes for graph-theory analysis of atomistic systems.

graphatoms represents extended systems, clusters and gas molecules as coloured bond graphs. Everything is a frozen, validated Pydantic model, so structures, energies and graph metadata can be exchanged, stored and compared without losing type safety.

Scope (v3): the application layer — CLI entry points, Hydra configs, reaction network generation, KMC runners and parallel executors — now lives in RxNetGen. This package provides the reusable chemical core: arrayapi, dataclasses, geometry, system and utils.

Features

  • Validated graph models: SysGraph, System, Cluster and Gas are immutable Pydantic models with numpydantic-checked arrays.
  • Multi-format interoperability: build from and export to ASE Atoms, pymatgen Structure/Molecule, RDKit molecules, igraph graphs and plain dictionaries.
  • Chemical graph analysis: bond perception, neighbour lists, hop distances, chordless cycles, connected components, Weisfeiler–Lehman hashes, canonical keys (BLISS) and SMARTS extraction.
  • Structure matching: pattern-to-system matching (BondGraph.get_match_mode) and system-to-system equivalence via coloured graph isomorphism or ITLEE — Invariant and Tolerant Local Environment Equivalence (Williams, 2024).
  • Geometry tooling: minimum image convention, rotation, sphere sampling and distance/bond/neighbour construction.
  • Thermochemistry: gas-phase enthalpy, entropy and free energy from vibrational frequencies, plus minima/transition-state checks.
  • Persistent storage: a uniform database interface with in-memory (dict), folder, HDF5 and SQLite backends.
  • Array API compatibility: backend-agnostic helpers that work with NumPy, PyTorch, JAX, CuPy and other array-API-compliant libraries.

Installation

pip install graphatoms

With conda:

conda install -c conda-forge graphatoms

Python 3.12 or newer is required.

Quick start

A periodic system and a local cluster

import numpy as np
from ase.build import fcc111

from graphatoms.system import Cluster, System

atoms = fcc111("Pt", size=(3, 3, 4), vacuum=10.0)
system = System.from_ase(
    atoms,
    parse_bonds={"method": "raw"},
    parse_atoms_is_outer_or_not=True,  # detect surface atoms
)

print(system.formula, system.natoms, system.nbonds)
print(system.is_periodic, system.idx_outer)

# Grow a movable cluster around atom 0; atoms farther than `env_threshold`
# are fixed, and atoms closer than `max_moved_threshold` may move.
cluster = Cluster.from_select(
    system,
    core=np.array([0]),
    method="hop",
    max_moved_threshold=1,
    env_threshold=2,
)
print(cluster.ncore, cluster.nmoved, cluster.nfix)

A gas molecule

import numpy as np

from graphatoms.system import Gas

gas = Gas.from_name("CH4", sticking=1.0)
gas = gas.update_energetics(
    energy=-0.5,
    fmax=0.02,
    frequencies=np.array(
        [1300.0, 1300.0, 1300.0, 1500.0, 1500.0, 1500.0, 2900.0, 2900.0, 2900.0]
    ),
)

print(gas.formula, gas.natoms)
print(gas.get_enthalpy(temp=300.0))
print(gas.get_free_energy(temp=300.0))

Equivalence checks

# `other` is another SysGraph with the same number of atoms.
same_topology = system.is_equivalent(other, method="graph")
same_geometry = system.is_equivalent(
    other,
    method="itlee",
    tolerance=0.1,  # L2 tolerance in Å
    fields=("numbers", "is_fix"),
)

method="graph" compares the coloured bond graph (hash bucket first, then igraph isomorphism). method="itlee" compares equal-sized coloured point clouds under rotation, translation and atom permutation. For pattern-to-system queries, use BondGraph.get_match_mode.

Storage

from pathlib import Path

from graphatoms.system import SysGraph
from graphatoms.system.database import get_db

db = get_db(format="hdf5", path=Path("systems.h5"))
db.add(SysGraph.from_ase(atoms, parse_bonds={"method": "raw"}))

for key in db:
    stored = SysGraph.from_ase(db[key], parse_bonds=None)
    print(key, stored.formula)

Supported formats: dict (default), folder/dir, hdf5/h5, sqlite. Records are stored as ASE Atoms; rebuild a graph from a record with SysGraph.from_ase().

Module structure

src/graphatoms/
├── arrayapi/          # array-API namespace resolution and typing
├── dataclasses/       # Pydantic/numpydantic base models, PyArrow schemas
├── geometry/          # bond_list, neighbor_list, distance_pairs,
│                      # mic, rotation, sample, itlee
├── system/            # core classes
│   ├── atoms.py       # Box, Energetics, Matter, Structure
│   ├── bonds.py       # BondGraph: graph metrics, hashes, matching
│   ├── graph.py       # SysGraph: structure + bonds + atom tags
│   ├── system.py      # System: full periodic/extended systems
│   ├── sysCluster.py  # Cluster: movable/fixed regions around a site
│   ├── sysGas.py      # Gas: ideal-gas thermochemistry
│   └── database/      # dict, folder, HDF5, SQLite backends
└── utils/             # bytestool, parser (Hydra), rdutils, subgraph

The public objects live in their submodules rather than the package root:

from graphatoms.system import SysGraph, System, Cluster, Gas
from graphatoms.system.database import get_db
from graphatoms.geometry import bond_list, neighbor_list, distance_pairs

Data model

SysGraph combines four mixins:

Mixin Contents
Structure numbers, positions, cell/pbc, plus Energetics
BondGraph bond pair, shift, order, coordination, derived P/CN
AtomTag boolean tags is_adsorbate, is_outer, is_core, is_fix
GasMixin sticking coefficient and the derived is_gas flag

System is a SysGraph for the full system, Cluster is a selected, possibly partially fixed region of it, and Gas adds a sticking coefficient and ideal-gas thermodynamics. All of them accept from_ase(), to_ase(), from_dict()/to_dict(), from_igraph()/ to_igraph() and, where meaningful, pymatgen/RDKit conversions.

Requirements

Runtime dependencies:

  • Python >= 3.12
  • ase
  • pymatgen > 2023.6
  • rdkit >= 2025
  • numpy >= 2, < 3
  • scipy >= 1.10
  • scikit-learn >= 1.5
  • array-api-compat >= 1.10
  • array-api-extra >= 0.10
  • pyarrow
  • pandas
  • igraph >= 0.11
  • h5py >= 3.16
  • numpydantic
  • pydantic >= 2.10
  • hydra-core >= 1.1
  • pyyaml >= 6.0
  • tomli-w
  • typing-extensions

Development

The project is managed with pixi (or uv):

pixi install
pixi run test        # pytest -s -vv
pixi run benchmark  # benchmark suite

With uv:

uv sync
uv run pytest src/tests/ -v
uv run pytest src/tests-benchmark/ -v

Lint and format with Ruff:

ruff check .
ruff format .

Array API compatibility

graphatoms.arrayapi resolves the active array namespace, and graphatoms.utils.subgraph implements backend-agnostic graph helpers:

  • subgraph() — extract an induced subgraph from edge indices
  • map_index() — map indices to positions in a reference index array
  • index_to_mask() — convert indices to a boolean mask
  • maybe_num_nodes() — infer the node count from edge indices

These functions only use Array API standard operations, so the same code runs on NumPy, PyTorch and JAX arrays.

License

GPL-3.0-or-later

Authors

Metadata

Release files for graphatoms 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graphatoms 3.0.0
File Size Uploaded Provenance Actions
graphatoms-3.0.0.tar.gz 177.8 kB With provenance Details for graphatoms-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for graphatoms 3.0.0
File Interpreter ABI Platform Actions
graphatoms-3.0.0-py3-none-any.whl Python 3 none any Details for graphatoms-3.0.0-py3-none-any.whl

Total release size: 368.6 kB

Release files / graphatoms-3.0.0.tar.gz

Download URL graphatoms-3.0.0.tar.gz
Size 177.8 kB
Tags Source
SHA-256 checksum
How to use checksums
365637e7f3b48b8e64786ea1d11507dde8fdde7aa3ca6d09f1326d1b44addcf0
BLAKE2b-256 checksum
How to use checksums
23dd240c844dc62fa7784e0fbef0b911909ad18433fc99cbd31f92711fe5639c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / graphatoms-3.0.0-py3-none-any.whl

Download URL graphatoms-3.0.0-py3-none-any.whl
Size 190.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1947293d18f46a1bb8f34874761a1335b0eda71e98cbaa73192071f30df8cf2d
BLAKE2b-256 checksum
How to use checksums
982fe5fc5b58922d9840cb02d4223b1a41a15b3cab0ef352b6839b8d27457a80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for graphatoms 3.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for graphatoms-3.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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