pyopensn.solver.DiscreteOrdinatesProblem
- class pyopensn.solver.DiscreteOrdinatesProblem
Base class for discrete ordinates problems in Cartesian geometry.
This class implements the algorithms necessary to solve a problem using the discrete ordinates method. When paired with a solver base, the result is a solver instance configured for a specific problem type (steady-state, transient, adjoint, k-eigenvalue, etc.).
Wrapper of
opensn::DiscreteOrdinatesProblem.- ComputeBalance(self: pyopensn.solver.DiscreteOrdinatesProblem) None
Compute and print particle balance for the problem.
- ComputeFissionRate(self: pyopensn.solver.LBSProblem, scalar_flux_iterate: str) float
Computes the total fission rate.
- Parameters:
scalar_flux_iterate ({'old', 'new'}) –
- Specifies which scalar flux vector to use in the calculation.
’old’: Use the previous scalar flux iterate.
’new’: Use the current scalar flux iterate.
- Returns:
The total fission rate.
- Return type:
float
- Raises:
ValueError – If scalar_flux_iterate is not ‘old’ or ‘new’.
- ComputeLeakage(self: pyopensn.solver.DiscreteOrdinatesProblem, bnd_names: list) dict
Compute leakage for the problem.
- Parameters:
bnd_names (List[str]) – A list of boundary names for which leakage should be computed.
- Returns:
A dictionary mapping boundary names to group-wise leakage vectors. Each array contains the outgoing angular flux (per group) integrated over the corresponding boundary surface.
- Return type:
Dict[str, numpy.ndarray]
- Raises:
RuntimeError – If save_angular_flux option was not enabled during problem setup.
ValueError – If one or more boundary ids are not present on the current mesh.
- CreateAndWriteSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str) None
Write source moments from latest flux iterate to file.
- Parameters:
file_base (str) – File basename.
- GetFieldFunctions(self: pyopensn.solver.Problem) list
Get the list of field functions.
- Returns:
List of grid-based field functions representing solution data such as scalar fluxes.
- Return type:
- GetPowerFieldFunction(self: pyopensn.solver.LBSProblem) pyopensn.fieldfunc.FieldFunctionGridBased
Returns the power generation field function, if enabled.
- GetPsi(self: pyopensn.solver.DiscreteOrdinatesProblem) list
Return psi as a list of NumPy arrays (float64), using zero-copy views into the underlying data.
- GetScalarFieldFunctionList(self: pyopensn.solver.LBSProblem, only_scalar_flux: bool = True) list
Return field functions grouped by energy group and, optionally, by moment.
- Parameters:
only_scalar_flux (bool, default=True) –
If True, returns only the zeroth moment (scalar flux) field function for each group. The result is a flat list of field functions, one per group.
If False, returns all moment field functions for each group. The result is a nested list where each entry corresponds to a group and contains a list of field functions for all moments (e.g., scalar flux, higher-order moments).
- Returns:
The structure of the returned list depends on the only_scalar_flux flag.
- Return type:
Union[List[pyopensn.fieldfunc.FieldFunctionGridBased], List[List[pyopensn.fieldfunc.FieldFunctionGridBased]]]
Notes
The moment index varies more rapidly than the group index when only_scalar_flux is False.
- ReadAngularFluxes(self: opensn::DiscreteOrdinatesProblem, file_base: str) None
Read angular fluxes from file.
- Parameters:
file_base (str) – File basename.
- ReadFluxMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read flux moment data.
- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True if all flux moments are in a single file.
- ReadFluxMomentsAndMakeSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read flux moments and compute corresponding source moments.
- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True if all flux moments are in a single file.
- ReadSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read source moments from file.
- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True if all source moments are in a single file.
- SetAdjoint(self: pyopensn.solver.LBSProblem, arg0: bool) None
- SetBoundaryOptions(self: pyopensn.solver.LBSProblem, **kwargs) None
Set or clear boundary conditions.
- Parameters:
clear_boundary_conditions (bool, default=False) – If true, all current boundary conditions are deleted.
boundary_conditions (List[Dict]) –
- A list of boundary condition dictionaries. Each dictionary supports:
- name: str (required)
Boundary name that identifies the specific boundary.
- type: {‘vacuum’, ‘isotropic’, ‘reflecting’} (required)
Boundary type specification.
- group_strength: List[float], optional
Required when
type='isotropic'. Isotropic strength per group.
- function_name: str, optional, default=’’
Name of a registered function to evaluate on the boundary.
- SetOptions(self: pyopensn.solver.DiscreteOrdinatesProblem, **kwargs) None
Set problem options from a large list of parameters.
- Parameters:
adjoint (bool, default=False) – Flag for toggling whether the solver is in adjoint mode.
- SetPointSources(self: pyopensn.solver.LBSProblem, **kwargs) None
Set or clear point sources.
- Parameters:
clear_point_sources (bool, default=False) – If true, all current the point sources of the problem are deleted.
point_sources (List[pyopensn.source.PointSource]) – List of new point sources to be added to the problem.
- SetVolumetricSources(self: pyopensn.solver.LBSProblem, **kwargs) None
Set or clear volumetric sources.
- Parameters:
clear_volumetric_sources (bool, default=False) – If true, all current the volumetric sources of the problem are deleted.
volumetric_sources (List[pyopensn.source.VolumetricSource]) – List of new volumetric sources to be added to the problem.
- WriteAngularFluxes(self: opensn::DiscreteOrdinatesProblem, file_base: str) None
Write angular flux data to file.
- Parameters:
file_base (str) – File basename.
- WriteFluxMoments(self: pyopensn.solver.LBSProblem, file_base: str) None
Write flux moments to file.
- Parameters:
file_base (str) – File basename.
- __init__(self: pyopensn.solver.DiscreteOrdinatesProblem, **kwargs) None
Construct a discrete ordinates problem with Cartesian geometry.
- Parameters:
mesh (MeshContinuum) – The spatial mesh.
num_groups (int) – The total number of energy groups.
groupsets (List[Dict], default=[]) –
A list of input parameter blocks, each block provides the iterative properties for a groupset. Each dictionary supports:
- groups_from_to: List[int] (required)
Two-entry list with the first and last group id for the groupset, e.g.
[0, 3].
- angular_quadrature: pyopensn.aquad.AngularQuadrature, optional
Handle to an angular quadrature.
- angle_aggregation_type: {‘polar’, ‘single’, ‘azimuthal’}, default=’polar’
Angle aggregation method to use during sweeping.
- angle_aggregation_num_subsets: int, default=1
Number of angle subsets used for aggregation.
inner_linear_method: {‘classic_richardson’, ‘petsc_richardson’, ‘petsc_gmres’, ‘petsc_bicgstab’}, default=’petsc_richardson’
Iterative method used for inner linear solves.
- l_abs_tol: float, default=1.0e-6
Inner linear solver absolute residual tolerance.
- l_max_its: int, default=200
Inner linear solver maximum iterations.
- gmres_restart_interval: int, default=30
GMRES restart interval, if GMRES is used.
- allow_cycles: bool, default=True
Whether cyclic dependencies are allowed in sweeps.
- apply_wgdsa: bool, default=False
Enable within-group DSA for this groupset.
- wgdsa_l_abs_tol: float, default=1.0e-4
WGDSA linear absolute tolerance.
- wgdsa_l_max_its: int, default=30
WGDSA maximum iterations.
- wgdsa_verbose: bool, default=False
Verbose WGDSA output.
- wgdsa_petsc_options: str, default=’’
PETSc options string for the WGDSA solver.
- apply_tgdsa: bool, default=False
Enable two-grid DSA for this groupset.
- tgdsa_l_abs_tol: float, default=1.0e-4
TGDSA linear absolute tolerance.
- tgdsa_l_max_its: int, default=30
TGDSA maximum iterations.
- tgdsa_verbose: bool, default=False
Verbose TGDSA output.
- tgdsa_petsc_options: str, default=’’
PETSc options string for the TGDSA solver.
xs_map (List[Dict], default=[]) –
- A list of mappings from block ids to cross-section definitions. Each dictionary supports:
- block_ids: List[int] (required)
Mesh block IDs to associate with the cross section.
- xs: pyopensn.xs.MultiGroupXS (required)
Cross-section object to assign to the specified blocks.
boundary_conditions (List[Dict], default=[]) –
- A list containing tables for each boundary specification. Each dictionary supports:
- name: str (required)
Boundary name that identifies the specific boundary.
- type: {‘vacuum’, ‘isotropic’, ‘reflecting’} (required)
Boundary type specification.
- group_strength: List[float], optional
Required when
type='isotropic'. Isotropic strength per group.
- function_name: str, optional, default=’’
Name of a registered function to evaluate on the boundary.
point_sources (List[pyopensn.source.PointSource], default=[]) – A list of point sources.
volumetric_sources (List[pyopensn.source.VolumetricSource], default=[]) – A list of volumetric sources.
options (Dict, default={}) –
A block of optional configuration parameters. Each dictionary supports the same keys as
LBSProblem.SetOptions(), including:max_mpi_message_size: int, default=32768
restart_writes_enabled: bool, default=False
write_delayed_psi_to_restart: bool, default=True
read_restart_path: str, default=’’
write_restart_path: str, default=’’
write_restart_time_interval: int, default=0
use_precursors: bool, default=False
use_source_moments: bool, default=False
save_angular_flux: bool, default=False
verbose_inner_iterations: bool, default=True
verbose_outer_iterations: bool, default=True
max_ags_iterations: int, default=100
ags_tolerance: float, default=1.0e-6
ags_convergence_check: {‘l2’, ‘pointwise’}, default=’l2’
verbose_ags_iterations: bool, default=True
power_field_function_on: bool, default=False
power_default_kappa: float, default=3.20435e-11
power_normalization: float, default=-1.0
field_function_prefix_option: {‘prefix’, ‘solver_name’}, default=’prefix’
field_function_prefix: str, default=’’
sweep_type (str, default="AAH") – The sweep type to use. Must be one of AAH or CBC. Defaults to AAH.
use_gpus (bool, default=False) – A flag specifying whether GPU acceleration is used for the sweep. Currently, only
AAHis supported.time_dependent (bool, default=False) – Enable time-dependent sweeps. Currently only supported with
sweep_type="AAH".