Python API

Everything listed here is importable from the top-level ndiffusion package. The solver classes, Materials, the mesh and the result types are compiled from C++; the rest is pure Python.

Solvers

KEigenSolver

Matrix-free 1-D multigroup neutron diffusion k-eigenvalue solver.

FixedSourceSolver

Matrix-free 1-D multigroup neutron diffusion fixed-source solver.

TimeDependentSolver

1-D multigroup time-dependent neutron diffusion solver.

KEigenSolver2D

Matrix-free 2-D multigroup neutron diffusion k-eigenvalue solver on a structured Cartesian or RZ mesh.

FixedSourceSolver2D

Matrix-free 2-D multigroup neutron diffusion fixed-source solver on a structured Cartesian or RZ mesh.

TimeDependentSolver2D

2-D multigroup time-dependent neutron diffusion solver on a structured Cartesian or RZ mesh.

KEigenSolverUnstructured2D

Matrix-free 2-D multigroup neutron diffusion k-eigenvalue solver on an unstructured polygonal mesh.

FixedSourceSolverUnstructured2D

Matrix-free 2-D multigroup neutron diffusion fixed-source solver on an unstructured polygonal mesh.

TimeDependentSolverUnstructured2D

2-D multigroup time-dependent neutron diffusion solver on an unstructured polygonal mesh.

Inputs and results

Materials

Cross-section data for all materials and energy groups.

BoundaryCondition

Robin BC on one edge of the domain: A*phi + B*(dphi/dn) = 0, with n the outward normal, so the coefficients mean the same thing on every edge.

DelayedNeutronData

Delayed neutron precursor data for the time-dependent solvers.

Geometry

Coordinate system for 1-D problems.

Geometry2D

Coordinate system for 2-D structured mesh problems.

UnstructuredMesh2D

2-D unstructured mesh of polygonal cells.

DiffusionResult

FixedSourceResult

TimeDependentResult

ConvergenceWarning

Issued when a solver stops at its iteration cap before meeting its tolerance.

Building inputs

make_materials

Build a configured Materials object from a list of cross-section dicts.

make_materials_from_transport

Build a Materials from a list of transport cross-section dicts.

transport_to_diffusion

Convert one material's transport cross sections to diffusion ones.

make_medium_map

Build a flat medium_map list from a compact region specification.

boundary_conditions

Compute Robin boundary condition coefficients.

make_adjoint_materials

Return a new Materials for the adjoint diffusion problem.

make_delayed_data

Build a DelayedNeutronData from per-material precursor specs.

scale_to_critical

Return a copy of mats with nusigf divided by keff.

kinetics.DELAYED_U235_6GROUP

Standard 6-group delayed neutron parameters for thermal fission in U-235 (Keepin, Physics of Nuclear Kinetics, 1965).

Meshes

load_gmsh

Load a Gmsh .msh file into an UnstructuredMesh2D.

assign_materials

Paint material indices onto an existing mesh.

copy_mesh

Return an independent copy of mesh, including any attached names.

validate_mesh

Raise ValueError unless the mesh connectivity is structurally sound: matching vx/vy lengths, cell_offsets starting at 0 and stepping by at least 3 per cell up to len(cell_vertices), vertex indices in range, paired bface_v0/bface_v1, and no zero-area cells.

cell_centroids

Return (cx, cy) cell centroids, each of length n_cells.

cell_areas

Return the area of each cell, length n_cells.

Post-processing

cell_volumes

Cell volumes, in the same order as the solver's cells.

reaction_rate

Reaction rate density Sigma phi per cell.

power_density

Fission power density kappa * Sigma_f * phi per cell.

normalize_to_power

Scale flux so the fission power integrates to total_power.

region_powers

Integrate a per-cell density over regions.

peaking_factors

Peak-to-average ratio of a power density.

save_result

Write a solver result to an .npz file.

load_result

Read a result written by save_result().

postprocess.KAPPA_U235

Recoverable energy per fission (J), the usual 200 MeV for U-235.

postprocess.NU_U235

Neutrons per thermal fission of U-235.

Solution verification

nearby_fixed_source

Run the method of nearby problems for a fixed-source diffusion solve.

nearby_k_eigenvalue

Run the method of nearby problems for a k-eigenvalue diffusion solve.

nearby_qoi

Discretization error of normalized quantities of interest.

unstructured_operator

Assemble the sparse operator of the unstructured FVM solvers.

fission_source

Public helper: fission production F phi for a solver flux.

NearbyFixedResult

NearbyKResult

NearbyQoIResult

UnstructuredOperator

Sparse unstructured FVM operator.

Modules

layouts

Preset core layouts, symmetry orientations, and matching boundary conditions.

materials

Named cross-section sets and the published benchmarks that use them.