Core API¶
The package-level reference below contains Morana’s public problem-definition, numerical-control, execution-report, result, plotting, and export objects. Finite-volume solve functions are documented separately in the finite-volume reference. Start with the modeling and solver workflow for the intended workflow.
morana ¶
Public API for Morana hex-z diffusion calculations.
Problem definitions live in
ProblemConfiguration objects and
execute through method-scoped functions such as
solve_fixed_source.
BoundaryCondition
dataclass
¶
BoundaryCondition(
kind: str,
flux: ndarray | None = None,
alpha: float | None = None,
beta: float | None = None,
current: ndarray | None = None,
)
Represent immutable diffusion boundary physics for selected faces.
Prefer the named constructors over direct construction; they make the
physical convention explicit. Attach the resulting condition to exposed
faces with globally() or an on_*() method. Boundary vectors are
copied into read-only arrays and are ordered fast to thermal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Nonempty direct-construction boundary kind. Supported values are
|
required |
flux
|
ndarray | None
|
Nonempty, finite, nonnegative one-dimensional prescribed face-flux
spectrum in |
None
|
alpha
|
float | None
|
Finite, nonnegative, dimensionless outward net-current-over-face-flux
coefficient for |
None
|
beta
|
float | None
|
Finite, dimensionless returned-to-outgoing partial-current ratio in
|
None
|
current
|
ndarray | None
|
Nonempty, finite, nonnegative one-dimensional imposed incoming
partial-current spectrum in |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
Reflective, vacuum, zero-Dirichlet, and Robin conditions are homogeneous.
A Dirichlet condition is homogeneous when its resolved flux vector is
zero. A partial-current-return condition is homogeneous when its optional
current is absent or resolves to zero; an incoming-current condition is
homogeneous only when its current resolves to zero. Only homogeneous
conditions are accepted by morana.solvers.finite_volume.solve_keff(). See the
modeling workflow and exposed-boundary theory for selector precedence and
finite-volume equations.
dirichlet
classmethod
¶
Return a prescribed group-resolved face-flux boundary condition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flux
|
ndarray | list[float]
|
Nonempty, finite, nonnegative one-dimensional face-flux spectrum
in |
required |
Notes
A nonzero spectrum contributes an inhomogeneous boundary source and
is therefore unavailable to morana.solvers.finite_volume.solve_keff(). Use
zero_dirichlet() for a homogeneous zero-flux boundary.
globally ¶
Apply this condition to every exposed face as a fallback.
incoming_current
classmethod
¶
Return a pure group-resolved incoming partial-current boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
ndarray | list[float]
|
Nonempty, finite, nonnegative imposed incoming partial-current
spectrum in |
required |
Notes
This is a Marshak-vacuum response with independent incidence:
J_out = phi_b / 2 - 2 * current. A nonzero spectrum creates an
inhomogeneous boundary source and is unavailable to
morana.solvers.finite_volume.solve_keff().
on_bottom ¶
Apply this condition to physical exterior bottom faces.
on_excluded ¶
on_excluded(
*,
key: str | None = None,
kind: str | None = None,
direction: str | None = None
) -> "BoundaryAssignment"
Apply this condition to faces adjoining excluded material-mesh regions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | None
|
Excluded neighbor key to match. The key must be a string.
Mutually exclusive with |
None
|
kind
|
str | None
|
Excluded-region kind to match, such as |
None
|
direction
|
str | None
|
Optional radial ( |
None
|
Notes
Every supplied selector argument must match; an omitted argument
matches any value. Therefore, on_excluded() selects every
excluded-region interface. This selector does not apply to physical
exterior faces. Compatible excluded-interface assignments resolve by
key and direction, key, kind and direction, kind, direction, then the
unqualified excluded-interface rule; the global rule is the final
fallback.
partial_current_return
classmethod
¶
partial_current_return(
beta: float,
current: ndarray | list[float] | None = None,
) -> "BoundaryCondition"
Return a partial-current-return boundary with optional incidence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
beta
|
float
|
Finite returned-to-outgoing partial-current ratio in |
required |
current
|
ndarray | list[float] | None
|
Optional nonempty, finite, nonnegative group-resolved imposed
incoming partial current in |
None
|
Notes
Morana applies j_minus = beta * j_plus + current independently in
each group. A nonzero current creates an inhomogeneous boundary
source and is unavailable to morana.solvers.finite_volume.solve_keff().
reflective
classmethod
¶
Return a homogeneous reflective boundary with J_out = 0.
This condition contributes neither leakage nor a boundary source and
is equivalent to partial_current_return(beta=1.0) without imposed
incidence.
robin
classmethod
¶
Return a homogeneous scalar Robin-current boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Finite, nonnegative, dimensionless coefficient in
|
required |
vacuum
classmethod
¶
Return a homogeneous Marshak-vacuum boundary.
Morana uses J_out = phi_b / 2 at the physical face. It is
equivalent to robin(alpha=0.5) and to
partial_current_return(beta=0.0) without imposed incidence.
zero_dirichlet
classmethod
¶
Return a homogeneous Dirichlet boundary with phi_b = 0.
This is not the Marshak-vacuum approximation: it prescribes zero physical face flux and is the limiting case of a Robin coefficient tending to infinity.
BoundaryConditionSet
dataclass
¶
Store selector-bound boundary conditions and resolve exposed faces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*assignments
|
BoundaryAssignment
|
Fluent boundary assignments returned by methods such as
|
()
|
Attributes:
| Name | Type | Description |
|---|---|---|
assignments |
tuple[BoundaryAssignment, ...]
|
Tuple of immutable assignments in construction order. |
Notes
BoundaryConditionSet is immutable. Use with_assignment() to
construct a separate checked set with one additional assignment.
Resolution is independent of construction order. An excluded interface
uses key-and-direction, key, kind-and-direction, kind, direction-only,
any-excluded, then global precedence. A physical exterior face uses its
matching radial, bottom, or top selector, then outer, then global
precedence. Call check_coverage with the current material mesh to
require a condition for every exposed radial and axial face. Problem
assembly and solver execution perform the same coverage requirement.
Build a possibly incomplete boundary set from fluent assignments.
Raises:
| Type | Description |
|---|---|
TypeError
|
If an input is not a |
ValueError
|
If an input duplicates a selector already present in this set. |
check_coverage ¶
Require every exposed radial and axial face to resolve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material_mesh
|
'MaterialMesh'
|
Material layout whose active cells and exposed faces are checked. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If one or more exposed faces lack a resolved condition. The error lists every uncovered face with its layer, active-cell ID, direction, topology kind, and excluded-neighbor identity when applicable. |
Notes
This method does not mutate the set or the material mesh. Use
ProblemConfiguration.check_boundary_coverage() when validating the
boundary set attached to a complete problem definition.
resolve ¶
Resolve a condition for one exposed radial or axial face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
'DomainFace'
|
Exposed |
required |
Returns:
| Type | Description |
|---|---|
BoundaryCondition
|
Condition selected by the locked topology precedence. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
Resolution uses selector specificity, not assignment construction order. See the class documentation for both physical-exterior and excluded-interface precedence chains.
with_assignment ¶
Return a new set with one additional fluent assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assignment
|
BoundaryAssignment
|
Fluent |
required |
Returns:
| Type | Description |
|---|---|
BoundaryConditionSet
|
New set; this set and its assignment tuple are unchanged. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
BoundarySelector
dataclass
¶
BoundarySelector(
scope: str,
direction: str | None = None,
excluded_key: str | None = None,
excluded_kind: str | None = None,
)
Immutably select exposed boundary faces by topology, not physics.
Prefer the fluent BoundaryCondition selection methods in ordinary
problem definitions. Direct construction is available when constructing a
BoundaryAssignment explicitly. A selector matches topology only; its
associated condition supplies the boundary physics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
str
|
Closed selector vocabulary: |
required |
direction
|
str | None
|
Optional direction filter for |
None
|
excluded_key
|
str | None
|
Optional human-readable material-mesh excluded key for
|
None
|
excluded_kind
|
str | None
|
Optional human-readable excluded-region kind for |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the scope or direction is unknown; direction is used with another scope; an excluded filter is used with another scope; both excluded filters are supplied; or a supplied identifier is empty, whitespace-only, or non-printable. |
Notes
to_excluded filters are combined, and omitted filters match any value.
Selector precedence is resolved by BoundaryConditionSet; the selector
does not carry a numeric priority.
specificity_key
property
¶
Return the complete selector identity for duplicate detection.
This tuple is not a precedence rank. BoundaryConditionSet rejects
assignments with equal identities and resolves distinct overlapping
selectors by its documented topology precedence.
bottom
classmethod
¶
Select physical exterior faces at the bottom of the stack.
Excluded interfaces to a lower in-stack position are selected only by
to_excluded(direction="bottom").
everywhere
classmethod
¶
Select every exposed face as the global fallback.
This includes both physical exterior and excluded-interface faces. More specific compatible selectors take precedence.
outer
classmethod
¶
Select every physical exterior face, radial and axial.
Excluded-interface faces are not physical exterior faces and are not selected. Radial, bottom, and top selectors refine this scope.
radial
classmethod
¶
Select physical lateral exterior faces only.
This scope excludes bottom, top, and excluded-interface faces. Morana does not provide direction-specific physical-exterior radial selectors.
to_excluded
classmethod
¶
to_excluded(
key: str | None = None,
kind: str | None = None,
direction: str | None = None,
) -> "BoundarySelector"
Select faces adjoining excluded material-mesh positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | None
|
Optional excluded neighbor key. The key must be a string.
Mutually exclusive with |
None
|
kind
|
str | None
|
Optional excluded-region kind. Mutually exclusive with |
None
|
direction
|
str | None
|
Optional radial or axial face direction: |
None
|
Notes
Every supplied filter must match, while an omitted filter matches any
value. Thus to_excluded() selects every excluded interface. This
factory does not select physical exterior faces.
top
classmethod
¶
Select physical exterior faces at the top of the stack.
Excluded interfaces to an upper in-stack position are selected only by
to_excluded(direction="top").
CellInspection
dataclass
¶
Store one read-only active-cell inspection value.
Instances are returned by Result.cell_at. Direct construction is not
supported.
Attributes:
| Name | Type | Description |
|---|---|---|
material_key |
str
|
Material-layout key assigned to the selected cell. |
cross_sections |
CrossSections
|
Immutable macroscopic cross sections assigned to |
flux |
ndarray
|
Read-only one-dimensional cell-average scalar-flux array in
|
Reject direct construction; inspect a completed result instead.
CellSource
dataclass
¶
Store explicit group/cell source values by axial layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
tuple[ndarray, ...]
|
Bottom-to-top tuple of group-major arrays shaped
|
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a layer is not iterable or contains values other than real non-Boolean numbers. |
ValueError
|
If no layer is supplied, a layer is not two-dimensional, no group is supplied, or layer group counts differ. |
Notes
A cell source does not own a material mesh. Assembly requires exactly one
supplied source layer per material-mesh layer and checks each column count
against that selected layer’s active-cell count. It checks finiteness and
nonnegativity then, not at construction. CellSource is immutable;
construct a replacement source to change its layers.
values ¶
Return explicit read-only source values for one selected layer.
The selected array must have exactly one column for every compact
active ID. Requesting an index outside this source’s layer tuple raises
ValueError.
CrossSections
dataclass
¶
CrossSections(
D: ndarray | list[float],
sigma_a: ndarray | list[float],
sigma_s: ndarray | list[list[float]],
fission: FissionData | None,
*,
multiplicity_matrix: (
ndarray | list[list[float]] | None
) = None
)
Store group-major macroscopic cross sections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
D
|
ndarray | list[float]
|
Nonempty one-dimensional diffusion-coefficient array in cm. Its length defines the number of energy groups. |
required |
sigma_a
|
ndarray | list[float]
|
One-dimensional absorption macroscopic cross-section array in
|
required |
sigma_s
|
ndarray | list[list[float]]
|
Complete P0 scattering-transfer matrix in |
required |
multiplicity_matrix
|
ndarray | list[list[float]] | None
|
Optional scattering-neutron emission multiplicity with shape
|
None
|
fission
|
FissionData | None
|
Optional checked fission-physics bundle. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
groups |
int
|
Number of energy groups derived from the length of |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a numerical field contains a non-real or Boolean value. |
ValueError
|
If shapes are inconsistent, no groups are supplied, a numeric value is
nonfinite or negative, or the supplied fission bundle has an
inconsistent group count. |
Notes
Public group ordering is fast-to-thermal. Inputs are converted to NumPy
arrays immediately and copied so the container owns its numerical data.
Stored numerical arrays are read-only. CrossSections is immutable after
construction. Construct a replacement value when changing group data.
from_openmc_mgxs_hdf5
classmethod
¶
from_openmc_mgxs_hdf5(
path: str | Path,
dataset: str,
temperature: float,
*,
diffusion: str
) -> CrossSections
Import selected macroscopic data from an OpenMC runtime-MGXS file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
OpenMC runtime-library HDF5 file emitted by
|
required |
dataset
|
str
|
Exact name of one direct-child macroscopic record in the runtime
library. Nuclide-like records carrying |
required |
temperature
|
float
|
Exact stored physical temperature in K, apart from a small floating-point representation tolerance. |
required |
diffusion
|
str
|
Required diffusion convention. |
required |
Returns:
| Type | Description |
|---|---|
CrossSections
|
Immutable selected material data. The imported value retains no source-file, energy-grid, or selection provenance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the file is unreadable or is not a supported runtime-MGXS library; the material or temperature selection is invalid; the diffusion convention is unsupported; or required record data are missing, inconsistent, or outside their accepted ranges. |
Notes
The conversion supports nonfissionable records and fissionable records
with either separable vector nu-fission plus chi or general
transfer matrix nu-fission production data. It requires
finite nonnegative P0 scalar-flux isotropic scattering, and finite
signed higher Legendre moments, in the runtime writer’s
[G][G'][Order] layout and expands its compact
bands to Morana’s complete incoming-to-outgoing
sigma_s[g_from, g_to] matrix. A separate valid
multiplicity_matrix is retained; its absence uses the compact
unit-multiplicity representation. A present valid kappa-fission
vector is retained as
FissionData.kappa_sigma_f in eV / cm.
The importer warns when discarding higher scattering moments, known optional data outside Morana’s steady diffusion scope, or unrecognized selected-temperature fields. See the OpenMC MGXS import guide for the data, unit, warning, and rejection contracts.
The runtime format does not identify whether total came from
OpenMC TotalXS or TransportXS. Selecting "p1-outscatter"
for a TransportXS value would apply a second transport correction;
the caller must avoid this invalid combination because Morana cannot
detect it from the file.
DirectLinearSolveSettings
dataclass
¶
Configure the sparse-direct reference linear-solve path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_residual_tolerance
|
float
|
Finite positive real bound applied to Morana’s independently calculated true relative residual after SciPy returns a candidate solution. Boolean values are not accepted. |
1e-10
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
DomainFace
dataclass
¶
Store a discretization-neutral active-cell face description.
Instances are returned by MaterialMesh.face. Direct construction is
not supported.
Attributes:
| Name | Type | Description |
|---|---|---|
axial_index, active_id, openmc_index |
Axial, slice-local, and geometric identity of the owning active cell. |
|
direction, kind |
Canonical face direction and its internal, outer, or excluded-interface topology classification. |
|
neighbor_axial_index, neighbor_active_id, neighbor_openmc_index |
In-stack axial, slice-local, and geometric identity of an internal or excluded-interface neighbor. |
|
neighbor_key, neighbor_key_kind |
Excluded-region identity available only for an excluded interface. |
Notes
A domain face describes topology only. Boundary physics, face geometry, and
finite-volume conductance are resolved separately by their owning layers.
MaterialMesh.face() constructs topology-consistent values. For an
"internal" face, every neighbor-identity field is present and both
excluded-region fields are None. For a "to_excluded" face, the
neighbor axial and OpenMC indices and both excluded-region fields are
present, while neighbor_active_id is None. For an "outer"
face, every neighbor field is None.
DomainFace is an immutable value record. It carries a snapshot of one
topology query and has no live reference to a MaterialMesh.
Reject direct construction; obtain faces from MaterialMesh.
ExcludedRegion
dataclass
¶
Describe a non-solved material-mesh region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Human-readable public region-kind identifier used by boundary selectors and provenance. It must contain a non-whitespace character and only printable characters. Its spelling is preserved, it is not restricted to a closed vocabulary, and kind-based selection uses exact equality. |
required |
color
|
str | None
|
Optional nonempty plotting-color string. Its syntax is not validated at
construction. A custom region without a color resolves to |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
Notes
ExcludedRegion is an immutable region description, not an excluded-position
identity. Register it as a value in MaterialMesh.stack’s
excluded_regions mapping; that mapping’s string key is the
excluded-region identity. Select one such identity with
on_excluded(key=...) or every identity sharing this kind with
on_excluded(kind=...).
Excluded regions live in MaterialMesh layouts but are not active
materials. They receive no unknown, source, cross sections, or neutron
balance contribution. The built-in key "0" is always the reserved
"inactive" region with plotting color "white"; it cannot be
redefined.
FissionData
dataclass
¶
FissionData(
neutron_production: SeparableFission | FissionTransfer,
*,
kappa_sigma_f: ndarray | list[float] | None = None
)
Bundle fission physics for one multigroup material.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neutron_production
|
SeparableFission | FissionTransfer
|
Exactly one checked neutron-production representation:
|
required |
kappa_sigma_f
|
ndarray | list[float] | None
|
Optional incident-group recoverable fission-energy production cross
section in |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
groups |
int
|
Number of energy groups. |
fission_transfer |
ndarray
|
Canonical read-only event-oriented transfer array with indexing
|
fission_production |
ndarray
|
Canonical read-only total neutron production by incident group. |
Notes
FissionData retains the caller-selected neutron-production value. Use
SeparableFission when a common outgoing spectrum is appropriate; use
FissionTransfer for general incident-to-outgoing group production.
The derived fission_transfer and fission_production properties give
both forms one common operator-facing representation.
FissionSourceNormalization
dataclass
¶
Scale a converged eigenfunction to a target fission-source rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate
|
float
|
Finite positive total fission-neutron source rate in |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
Use PowerNormalization when recoverable fission-energy production
cross sections are available and a thermal-power target is required.
FissionTransfer
dataclass
¶
Store general fission-neutron transfer data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fission_transfer
|
ndarray | list[list[float]]
|
Square fission-neutron transfer array in |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
groups |
int
|
Number of energy groups. |
fission_production |
ndarray
|
Read-only derived total neutron production by incident group. |
FixedSourceBalance
dataclass
¶
Store one immutable fixed-source neutron-balance record.
Instances are retained by solver-produced results or restored from checked result archives. Direct construction is not supported.
Attributes:
| Name | Type | Description |
|---|---|---|
by_group |
Mapping[str, ndarray]
|
Finite group-resolved vectors in |
by_layer_group |
Mapping[str, tuple[ndarray, ...]]
|
Bottom-to-top finite group-resolved vectors in |
Reject direct construction; balances belong to completed results.
FixedSourceSettings
dataclass
¶
FixedSourceSettings(
linear_solve: LinearSolveSettings = DirectLinearSolveSettings(),
flux_nonnegativity_tolerance: float = 1e-12,
)
Configure one fixed-source solve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
linear_solve
|
LinearSolveSettings
|
Immutable per-call direct or GMRES policy. Direct solving is the default reference path. |
DirectLinearSolveSettings()
|
flux_nonnegativity_tolerance
|
float
|
Finite nonnegative real relative tolerance for accepting and cleaning negative roundoff in the solved scalar-flux vector. The threshold is this value times the candidate vector’s largest absolute component. Zero rejects every negative candidate; Boolean values are not accepted. |
1e-12
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
GmresLinearSolveSettings
dataclass
¶
GmresLinearSolveSettings(
relative_residual_tolerance: float = 1e-10,
max_krylov_iterations: int = 1000,
restart: int = 50,
preconditioner: LinearPreconditioner = NoPreconditioner(),
)
Configure restarted GMRES and its one typed preconditioner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_residual_tolerance
|
float
|
Finite positive real bound supplied to GMRES and applied again to Morana’s independently calculated true relative residual. Boolean values are not accepted. |
1e-10
|
max_krylov_iterations
|
int
|
Positive non-Boolean integer maximum number of Krylov iterations across all restarts. |
1000
|
restart
|
int
|
Positive non-Boolean integer number of Krylov vectors retained in one
GMRES cycle. It may not exceed |
50
|
preconditioner
|
LinearPreconditioner
|
One immutable no, Jacobi, or threshold-ILU preconditioner policy. |
NoPreconditioner()
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a numerical control has an unsupported type or is Boolean, or if
|
ValueError
|
If a numerical control is out of range, cannot be represented as a
finite |
HexPlanarMesh
dataclass
¶
Represent a regular 2D hexagonal mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_rings
|
int
|
Positive integer OpenMC-style ring count. |
required |
pitch
|
float
|
Finite positive flat-to-flat hexagon pitch in cm. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
n_cells |
int
|
Number of positions in the complete regular lattice. |
coords |
tuple[tuple[int, int], ...]
|
Integer |
openmc_indices |
tuple[OpenMCIndex, ...]
|
|
direction_labels |
tuple[str, ...]
|
Radial neighbor directions in the fixed order |
area, face_length, center_distance, center_to_face |
Per-cell planar area in |
|
index_of |
Mapping[tuple[int, int], int]
|
Newly constructed mapping from a lattice coordinate to its planar ID. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
The mesh is a full regular lattice. OpenMC-style ring indices and integer
lattice coordinates are constructed internally from num_rings
using the locked OpenMC orientation="x" ring-order convention. The
coordinate basis is aligned with Morana’s x and u face directions:
x+ points right and u+ points upper-right.
Planar IDs enumerate rings outermost to innermost; positions within a ring
start at x+ and proceed clockwise. planar_id_at() is the safe
reverse lookup and returns None for an index outside this mesh.
neighbors() returns full-lattice planar IDs in direction_labels
order and uses None for a physical lattice perimeter. The mesh has no
material, active-domain, or axial information; MaterialMesh supplies
those layers of the problem definition.
center_distance
property
¶
Return the center-to-center distance across a face in cm.
center_to_face
property
¶
Return the perpendicular center-to-face distance in cm.
coords
property
¶
Return lattice (x, u) coordinates in outer-to-inner ID order.
direction_labels
property
¶
Return the mesh-owned face-direction labels in neighbor order.
index_of
property
¶
Return the immutable mapping from lattice coordinate to planar ID.
openmc_indices
property
¶
Return orientation-x OpenMC ring indices in planar-ID order.
cartesian_center ¶
Return a center using the (x, u) Cartesian transform.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
cell_vertices ¶
Return Cartesian vertices for one hexagonal cell.
Vertices are ordered counter-clockwise.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
export_vtu ¶
Export the full lattice as a VTK XML unstructured grid.
Each cell is one planar VTK polygon. Cell data comprises planar_id,
lattice_x, lattice_u, openmc_ring, and
openmc_position in planar-ID order. The mesh pitch is encoded in
geometry. Parent directories are
created when needed; an existing file at path is replaced.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
IsADirectoryError
|
If |
OSError
|
If the parent directory cannot be created or the VTU file cannot be written. |
lattice_coord ¶
Return the (x, u) lattice coordinate for a planar ID.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
neighbors ¶
Return neighbors in direction_labels order, using None outside.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
openmc_index ¶
Return the orientation-x OpenMC ring index for a planar ID.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
planar_id_at ¶
Return the planar ID at an OpenMC index, or None if absent.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
plot_matplotlib ¶
Plot the full lattice with planar, lattice, and OpenMC labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes | None
|
Optional axes to populate. A new figure and axes are created when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
The populated axes. Each cell label lists planar ID, |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
to_plotly ¶
Return a Plotly full-lattice figure with per-cell inspection labels.
The visible cell label lists planar ID, (x, u), and
ring/position. Hover text also gives the Cartesian center in cm.
IluPreconditioner
dataclass
¶
Select threshold incomplete-LU preconditioning for GMRES.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drop_tolerance
|
float
|
Finite nonnegative real threshold used to drop incomplete-factor entries. Boolean values are not accepted. |
0.0001
|
fill_factor
|
float
|
Finite positive real upper bound on incomplete-factor fill relative to the original sparse matrix. Boolean values are not accepted. |
10.0
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If either control is not a real number or is Boolean. |
ValueError
|
If either control is not finite after conversion to |
JacobiPreconditioner
dataclass
¶
Select diagonal (Jacobi) preconditioning for GMRES.
KeffBalance
dataclass
¶
Store one immutable criticality neutron-balance record.
Instances are retained by solver-produced criticality results or restored from checked result archives. Direct construction is not supported.
Attributes:
| Name | Type | Description |
|---|---|---|
by_group |
Mapping[str, ndarray]
|
Finite group-resolved vectors in |
by_layer_group |
Mapping[str, tuple[ndarray, ...]]
|
Bottom-to-top finite group-resolved vectors in |
Reject direct construction; balances belong to completed results.
KeffOuterIterationReport
dataclass
¶
Describe one completed finite-volume criticality outer iteration.
Instances are retained by solver-produced criticality results or restored from checked result archives. Direct construction is not supported.
Attributes:
| Name | Type | Description |
|---|---|---|
iteration |
int
|
Positive one-based power-iteration index. |
linear_solve |
LinearSolveReport
|
Completed loss-system solve nested in this outer iteration. |
keff |
float
|
Finite positive multiplication-factor estimate. |
keff_change |
float
|
Finite nonnegative relative multiplication-factor change. |
flux_change |
float
|
Finite nonnegative volume-weighted normalized-flux change. |
keff_relative_residual |
float
|
Finite nonnegative relative eigenvalue-equation residual. |
Reject direct construction; reports belong to completed results.
KeffSettings
dataclass
¶
KeffSettings(
inner_linear_solve: LinearSolveSettings = DirectLinearSolveSettings(),
max_outer_iterations: int = 100,
keff_change_tolerance: float = 1e-10,
flux_change_tolerance: float = 1e-10,
keff_relative_residual_tolerance: float = 1e-10,
flux_nonnegativity_tolerance: float = 1e-12,
eigenvalue_iteration: EigenvalueIterationSettings = PowerIterationSettings(),
)
Configure one source-normalized fission eigenvalue solve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner_linear_solve
|
LinearSolveSettings
|
Immutable direct or GMRES policy applied separately to each outer iteration. Direct solving is the default reference path. |
DirectLinearSolveSettings()
|
max_outer_iterations
|
int
|
Positive non-Boolean integer maximum power-iteration count. |
100
|
keff_change_tolerance
|
float
|
Finite positive real relative multiplication-factor change tolerance. Boolean values are not accepted. |
1e-10
|
flux_change_tolerance
|
float
|
Finite positive real volume-weighted normalized-flux change tolerance. Boolean values are not accepted. |
1e-10
|
keff_relative_residual_tolerance
|
float
|
Finite positive real relative eigenvalue-equation residual tolerance. Boolean values are not accepted. |
1e-10
|
flux_nonnegativity_tolerance
|
float
|
Finite nonnegative real relative tolerance for accepting and cleaning negative roundoff in a power-iteration flux vector. The threshold is this value times the candidate vector’s largest absolute component. Zero rejects every negative candidate; Boolean values are not accepted. |
1e-12
|
eigenvalue_iteration
|
EigenvalueIterationSettings
|
Immutable ordinary-power or fixed-Wielandt-shift policy. Ordinary power iteration is the default reference path. |
PowerIterationSettings()
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a policy input is unsupported, or if a numerical control has an unsupported type or is Boolean. |
ValueError
|
If a numerical control is out of range or cannot be represented as a
finite |
KeffSolveReport
dataclass
¶
Retain completed records for every criticality outer iteration.
Instances are retained by solver-produced criticality results or restored from checked result archives. Direct construction is not supported.
Attributes:
| Name | Type | Description |
|---|---|---|
outer_iterations |
tuple[KeffOuterIterationReport, ...]
|
Nonempty consecutive one-based outer-iteration records. |
eigenvalue_iteration |
EigenvalueIterationSettings
|
Immutable ordinary-power or fixed-Wielandt-shift policy used for the recorded criticality solve. |
iterations |
int
|
Number of completed criticality outer iterations. |
final_outer_iteration |
KeffOuterIterationReport
|
Final completed outer-iteration record. |
Reject direct construction; reports belong to completed results.
LinearSolveReport
dataclass
¶
Describe one completed finite-volume linear solve.
Instances are retained by solver-produced results or restored from checked result archives. Direct construction is not supported.
Attributes:
| Name | Type | Description |
|---|---|---|
linear_solve |
LinearSolveSettings
|
Immutable strategy and, for GMRES, preconditioner policy used by the completed solve. |
iterations |
int
|
Nonnegative number of direct or Krylov iterations reported for this solve. |
true_relative_residual |
float
|
Finite nonnegative true residual calculated by Morana from the final flux, operator, and right-hand side. |
Reject direct construction; reports belong to completed results.
Material
dataclass
¶
Represent a user-visible material identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Public material name used by material meshes and source definitions.
The built-in excluded-region key |
required |
xs
|
CrossSections | None
|
Optional cross sections associated with this material. Cross sections may be omitted for layout-only or plotting use, but every active material requires them when a solver constructs its operators. |
None
|
color
|
str | None
|
Optional nonempty plotting-color string. Its syntax is passed through
without validation. Material-layout plots use it when this material is
supplied in their |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
Notes
Material is immutable. Construct and validate a replacement material
before placing it in a ProblemConfiguration.
MaterialMesh ¶
Store material keys for every lattice position.
Attributes:
| Name | Type | Description |
|---|---|---|
mesh |
HexPlanarMesh
|
Authoritative planar mesh shared by all layers. |
layers |
tuple[Mapping[OpenMCIndex, str], ...]
|
Read-only completed material-key mappings in bottom-to-top order. |
axial_layer_heights |
tuple[float, ...]
|
Immutable positive heights in bottom-to-top order. |
excluded_regions |
Mapping[str, ExcludedRegion]
|
Read-only excluded-region catalog. |
Notes
HexPlanarMesh owns only the full regular geometry. MaterialMesh overlays
material keys on that geometry and defines the active solution domain.
Unassigned positions default to the built-in inactive excluded key "0".
Direct construction is rejected; use
MaterialMesh.stack.
The public API is persistent: public properties expose read-only mappings and immutable height tuples, and supported assignment changes construct an independent material mesh rather than modifying this one. Treat the underscore-prefixed owned state as internal implementation detail.
Reject direct construction; completed meshes are stacked slices.
axial_layer_heights
property
¶
Return the immutable positive layer heights in axial order.
excluded_regions
property
¶
Return the read-only excluded-region catalog.
face_direction_labels
property
¶
Return radial and axial face labels in canonical domain order.
layers
property
¶
Return read-only complete material-key mappings in axial order.
active_id_at ¶
Return a slice-local active ID at a lattice position, or None.
axial_index selects the layer before openmc_index identifies
its planar position.
None means that the position is excluded in the selected layer or
is not a position of the complete planar mesh. Use key_at when
those cases need to be distinguished.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
active_indices ¶
Return active OpenMC positions in compact solver order.
The order is the selected subset of mesh.openmc_indices. It is the
canonical order for slice-local active IDs and the active-cell axis of
solver arrays for this layer.
axial_face_area ¶
Return one axial top/bottom face area for an axial material layer.
cell_volume ¶
Return one hex-z cell volume for an axial material layer.
export_vtm ¶
Export active and excluded material cells as VTK multiblock data.
The .vtm file references one .vtu leaf dataset per domain group.
ParaView can toggle those leaf datasets through the MultiBlock Inspector.
The adjacent material_keys.json maps each exported material_key_id
to its material key.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
IsADirectoryError
|
If |
OSError
|
If an output directory cannot be created or an output file cannot be written. |
face ¶
Return the topology description for one active-cell face.
axial_index and active_id identify the cell in that order.
The result is independent of discretization details. Solvers decide
how to turn the face classification into matrix coefficients or
response relations.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
key_at ¶
Return the completed material key at one axial-layer position.
Unassigned positions have the built-in inactive key "0". A
position outside the full planar mesh raises KeyError.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
layer_height ¶
Return the height of one axial material layer in cm.
material_by_active_id ¶
Return a read-only material mapping keyed by slice-local active ID.
The mapping insertion order matches active_indices(axial_index) and
therefore the selected layer’s compact solver order. The returned
mapping is a stable view of state derived when the material mesh is
constructed; copy it with dict(...) if mutation is required.
material_colors ¶
Return resolved plotting colors for every key in the layout.
Excluded-region colors take precedence and use the region’s configured
color or its default. For active keys, a supplied Material.color
takes precedence over the repeating default palette. Active palette
entries are assigned in first-use order while scanning layers bottom to
top and positions in planar order.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If a material-mapping key is empty or differs from its
|
n_active_cells ¶
Return the number of active solver cells in one axial layer.
openmc_index_for_active_id ¶
Return the lattice position for a slice-local active ID.
axial_index selects the layer before active_id identifies a
cell in its compact order. The ID must be a nonnegative integer in the
selected layer. Another input type raises TypeError; a negative or
out-of-range integer raises ValueError.
plot_matplotlib ¶
plot_matplotlib(
axial_index: int,
materials: Mapping[str, Material] | None = None,
ax: Axes | None = None,
) -> Axes
Plot one axial material slice with resolved material-key colors.
materials optionally supplies Material definitions by active key;
its explicit colors are resolved by material_colors. When ax is
omitted, the method creates and returns a new Matplotlib axes.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If a material-mapping key is empty or differs from its
|
radial_face_area ¶
Return one radial face area for an axial material layer.
stack
classmethod
¶
stack(
slices: tuple[MaterialSlice, ...],
*,
excluded_regions: (
Mapping[str, ExcludedRegion] | None
) = None
) -> "MaterialMesh"
Complete a bottom-to-top stack of reusable material slices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slices
|
tuple[MaterialSlice, ...]
|
Nonempty tuple of |
required |
excluded_regions
|
Mapping[str, ExcludedRegion] | None
|
Optional mapping from keys to |
None
|
Returns:
| Type | Description |
|---|---|
MaterialMesh
|
An independent completed layout with read-only layer mappings and excluded-region catalog. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
to_plotly ¶
Return a Plotly figure for one axial material slice.
materials optionally supplies Material definitions by active key.
Color resolution follows material_colors.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If a material-mapping key is empty or differs from its
|
z_bounds ¶
Return cumulative lower and upper coordinates for one layer.
MaterialSlice
dataclass
¶
Immutable height-bearing planar material-layout input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
HexPlanarMesh
|
Authoritative |
required |
material_keys
|
Mapping[OpenMCIndex, str]
|
Sparse mapping from OpenMC positions to active or excluded keys.
Keys must be |
required |
height
|
float
|
Finite positive axial height in cm. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
A slice is reusable construction data. It deliberately does not own the
excluded-region catalog or compact active-cell IDs; MaterialMesh.stack
applies those domain-level decisions to a bottom-to-top slice stack. Thus,
a key is not classified as active or excluded until stacking, when the
material mesh receives its excluded-region catalog.
extrude ¶
extrude(
*,
count: int | None = None,
heights: tuple[float, ...] | None = None
) -> tuple["MaterialSlice", ...]
Return a composable uniform or explicitly height-bearing fragment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int | None
|
Positive integer number of copies retaining this slice’s height.
Provide this argument or |
None
|
heights
|
tuple[float, ...] | None
|
Nonempty tuple of finite positive heights in cm. Provide this
argument or |
None
|
Returns:
| Type | Description |
|---|---|
tuple[MaterialSlice, ...]
|
A bottom-to-top fragment suitable for concatenation and passing to
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If neither or both forms are supplied, |
from_openmc_rings
classmethod
¶
from_openmc_rings(
mesh: HexPlanarMesh,
rings: list[list[str]],
*,
height: float
) -> "MaterialSlice"
Build one reusable complete slice from OpenMC-style ring data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
HexPlanarMesh
|
Authoritative |
required |
rings
|
list[list[str]]
|
List of lists of human-readable material keys for every mesh ring,
ordered outermost to innermost. Ring |
required |
height
|
float
|
Finite positive slice height in cm. |
required |
Returns:
| Type | Description |
|---|---|
MaterialSlice
|
An immutable slice with a complete material-key mapping. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the number of rings or a ring length does not match |
Notes
Ring values are human-readable identifiers. Their active or excluded
classification remains a MaterialMesh.stack decision.
MaterialSource
dataclass
¶
Assign volumetric source vectors by material name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values_by_material
|
Mapping[str, ndarray | list[float]]
|
Nonempty mapping from nonempty material names to common-length
nonempty group-major vectors in |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If a material name is empty, the mapping is empty, a vector is empty or not one-dimensional, or vectors do not have one common group count. |
Notes
Every material in a selected active layer must have an entry; evaluation
otherwise raises ValueError naming the missing material. The mapping
may contain unused entries. Finiteness, nonnegativity, and compatibility
with the problem group count are checked during source assembly rather
than construction. The stored vectors and mapping are immutable; construct
a replacement source to change material-wise values.
values ¶
Return material-wise source values in compact active-ID order.
The returned array is read-only with one column for each selected
active ID. An empty layer produces a read-only (groups, 0) array.
NoPreconditioner
dataclass
¶
Select unpreconditioned GMRES execution.
OpenMCIndex
dataclass
¶
Identify one serialized position in an OpenMC-style hexagonal ring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ring
|
int
|
Zero-based serialized ring index. For a |
required |
position
|
int
|
Zero-based position within |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
This is an immutable, hashable value object. Its dataclass ordering is
lexicographic by (ring, position), which matches a mesh’s outer-to-
inner serialized ring order but is not the same as spatial ordering around
the lattice.
OpenMCIndex validates that both fields are nonnegative integers, but
membership remains mesh-relative. For a mesh with n rings, a valid
ring is 0 <= ring < n and its valid positions are
0 <= position < max(6 * (n - 1 - ring), 1). HexPlanarMesh creates
its complete valid sequence as openmc_indices;
HexPlanarMesh.planar_id_at() returns None for an index outside that
sequence, and MaterialSlice rejects such indices as sparse keys.
The type records a ring-position identity only. It does not require
OpenMC at runtime and does not identify a compact material-mesh
active_id; use the latter only with an explicit axial layer.
PowerIterationSettings
dataclass
¶
Select ordinary fission-source-normalized power iteration.
PowerNormalization
dataclass
¶
Scale a converged eigenfunction to a target recoverable thermal power.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power
|
float
|
Finite positive target recoverable thermal power in W (J / s). Every
fissionable material in the active domain must provide
|
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
The target scales the returned flux and neutron-balance terms but does
not alter the returned k_eff. kappa_sigma_f directly represents
recoverable fission-energy production, avoiding an implied or fixed value
for neutrons emitted per fission.
ProblemConfiguration
dataclass
¶
ProblemConfiguration(
mesh: HexPlanarMesh,
materials: Mapping[str, Material],
material_mesh: MaterialMesh,
*,
boundary: BoundaryConditionSet | None = None,
source: (
UniformSource | MaterialSource | CellSource | None
) = None,
name: str | None = None
)
In-memory representation of a neutronics problem definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
HexPlanarMesh
|
Hexagonal mesh topology and geometry. |
required |
materials
|
Mapping[str, Material]
|
Mapping from public material name to material object. Every mapping key
must match its |
required |
material_mesh
|
MaterialMesh
|
Material-key layout over the full lattice. This defines the active
solution domain and must use |
required |
boundary
|
BoundaryConditionSet | None
|
Boundary-condition assignments for exposed mesh faces. The default is empty; a solve requires complete boundary coverage. |
None
|
source
|
UniformSource | MaterialSource | CellSource | None
|
Optional volumetric fixed-source object. A fixed-source solve may use this source, an inhomogeneous boundary contribution, or both; eigenvalue solves reject an external source. |
None
|
name
|
str | None
|
Optional nonempty configuration name for provenance and serialization. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If an input does not have its documented type. |
ValueError
|
If checked values are incompatible, a name is invalid, or a material layout refers to an unknown material. |
Notes
Public state is read-only. Use set_materials(), replace_material(),
set_material_mesh(), set_boundary(), add_boundary(),
assign_material(), set_source(), and set_name() to change an
existing configuration.
Check and own one mutable problem definition.
material_mesh
property
¶
Return the immutable material layout for this configuration.
materials
property
¶
Return the read-only name-to-immutable-material mapping.
source
property
¶
Return the optional fixed-source definition.
unused_material_names
property
¶
Return configured material names absent from every active mesh cell.
The returned set is derived from all axial layers of material_mesh.
Excluded positions do not use material definitions.
add_boundary ¶
Add one boundary assignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assignment
|
BoundaryAssignment
|
Assignment appended through |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If its selector duplicates an existing assignment. |
assign_material ¶
Assign a known material to one axial-layer lattice position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axial_index
|
int
|
Bottom-to-top axial-layer index. |
required |
openmc_index
|
OpenMCIndex
|
Public OpenMC-style position in the shared planar mesh. |
required |
material
|
str
|
Public name of a material in |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
The replacement updates only the specified layer. The previous immutable material mesh remains unchanged.
check_boundary_coverage ¶
Require conditions for every exposed face of the configured layout.
Raises:
| Type | Description |
|---|---|
ValueError
|
If one or more physical-exterior or excluded-region faces are uncovered. |
check_no_unused_materials ¶
Require every configured material to occur in an active mesh cell.
Raises:
| Type | Description |
|---|---|
ValueError
|
If one or more configured material names are absent from every active cell in every axial layer. |
replace_material ¶
Replace one existing material definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
Material
|
Replacement immutable material. Its name must already identify a material in this configuration. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If its name is not present. |
set_boundary ¶
Replace all boundary assignments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
boundary
|
BoundaryConditionSet
|
Complete replacement boundary-condition set. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
set_material_mesh ¶
Replace the full material layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material_mesh
|
MaterialMesh
|
Completed immutable material layout over this configuration’s planar mesh. Every active material key must identify a configured material. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If it uses different geometry or assigns an unknown material. |
set_materials ¶
Replace all material definitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
materials
|
Mapping[str, Material]
|
Complete name-to-material replacement mapping. Every key must
match its immutable |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If a name is invalid, a key does not match |
set_name ¶
Replace the provenance name.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
set_source ¶
Set or clear the fixed-source definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
UniformSource | MaterialSource | CellSource | None
|
Volumetric fixed-source definition, or |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
snapshot ¶
Return an immutable, non-aliasing problem-definition snapshot.
Returns:
| Type | Description |
|---|---|
ProblemConfigurationSnapshot
|
Non-aliasing snapshot of geometry, material layout, material and excluded-region definitions, boundary assignments, source, and name. Its public values are freshly reconstructed, not live references to this mutable configuration. It can be passed to a supported solve function or retained as result provenance. |
ProblemConfigurationSnapshot
dataclass
¶
Immutable, non-aliasing problem definition and result provenance.
The snapshot privately owns geometry, material-layout, definition,
boundary, source, and provenance records. Its public properties restore
fresh immutable Morana values on each access, never a live object or NumPy
array from the configuration it captures. Pass it to a supported solve
function as immutable input, retain it as result provenance, or call
to_configuration() to create an independent mutable problem owner.
UniformSource, MaterialSource, and CellSource are the complete
supported fixed-source set. Each is snapshotable and reconstructible.
boundary
property
¶
Return a fresh immutable boundary-assignment set.
material_mesh
property
¶
Return a fresh immutable material-layout value.
materials
property
¶
Return a fresh read-only mapping of immutable material values.
source
property
¶
Return a fresh built-in source definition, when present.
excluded_region_map ¶
Return fresh excluded-region descriptions keyed by layout key.
to_configuration ¶
Reconstruct an independent mutable configuration owner.
Result
dataclass
¶
Store solution arrays and immutable run provenance.
Instances are returned by the supported solve functions or restored with
load_from_disk. Direct construction is not supported.
Attributes:
| Name | Type | Description |
|---|---|---|
flux |
tuple[ndarray, ...]
|
Bottom-to-top read-only cell-average scalar-flux arrays in
|
balance |
FixedSourceBalance | KeffBalance
|
Immutable mode-specific balance record containing group, layer-group, scalar, and derived-ratio diagnostics. |
configuration_snapshot |
ProblemConfigurationSnapshot
|
Immutable complete, non-aliasing configuration snapshot associated
with the completed solve. Its public configuration values are freshly
reconstructed on access. Call |
solve_settings |
FixedSourceSettings | KeffSettings
|
Immutable numerical settings captured for the completed solve. |
normalization |
FissionSourceNormalization | PowerNormalization | None
|
Immutable fission-source-rate or recoverable-power normalization for a
criticality result, otherwise |
execution_report |
LinearSolveReport | KeffSolveReport
|
Immutable typed solver diagnostics and convergence information. |
keff |
float | None
|
Final multiplication-factor estimate for a criticality report,
otherwise |
groups |
int
|
Shared number of energy groups, ordered fast to thermal. |
n_axial_layers |
int
|
Number of bottom-to-top stored flux layers. |
Notes
Result is immutable. Flux arrays and balance diagnostics are owned
immutable values, preserving a complete internally consistent record for
plotting, export, and provenance.
The active-cell axis is compact and layer-local. Use flux_layer() to
select one layer, and use the configuration snapshot or inspection methods
to map values back to full planar positions; excluded positions have no
stored flux value.
Reject direct construction; use a solve function or archive loader.
keff
property
¶
Return the final multiplication-factor estimate, when applicable.
solve_mode
property
¶
Return the solve-mode identifier derived from typed provenance.
cell_at ¶
Return the material data and all-group flux at one active cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axial_index
|
int
|
Nonnegative bottom-to-top axial-layer index. |
required |
openmc_index
|
OpenMCIndex
|
Planar OpenMC-style position in the complete material mesh. |
required |
Returns:
| Type | Description |
|---|---|
CellInspection
|
The selected material key, its macroscopic cross sections, and a read-only one-dimensional flux array in fast-to-thermal order. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
IndexError
|
If |
KeyError
|
If |
ValueError
|
If the selected position is excluded, or its material has no cross sections. |
export_vtm ¶
Export reconstructed material layout and flux data as VTM blocks.
The VTM references active and excluded VTU leaves. It includes one
full-lattice flux_gN cell array per group in fast-to-thermal order;
excluded-cell flux entries are NaN. Parent directories are created
when needed.
The VTM leaf directory contains material_keys.json, which maps each
exported material_key_id to its material key.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
IsADirectoryError
|
If |
OSError
|
If an output directory cannot be created or an output file cannot be written. |
flux_layer ¶
Return the owned read-only group-major flux for one axial layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axial_index
|
int
|
Nonnegative bottom-to-top axial-layer index. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array shaped |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
load_from_disk
classmethod
¶
Load a checked result from a versioned non-pickle archive.
The loader accepts only supported archive schema versions, validates
the ZIP member inventory and payload SHA-256 hashes, loads all NumPy
payloads with allow_pickle=False, and reconstructs a checked
completed result from its internal archive representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Source |
required |
Returns:
| Type | Description |
|---|---|
Result
|
New immutable result with independently owned arrays and provenance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the archive is malformed, unsupported, inconsistent, or fails checked completed-result reconstruction. |
OSError
|
If the archive cannot be read. |
plot_matplotlib ¶
Plot one energy group on one axial slice using Matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
int
|
Zero-based fast-to-thermal group index. |
required |
axial_index
|
int
|
Nonnegative bottom-to-top layer index. |
required |
ax
|
Axes | None
|
Optional axes to populate. A new figure and axes are created when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
Populated axes with a scalar-flux colorbar. Excluded positions are rendered in the fixed excluded-flux color. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the selected group or layer is invalid or the layer has no active flux values. |
plot_plotly ¶
Return a Plotly plot of one energy group on one axial slice.
Polygon hover text includes full-lattice material-position details
and the selected scalar flux. Excluded positions use the fixed
excluded-flux color and report nan flux.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the selected group or layer is invalid or the layer has no active flux values. |
save_to_disk ¶
Save this result as a versioned non-pickle .morana-result archive.
The archive is a standard DEFLATE-compressed ZIP file containing an
explicit JSON manifest and named .npy payloads. It records the
result, detailed balances, solve settings, normalization, and complete
configuration provenance. Array payloads are written without pickle and
are checksummed. Parent directories are created and the completed
archive replaces path atomically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination archive path. The suffix is conventionally
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the result cannot be represented by the archive schema. |
OSError
|
If the destination cannot be created or replaced. |
SeparableFission
dataclass
¶
SeparableFission(
nu_sigma_f: ndarray | list[float],
chi: ndarray | list[float],
*,
chi_normalization_tolerance: float = 1e-08
)
Store compact separable fission-neutron production data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nu_sigma_f
|
ndarray | list[float]
|
One-dimensional incident-group fission-neutron production cross
section in |
required |
chi
|
ndarray | list[float]
|
One-dimensional outgoing-group fission spectrum. It must have the
same group count as |
required |
chi_normalization_tolerance
|
float
|
Finite positive accepted deviation of the input fission-spectrum sum
from one. Defaults to |
1e-08
|
Attributes:
| Name | Type | Description |
|---|---|---|
groups |
int
|
Number of energy groups. |
fission_transfer |
ndarray
|
Read-only derived fission-neutron transfer array with event-oriented
indexing |
fission_production |
ndarray
|
Read-only derived total neutron production by incident group. |
Notes
SeparableFission owns immutable numerical inputs. Its derived transfer
is nu_sigma_f[g_from] * chi[g_to].
UniformSource
dataclass
¶
Apply one volumetric source vector to every active cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strength
|
ndarray | list[float]
|
Nonempty one-dimensional group-major source vector in
|
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Notes
The vector is broadcast to every active cell in the selected layer,
including a valid zero-column result for an empty layer. Finiteness,
nonnegativity, and compatibility with the problem group count are checked
during source assembly rather than construction. UniformSource is
immutable; construct a replacement source to change its strength.
values ¶
Broadcast source strength over the selected layer’s active cells.
The returned read-only array has shape
(len(strength), len(material_by_active_id)). axial_index is
checked only as a nonnegative explicit index because this source does
not own an axial stack.
WielandtShiftSettings
dataclass
¶
Select fixed Wielandt-shifted fission-source power iteration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shift_inverse_keff
|
float
|
Finite nonnegative real fixed shift applied to the inverse
multiplication factor in the shifted operator |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |