|
RadCluster
Graph-based cluster dynamics for irradiated materials
|
Functions | |
| str | vertex (Population pop, int n) |
| range | _sizes (Population pop, int n_max) |
| to_networkx (ReactionAdmissibilityGraph rag, int n_max=40, bool include_binary=True) | |
| None | write_graphml (G, path) |
| str | structural_report (ReactionAdmissibilityGraph rag, int n_max=40) |
Variables | |
| ap | |
| type | |
| int | |
| default | |
| help | |
| choices | |
| action | |
| Path | |
| a = ap.parse_args() | |
| inp | |
| rag | |
| _ | |
| equations | |
| cascade | |
| str | report = structural_report(rag, n_max=a.n_max) |
| encoding | |
| G | |
core/to_networkx.py — explicit materialization of a RAG for diagnostics.
Host-independent. The production path keeps the reaction admissibility
graph *implicit*: an :class:`Edge` is a size-parameterized family, and the
graph walker never instantiates a vertex. That is the right choice for the
inner loop (see the paper, Section "Implementation"), but it means the
standard structural queries — connectivity, reachability from the monomer
pools, orphaned vertices, cycle structure — are not available for free.
This module supplies them by exporting the declared graph, truncated at a
chosen size cut-off, into an explicit ``networkx.MultiDiGraph``. It is a
DIAGNOSTIC path only: nothing in the solver imports it, and NetworkX is an
optional dependency.
Typical use::
from py_utils.materials import build_eurofer_rag
from py_utils.core.to_networkx import to_networkx, structural_report
rag, layout = build_eurofer_rag(inp, rr)
G = to_networkx(rag, n_max=40)
print(structural_report(rag, n_max=40))
Cite as: NetworkX, Hagberg, Schult & Swart, Proc. SciPy 2008.
|
protected |
Definition at line 44 of file to_networkx.py.
| str py_utils.core.to_networkx.structural_report | ( | ReactionAdmissibilityGraph | rag, |
| int | n_max = 40 |
||
| ) |
Human-readable structural audit of a declared RAG. Reports vertex/edge counts, weak connectivity, the set of vertices not reachable from the monomer pools (a declaration bug: population with no production channel), and the set with no outgoing edge (a sink-only trap). Intended to be run once per host declaration and quoted in the paper, not called during integration.
Definition at line 205 of file to_networkx.py.
| py_utils.core.to_networkx.to_networkx | ( | ReactionAdmissibilityGraph | rag, |
| int | n_max = 40, |
||
| bool | include_binary = True |
||
| ) |
Materialize ``rag`` up to size ``n_max`` as a ``networkx.MultiDiGraph``.
Parameters
----------
rag : ReactionAdmissibilityGraph
The host's declared graph.
n_max : int
Size cut-off. Keep it small (tens): the binary edge classes are
O(n_max**2) per family, which is exactly why the production path
does not materialize the graph at all.
include_binary : bool
Expand COALESCENCE and ANNIHILATION families. These are directed
*hyperedges* (two precursors); NetworkX has no hyperedge type, so
each is represented by its two tail->head arcs, both tagged
``hyperedge=True`` and sharing a ``hyper_id``. Set False for a
cleaner drawing.
Returns
-------
networkx.MultiDiGraph
Node attributes: ``polarity``, ``population``, ``size``.
Edge attributes: ``edge_class``, ``label``, ``kernel``,
``hyperedge``, ``hyper_id``.
Definition at line 51 of file to_networkx.py.
| str py_utils.core.to_networkx.vertex | ( | Population | pop, |
| int | n | ||
| ) |
Canonical string key for the vertex (polarity, size, population).
Definition at line 39 of file to_networkx.py.
| None py_utils.core.to_networkx.write_graphml | ( | G, | |
| path | |||
| ) |
Write ``G`` to GraphML, dropping attributes GraphML cannot represent.
``to_networkx`` tags every arc with ``hyper_id``, which is ``None`` on
the unary edge classes because they are not hyperedge members, and
``kernel`` is ``None`` for any edge the host declared without one.
The GraphML writer rejects ``None`` outright ("GraphML writer does not
support <class 'NoneType'> as data values"), so exporting the graph
unmodified always fails. Attributes are dropped rather than coerced:
an absent ``hyper_id`` is what "not a hyperedge" means, and writing a
sentinel would invite a reader to treat it as an id.
The input graph is not modified.
Definition at line 176 of file to_networkx.py.
|
protected |
Definition at line 292 of file to_networkx.py.
| py_utils.core.to_networkx.a = ap.parse_args() |
Definition at line 288 of file to_networkx.py.
| py_utils.core.to_networkx.action |
Definition at line 281 of file to_networkx.py.
| py_utils.core.to_networkx.ap |
Definition at line 270 of file to_networkx.py.
| py_utils.core.to_networkx.cascade |
Definition at line 293 of file to_networkx.py.
| py_utils.core.to_networkx.choices |
Definition at line 278 of file to_networkx.py.
| py_utils.core.to_networkx.default |
Definition at line 273 of file to_networkx.py.
| py_utils.core.to_networkx.encoding |
Definition at line 298 of file to_networkx.py.
| py_utils.core.to_networkx.equations |
Definition at line 293 of file to_networkx.py.
| py_utils.core.to_networkx.G |
Definition at line 301 of file to_networkx.py.
| py_utils.core.to_networkx.help |
Definition at line 274 of file to_networkx.py.
| py_utils.core.to_networkx.inp |
Definition at line 290 of file to_networkx.py.
| py_utils.core.to_networkx.int |
Definition at line 273 of file to_networkx.py.
| py_utils.core.to_networkx.Path |
Definition at line 284 of file to_networkx.py.
| py_utils.core.to_networkx.rag |
Definition at line 292 of file to_networkx.py.
| str py_utils.core.to_networkx.report = structural_report(rag, n_max=a.n_max) |
Definition at line 295 of file to_networkx.py.
| py_utils.core.to_networkx.type |
Definition at line 273 of file to_networkx.py.