kups.potential.common.graph
¶
Graph construction from atomic coordinates for potential evaluation.
This module builds molecular graphs (point clouds, hypergraphs) from
Indexed particle data for potential energy evaluation. Graphs honor the
cell's per-axis periodic mask via the neighbor list, support multiple
independent systems, and allow efficient incremental construction for Monte
Carlo via probes.
Key components:
- PointCloud: Indexed particles and systems
- HyperGraph: Point cloud with typed edges
- GraphConstructor: Builds graphs from a degree-parametrized neighbor list
- GraphInputConstructor: Full or incremental potential inputs
GRAPH_GEOMETRY = lens(lambda inp: inp.graph).nest(POINTCLOUD_GEOMETRY)
module-attribute
¶
Adapter from a graph-bearing potential input to Geometry.
POINTCLOUD_GEOMETRY = lens(_pointcloud_geometry)
module-attribute
¶
Geometry adapter shared by graph, fused, and reciprocal-space inputs.
GraphConstructor
¶
Constructs graphs from a degree-parametrized neighbor list.
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
View[State, Table[ParticleId, P]]
|
View extracting |
systems |
View[State, Table[SystemId, S]]
|
View extracting |
neighborlist |
View[State, NeighborList[Degree]]
|
View extracting the neighbor list implementation for the state. |
probe |
Probe[State, Ptch, IsParticleProbe[P]] | None
|
Optional particle probe, which may also supply neighbor lists. |
Source code in src/kups/potential/common/graph.py
GraphInputConstructor
¶
Bases: InputConstructor[State, GraphPotentialInput[Params, P, S, Degree], Ptch]
Construct full or affected graph inputs for the shared sum composers.
A graph probe restricts proposals to affected interactions, keeping
parameters from the current state. Without a probe, apply the patch to
the full state before reading parameters and constructing the graph.
old_input selects the current state in either case.
Source code in src/kups/potential/common/graph.py
GraphPairEnergy
¶
Derive edge energies and per-system totals from a pair term.
Graph edges already encode inclusion, exclusion and periodic-image rules.
The pair term supplies the features, cutoff and kernel. Directed edges
contribute half their energy to each system's total. fuse_pair_potentials
can collect the same term to share geometry and neighbor traversal with
other pair terms.
Source code in src/kups/potential/common/graph.py
edge_energies(inp)
¶
Evaluate the pair term on each directed edge, ignoring padded edges.
Source code in src/kups/potential/common/graph.py
GraphPotentialInput
¶
Bases: NamedTuple, Generic[Params, Part, Sys, Degree]
Input bundle for graph-based potential energy functions.
Source code in src/kups/potential/common/graph.py
HyperGraph
¶
Bases: PointCloud[Part, Sys], Generic[Part, Sys, Degree]
Point cloud with edges representing particle interactions.
Generic in Part (particle data), Sys (system data), and
Degree (number of particles per edge: 2=pairs, 3=triplets).
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Table[ParticleId, Part]
|
Inherited -- indexed particle data. |
systems |
Table[SystemId, Sys]
|
Inherited -- indexed system data. |
edges |
Edges[Degree]
|
Edge connectivity with |
Source code in src/kups/potential/common/graph.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
sorted_by_system(sort_edges=False, *, return_sort_order=False)
¶
Sort particles by system index and remap edges accordingly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sort_edges
|
bool
|
If True, also sort edges by the system of their first particle. |
False
|
return_sort_order
|
bool
|
If True, also return the sort permutation. |
False
|
Source code in src/kups/potential/common/graph.py
IsGraphInput
¶
Bases: Protocol
A potential input exposing a graph of particles and systems.
Source code in src/kups/potential/common/graph.py
IsGraphProbe
¶
Bases: IsParticleProbe[P], Protocol
Particle probe supplying neighbor lists for incremental graph construction.
Source code in src/kups/potential/common/graph.py
IsParticleProbe
¶
PointCloud
¶
Bases: Generic[Part, Sys]
Indexed particles and systems, the base for all graph representations.
Generic in Part (particle data with positions and system assignment)
and Sys (system data with cell).
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Table[ParticleId, Part]
|
Indexed particle data with positions and system assignment. |
systems |
Table[SystemId, Sys]
|
Indexed system data with cell information. |
Source code in src/kups/potential/common/graph.py
graph_pair_energies(pair, parameters, graph, inclusion, exclusion)
¶
Evaluate pair terms on compacted edges with their remaining group masks.