pyopensn.solver.CMFDAcceleration

class pyopensn.solver.CMFDAcceleration

Construct a CMFD accelerator for the power iteration k-eigenvalue solver.

Wrapper of opensn::CMFDAcceleration.

GetHomogenizedDiffusionCoefficient(self: pyopensn.solver.CMFDAcceleration, coarse_cell_global_id: int) → list[float]

Return the diffusion coefficients of the last assembled CMFD operator for one coarse cell.

The operator lifecycle, exceptions, and collectivity are as for GetHomogenizedRemovalXS().

Parameters:

coarse_cell_global_id (int) – Global id of a coarse cell owned by the calling rank.

Returns:

One diffusion coefficient per CMFD energy group.

Return type:

List[float]

GetHomogenizedProductionXS(self: pyopensn.solver.CMFDAcceleration, coarse_cell_global_id: int) → list[float]

Return the production matrix of the last assembled CMFD operator for one coarse cell.

Delayed production is included when precursors are enabled. In adjoint mode the matrix is the transpose used by the adjoint operator. The operator lifecycle, exceptions, and collectivity are as for GetHomogenizedRemovalXS().

Parameters:

coarse_cell_global_id (int) – Global id of a coarse cell owned by the calling rank.

Returns:

Row-major matrix with num_coarse_groups**2 entries; entry [g, gp] is the production in coarse group g per unit flux in coarse group gp.

Return type:

List[float]

GetHomogenizedRemovalXS(self: pyopensn.solver.CMFDAcceleration, coarse_cell_global_id: int) → list[float]

Return the removal coefficients of the last assembled CMFD operator for one coarse cell.

Each Execute() of the owning solver first assembles a volume-weighted operator. Each power iteration then reassembles it from the transport iterate produced by that iteration’s sweeps, before the CMFD correction is applied. After Execute() returns, the values are those of its last assembly.

Parameters:

coarse_cell_global_id (int) – Global id of a coarse cell owned by the calling rank. Ids run from zero to GetNumCoarseCells() - 1; with "local_aggregation" and "global_aggregation" each coarse cell is owned by one rank.

Returns:

One removal coefficient per CMFD energy group.

Return type:

List[float]

Raises:
  • ValueError – If the coarse cell is not owned by the calling rank.

  • RuntimeError – If called before the first Execute() of the owning solver.

Notes

Not collective.

GetHomogenizedScatteringXS(self: pyopensn.solver.CMFDAcceleration, coarse_cell_global_id: int) → list[float]

Return the P0 transfer matrix of the last assembled CMFD operator for one coarse cell.

The diagonal is the within-group transfer, which the operator already accounts for in the removal coefficient. In adjoint mode the matrix is the transpose used by the adjoint operator. The operator lifecycle, exceptions, and collectivity are as for GetHomogenizedRemovalXS().

Parameters:

coarse_cell_global_id (int) – Global id of a coarse cell owned by the calling rank.

Returns:

Row-major matrix with num_coarse_groups**2 entries; entry [g, gp] is the transfer from coarse group gp to g.

Return type:

List[float]

GetNumAppliedCorrections(self: pyopensn.solver.CMFDAcceleration) → int

Return the number of CMFD corrections applied during the last power-iteration solve.

The count is reset at the start of each solve.

GetNumCoarseCells(self: pyopensn.solver.CMFDAcceleration) → int

Return the global number of CMFD coarse cells.

The owning solver builds the coarse mesh at the start of each Execute(); before the first Execute() the count is zero.

GetNumSkippedCorrections(self: pyopensn.solver.CMFDAcceleration) → int

Return the number of CMFD corrections skipped during the last power-iteration solve.

A correction is skipped when a coarse linear solve does not converge, when the coarse power iteration breaks down with a coarse fission production or k that is not positive and finite, when it does not meet its tolerances within 1000 iterations, or when the correction would give a non-finite flux or an invalid k. The power iteration then uses the unaccelerated transport update. The count is reset at the start of each solve.

__init__(self: pyopensn.solver.CMFDAcceleration, **kwargs) → None

CMFD acceleration for the power iteration k-eigenvalue solver.

Each power iteration runs the transport update, with at most sweeps_per_update within-group iterations of each groupset in each across-groupset pass (one iteration and one pass by default), restricts the transport flux and currents to a coarse mesh, solves the coarse partial-current CMFD (pCMFD) eigenproblem, and scales the transport scalar flux of each coarse cell and coarse group by the ratio of the coarse solution to the restricted flux. The method is fixed: the partial-current closure, unrelaxed corrections, a Wielandt-shifted coarse power iteration converged to a fraction of the transport change, and an automatic coarse linear solver. A coarse value whose restricted transport flux is negative, or whose correction ratio is negative or not finite, keeps the shape of the transport flux: its fine flux is scaled by the overall amplitude of the coarse solution instead of its own ratio. The rest of the correction is applied. A correction whose coarse linear solve fails, whose coarse eigensolve does not converge within 1000 iterations to a positive, finite production and k, or that gives an invalid k or a non-finite flux, is skipped and the unaccelerated transport update is used for that power iteration.

The owning solver’s k_tol and fission_source_tol decide convergence. An update whose correction was skipped never ends the iteration.

Parameters:
  • problem (pyopensn.solver.DiscreteOrdinatesProblem) – Existing DiscreteOrdinatesProblem instance.

  • coarse_mesh (str or dict, default="local_aggregation") –

    The coarse mesh. A string selects a type with its defaults, and a dict selects a type and its parameters with a "type" key:

    • "local_aggregation" or {"type": "local_aggregation", "size": 32}: connected aggregates of about size fine cells within each MPI rank. The general default for unstructured meshes. It does not follow axial layers on extruded meshes.

    • {"type": "global_aggregation", "size": 32}: aggregates that may span MPI ranks. It does not repartition the transport mesh.

    • {"type": "reactor_lattice", "origin": [x0, y0], "pitch": [px, py], "shape": [nx, ny], "axial_edges": [z0, z1, ...]}: one coarse cell per face-connected part of the transport cells in each lattice cell and axial layer, covering [x0, x0 + nx px] by [y0, y0 + ny py]. Without axial_edges, the lattice cells are whole columns. The recommended coarse mesh for lattice problems.

    • {"type": "cartesian", "x_edges": [...], "y_edges": [...], "z_edges": [...]}: one coarse cell per face-connected part of the transport cells in each Cartesian box. Each edge list is strictly increasing and optional, and an omitted list leaves that axis undivided. At least one is required.

    • {"type": "logical_volumes", "volumes": [lv, ...]}: one coarse cell per connected part of each logical volume. Each cell centroid must lie in exactly one volume.

    • "identity": one coarse cell per transport cell, for testing.

    The overlays (reactor_lattice, cartesian and logical_volumes) assign each transport cell by its centroid. Every centroid must lie in exactly one region, and a centroid outside the lattice, outside the given edges of an axis, or in no logical volume is an error. A region becomes one coarse cell per face-connected part of the transport cells in it, so a region in two disconnected parts gives two coarse cells and an empty region gives none.

    Coarse cells may contain several materials. Their coefficients are homogenized from the transport flux before every correction, which preserves the reaction rates of the transport iterate. Where the fluxes of a coarse group cancel within roundoff, the coefficients of that group use volume weights instead and do not preserve the rates. The lattice and Cartesian types log the number of fine faces between coarse cells that do not lie on a coarse-mesh plane, and warn about intervals narrower than a tenth of the median width along their axis.

  • coarse_groups (int or str, default="auto") – Number of CMFD energy groups. The G transport groups are split into consecutive coarse groups of ceil(G / coarse_groups) groups each, which may give fewer coarse groups than requested. The value is a target count, not a width, so not every split of the deprecated group_aggregation_size can be reproduced. For example, G = 10 with group_aggregation_size=6 gives groups of 6 and 4, and coarse_groups=2 gives 5 and 5. "auto" keeps every group when G <= 16 and targets 16 coarse groups otherwise.

  • verbose (bool, default=False) – If true, prints the coarse-cell optical thickness, operator sign counts, balance residuals, correction metrics and timings.

  • petsc_options (str, default="") – PETSc options for the coarse linear solver. They reach only the coarse solver of this accelerator. Their prefix is the accelerator name with nothing in between, so with name="cmfd_" the KSP type is "-cmfd_ksp_type fgmres". They are applied after the automatic choice and replace it where they overlap.

  • name (str, default="CMFDAcceleration") – Name of the accelerator, and the PETSc options prefix of its coarse linear solver.

Notes

Coarse linear solver. CMFD factorizes the coarse operator with SuperLU_DIST or MUMPS, or with PETSc’s own LU on one rank, when the estimated memory of the factorization is at most 1 GiB per MPI rank, and otherwise uses FGMRES with an additive Schwarz preconditioner and ILU(0) subdomain solves. A coarse solve is accepted only if its true residual is small, so a failed iterative solve skips the correction instead of applying it.

Optically thick coarse cells. With one sweep per update, CMFD converges at a rate that approaches the scattering ratio as the coarse cells become optically thick: about 0.67 per update at 1.35 transport mean free paths, 0.89 at 5.4 and 0.99 at 22, in a medium with scattering ratio 0.99. CMFD warns once when coarse cells are thicker than 3 mean free paths. Thinner transport cells in that direction restore fast convergence. The coarse mesh cannot be finer than the transport mesh.

Deprecated parameters. These names are accepted with a warning for one release: aggregation_size (use coarse_mesh={"type": t, "size": n} with t the aggregation type in use), group_aggregation_size (use coarse_groups, which gives the same number of coarse groups but can move their boundaries), update_wgs_max_its (use sweeps_per_update of the solver; the deprecated value is used while that is automatic), allow_mixed_material_aggregation=True (aggregates may always contain several materials, where earlier releases kept them within one mesh block by default), and current_closure="partial", relaxation=1, inactive_iterations=0, update_wgs_abs_tol, balance_residual_tolerance, correction_max_attempts, correction_min_damping, coarse_solver_policy, coarse_direct_solve_threshold, l_abs_tol, l_rel_tol, max_iters, pi_max_its, pi_k_tol and pi_phi_tol, which are ignored. current_closure="net", relaxation other than 1, inactive_iterations other than 0, and allow_mixed_material_aggregation=False are errors.