GraphAtoms 2.3.3__tar.gz → 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. graphatoms-3.1.0/PKG-INFO +306 -0
  2. graphatoms-3.1.0/README.md +268 -0
  3. {graphatoms-2.3.3 → graphatoms-3.1.0}/pyproject.toml +13 -24
  4. {graphatoms-2.3.3 → graphatoms-3.1.0}/pyproject.toml.orig +18 -36
  5. graphatoms-3.1.0/src/graphatoms/geometry/__init__.py +19 -0
  6. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/geometry/_bond_list.py +8 -32
  7. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/geometry/_inner_outer.py +25 -5
  8. graphatoms-3.1.0/src/graphatoms/geometry/itlee.py +599 -0
  9. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/bonds.py +96 -11
  10. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/graph.py +487 -12
  11. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/sysCluster.py +5 -2
  12. graphatoms-2.3.3/PKG-INFO +0 -185
  13. graphatoms-2.3.3/README.md +0 -143
  14. graphatoms-2.3.3/src/graphatoms/enterpoint/__init__.py +0 -0
  15. graphatoms-2.3.3/src/graphatoms/enterpoint/config/__init__.py +0 -116
  16. graphatoms-2.3.3/src/graphatoms/enterpoint/config/atoms/__init__.py +0 -24
  17. graphatoms-2.3.3/src/graphatoms/enterpoint/config/atoms/aseread.yaml +0 -5
  18. graphatoms-2.3.3/src/graphatoms/enterpoint/config/atoms/octahedron.yaml +0 -7
  19. graphatoms-2.3.3/src/graphatoms/enterpoint/config/bonds/__init__.py +0 -23
  20. graphatoms-2.3.3/src/graphatoms/enterpoint/config/bonds/raw.yaml +0 -8
  21. graphatoms-2.3.3/src/graphatoms/enterpoint/config/calculator/__init__.py +0 -29
  22. graphatoms-2.3.3/src/graphatoms/enterpoint/config/calculator/emt.yaml +0 -4
  23. graphatoms-2.3.3/src/graphatoms/enterpoint/config/calculator/nequip.yaml +0 -9
  24. graphatoms-2.3.3/src/graphatoms/enterpoint/config/example.yaml +0 -71
  25. graphatoms-2.3.3/src/graphatoms/enterpoint/config/run.yaml +0 -25
  26. graphatoms-2.3.3/src/graphatoms/enterpoint/network/__init__.py +0 -13
  27. graphatoms-2.3.3/src/graphatoms/enterpoint/network/_clsnetwork.py +0 -808
  28. graphatoms-2.3.3/src/graphatoms/enterpoint/network/_commands.py +0 -139
  29. graphatoms-2.3.3/src/graphatoms/enterpoint/network/_metadata.py +0 -405
  30. graphatoms-2.3.3/src/graphatoms/enterpoint/network/_recorder.py +0 -301
  31. graphatoms-2.3.3/src/graphatoms/enterpoint/network/_scheduler.py +0 -161
  32. graphatoms-2.3.3/src/graphatoms/enterpoint/parallel/__init__.py +0 -174
  33. graphatoms-2.3.3/src/graphatoms/enterpoint/parallel/_base.py +0 -152
  34. graphatoms-2.3.3/src/graphatoms/enterpoint/parallel/_dask.py +0 -47
  35. graphatoms-2.3.3/src/graphatoms/enterpoint/parallel/_executorlib.py +0 -48
  36. graphatoms-2.3.3/src/graphatoms/enterpoint/parallel/_ray.py +0 -121
  37. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/__init__.py +0 -35
  38. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/common/__init__.py +0 -21
  39. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/common/_base.py +0 -426
  40. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/common/_errors.py +0 -69
  41. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/common/_helper.py +0 -847
  42. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/general/__init__.py +0 -0
  43. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/general/_expl.py +0 -460
  44. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/general/otfkmc.py +0 -263
  45. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/general/rxngen.py +0 -161
  46. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/__init__.py +0 -0
  47. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/_helperv2.py +0 -427
  48. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/general/__init__.py +0 -0
  49. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/general/_expl.py +0 -160
  50. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/general/otfkmc.py +0 -16
  51. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/general/rxngen.py +0 -18
  52. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/ray/__init__.py +0 -0
  53. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/ray/_expl.py +0 -51
  54. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/ray/_helper.py +0 -183
  55. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/ray/otfkmc.py +0 -9
  56. graphatoms-2.3.3/src/graphatoms/enterpoint/runner/v2/ray/rxngen.py +0 -5
  57. graphatoms-2.3.3/src/graphatoms/geometry/__init__.py +0 -11
  58. graphatoms-2.3.3/src/graphatoms/geometry/_distance_pairs.py +0 -306
  59. graphatoms-2.3.3/src/graphatoms/geometry/_neighbor_list.py +0 -287
  60. graphatoms-2.3.3/src/graphatoms/reaction/__init__.py +0 -16
  61. graphatoms-2.3.3/src/graphatoms/reaction/_event.py +0 -632
  62. graphatoms-2.3.3/src/graphatoms/reaction/reaction.py +0 -48
  63. graphatoms-2.3.3/src/graphatoms/reaction/xxsorption.py +0 -214
  64. graphatoms-2.3.3/src/graphatoms/utils/adsorption.py +0 -794
  65. graphatoms-2.3.3/src/graphatoms/utils/aseqhull.py +0 -89
  66. graphatoms-2.3.3/src/graphatoms/utils/asetools.py +0 -420
  67. graphatoms-2.3.3/src/graphatoms/utils/logger.py +0 -69
  68. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/LICENSE +0 -0
  69. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/__init__.py +0 -0
  70. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/arrayapi/__init__.py +0 -0
  71. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/arrayapi/compat.py +0 -0
  72. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/arrayapi/typing.py +0 -0
  73. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/dataclasses/__init__.py +0 -0
  74. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/dataclasses/_numpydantic.py +0 -0
  75. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/dataclasses/_pydantic2pyarrow.py +0 -0
  76. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/dataclasses/_pydanticMixin.py +0 -0
  77. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/dataclasses/_pydanticModel.py +0 -0
  78. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/dataclasses/graph.py +0 -0
  79. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/geometry/mic.py +0 -0
  80. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/geometry/rotation.py +0 -0
  81. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/geometry/sample.py +0 -0
  82. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/__init__.py +0 -0
  83. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/atoms.py +0 -0
  84. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/database/__init__.py +0 -0
  85. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/database/abc.py +0 -0
  86. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/database/dict.py +0 -0
  87. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/database/dir.py +0 -0
  88. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/database/hdf5.py +0 -0
  89. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/database/sqliteASE.py +0 -0
  90. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/sysGas.py +0 -0
  91. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/system/system.py +0 -0
  92. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/utils/__init__.py +0 -0
  93. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/utils/bytestool.py +0 -0
  94. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/utils/parser.py +0 -0
  95. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/utils/rdutils.py +0 -0
  96. {graphatoms-2.3.3 → graphatoms-3.1.0}/src/graphatoms/utils/subgraph.py +0 -0
@@ -0,0 +1,306 @@
1
+ Metadata-Version: 2.4
2
+ Name: graphatoms
3
+ Version: 3.1.0
4
+ Summary: The Chemical Core Class for Graph Theory Analysis.
5
+ Keywords: chemistry,graph theory,reaction,event,KMC
6
+ Author: LiuGaoyong
7
+ Author-email: LiuGaoyong <liugaoyong_88@163.com>
8
+ License-Expression: GPL-3.0-or-later
9
+ License-File: src/LICENSE
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
12
+ Classifier: Intended Audience :: Science/Research
13
+ Requires-Dist: ase
14
+ Requires-Dist: arrayff>=0.0.1
15
+ Requires-Dist: pymatgen>2023.6
16
+ Requires-Dist: rdkit>=2025
17
+ Requires-Dist: numpy>=2,<3
18
+ Requires-Dist: scipy>=1.10,<2
19
+ Requires-Dist: scikit-learn>=1.5
20
+ Requires-Dist: array-api-compat>=1.10
21
+ Requires-Dist: array-api-extra>=0.10
22
+ Requires-Dist: pyarrow
23
+ Requires-Dist: pandas
24
+ Requires-Dist: igraph>=0.11
25
+ Requires-Dist: h5py>=3.16
26
+ Requires-Dist: numpydantic
27
+ Requires-Dist: pydantic>=2.10
28
+ Requires-Dist: tomli ; python_full_version < '3.11'
29
+ Requires-Dist: tomli-w
30
+ Requires-Dist: pyyaml>=6.0
31
+ Requires-Dist: hydra-core>=1.1
32
+ Requires-Dist: typing-extensions
33
+ Requires-Python: >=3.12
34
+ Project-URL: Homepage, https://github.com/LiuGaoyong/GraphAtoms
35
+ Project-URL: Repository, https://github.com/LiuGaoyong/GraphAtoms
36
+ Project-URL: Issues, https://github.com/LiuGaoyong/GraphAtoms/issues/
37
+ Description-Content-Type: text/markdown
38
+
39
+ # graphatoms
40
+
41
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/graphatoms.svg)](https://anaconda.org/conda-forge/graphatoms)
42
+ [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/graphatoms.svg)](https://anaconda.org/conda-forge/graphatoms)
43
+ [![PyPI version](https://img.shields.io/pypi/v/graphatoms)](https://pypi.org/project/graphatoms/)
44
+ [![PyPI Downloads](https://static.pepy.tech/badge/graphatoms)](https://pepy.tech/projects/graphatoms)
45
+
46
+ The chemical core classes for graph-theory analysis of atomistic systems.
47
+
48
+ `graphatoms` represents extended systems, clusters and gas molecules as
49
+ coloured bond graphs. Everything is a frozen, validated
50
+ [Pydantic](https://docs.pydantic.dev/) model, so structures, energies and
51
+ graph metadata can be exchanged, stored and compared without losing type
52
+ safety.
53
+
54
+ > **Scope (v3)**: the application layer — CLI entry points, Hydra configs,
55
+ > reaction network generation, KMC runners and parallel executors — now lives
56
+ > in [RxNetGen](https://github.com/LiuGaoyong/RxNetGen). This package provides
57
+ > the reusable chemical core: `arrayapi`, `dataclasses`, `geometry`, `system`
58
+ > and `utils`.
59
+
60
+ ## Features
61
+
62
+ - **Validated graph models**: `SysGraph`, `System`, `Cluster` and `Gas` are
63
+ immutable Pydantic models with `numpydantic`-checked arrays.
64
+ - **Multi-format interoperability**: build from and export to ASE `Atoms`,
65
+ pymatgen `Structure`/`Molecule`, RDKit molecules, igraph graphs and plain
66
+ dictionaries.
67
+ - **Chemical graph analysis**: bond perception, neighbour lists, hop
68
+ distances, chordless cycles, connected components, Weisfeiler–Lehman
69
+ hashes, canonical keys (BLISS) and SMARTS extraction.
70
+ - **Structure matching**: pattern-to-system matching
71
+ (`BondGraph.get_match_mode`) and system-to-system equivalence via coloured
72
+ graph isomorphism or **ITLEE** — Invariant and Tolerant Local Environment
73
+ Equivalence (Williams, 2024).
74
+ - **Geometry tooling**: minimum image convention, rotation, sphere sampling
75
+ and distance/bond/neighbour construction.
76
+ - **Thermochemistry**: gas-phase enthalpy, entropy and free energy from
77
+ vibrational frequencies, plus minima/transition-state checks.
78
+ - **Persistent storage**: a uniform database interface with in-memory
79
+ (`dict`), folder, HDF5 and SQLite backends.
80
+ - **Array API compatibility**: backend-agnostic helpers that work with
81
+ NumPy, PyTorch, JAX, CuPy and other array-API-compliant libraries.
82
+
83
+ ## Installation
84
+
85
+ ```bash
86
+ pip install graphatoms
87
+ ```
88
+
89
+ With conda:
90
+
91
+ ```bash
92
+ conda install -c conda-forge graphatoms
93
+ ```
94
+
95
+ Python 3.12 or newer is required.
96
+
97
+ ## Quick start
98
+
99
+ ### A periodic system and a local cluster
100
+
101
+ ```python
102
+ import numpy as np
103
+ from ase.build import fcc111
104
+
105
+ from graphatoms.system import Cluster, System
106
+
107
+ atoms = fcc111("Pt", size=(3, 3, 4), vacuum=10.0)
108
+ system = System.from_ase(
109
+ atoms,
110
+ parse_bonds={"method": "raw"},
111
+ parse_atoms_is_outer_or_not=True, # detect surface atoms
112
+ )
113
+
114
+ print(system.formula, system.natoms, system.nbonds)
115
+ print(system.is_periodic, system.idx_outer)
116
+
117
+ # Grow a movable cluster around atom 0; atoms farther than `env_threshold`
118
+ # are fixed, and atoms closer than `max_moved_threshold` may move.
119
+ cluster = Cluster.from_select(
120
+ system,
121
+ core=np.array([0]),
122
+ method="hop",
123
+ max_moved_threshold=1,
124
+ env_threshold=2,
125
+ )
126
+ print(cluster.ncore, cluster.nmoved, cluster.nfix)
127
+ ```
128
+
129
+ ### A gas molecule
130
+
131
+ ```python
132
+ import numpy as np
133
+
134
+ from graphatoms.system import Gas
135
+
136
+ gas = Gas.from_name("CH4", sticking=1.0)
137
+ gas = gas.update_energetics(
138
+ energy=-0.5,
139
+ fmax=0.02,
140
+ frequencies=np.array(
141
+ [1300.0, 1300.0, 1300.0, 1500.0, 1500.0, 1500.0, 2900.0, 2900.0, 2900.0]
142
+ ),
143
+ )
144
+
145
+ print(gas.formula, gas.natoms)
146
+ print(gas.get_enthalpy(temp=300.0))
147
+ print(gas.get_free_energy(temp=300.0))
148
+ ```
149
+
150
+ ### Equivalence checks
151
+
152
+ ```python
153
+ # `other` is another SysGraph with the same number of atoms.
154
+ same_topology = system.is_equivalent(other, method="graph")
155
+ same_geometry = system.is_equivalent(
156
+ other,
157
+ method="itlee",
158
+ tolerance=0.1, # L2 tolerance in Å
159
+ fields=("numbers", "is_fix"),
160
+ )
161
+ ```
162
+
163
+ `method="graph"` compares the coloured bond graph (hash bucket first, then
164
+ igraph isomorphism). `method="itlee"` compares equal-sized coloured point
165
+ clouds under rotation, translation and atom permutation. For
166
+ pattern-to-system queries, use `BondGraph.get_match_mode`.
167
+
168
+ ### Storage
169
+
170
+ ```python
171
+ from pathlib import Path
172
+
173
+ from graphatoms.system import SysGraph
174
+ from graphatoms.system.database import get_db
175
+
176
+ db = get_db(format="hdf5", path=Path("systems.h5"))
177
+ db.add(SysGraph.from_ase(atoms, parse_bonds={"method": "raw"}))
178
+
179
+ for key in db:
180
+ stored = SysGraph.from_ase(db[key], parse_bonds=None)
181
+ print(key, stored.formula)
182
+ ```
183
+
184
+ Supported formats: `dict` (default), `folder`/`dir`, `hdf5`/`h5`, `sqlite`.
185
+ Records are stored as ASE `Atoms`; rebuild a graph from a record with
186
+ `SysGraph.from_ase()`.
187
+
188
+ ## Module structure
189
+
190
+ ```
191
+ src/graphatoms/
192
+ ├── arrayapi/ # array-API namespace resolution and typing
193
+ ├── dataclasses/ # Pydantic/numpydantic base models, PyArrow schemas
194
+ ├── geometry/ # bond_list, neighbor_list, distance_pairs,
195
+ │ # mic, rotation, sample, itlee
196
+ ├── system/ # core classes
197
+ │ ├── atoms.py # Box, Energetics, Matter, Structure
198
+ │ ├── bonds.py # BondGraph: graph metrics, hashes, matching
199
+ │ ├── graph.py # SysGraph: structure + bonds + atom tags
200
+ │ ├── system.py # System: full periodic/extended systems
201
+ │ ├── sysCluster.py # Cluster: movable/fixed regions around a site
202
+ │ ├── sysGas.py # Gas: ideal-gas thermochemistry
203
+ │ └── database/ # dict, folder, HDF5, SQLite backends
204
+ └── utils/ # bytestool, parser (Hydra), rdutils, subgraph
205
+ ```
206
+
207
+ The public objects live in their submodules rather than the package root:
208
+
209
+ ```python
210
+ from graphatoms.system import SysGraph, System, Cluster, Gas
211
+ from graphatoms.system.database import get_db
212
+ from graphatoms.geometry import bond_list, neighbor_list, distance_pairs
213
+ ```
214
+
215
+ ## Data model
216
+
217
+ `SysGraph` combines four mixins:
218
+
219
+ | Mixin | Contents |
220
+ | ----------- | --------------------------------------------------------------- |
221
+ | `Structure` | `numbers`, `positions`, `cell`/`pbc`, plus `Energetics` |
222
+ | `BondGraph` | bond `pair`, `shift`, `order`, `coordination`, derived `P`/`CN` |
223
+ | `AtomTag` | boolean tags `is_adsorbate`, `is_outer`, `is_core`, `is_fix` |
224
+ | `GasMixin` | `sticking` coefficient and the derived `is_gas` flag |
225
+
226
+ `System` is a `SysGraph` for the full system, `Cluster` is a selected,
227
+ possibly partially fixed region of it, and `Gas` adds a `sticking`
228
+ coefficient and ideal-gas thermodynamics. All of them accept
229
+ `from_ase()`, `to_ase()`, `from_dict()`/`to_dict()`, `from_igraph()`/
230
+ `to_igraph()` and, where meaningful, pymatgen/RDKit conversions.
231
+
232
+ ## Requirements
233
+
234
+ Runtime dependencies:
235
+
236
+ - Python >= 3.12
237
+ - ase
238
+ - pymatgen > 2023.6
239
+ - rdkit >= 2025
240
+ - numpy >= 2, < 3
241
+ - scipy >= 1.10
242
+ - scikit-learn >= 1.5
243
+ - array-api-compat >= 1.10
244
+ - array-api-extra >= 0.10
245
+ - pyarrow
246
+ - pandas
247
+ - igraph >= 0.11
248
+ - h5py >= 3.16
249
+ - numpydantic
250
+ - pydantic >= 2.10
251
+ - hydra-core >= 1.1
252
+ - pyyaml >= 6.0
253
+ - tomli-w
254
+ - typing-extensions
255
+
256
+ ## Development
257
+
258
+ The project is managed with [pixi](https://pixi.sh/) (or `uv`):
259
+
260
+ ```bash
261
+ pixi install
262
+ pixi run test # pytest -s -vv
263
+ pixi run benchmark # benchmark suite
264
+ ```
265
+
266
+ With `uv`:
267
+
268
+ ```bash
269
+ uv sync
270
+ uv run pytest src/tests/ -v
271
+ uv run pytest src/tests-benchmark/ -v
272
+ ```
273
+
274
+ Lint and format with Ruff:
275
+
276
+ ```bash
277
+ ruff check .
278
+ ruff format .
279
+ ```
280
+
281
+ ## Array API compatibility
282
+
283
+ `graphatoms.arrayapi` resolves the active array namespace, and
284
+ `graphatoms.utils.subgraph` implements backend-agnostic graph helpers:
285
+
286
+ - `subgraph()` — extract an induced subgraph from edge indices
287
+ - `map_index()` — map indices to positions in a reference index array
288
+ - `index_to_mask()` — convert indices to a boolean mask
289
+ - `maybe_num_nodes()` — infer the node count from edge indices
290
+
291
+ These functions only use Array API standard operations, so the same code runs
292
+ on NumPy, PyTorch and JAX arrays.
293
+
294
+ ## License
295
+
296
+ GPL-3.0-or-later
297
+
298
+ ## Authors
299
+
300
+ - LiuGaoyong (liugaoyong_88@163.com)
301
+
302
+ ## Links
303
+
304
+ - Homepage: https://github.com/LiuGaoyong/GraphAtoms
305
+ - Repository: https://github.com/LiuGaoyong/GraphAtoms
306
+ - Issues: https://github.com/LiuGaoyong/GraphAtoms/issues/
@@ -0,0 +1,268 @@
1
+ # graphatoms
2
+
3
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/graphatoms.svg)](https://anaconda.org/conda-forge/graphatoms)
4
+ [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/graphatoms.svg)](https://anaconda.org/conda-forge/graphatoms)
5
+ [![PyPI version](https://img.shields.io/pypi/v/graphatoms)](https://pypi.org/project/graphatoms/)
6
+ [![PyPI Downloads](https://static.pepy.tech/badge/graphatoms)](https://pepy.tech/projects/graphatoms)
7
+
8
+ The chemical core classes for graph-theory analysis of atomistic systems.
9
+
10
+ `graphatoms` represents extended systems, clusters and gas molecules as
11
+ coloured bond graphs. Everything is a frozen, validated
12
+ [Pydantic](https://docs.pydantic.dev/) model, so structures, energies and
13
+ graph metadata can be exchanged, stored and compared without losing type
14
+ safety.
15
+
16
+ > **Scope (v3)**: the application layer — CLI entry points, Hydra configs,
17
+ > reaction network generation, KMC runners and parallel executors — now lives
18
+ > in [RxNetGen](https://github.com/LiuGaoyong/RxNetGen). This package provides
19
+ > the reusable chemical core: `arrayapi`, `dataclasses`, `geometry`, `system`
20
+ > and `utils`.
21
+
22
+ ## Features
23
+
24
+ - **Validated graph models**: `SysGraph`, `System`, `Cluster` and `Gas` are
25
+ immutable Pydantic models with `numpydantic`-checked arrays.
26
+ - **Multi-format interoperability**: build from and export to ASE `Atoms`,
27
+ pymatgen `Structure`/`Molecule`, RDKit molecules, igraph graphs and plain
28
+ dictionaries.
29
+ - **Chemical graph analysis**: bond perception, neighbour lists, hop
30
+ distances, chordless cycles, connected components, Weisfeiler–Lehman
31
+ hashes, canonical keys (BLISS) and SMARTS extraction.
32
+ - **Structure matching**: pattern-to-system matching
33
+ (`BondGraph.get_match_mode`) and system-to-system equivalence via coloured
34
+ graph isomorphism or **ITLEE** — Invariant and Tolerant Local Environment
35
+ Equivalence (Williams, 2024).
36
+ - **Geometry tooling**: minimum image convention, rotation, sphere sampling
37
+ and distance/bond/neighbour construction.
38
+ - **Thermochemistry**: gas-phase enthalpy, entropy and free energy from
39
+ vibrational frequencies, plus minima/transition-state checks.
40
+ - **Persistent storage**: a uniform database interface with in-memory
41
+ (`dict`), folder, HDF5 and SQLite backends.
42
+ - **Array API compatibility**: backend-agnostic helpers that work with
43
+ NumPy, PyTorch, JAX, CuPy and other array-API-compliant libraries.
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install graphatoms
49
+ ```
50
+
51
+ With conda:
52
+
53
+ ```bash
54
+ conda install -c conda-forge graphatoms
55
+ ```
56
+
57
+ Python 3.12 or newer is required.
58
+
59
+ ## Quick start
60
+
61
+ ### A periodic system and a local cluster
62
+
63
+ ```python
64
+ import numpy as np
65
+ from ase.build import fcc111
66
+
67
+ from graphatoms.system import Cluster, System
68
+
69
+ atoms = fcc111("Pt", size=(3, 3, 4), vacuum=10.0)
70
+ system = System.from_ase(
71
+ atoms,
72
+ parse_bonds={"method": "raw"},
73
+ parse_atoms_is_outer_or_not=True, # detect surface atoms
74
+ )
75
+
76
+ print(system.formula, system.natoms, system.nbonds)
77
+ print(system.is_periodic, system.idx_outer)
78
+
79
+ # Grow a movable cluster around atom 0; atoms farther than `env_threshold`
80
+ # are fixed, and atoms closer than `max_moved_threshold` may move.
81
+ cluster = Cluster.from_select(
82
+ system,
83
+ core=np.array([0]),
84
+ method="hop",
85
+ max_moved_threshold=1,
86
+ env_threshold=2,
87
+ )
88
+ print(cluster.ncore, cluster.nmoved, cluster.nfix)
89
+ ```
90
+
91
+ ### A gas molecule
92
+
93
+ ```python
94
+ import numpy as np
95
+
96
+ from graphatoms.system import Gas
97
+
98
+ gas = Gas.from_name("CH4", sticking=1.0)
99
+ gas = gas.update_energetics(
100
+ energy=-0.5,
101
+ fmax=0.02,
102
+ frequencies=np.array(
103
+ [1300.0, 1300.0, 1300.0, 1500.0, 1500.0, 1500.0, 2900.0, 2900.0, 2900.0]
104
+ ),
105
+ )
106
+
107
+ print(gas.formula, gas.natoms)
108
+ print(gas.get_enthalpy(temp=300.0))
109
+ print(gas.get_free_energy(temp=300.0))
110
+ ```
111
+
112
+ ### Equivalence checks
113
+
114
+ ```python
115
+ # `other` is another SysGraph with the same number of atoms.
116
+ same_topology = system.is_equivalent(other, method="graph")
117
+ same_geometry = system.is_equivalent(
118
+ other,
119
+ method="itlee",
120
+ tolerance=0.1, # L2 tolerance in Å
121
+ fields=("numbers", "is_fix"),
122
+ )
123
+ ```
124
+
125
+ `method="graph"` compares the coloured bond graph (hash bucket first, then
126
+ igraph isomorphism). `method="itlee"` compares equal-sized coloured point
127
+ clouds under rotation, translation and atom permutation. For
128
+ pattern-to-system queries, use `BondGraph.get_match_mode`.
129
+
130
+ ### Storage
131
+
132
+ ```python
133
+ from pathlib import Path
134
+
135
+ from graphatoms.system import SysGraph
136
+ from graphatoms.system.database import get_db
137
+
138
+ db = get_db(format="hdf5", path=Path("systems.h5"))
139
+ db.add(SysGraph.from_ase(atoms, parse_bonds={"method": "raw"}))
140
+
141
+ for key in db:
142
+ stored = SysGraph.from_ase(db[key], parse_bonds=None)
143
+ print(key, stored.formula)
144
+ ```
145
+
146
+ Supported formats: `dict` (default), `folder`/`dir`, `hdf5`/`h5`, `sqlite`.
147
+ Records are stored as ASE `Atoms`; rebuild a graph from a record with
148
+ `SysGraph.from_ase()`.
149
+
150
+ ## Module structure
151
+
152
+ ```
153
+ src/graphatoms/
154
+ ├── arrayapi/ # array-API namespace resolution and typing
155
+ ├── dataclasses/ # Pydantic/numpydantic base models, PyArrow schemas
156
+ ├── geometry/ # bond_list, neighbor_list, distance_pairs,
157
+ │ # mic, rotation, sample, itlee
158
+ ├── system/ # core classes
159
+ │ ├── atoms.py # Box, Energetics, Matter, Structure
160
+ │ ├── bonds.py # BondGraph: graph metrics, hashes, matching
161
+ │ ├── graph.py # SysGraph: structure + bonds + atom tags
162
+ │ ├── system.py # System: full periodic/extended systems
163
+ │ ├── sysCluster.py # Cluster: movable/fixed regions around a site
164
+ │ ├── sysGas.py # Gas: ideal-gas thermochemistry
165
+ │ └── database/ # dict, folder, HDF5, SQLite backends
166
+ └── utils/ # bytestool, parser (Hydra), rdutils, subgraph
167
+ ```
168
+
169
+ The public objects live in their submodules rather than the package root:
170
+
171
+ ```python
172
+ from graphatoms.system import SysGraph, System, Cluster, Gas
173
+ from graphatoms.system.database import get_db
174
+ from graphatoms.geometry import bond_list, neighbor_list, distance_pairs
175
+ ```
176
+
177
+ ## Data model
178
+
179
+ `SysGraph` combines four mixins:
180
+
181
+ | Mixin | Contents |
182
+ | ----------- | --------------------------------------------------------------- |
183
+ | `Structure` | `numbers`, `positions`, `cell`/`pbc`, plus `Energetics` |
184
+ | `BondGraph` | bond `pair`, `shift`, `order`, `coordination`, derived `P`/`CN` |
185
+ | `AtomTag` | boolean tags `is_adsorbate`, `is_outer`, `is_core`, `is_fix` |
186
+ | `GasMixin` | `sticking` coefficient and the derived `is_gas` flag |
187
+
188
+ `System` is a `SysGraph` for the full system, `Cluster` is a selected,
189
+ possibly partially fixed region of it, and `Gas` adds a `sticking`
190
+ coefficient and ideal-gas thermodynamics. All of them accept
191
+ `from_ase()`, `to_ase()`, `from_dict()`/`to_dict()`, `from_igraph()`/
192
+ `to_igraph()` and, where meaningful, pymatgen/RDKit conversions.
193
+
194
+ ## Requirements
195
+
196
+ Runtime dependencies:
197
+
198
+ - Python >= 3.12
199
+ - ase
200
+ - pymatgen > 2023.6
201
+ - rdkit >= 2025
202
+ - numpy >= 2, < 3
203
+ - scipy >= 1.10
204
+ - scikit-learn >= 1.5
205
+ - array-api-compat >= 1.10
206
+ - array-api-extra >= 0.10
207
+ - pyarrow
208
+ - pandas
209
+ - igraph >= 0.11
210
+ - h5py >= 3.16
211
+ - numpydantic
212
+ - pydantic >= 2.10
213
+ - hydra-core >= 1.1
214
+ - pyyaml >= 6.0
215
+ - tomli-w
216
+ - typing-extensions
217
+
218
+ ## Development
219
+
220
+ The project is managed with [pixi](https://pixi.sh/) (or `uv`):
221
+
222
+ ```bash
223
+ pixi install
224
+ pixi run test # pytest -s -vv
225
+ pixi run benchmark # benchmark suite
226
+ ```
227
+
228
+ With `uv`:
229
+
230
+ ```bash
231
+ uv sync
232
+ uv run pytest src/tests/ -v
233
+ uv run pytest src/tests-benchmark/ -v
234
+ ```
235
+
236
+ Lint and format with Ruff:
237
+
238
+ ```bash
239
+ ruff check .
240
+ ruff format .
241
+ ```
242
+
243
+ ## Array API compatibility
244
+
245
+ `graphatoms.arrayapi` resolves the active array namespace, and
246
+ `graphatoms.utils.subgraph` implements backend-agnostic graph helpers:
247
+
248
+ - `subgraph()` — extract an induced subgraph from edge indices
249
+ - `map_index()` — map indices to positions in a reference index array
250
+ - `index_to_mask()` — convert indices to a boolean mask
251
+ - `maybe_num_nodes()` — infer the node count from edge indices
252
+
253
+ These functions only use Array API standard operations, so the same code runs
254
+ on NumPy, PyTorch and JAX arrays.
255
+
256
+ ## License
257
+
258
+ GPL-3.0-or-later
259
+
260
+ ## Authors
261
+
262
+ - LiuGaoyong (liugaoyong_88@163.com)
263
+
264
+ ## Links
265
+
266
+ - Homepage: https://github.com/LiuGaoyong/GraphAtoms
267
+ - Repository: https://github.com/LiuGaoyong/GraphAtoms
268
+ - Issues: https://github.com/LiuGaoyong/GraphAtoms/issues/
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "graphatoms"
7
- version = "2.3.3"
7
+ version = "3.1.0"
8
8
  readme = "README.md"
9
9
  description = "The Chemical Core Class for Graph Theory Analysis."
10
10
  license-files = ["src/LICENSE"]
@@ -24,6 +24,7 @@ classifiers = [
24
24
  ]
25
25
  dependencies = [
26
26
  "ase",
27
+ "arrayff>=0.0.1",
27
28
  "pymatgen>2023.6",
28
29
  "rdkit>=2025",
29
30
  "numpy>=2,<3",
@@ -36,17 +37,12 @@ dependencies = [
36
37
  "igraph>=0.11",
37
38
  "h5py>=3.16",
38
39
  "numpydantic",
39
- "ovld",
40
40
  "pydantic>=2.10",
41
- "python-snappy>=0.7.3",
42
41
  "tomli; python_version < '3.11'",
43
42
  "tomli-w",
43
+ "pyyaml>=6.0",
44
+ "hydra-core>=1.1",
44
45
  "typing-extensions",
45
- "joblib",
46
- "executorlib",
47
- "hydra-core",
48
- "typer",
49
- "loguru",
50
46
  ]
51
47
 
52
48
  [project.urls]
@@ -54,11 +50,6 @@ Homepage = "https://github.com/LiuGaoyong/GraphAtoms"
54
50
  Repository = "https://github.com/LiuGaoyong/GraphAtoms"
55
51
  Issues = "https://github.com/LiuGaoyong/GraphAtoms/issues/"
56
52
 
57
- [project.scripts]
58
- graphatoms-config = "graphatoms.enterpoint.config:print_config"
59
- graphatoms-network = "graphatoms.enterpoint.network:main"
60
- graphatoms-run = "graphatoms.enterpoint.runner:run"
61
-
62
53
  [[project.authors]]
63
54
  name = "LiuGaoyong"
64
55
  email = "liugaoyong_88@163.com"
@@ -66,22 +57,20 @@ email = "liugaoyong_88@163.com"
66
57
  [dependency-groups]
67
58
  dev = [
68
59
  "ruff>=0.11",
69
- "openbabel-wheel",
60
+ "python-snappy>=0.7.3",
70
61
  "array-api-strict",
71
62
  "pytest>=8.3",
72
63
  "pytest-xdist",
73
64
  "jupyterlab",
74
65
  "chemiscope",
75
66
  "nglview",
76
- "grpcio",
77
- "ray",
78
67
  ]
79
68
 
80
69
  [tool.uv]
81
70
  package = true
82
71
 
83
72
  [[tool.uv.index]]
84
- url = "https://mirrors.nju.edu.cn/pypi/web/simple"
73
+ url = "https://mirrors.cernet.edu.cn/pypi/web/simple"
85
74
  default = true
86
75
 
87
76
  [tool.pytest.ini_options]
@@ -147,6 +136,7 @@ benchmark = "pytest -s src/tests-benchmark/*.py"
147
136
  [tool.pixi.dependencies]
148
137
  python = ">=3.12"
149
138
  pytest = ">=8"
139
+ arrayff = ">=0.0.1"
150
140
  array-api-compat = ">=1.15.0"
151
141
  array-api-extra = ">=0.11.0"
152
142
  array-api-strict = ">=2.5"
@@ -162,13 +152,12 @@ pydantic = ">=2.10.0"
162
152
  numpydantic = ">=1.8.1"
163
153
  python-snappy = ">=0.7.3"
164
154
  h5py = ">=3.16"
165
- hydra-core = ">=1.3.0"
166
155
  tomli-w = ">=1.2.0"
167
- loguru = ">=0.7.3"
168
156
  jupyterlab = ">=4.5.8"
169
- joblib = ">=1.1.0"
170
- ovld = ">=0.5.15"
171
157
  pytest-xdist = ">=3.8.0"
172
- executorlib = ">=1.8"
173
- typer = ">=0.20"
174
- grpcio = ">=1.52.0"
158
+ nglview = ">=0.14.0"
159
+ ruff = ">=0.11"
160
+ chemiscope = ">=0.1.0"
161
+ pyyaml = ">=6.0"
162
+ hydra-core = ">=1.1"
163
+ typing-extensions = ">=4.12.0"