openmc.cmfd.CMFDRun¶
- class openmc.cmfd.CMFDRun[source]¶
Class for running CMFD acceleration through the C API.
- Variables
tally_begin (int) – Batch number at which CMFD tallies should begin accumulating
solver_begin (int) – Batch number at which CMFD solver should start executing
ref_d (list of floats) – List of reference diffusion coefficients to fix CMFD parameters to
display (dict) –
Dictionary indicating which CMFD results to output. Note that CMFD k-effective will always be outputted. Acceptable keys are:
”balance” - Whether to output RMS [%] of the residual from the neutron balance equation on CMFD tallies (bool)
”dominance” - Whether to output the estimated dominance ratio from the CMFD iterations (bool)
”entropy” - Whether to output the entropy of the CMFD predicted fission source (bool)
”source” - Whether to output the RMS [%] between the OpenMC fission source and CMFD fission source (bool)
downscatter (bool) – Indicate whether an effective downscatter cross section should be used when using 2-group CMFD.
feedback (bool) – Indicate whether or not the CMFD diffusion result is used to adjust the weight of fission source neutrons on the next OpenMC batch. Defaults to False.
cmfd_ktol (float) – Tolerance on the eigenvalue when performing CMFD power iteration
mesh (openmc.cmfd.CMFDMesh) – Structured mesh to be used for acceleration
norm (float) – Normalization factor applied to the CMFD fission source distribution
power_monitor (bool) – View convergence of power iteration during CMFD acceleration
run_adjoint (bool) – Perform adjoint calculation on the last batch
w_shift (float) – Optional Wielandt shift parameter for accelerating power iterations. By default, it is very large so there is effectively no impact.
stol (float) – Tolerance on the fission source when performing CMFD power iteration
reset (list of int) – List of batch numbers at which CMFD tallies should be reset
write_matrices (bool) – Write sparse matrices that are used during CMFD acceleration (loss, production) and resultant normalized flux vector phi to file
spectral (float) – Optional spectral radius that can be used to accelerate the convergence of Gauss-Seidel iterations during CMFD power iteration.
gauss_seidel_tolerance (Iterable of float) – Two parameters specifying the absolute inner tolerance and the relative inner tolerance for Gauss-Seidel iterations when performing CMFD.
adjoint_type ({'physical', 'math'}) –
Stores type of adjoint calculation that should be performed.
run_adjoint
must be true for an adjoint calculation to be performed. Options are:”physical” - Create adjoint matrices from physical parameters of CMFD problem
”math” - Create adjoint matrices mathematically as the transpose of loss and production CMFD matrices
window_type ({'expanding', 'rolling', 'none'}) –
Specifies type of tally window scheme to use to accumulate CMFD tallies. Options are:
”expanding” - Have an expanding window that doubles in size to give more weight to more recent tallies as more generations are simulated
”rolling” - Have a fixed window size that aggregates tallies from the same number of previous generations tallied
”none” - Don’t use a windowing scheme so that all tallies from last time they were reset are used for the CMFD algorithm.
window_size (int) – Size of window to use for tally window scheme. Only relevant when window_type is set to “rolling”
indices (numpy.ndarray) – Stores spatial and group dimensions as [nx, ny, nz, ng]
cmfd_src (numpy.ndarray) – CMFD source distribution calculated from solving CMFD equations
entropy (list of floats) – “Shannon entropy” from CMFD fission source, stored for each generation that CMFD is invoked
balance (list of floats) – RMS of neutron balance equations, stored for each generation that CMFD is invoked
src_cmp (list of floats) – RMS deviation of OpenMC and CMFD normalized source, stored for each generation that CMFD is invoked
dom (list of floats) – Dominance ratio from solving CMFD matrix equations, stored for each generation that CMFD is invoked
k_cmfd (list of floats) – List of CMFD k-effectives, stored for each generation that CMFD is invoked
time_cmfd (float) – Time for entire CMFD calculation, in seconds
time_cmfdbuild (float) – Time for building CMFD matrices, in seconds
time_cmfdsolve (float) – Time for solving CMFD matrix equations, in seconds
use_all_threads (bool) – Whether to use all threads allocated to OpenMC for CMFD solver
intracomm (mpi4py.MPI.Intracomm or None) – MPI intercommunicator for running MPI commands
- finalize()[source]¶
Finalize simulation by calling
openmc.lib.simulation_finalize()
and print out CMFD timing information.
- init()[source]¶
Initialize CMFDRun instance by setting up CMFD parameters and calling
openmc.lib.simulation_init()
- iter_batches()[source]¶
Iterator over batches.
This function returns a generator-iterator that allows Python code to be run between batches when running an OpenMC simulation with CMFD. It should be used in conjunction with :func`openmc.cmfd.CMFDRun.run_in_memory` to ensure proper initialization/finalization of CMFDRun instance.
- next_batch()[source]¶
Run next batch for CMFDRun.
- Returns
Status after running a batch (0=normal, 1=reached maximum number of batches, 2=tally triggers reached)
- Return type
- run(**kwargs)[source]¶
Run OpenMC with coarse mesh finite difference acceleration
This method is called by the user to run CMFD once instance variables of CMFDRun class are set
- Parameters
**kwargs – All keyword arguments are passed to
openmc.lib.run_in_memory()
.
- run_in_memory(**kwargs)[source]¶
Context manager for running CMFD functions with OpenMC shared library functions.
This function can be used with a ‘with’ statement to ensure the CMFDRun class is properly initialized/finalized. For example:
from openmc import cmfd cmfd_run = cmfd.CMFDRun() with cmfd_run.run_in_memory(): do_stuff_before_simulation_start() for _ in cmfd_run.iter_batches(): do_stuff_between_batches()
- Parameters
**kwargs – All keyword arguments passed to
openmc.lib.run_in_memory()
.