diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 27b7e17a9..9f05a56dc 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -43,6 +43,7 @@ extern "C" { int openmc_global_tallies(double** ptr); int openmc_hard_reset(); int openmc_init(int argc, char* argv[], const void* intracomm); + bool openmc_is_statepoint_batch(); int openmc_legendre_filter_get_order(int32_t index, int* order); int openmc_legendre_filter_set_order(int32_t index, int order); int openmc_load_nuclide(const char* name); diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 77127db0a..8f4376717 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -27,6 +27,7 @@ extern bool assume_separate; //!< assume tallies are spatially separate extern bool check_overlaps; //!< check overlaps in geometry? extern bool confidence_intervals; //!< use confidence intervals for results? extern bool create_fission_neutrons; //!< create fission neutrons (fixed source)? +extern "C" bool cmfd_run; //!< is a CMFD run? extern "C" bool dagmc; //!< indicator of DAGMC geometry extern "C" bool entropy_on; //!< calculate Shannon entropy? extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular? @@ -36,7 +37,7 @@ extern bool particle_restart_run; //!< particle restart run? extern "C" bool photon_transport; //!< photon transport turned on? extern "C" bool reduce_tallies; //!< reduce tallies at end of batch? extern bool res_scat_on; //!< use resonance upscattering method? -extern bool restart_run; //!< restart run? +extern "C" bool restart_run; //!< restart run? extern "C" bool run_CE; //!< run with continuous-energy data? extern bool source_latest; //!< write latest source at each batch? extern bool source_separate; //!< write source to separate file? @@ -57,7 +58,7 @@ extern std::string path_output; //!< directory where output files are extern std::string path_particle_restart; //!< path to a particle restart file extern std::string path_source; extern std::string path_sourcepoint; //!< path to a source file -extern std::string path_statepoint; //!< path to a statepoint file +extern "C" std::string path_statepoint; //!< path to a statepoint file extern "C" int32_t n_batches; //!< number of (inactive+active) batches extern "C" int32_t n_inactive; //!< number of inactive batches diff --git a/openmc/capi/core.py b/openmc/capi/core.py index baba0b833..aae17e06a 100644 --- a/openmc/capi/core.py +++ b/openmc/capi/core.py @@ -48,6 +48,7 @@ _init_linsolver_argtypes = [_array_1d_int, c_int, _array_1d_int, c_int, c_int, c_double, _array_1d_int, _array_1d_int] _dll.openmc_initialize_linsolver.argtypes = _init_linsolver_argtypes _dll.openmc_initialize_linsolver.restype = None +_dll.openmc_is_statepoint_batch.restype = c_bool _dll.openmc_master.restype = c_bool _dll.openmc_next_batch.argtypes = [POINTER(c_int)] _dll.openmc_next_batch.restype = c_int @@ -187,6 +188,18 @@ def init(args=None, intracomm=None): _dll.openmc_init(argc, argv, intracomm) +def is_statepoint_batch(): + """Return whether statepoint will be written in current batch or not. + + Returns + ------- + bool + Whether is statepoint batch or not + + """ + return _dll.openmc_is_statepoint_batch() + + def iter_batches(): """Iterator over batches. diff --git a/openmc/capi/settings.py b/openmc/capi/settings.py index 115962395..78794d856 100644 --- a/openmc/capi/settings.py +++ b/openmc/capi/settings.py @@ -18,10 +18,12 @@ _dll.openmc_get_seed.restype = c_int64 class _Settings(object): # Attributes that are accessed through a descriptor batches = _DLLGlobal(c_int32, 'n_batches') + cmfd_run = _DLLGlobal(c_bool, 'cmfd_run') entropy_on = _DLLGlobal(c_bool, 'entropy_on') generations_per_batch = _DLLGlobal(c_int32, 'gen_per_batch') inactive = _DLLGlobal(c_int32, 'n_inactive') particles = _DLLGlobal(c_int64, 'n_particles') + restart_run = _DLLGlobal(c_bool, 'restart_run') run_CE = _DLLGlobal(c_bool, 'run_CE') verbosity = _DLLGlobal(c_int, 'verbosity') @@ -43,6 +45,11 @@ class _Settings(object): else: raise ValueError('Invalid run mode: {}'.format(mode)) + @property + def path_statepoint(self): + path = c_char_p.in_dll(_dll, 'path_statepoint').value + return path.decode() + @property def seed(self): return _dll.openmc_get_seed() diff --git a/openmc/cmfd.py b/openmc/cmfd.py index 244ceadcf..742cdeabf 100644 --- a/openmc/cmfd.py +++ b/openmc/cmfd.py @@ -10,14 +10,17 @@ References """ +from contextlib import contextmanager from collections.abc import Iterable, Mapping from numbers import Real, Integral import sys import time -from ctypes import c_int, c_double +from ctypes import c_int +import warnings import numpy as np from scipy import sparse +import h5py import openmc.capi from openmc.checkvalue import (check_type, check_length, check_value, @@ -191,8 +194,12 @@ class CMFDRun(object): Attributes ---------- - begin : int - Batch number at which CMFD calculations should begin + tally_begin : int + Batch number at which CMFD tallies should begin accummulating + feedback_begin: int + Batch number at which CMFD feedback should be turned on + ref_d : list of floats + List of reference diffusion coefficients to fix CMFD parameters to dhat_reset : bool Indicate whether :math:`\widehat{D}` nonlinear CMFD parameters should be reset to zero before solving CMFD eigenproblem. @@ -251,6 +258,21 @@ class CMFDRun(object): * "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 @@ -287,7 +309,9 @@ class CMFDRun(object): """ # Variables that users can modify - self._begin = 1 + self._tally_begin = 1 + self._feedback_begin = 1 + self._ref_d = [] self._dhat_reset = False self._display = {'balance': False, 'dominance': False, 'entropy': False, 'source': False} @@ -305,9 +329,12 @@ class CMFDRun(object): self._spectral = 0.0 self._gauss_seidel_tolerance = [1.e-10, 1.e-5] self._adjoint_type = 'physical' + self._window_type = 'none' + self._window_size = 10 self._intracomm = None # External variables used during runtime but users cannot control + self._set_reference_params = False self._indices = np.zeros(4, dtype=np.int32) self._egrid = None self._albedo = None @@ -323,6 +350,13 @@ class CMFDRun(object): self._adj_keff = None self._phi = None self._adj_phi = None + self._openmc_src_rate = None + self._flux_rate = None + self._total_rate = None + self._p1scatt_rate = None + self._scatt_rate = None + self._nfiss_rate = None + self._current_rate = None self._flux = None self._totalxs = None self._p1scattxs = None @@ -337,12 +371,13 @@ class CMFDRun(object): self._openmc_src = None self._sourcecounts = None self._weightfactors = None - self._entropy = None - self._balance = None - self._src_cmp = None - self._dom = None - self._k_cmfd = None + self._entropy = [] + self._balance = [] + self._src_cmp = [] + self._dom = [] + self._k_cmfd = [] self._resnb = None + self._reset_every = None self._time_cmfd = None self._time_cmfdbuild = None self._time_cmfdsolve = None @@ -379,8 +414,16 @@ class CMFDRun(object): self._prod_col = None @property - def begin(self): - return self._begin + def tally_begin(self): + return self._tally_begin + + @property + def feedback_begin(self): + return self._feedback_begin + + @property + def ref_d(self): + return self._ref_d @property def dhat_reset(self): @@ -414,6 +457,14 @@ class CMFDRun(object): def adjoint_type(self): return self._adjoint_type + @property + def window_type(self): + return self._window_type + + @property + def window_size(self): + return self._window_size + @property def power_monitor(self): return self._power_monitor @@ -474,11 +525,23 @@ class CMFDRun(object): def k_cmfd(self): return self._k_cmfd - @begin.setter - def begin(self, begin): - check_type('CMFD begin batch', begin, Integral) - check_greater_than('CMFD begin batch', begin, 0) - self._begin = begin + @tally_begin.setter + def tally_begin(self, begin): + check_type('CMFD tally begin batch', begin, Integral) + check_greater_than('CMFD tally begin batch', begin, 0) + self._tally_begin = begin + + @feedback_begin.setter + def feedback_begin(self, begin): + check_type('CMFD feedback begin batch', begin, Integral) + check_greater_than('CMFD feedback begin batch', begin, 0) + self._feedback_begin = begin + + @ref_d.setter + def ref_d(self, diff_params): + check_type('Reference diffusion params', diff_params, + Iterable, Real) + self._ref_d = np.array(diff_params) @dhat_reset.setter def dhat_reset(self, dhat_reset): @@ -569,6 +632,23 @@ class CMFDRun(object): ['math', 'physical']) self._adjoint_type = adjoint_type + @window_type.setter + def window_type(self, window_type): + check_type('CMFD window type', window_type, str) + check_value('CMFD window type', window_type, + ['none', 'rolling', 'expanding']) + self._window_type = window_type + + @window_size.setter + def window_size(self, window_size): + check_type('CMFD window size', window_size, Integral) + check_greater_than('CMFD window size', window_size, 0) + if self._window_type != 'rolling': + warn_msg = 'Window size will have no effect on CMFD simulation ' \ + 'unless window type is set to "rolling".' + warnings.warn(warn_msg, RuntimeWarning) + self._window_size = window_size + @power_monitor.setter def power_monitor(self, power_monitor): check_type('CMFD power monitor', power_monitor, bool) @@ -623,6 +703,31 @@ class CMFDRun(object): All keyword arguments are passed to :func:`openmc.capi.run_in_memory`. + """ + with self.run_in_memory(**kwargs): + for _ in self.iter_batches(): + pass + + @contextmanager + def run_in_memory(self, **kwargs): + """ 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 :func:`openmc.capi.run_in_memory`. + """ # Store intracomm for part of CMFD routine where MPI reduce and # broadcast calls are made @@ -633,47 +738,171 @@ class CMFDRun(object): # Run and pass arguments to C API run_in_memory function with openmc.capi.run_in_memory(**kwargs): - # Configure CMFD parameters and tallies - self._configure_cmfd() + self.init() + yield + self.finalize() - # Set up CMFD coremap - self._set_coremap() + def iter_batches(self): + """ Iterator over batches. - # Compute and store array indices used to build cross section - # arrays - self._precompute_array_indices() + 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. - # Compute and store row and column indices used to build CMFD - # matrices - self._precompute_matrix_indices() + """ + status = 0 + while status == 0: + status = self.next_batch() + yield - # Initialize all variables used for linear solver in C++ - self._initialize_linsolver() + def init(self): + """ Initialize CMFDRun instance by setting up CMFD parameters and + calling :func:`openmc.capi.simulation_init` - # Initialize simulation - openmc.capi.simulation_init() + """ + # Configure CMFD parameters and tallies + self._configure_cmfd() - status = 0 - while status == 0: - # Initialize CMFD batch - self._cmfd_init_batch() + # Initialize all arrays used for CMFD solver + self._allocate_cmfd() - # Run next batch - status = openmc.capi.next_batch() + # Compute and store array indices used to build cross section + # arrays + self._precompute_array_indices() - # Perform CMFD calculation if on - if self._cmfd_on: - self._execute_cmfd() + # Compute and store row and column indices used to build CMFD + # matrices + self._precompute_matrix_indices() - # Write CMFD output if CMFD on for current batch - if openmc.capi.master(): - self._write_cmfd_output() + # Initialize all variables used for linear solver in C++ + self._initialize_linsolver() - # Finalize simuation - openmc.capi.simulation_finalize() + # Initialize simulation + openmc.capi.simulation_init() - # Print out CMFD timing statistics - self._write_cmfd_timing_stats() + # Set cmfd_run variable to True through C API + openmc.capi.settings.cmfd_run = True + + def next_batch(self): + """ Run next batch for CMFDRun. + + Returns + ------- + int + Status after running a batch (0=normal, 1=reached maximum number of + batches, 2=tally triggers reached) + + """ + # Initialize CMFD batch + self._cmfd_init_batch() + + # Run next batch + status = openmc.capi.next_batch() + + # Perform CMFD calculation if on + if self._cmfd_on: + self._execute_cmfd() + + # Write CMFD output if CMFD on for current batch + if openmc.capi.master(): + self._write_cmfd_output() + + # Write CMFD data to statepoint + if openmc.capi.is_statepoint_batch(): + self.statepoint_write() + return status + + def finalize(self): + """ Finalize simulation by calling + :func:`openmc.capi.simulation_finalize` and print out CMFD timing + information. + + """ + # Finalize simuation + openmc.capi.simulation_finalize() + + # Print out CMFD timing statistics + self._write_cmfd_timing_stats() + + def statepoint_write(self, filename=None): + """Write all simulation parameters to statepoint + + Parameters + ---------- + filename : str + Filename of statepoint + + """ + if filename is None: + batch_str_len = len(str(openmc.capi.settings.batches)) + batch_str = str(openmc.capi.current_batch()).zfill(batch_str_len) + filename = 'statepoint.{}.h5'.format(batch_str) + + # Call C API statepoint_write to save source distribution with CMFD + # feedback + openmc.capi.statepoint_write(filename=filename) + + # Append CMFD data to statepoint file using h5py + self._write_cmfd_statepoint(filename) + + def _write_cmfd_statepoint(self, filename): + """Append all CNFD simulation parameters to existing statepoint + + Parameters + ---------- + filename : str + Filename of statepoint + + """ + if openmc.capi.master(): + with h5py.File(filename, 'a') as f: + if 'cmfd' not in f: + if openmc.capi.settings.verbosity >= 5: + print(' Writing CMFD data to {}...'.format(filename)) + sys.stdout.flush() + cmfd_group = f.create_group("cmfd") + cmfd_group.attrs['cmfd_on'] = self._cmfd_on + cmfd_group.attrs['feedback'] = self._feedback + cmfd_group.attrs['feedback_begin'] = self._feedback_begin + cmfd_group.attrs['mesh_id'] = self._mesh_id + cmfd_group.attrs['tally_begin'] = self._tally_begin + cmfd_group.attrs['time_cmfd'] = self._time_cmfd + cmfd_group.attrs['time_cmfdbuild'] = self._time_cmfdbuild + cmfd_group.attrs['time_cmfdsolve'] = self._time_cmfdsolve + cmfd_group.attrs['window_size'] = self._window_size + cmfd_group.attrs['window_type'] = self._window_type + cmfd_group.create_dataset('k_cmfd', data=self._k_cmfd) + cmfd_group.create_dataset('dom', data=self._dom) + cmfd_group.create_dataset('src_cmp', data=self._src_cmp) + cmfd_group.create_dataset('balance', data=self._balance) + cmfd_group.create_dataset('entropy', data=self._entropy) + cmfd_group.create_dataset('reset', data=self._reset) + cmfd_group.create_dataset('albedo', data=self._albedo) + cmfd_group.create_dataset('coremap', data=self._coremap) + cmfd_group.create_dataset('egrid', data=self._egrid) + cmfd_group.create_dataset('indices', data=self._indices) + cmfd_group.create_dataset('tally_ids', + data=self._tally_ids) + cmfd_group.create_dataset('current_rate', + data=self._current_rate) + cmfd_group.create_dataset('flux_rate', + data=self._flux_rate) + cmfd_group.create_dataset('nfiss_rate', + data=self._nfiss_rate) + cmfd_group.create_dataset('openmc_src_rate', + data=self._openmc_src_rate) + cmfd_group.create_dataset('p1scatt_rate', + data=self._p1scatt_rate) + cmfd_group.create_dataset('scatt_rate', + data=self._scatt_rate) + cmfd_group.create_dataset('total_rate', + data=self._total_rate) + elif openmc.settings.verbosity >= 5: + print(' CMFD data not written to statepoint file' + 'as it already exists in {}'.format(filename)) + sys.stdout.flush() def _initialize_linsolver(self): # Determine number of rows in CMFD matrix @@ -731,16 +960,38 @@ class CMFDRun(object): def _configure_cmfd(self): """Initialize CMFD parameters and set CMFD input variables""" - # Read in cmfd input defined in Python - self._read_cmfd_input() + # Check if restarting simulation from statepoint file + if not openmc.capi.settings.restart_run: + # Read in cmfd input defined in Python + self._read_cmfd_input() - # Initialize timers - self._time_cmfd = 0.0 - self._time_cmfdbuild = 0.0 - self._time_cmfdsolve = 0.0 + # Set up CMFD coremap + self._set_coremap() - # Initialize all numpy arrays used for CMFD solver - self._allocate_cmfd() + # Extract spatial and energy indices + nx, ny, nz, ng = self._indices + + # Allocate parameters that need to stored for tally window + self._openmc_src_rate = np.zeros((nx, ny, nz, ng, 0)) + self._flux_rate = np.zeros((nx, ny, nz, ng, 0)) + self._total_rate = np.zeros((nx, ny, nz, ng, 0)) + self._p1scatt_rate = np.zeros((nx, ny, nz, ng, 0)) + self._scatt_rate = np.zeros((nx, ny, nz, ng, ng, 0)) + self._nfiss_rate = np.zeros((nx, ny, nz, ng, ng, 0)) + self._current_rate = np.zeros((nx, ny, nz, 12, ng, 0)) + + # Initialize timers + self._time_cmfd = 0.0 + self._time_cmfdbuild = 0.0 + self._time_cmfdsolve = 0.0 + + # Initialize parameters for CMFD tally windows + self._set_tally_window() + + else: + # Reset CMFD parameters from statepoint file + path_statepoint = openmc.capi.settings.path_statepoint + self._reset_cmfd(path_statepoint) def _read_cmfd_input(self): """Sets values of additional instance variables based on user input""" @@ -788,20 +1039,94 @@ class CMFDRun(object): self._coremap = np.ones((np.product(self._indices[0:3])), dtype=int) + # Check CMFD tallies accummulated before feedback turned on + if self._feedback and self._feedback_begin < self._tally_begin: + raise ValueError('Tally begin must be less than or equal to ' + 'feedback begin') + # Set number of batches where cmfd tallies should be reset - if self._reset is not None: - self._n_resets = len(self._reset) + self._n_resets = len(self._reset) # Create tally objects self._create_cmfd_tally() + def _reset_cmfd(self, filename): + """Reset all CMFD parameters from statepoint + + Parameters + ---------- + filename : str + Filename of statepoint to read from + + """ + with h5py.File(filename, 'r') as f: + if 'cmfd' not in f: + raise OpenMCError('Could not find CMFD parameters in ', + 'file {}'.format(filename)) + else: + # Overwrite CMFD values from statepoint + if (openmc.capi.master() and + openmc.capi.settings.verbosity >= 5): + print(' Loading CMFD data from {}...'.format(filename)) + sys.stdout.flush() + cmfd_group = f['cmfd'] + self._cmfd_on = cmfd_group.attrs['cmfd_on'] + self._feedback = cmfd_group.attrs['feedback'] + self._feedback_begin = cmfd_group.attrs['feedback_begin'] + self._tally_begin = cmfd_group.attrs['tally_begin'] + self._time_cmfd = cmfd_group.attrs['time_cmfd'] + self._time_cmfdbuild = cmfd_group.attrs['time_cmfdbuild'] + self._time_cmfdsolve = cmfd_group.attrs['time_cmfdsolve'] + self._window_size = cmfd_group.attrs['window_size'] + self._window_type = cmfd_group.attrs['window_type'] + self._k_cmfd = list(cmfd_group['k_cmfd']) + self._dom = list(cmfd_group['dom']) + self._src_cmp = list(cmfd_group['src_cmp']) + self._balance = list(cmfd_group['balance']) + self._entropy = list(cmfd_group['entropy']) + self._reset = list(cmfd_group['reset']) + self._albedo = cmfd_group['albedo'][()] + self._coremap = cmfd_group['coremap'][()] + self._egrid = cmfd_group['egrid'][()] + self._indices = cmfd_group['indices'][()] + self._current_rate = cmfd_group['current_rate'][()] + self._flux_rate = cmfd_group['flux_rate'][()] + self._nfiss_rate = cmfd_group['nfiss_rate'][()] + self._openmc_src_rate = cmfd_group['openmc_src_rate'][()] + self._p1scatt_rate = cmfd_group['p1scatt_rate'][()] + self._scatt_rate = cmfd_group['scatt_rate'][()] + self._total_rate = cmfd_group['total_rate'][()] + + # Overwrite CMFD mesh properties + cmfd_mesh_name = 'mesh ' + str(cmfd_group.attrs['mesh_id']) + cmfd_mesh = f['tallies']['meshes'][cmfd_mesh_name] + self._mesh.dimension = cmfd_mesh['dimension'][()] + self._mesh.lower_left = cmfd_mesh['lower_left'][()] + self._mesh.upper_right = cmfd_mesh['upper_right'][()] + self._mesh.width = cmfd_mesh['width'][()] + + # Store tally ids from statepoint run + sp_tally_ids = list(cmfd_group['tally_ids']) + + # Set CMFD variables not in statepoint file + default_egrid = np.array([_ENERGY_MIN_NEUTRON, _ENERGY_MAX_NEUTRON]) + self._energy_filters = not np.array_equal(self._egrid, default_egrid) + self._n_resets = len(self._reset) + self._mat_dim = np.max(self._coremap) + 1 + self._reset_every = (self._window_type == 'expanding' or + self._window_type == 'rolling') + + # Recreate CMFD tallies in memory + self._create_cmfd_tally() + def _allocate_cmfd(self): """Allocates all numpy arrays and lists used in CMFD algorithm""" # Extract spatial and energy indices - nx = self._indices[0] - ny = self._indices[1] - nz = self._indices[2] - ng = self._indices[3] + nx, ny, nz, ng = self._indices + + # Allocate dimensions for each mesh cell + self._hxyz = np.zeros((nx, ny, nz, 3)) + self._hxyz[:] = openmc.capi.meshes[self._mesh_id].width # Allocate flux, cross sections and diffusion coefficient self._flux = np.zeros((nx, ny, nz, ng)) @@ -815,26 +1140,28 @@ class CMFDRun(object): self._dtilde = np.zeros((nx, ny, nz, ng, 6)) self._dhat = np.zeros((nx, ny, nz, ng, 6)) - # Allocate dimensions for each mesh cell - self._hxyz = np.zeros((nx, ny, nz, 3)) + # Set reference diffusion parameters + if self._ref_d: + self._set_reference_params = True + # Check length of reference diffusion parameters equal to number of + # energy groups + if len(self._ref_d) != self._indices[3]: + raise OpenMCError('Number of reference diffusion parameters ' + 'must equal number of CMFD energy groups') - # Allocate surface currents - self._current = np.zeros((nx, ny, nz, 12, ng)) - - # Allocate source distributions - self._cmfd_src = np.zeros((nx, ny, nz, ng)) - self._openmc_src = np.zeros((nx, ny, nz, ng)) - - # Allocate source weight modification variables - self._sourcecounts = np.zeros((nx*ny*nz, ng)) - self._weightfactors = np.ones((nx, ny, nz, ng)) - - # Allocate batchwise parameters - self._entropy = [] - self._balance = [] - self._src_cmp = [] - self._dom = [] - self._k_cmfd = [] + def _set_tally_window(self): + """Sets parameters to handle different tally window options""" + # Set parameters for expanding window + if self._window_type == 'expanding': + self._reset_every = True + self._window_size = 1 + # Set parameters for rolling window + elif self.window_type == 'rolling': + self._reset_every = True + # Set parameters for default case, with no window + else: + self._window_size = 1 + self._reset_every = False def _cmfd_init_batch(self): """Handles CMFD options at the beginning of each batch""" @@ -843,11 +1170,13 @@ class CMFDRun(object): current_batch = openmc.capi.current_batch() + 1 # Check to activate CMFD diffusion and possible feedback - if self._begin == current_batch: + # Check to activate CMFD tallies + if self._tally_begin == current_batch: self._cmfd_on = True # Check to reset tallies - if self._n_resets > 0 and current_batch in self._reset: + if ((self._n_resets > 0 and current_batch in self._reset) + or self._reset_every): self._cmfd_tally_reset() def _execute_cmfd(self): @@ -885,7 +1214,8 @@ class CMFDRun(object): def _cmfd_tally_reset(self): """Resets all CMFD tallies in memory""" # Print message - if openmc.capi.settings.verbosity >= 6 and openmc.capi.master(): + if (openmc.capi.settings.verbosity >= 6 and openmc.capi.master() and + not self._reset_every): print(' CMFD tallies reset') sys.stdout.flush() @@ -898,7 +1228,7 @@ class CMFDRun(object): """Configures CMFD object for a CMFD eigenvalue calculation """ - # Calculate all cross sections based on reaction rates from last batch + # Calculate all cross sections based on tally window averages self._compute_xs() # Compute effective downscatter cross section @@ -1042,15 +1372,9 @@ class CMFDRun(object): """ # Extract number of groups and number of accelerated regions - nx = self._indices[0] - ny = self._indices[1] - nz = self._indices[2] - ng = self._indices[3] + nx, ny, nz, ng = self._indices n = self._mat_dim - # Reset CMFD source to 0 - self._cmfd_src.fill(0.) - # Compute cmfd_src in a vecotorized manner by phi to the spatial # indices of the actual problem so that cmfd_flux can be multiplied by # nfissxs @@ -1111,13 +1435,7 @@ class CMFDRun(object): if new_weights: # Get spatial dimensions and energy groups - nx = self._indices[0] - ny = self._indices[1] - nz = self._indices[2] - ng = self._indices[3] - - # Set weight factors to default 1.0 - self._weightfactors.fill(1.0) + nx, ny, nz, ng = self._indices # Count bank site in mesh and reverse due to egrid structured outside = self._count_bank_sites() @@ -1147,12 +1465,13 @@ class CMFDRun(object): # Compute weight factors div_condition = np.logical_and(sourcecounts > 0, self._cmfd_src > 0) - with np.errstate(divide='ignore', invalid='ignore'): - self._weightfactors = (np.divide(self._cmfd_src * norm, - sourcecounts, where=div_condition, - out=np.ones_like(self._cmfd_src))) + self._weightfactors = (np.divide(self._cmfd_src * norm, + sourcecounts, where=div_condition, + out=np.ones_like(self._cmfd_src), + dtype=np.float32)) - if not self._feedback: + if (not self._feedback + or openmc.capi.current_batch() < self._feedback_begin): return # Broadcast weight factors to all procs @@ -1208,9 +1527,11 @@ class CMFDRun(object): bank = openmc.capi.source_bank() energy = self._egrid sites_outside = np.zeros(1, dtype=bool) + nxnynz = np.prod(self._indices[0:3]) ng = self._indices[3] outside = np.zeros(1, dtype=bool) + self._sourcecounts = np.zeros((nxnynz, ng)) count = np.zeros(self._sourcecounts.shape) # Get location and energy of each particle in source bank @@ -1572,32 +1893,36 @@ class CMFDRun(object): # Reshape coremap to three dimensional array # Indices of coremap in user input switched in x and z axes - nx = self._indices[0] - ny = self._indices[1] - nz = self._indices[2] + nx, ny, nz = self._indices[:3] self._coremap = self._coremap.reshape(nz, ny, nx) self._coremap = np.swapaxes(self._coremap, 0, 2) def _compute_xs(self): """Takes CMFD tallies from OpenMC and computes macroscopic cross - sections, flux, and diffusion coefficients for each mesh cell + sections, flux, and diffusion coefficients for each mesh cell using + a tally window scheme """ + # Update window size for expanding window if necessary + num_cmfd_batches = openmc.capi.current_batch() - self._tally_begin + 1 + if (self._window_type == 'expanding' and + num_cmfd_batches == self._window_size * 2): + self._window_size *= 2 + + # Discard tallies from oldest batch if window limit reached + tally_windows = self._flux_rate.shape[-1] + 1 + if tally_windows > self._window_size: + self._flux_rate = self._flux_rate[...,1:] + self._total_rate = self._total_rate[...,1:] + self._p1scatt_rate = self._p1scatt_rate[...,1:] + self._scatt_rate = self._scatt_rate[...,1:] + self._nfiss_rate = self._nfiss_rate[...,1:] + self._current_rate = self._current_rate[...,1:] + self._openmc_src_rate = self._openmc_src_rate[...,1:] + tally_windows -= 1 + # Extract spatial and energy indices - nx = self._indices[0] - ny = self._indices[1] - nz = self._indices[2] - ng = self._indices[3] - - # Set flux object and source distribution all to zeros - self._flux.fill(0.) - self._openmc_src.fill(0.) - - # Set mesh widths - self._hxyz[:,:,:,:] = openmc.capi.meshes[self._mesh_id].width - - # Reset keff_bal to zero - self._keff_bal = 0. + nx, ny, nz, ng = self._indices # Get tallies in-memory tallies = openmc.capi.tallies @@ -1632,81 +1957,115 @@ class CMFDRun(object): # Define target tally reshape dimensions. This defines how openmc # tallies are ordered by dimension - target_tally_shape = [nz, ny, nx, ng] + target_tally_shape = [nz, ny, nx, ng, 1] # Reshape flux array to target shape. Swap x and z axes so that - # flux shape is now [nx, ny, nz, ng] + # flux shape is now [nx, ny, nz, ng, 1] reshape_flux = np.swapaxes(flux.reshape(target_tally_shape), 0, 2) # Flip energy axis as tally results are given in reverse order of # energy group - self._flux = np.flip(reshape_flux, axis=3) + reshape_flux = np.flip(reshape_flux, axis=3) - # Get total rr and convert to total xs from CMFD tally 0 - tally_results = tallies[tally_id].results[:,1,1] - with np.errstate(divide='ignore', invalid='ignore'): - totalxs = np.divide(tally_results, flux, - where=flux > 0, - out=np.zeros_like(tally_results)) + # Bank flux to flux_rate + self._flux_rate = np.append(self._flux_rate, reshape_flux, axis=4) - # Reshape totalxs array to target shape. Swap x and z axes so that - # shape is now [nx, ny, nz, ng] - reshape_totalxs = np.swapaxes(totalxs.reshape(target_tally_shape), + # Compute flux as aggregate of banked flux_rate over tally window + self._flux = np.sum(self._flux_rate, axis=4) + + # Get total rr from CMFD tally 0 + totalrr = tallies[tally_id].results[:,1,1] + + # Reshape totalrr array to target shape. Swap x and z axes so that + # shape is now [nx, ny, nz, ng, 1] + reshape_totalrr = np.swapaxes(totalrr.reshape(target_tally_shape), 0, 2) - # Total xs is flipped in energy axis as tally results are given in + # Total rr is flipped in energy axis as tally results are given in # reverse order of energy group - self._totalxs = np.flip(reshape_totalxs, axis=3) + reshape_totalrr = np.flip(reshape_totalrr, axis=3) - # Get scattering xs from CMFD tally 1 + # Bank total rr to total_rate + self._total_rate = np.append(self._total_rate, reshape_totalrr, + axis=4) + + # Compute total xs as aggregate of banked total_rate over tally window + # divided by flux + self._totalxs = np.divide(np.sum(self._total_rate, axis=4), + self._flux, where=self._flux > 0, + out=np.zeros_like(self._totalxs)) + + # Get scattering rr from CMFD tally 1 # flux is repeated to account for extra dimensionality of scattering xs tally_id = self._tally_ids[1] - tally_results = tallies[tally_id].results[:,0,1] - with np.errstate(divide='ignore', invalid='ignore'): - scattxs = np.divide(tally_results, np.repeat(flux, ng), - where=np.repeat(flux > 0, ng), - out=np.zeros_like(tally_results)) + scattrr = tallies[tally_id].results[:,0,1] # Define target tally reshape dimensions for xs with incoming # and outgoing energies - target_tally_shape = [nz, ny, nx, ng, ng] + target_tally_shape = [nz, ny, nx, ng, ng, 1] - # Reshape scattxs array to target shape. Swap x and z axes so that - # shape is now [nx, ny, nz, ng, ng] - reshape_scattxs = np.swapaxes(scattxs.reshape(target_tally_shape), + # Reshape scattrr array to target shape. Swap x and z axes so that + # shape is now [nx, ny, nz, ng, ng, 1] + reshape_scattrr = np.swapaxes(scattrr.reshape(target_tally_shape), 0, 2) - # Scattering xs is flipped in both incoming and outgoing energy axes + # Scattering rr is flipped in both incoming and outgoing energy axes # as tally results are given in reverse order of energy group - self._scattxs = np.flip(reshape_scattxs, axis=3) - self._scattxs = np.flip(self._scattxs, axis=4) + reshape_scattrr = np.flip(reshape_scattrr, axis=3) + reshape_scattrr = np.flip(reshape_scattrr, axis=4) - # Get nu-fission xs from CMFD tally 1 - # flux is repeated to account for extra dimensionality of nu-fission xs - tally_results = tallies[tally_id].results[:,1,1] + # Bank scattering rr to scatt_rate + self._scatt_rate = np.append(self._scatt_rate, reshape_scattrr, + axis=5) + + # Compute scattering xs as aggregate of banked scatt_rate over tally + # window divided by flux. Flux dimensionality increased to account for + # extra dimensionality of scattering xs + extended_flux = self._flux[:,:,:,:,np.newaxis] + self._scattxs = np.divide(np.sum(self._scatt_rate, axis=5), + extended_flux, where=extended_flux > 0, + out=np.zeros_like(self._scattxs)) + + # Get nu-fission rr from CMFD tally 1 + nfissrr = tallies[tally_id].results[:,1,1] num_realizations = tallies[tally_id].num_realizations - with np.errstate(divide='ignore', invalid='ignore'): - nfissxs = np.divide(tally_results, np.repeat(flux, ng), - where=np.repeat(flux > 0, ng), - out=np.zeros_like(tally_results)) - # Reshape nfissxs array to target shape. Swap x and z axes so that - # shape is now [nx, ny, nz, ng, ng] - reshape_nfissxs = np.swapaxes(nfissxs.reshape(target_tally_shape), + # Reshape nfissrr array to target shape. Swap x and z axes so that + # shape is now [nx, ny, nz, ng, ng, 1] + reshape_nfissrr = np.swapaxes(nfissrr.reshape(target_tally_shape), 0, 2) - # Nu-fission xs is flipped in both incoming and outgoing energy axes + # Nu-fission rr is flipped in both incoming and outgoing energy axes # as tally results are given in reverse order of energy group - self._nfissxs = np.flip(reshape_nfissxs, axis=3) - self._nfissxs = np.flip(self._nfissxs, axis=4) + reshape_nfissrr = np.flip(reshape_nfissrr, axis=3) + reshape_nfissrr = np.flip(reshape_nfissrr, axis=4) + + # Bank nu-fission rr to nfiss_rate + self._nfiss_rate = np.append(self._nfiss_rate, reshape_nfissrr, + axis=5) + + # Compute nu-fission xs as aggregate of banked nfiss_rate over tally + # window divided by flux. Flux dimensionality increased to account for + # extra dimensionality of nu-fission xs + self._nfissxs = np.divide(np.sum(self._nfiss_rate, axis=5), + extended_flux, where=extended_flux > 0, + out=np.zeros_like(self._nfissxs)) # Openmc source distribution is sum of nu-fission rr in incoming # energies - self._openmc_src = np.sum(self._nfissxs*self._flux[:,:,:,:,np.newaxis], - axis=3) + openmc_src = np.sum(reshape_nfissrr, axis=3) + + # Bank OpenMC source distribution from current batch to + # openmc_src_rate + self._openmc_src_rate = np.append(self._openmc_src_rate, openmc_src, + axis=4) + + # Compute source distribution over entire tally window + self._openmc_src = np.sum(self._openmc_src_rate, axis=4) # Compute k_eff from source distribution - self._keff_bal = np.sum(self._openmc_src) / num_realizations + self._keff_bal = (np.sum(self._openmc_src) / num_realizations / + tally_windows) # Normalize openmc source distribution self._openmc_src /= np.sum(self._openmc_src) * self._norm @@ -1716,44 +2075,62 @@ class CMFDRun(object): tally_results = tallies[tally_id].results[:,0,1] # Filter tally results to include only accelerated regions - current = np.where(np.repeat(flux > 0, 12), tally_results, 0.) + current = np.where(np.repeat(is_cmfd_accel, 12), tally_results, 0.) # Define target tally reshape dimensions for current - target_tally_shape = [nz, ny, nx, 12, ng] + target_tally_shape = [nz, ny, nx, 12, ng, 1] # Reshape current array to target shape. Swap x and z axes so that - # shape is now [nx, ny, nz, ng, 12] + # shape is now [nx, ny, nz, 12, ng, 1] reshape_current = np.swapaxes(current.reshape(target_tally_shape), 0, 2) # Current is flipped in energy axis as tally results are given in # reverse order of energy group - self._current = np.flip(reshape_current, axis=4) + reshape_current = np.flip(reshape_current, axis=4) - # Get p1 scatter xs from CMFD tally 3 + # Bank current to current_rate + self._current_rate = np.append(self._current_rate, reshape_current, + axis=5) + + # Compute current as aggregate of banked current_rate over tally window + self._current = np.sum(self._current_rate, axis=5) + + # Get p1 scatter rr from CMFD tally 3 tally_id = self._tally_ids[3] - tally_results = tallies[tally_id].results[:,0,1] + p1scattrr = tallies[tally_id].results[:,0,1] # Define target tally reshape dimensions for p1 scatter tally - target_tally_shape = [nz, ny, nx, 2, ng] + target_tally_shape = [nz, ny, nx, 2, ng, 1] # Reshape and extract only p1 data from tally results as there is # no need for p0 data - p1scattrr = np.swapaxes(tally_results.reshape(target_tally_shape), - 0, 2)[:,:,:,1,:] + reshape_p1scattrr = np.swapaxes(p1scattrr.reshape(target_tally_shape), + 0, 2)[:,:,:,1,:,:] - # Store p1 scatter xs - # p1 scatter xs is flipped in energy axis as tally results are given in + # p1-scatter rr is flipped in energy axis as tally results are given in # reverse order of energy group - with np.errstate(divide='ignore', invalid='ignore'): - self._p1scattxs = np.divide(np.flip(p1scattrr, axis=3), self._flux, - where=self._flux > 0, - out=np.zeros_like(p1scattrr)) + reshape_p1scattrr = np.flip(reshape_p1scattrr, axis=3) - # Calculate and store diffusion coefficient - with np.errstate(divide='ignore', invalid='ignore'): - self._diffcof = np.where(self._flux > 0, 1.0 / (3.0 * - (self._totalxs - self._p1scattxs)), 0.) + # Bank p1-scatter rr to p1scatt_rate + self._p1scatt_rate = np.append(self._p1scatt_rate, reshape_p1scattrr, + axis=4) + + # Compute p1-scatter xs as aggregate of banked p1scatt_rate over tally + # window divided by flux + self._p1scattxs = np.divide(np.sum(self._p1scatt_rate, axis=4), + self._flux, where=self._flux > 0, + out=np.zeros_like(self._p1scattxs)) + + if self._set_reference_params: + # Set diffusion coefficients based on reference value + self._diffcof = np.where(self._flux > 0, + self._ref_d[None, None, None, :], 0.0) + else: + # Calculate and store diffusion coefficient + with np.errstate(divide='ignore', invalid='ignore'): + self._diffcof = np.where(self._flux > 0, 1.0 / (3.0 * + (self._totalxs-self._p1scattxs)), 0.) def _compute_effective_downscatter(self): """Changes downscatter rate for zero upscatter""" @@ -1781,10 +2158,9 @@ class CMFDRun(object): siga2 = sigt2 - sigs22 - sigs21 # Compute effective downscatter XS - with np.errstate(divide='ignore', invalid='ignore'): - sigs12_eff = sigs12 - sigs21 * np.divide(flux2, flux1, - where=flux1 > 0, - out=np.zeros_like(flux2)) + sigs12_eff = sigs12 - sigs21 * np.divide(flux2, flux1, + where=flux1 > 0, + out=np.zeros_like(flux2)) # Recompute total cross sections and record self._totalxs[:,:,:,0] = siga1 + sigs11 + sigs12_eff @@ -1851,9 +2227,7 @@ class CMFDRun(object): """ # Extract spatial indices - nx = self._indices[0] - ny = self._indices[1] - nz = self._indices[2] + nx, ny, nz = self._indices[:3] # Logical for determining whether region of interest is accelerated # region @@ -1993,7 +2367,7 @@ class CMFDRun(object): def _precompute_matrix_indices(self): """Computes the indices and row/column data used to populate CMFD CSR matrices. These indices are used in _build_loss_matrix and - _build_prod_matrix + _build_prod_matrix. """ # Extract energy group indices @@ -2226,10 +2600,9 @@ class CMFDRun(object): # a cell borders a reflector region on the left current_in_left = self._current[:,:,:,_CURRENTS['in_left'],:] current_out_left = self._current[:,:,:,_CURRENTS['out_left'],:] - with np.errstate(divide='ignore', invalid='ignore'): - ref_albedo = np.divide(current_in_left, current_out_left, - where=current_out_left > 1.0e-10, - out=np.ones_like(current_out_left)) + ref_albedo = np.divide(current_in_left, current_out_left, + where=current_out_left > 1.0e-10, + out=np.ones_like(current_out_left)) # Diffusion coefficient of neighbor to left neig_dc = np.roll(self._diffcof, 1, axis=0) @@ -2256,10 +2629,9 @@ class CMFDRun(object): # a cell borders a reflector region on the right current_in_right = self._current[:,:,:,_CURRENTS['in_right'],:] current_out_right = self._current[:,:,:,_CURRENTS['out_right'],:] - with np.errstate(divide='ignore', invalid='ignore'): - ref_albedo = np.divide(current_in_right, current_out_right, - where=current_out_right > 1.0e-10, - out=np.ones_like(current_out_right)) + ref_albedo = np.divide(current_in_right, current_out_right, + where=current_out_right > 1.0e-10, + out=np.ones_like(current_out_right)) # Diffusion coefficient of neighbor to right neig_dc = np.roll(self._diffcof, -1, axis=0) @@ -2286,10 +2658,9 @@ class CMFDRun(object): # a cell borders a reflector region on the back current_in_back = self._current[:,:,:,_CURRENTS['in_back'],:] current_out_back = self._current[:,:,:,_CURRENTS['out_back'],:] - with np.errstate(divide='ignore', invalid='ignore'): - ref_albedo = np.divide(current_in_back, current_out_back, - where=current_out_back > 1.0e-10, - out=np.ones_like(current_out_back)) + ref_albedo = np.divide(current_in_back, current_out_back, + where=current_out_back > 1.0e-10, + out=np.ones_like(current_out_back)) # Diffusion coefficient of neighbor to back neig_dc = np.roll(self._diffcof, 1, axis=1) @@ -2316,10 +2687,9 @@ class CMFDRun(object): # a cell borders a reflector region in the front current_in_front = self._current[:,:,:,_CURRENTS['in_front'],:] current_out_front = self._current[:,:,:,_CURRENTS['out_front'],:] - with np.errstate(divide='ignore', invalid='ignore'): - ref_albedo = np.divide(current_in_front, current_out_front, - where=current_out_front > 1.0e-10, - out=np.ones_like(current_out_front)) + ref_albedo = np.divide(current_in_front, current_out_front, + where=current_out_front > 1.0e-10, + out=np.ones_like(current_out_front)) # Diffusion coefficient of neighbor to front neig_dc = np.roll(self._diffcof, -1, axis=1) @@ -2346,10 +2716,9 @@ class CMFDRun(object): # a cell borders a reflector region on the bottom current_in_bottom = self._current[:,:,:,_CURRENTS['in_bottom'],:] current_out_bottom = self._current[:,:,:,_CURRENTS['out_bottom'],:] - with np.errstate(divide='ignore', invalid='ignore'): - ref_albedo = np.divide(current_in_bottom, current_out_bottom, - where=current_out_bottom > 1.0e-10, - out=np.ones_like(current_out_bottom)) + ref_albedo = np.divide(current_in_bottom, current_out_bottom, + where=current_out_bottom > 1.0e-10, + out=np.ones_like(current_out_bottom)) # Diffusion coefficient of neighbor to bottom neig_dc = np.roll(self._diffcof, 1, axis=2) @@ -2376,10 +2745,9 @@ class CMFDRun(object): # a cell borders a reflector region on the top current_in_top = self._current[:,:,:,_CURRENTS['in_top'],:] current_out_top = self._current[:,:,:,_CURRENTS['out_top'],:] - with np.errstate(divide='ignore', invalid='ignore'): - ref_albedo = np.divide(current_in_top, current_out_top, - where=current_out_top > 1.0e-10, - out=np.ones_like(current_out_top)) + ref_albedo = np.divide(current_in_top, current_out_top, + where=current_out_top > 1.0e-10, + out=np.ones_like(current_out_top)) # Diffusion coefficient of neighbor to top neig_dc = np.roll(self._diffcof, -1, axis=2) diff --git a/src/settings.cpp b/src/settings.cpp index 19ec9eabd..1c9d1161a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -40,6 +40,7 @@ namespace settings { // Default values for boolean flags bool assume_separate {false}; bool check_overlaps {false}; +bool cmfd_run {false}; bool confidence_intervals {false}; bool create_fission_neutrons {true}; bool dagmc {false}; diff --git a/src/simulation.cpp b/src/simulation.cpp index f94ba232a..8de1e7fbc 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -221,6 +221,16 @@ int openmc_next_batch(int* status) return 0; } +bool openmc_is_statepoint_batch() { + using namespace openmc; + using openmc::simulation::current_gen; + + if (!simulation::initialized) + return false; + else + return contains(settings::statepoint_batch, simulation::current_batch); +} + namespace openmc { //============================================================================== @@ -357,8 +367,10 @@ void finalize_batch() settings::statepoint_batch.insert(simulation::current_batch); } - // Write out state point if it's been specified for this batch - if (contains(settings::statepoint_batch, simulation::current_batch)) { + // Write out state point if it's been specified for this batch and is not + // a CMFD run instance + if (contains(settings::statepoint_batch, simulation::current_batch) + && !settings::cmfd_run) { if (contains(settings::sourcepoint_batch, simulation::current_batch) && settings::source_write && !settings::source_separate) { bool b = true; diff --git a/src/state_point.cpp b/src/state_point.cpp index 54f1cb38c..7516b0d48 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -29,9 +29,6 @@ namespace openmc { -extern "C" void statepoint_write_f(hid_t file_id); -extern "C" void load_state_point_f(hid_t file_id); - extern "C" int openmc_statepoint_write(const char* filename, bool* write_source) { diff --git a/tests/regression_tests/cmfd_feed/results_true.dat b/tests/regression_tests/cmfd_feed/results_true.dat index 85498af19..4a2c6eea2 100644 --- a/tests/regression_tests/cmfd_feed/results_true.dat +++ b/tests/regression_tests/cmfd_feed/results_true.dat @@ -378,7 +378,7 @@ tally 5: 5.253064E+00 1.396224E+00 2.996497E+01 -4.508840E+01 +4.508839E+01 3.818076E+00 7.509442E-01 1.574994E+01 @@ -461,11 +461,11 @@ cmfd dominance ratio cmfd openmc source comparison 6.959834E-03 5.655657E-03 -3.886185E-03 +3.886186E-03 4.035116E-03 3.043277E-03 -5.455475E-03 -4.515311E-03 +5.455474E-03 +4.515310E-03 2.439840E-03 2.114032E-03 2.673132E-03 diff --git a/tests/regression_tests/cmfd_feed/test.py b/tests/regression_tests/cmfd_feed/test.py index 04ac442e0..906c631ec 100644 --- a/tests/regression_tests/cmfd_feed/test.py +++ b/tests/regression_tests/cmfd_feed/test.py @@ -15,15 +15,16 @@ def test_cmfd_physical_adjoint(): """ # Initialize and set CMFD mesh cmfd_mesh = cmfd.CMFDMesh() - cmfd_mesh.lower_left = -10.0, -1.0, -1.0 - cmfd_mesh.upper_right = 10.0, 1.0, 1.0 - cmfd_mesh.dimension = 10, 1, 1 - cmfd_mesh.albedo = 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) # Initialize and run CMFDRun object cmfd_run = cmfd.CMFDRun() cmfd_run.mesh = cmfd_mesh - cmfd_run.begin = 5 + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 5 cmfd_run.feedback = True cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] cmfd_run.run_adjoint = True @@ -44,15 +45,16 @@ def test_cmfd_math_adjoint(): """ # Initialize and set CMFD mesh cmfd_mesh = cmfd.CMFDMesh() - cmfd_mesh.lower_left = -10.0, -1.0, -1.0 - cmfd_mesh.upper_right = 10.0, 1.0, 1.0 - cmfd_mesh.dimension = 10, 1, 1 - cmfd_mesh.albedo = 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) # Initialize and run CMFDRun object cmfd_run = cmfd.CMFDRun() cmfd_run.mesh = cmfd_mesh - cmfd_run.begin = 5 + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 5 cmfd_run.feedback = True cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] cmfd_run.run_adjoint = True @@ -72,15 +74,16 @@ def test_cmfd_write_matrices(): """ # Initialize and set CMFD mesh cmfd_mesh = cmfd.CMFDMesh() - cmfd_mesh.lower_left = -10.0, -1.0, -1.0 - cmfd_mesh.upper_right = 10.0, 1.0, 1.0 - cmfd_mesh.dimension = 10, 1, 1 - cmfd_mesh.albedo = 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) # Initialize and run CMFDRun object cmfd_run = cmfd.CMFDRun() cmfd_run.mesh = cmfd_mesh - cmfd_run.begin = 5 + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 5 cmfd_run.display = {'dominance': True} cmfd_run.feedback = True cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] @@ -119,15 +122,16 @@ def test_cmfd_feed(): """Test 1 group CMFD solver with CMFD feedback""" # Initialize and set CMFD mesh cmfd_mesh = cmfd.CMFDMesh() - cmfd_mesh.lower_left = -10.0, -1.0, -1.0 - cmfd_mesh.upper_right = 10.0, 1.0, 1.0 - cmfd_mesh.dimension = 10, 1, 1 - cmfd_mesh.albedo = 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) # Initialize and run CMFDRun object cmfd_run = cmfd.CMFDRun() cmfd_run.mesh = cmfd_mesh - cmfd_run.begin = 5 + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 5 cmfd_run.display = {'dominance': True} cmfd_run.feedback = True cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] diff --git a/tests/regression_tests/cmfd_feed_2g/results_true.dat b/tests/regression_tests/cmfd_feed_2g/results_true.dat index 4b3dc3c96..f16d82309 100644 --- a/tests/regression_tests/cmfd_feed_2g/results_true.dat +++ b/tests/regression_tests/cmfd_feed_2g/results_true.dat @@ -80,7 +80,7 @@ tally 3: 0.000000E+00 0.000000E+00 1.796382E-02 -3.190854E-05 +3.190855E-05 4.343238E+00 9.514040E-01 3.504683E+00 @@ -90,7 +90,7 @@ tally 3: 9.818871E+01 4.822799E+02 8.401346E-01 -3.664037E-02 +3.664038E-02 6.130607E+01 1.882837E+02 0.000000E+00 @@ -377,13 +377,13 @@ cmfd balance 4.16856E-04 6.38469E-04 3.92822E-04 -3.78983E-04 +3.78984E-04 2.68486E-04 4.84991E-04 1.08402E-03 -1.09178E-03 +1.09177E-03 5.45977E-04 -4.45555E-04 +4.45554E-04 4.01147E-04 3.71025E-04 3.57715E-04 @@ -408,21 +408,21 @@ cmfd dominance ratio 5.996E-03 cmfd openmc source comparison 1.931386E-05 -2.839162E-05 -1.407962E-05 -6.718148E-06 -9.164193E-06 -1.382539E-05 +2.839161E-05 +1.407963E-05 +6.718156E-06 +9.164199E-06 +1.382540E-05 2.871606E-05 4.192300E-05 -5.327516E-05 +5.327515E-05 6.566500E-05 -6.655541E-05 +6.655540E-05 6.034977E-05 6.004677E-05 -5.711623E-05 -6.271264E-05 -6.425363E-05 +5.711622E-05 +6.271263E-05 +6.425362E-05 cmfd source 2.510278E-01 2.480592E-01 diff --git a/tests/regression_tests/cmfd_feed_2g/test.py b/tests/regression_tests/cmfd_feed_2g/test.py index 22cc7e160..ba4d21609 100644 --- a/tests/regression_tests/cmfd_feed_2g/test.py +++ b/tests/regression_tests/cmfd_feed_2g/test.py @@ -7,16 +7,17 @@ def test_cmfd_feed_2g(): """Test 2 group CMFD solver results with CMFD feedback""" # Initialize and set CMFD mesh cmfd_mesh = cmfd.CMFDMesh() - cmfd_mesh.lower_left = -1.25984, -1.25984, -1.0 - cmfd_mesh.upper_right = 1.25984, 1.25984, 1.0 - cmfd_mesh.dimension = 2, 2, 1 - cmfd_mesh.energy = [0.0, 0.625, 20000000] - cmfd_mesh.albedo = 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 + cmfd_mesh.lower_left = (-1.25984, -1.25984, -1.0) + cmfd_mesh.upper_right = (1.25984, 1.25984, 1.0) + cmfd_mesh.dimension = (2, 2, 1) + cmfd_mesh.energy = (0.0, 0.625, 20000000) + cmfd_mesh.albedo = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0) # Initialize and run CMFDRun object cmfd_run = cmfd.CMFDRun() cmfd_run.mesh = cmfd_mesh - cmfd_run.begin = 5 + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 5 cmfd_run.display = {'dominance': True} cmfd_run.feedback = True cmfd_run.downscatter = True diff --git a/tests/regression_tests/cmfd_feed_expanding_window/__init__.py b/tests/regression_tests/cmfd_feed_expanding_window/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/regression_tests/cmfd_feed_expanding_window/geometry.xml b/tests/regression_tests/cmfd_feed_expanding_window/geometry.xml new file mode 100644 index 000000000..73ea679c4 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_expanding_window/geometry.xml @@ -0,0 +1,43 @@ + + + + + + 0 + -1 2 -3 4 -5 6 + 1 + + + + + x-plane + 10 + vacuum + + + x-plane + -10 + vacuum + + + y-plane + 1 + reflective + + + y-plane + -1 + reflective + + + z-plane + 1 + reflective + + + z-plane + -1 + reflective + + + diff --git a/tests/regression_tests/cmfd_feed_expanding_window/materials.xml b/tests/regression_tests/cmfd_feed_expanding_window/materials.xml new file mode 100644 index 000000000..70580e3a8 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_expanding_window/materials.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/regression_tests/cmfd_feed_expanding_window/results_true.dat b/tests/regression_tests/cmfd_feed_expanding_window/results_true.dat new file mode 100644 index 000000000..b67bef0f7 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_expanding_window/results_true.dat @@ -0,0 +1,488 @@ +k-combined: +1.165403E+00 1.129918E-02 +tally 1: +1.141961E+01 +1.307497E+01 +2.075941E+01 +4.316095E+01 +2.834539E+01 +8.063510E+01 +3.513869E+01 +1.238515E+02 +3.699858E+01 +1.372516E+02 +3.612668E+01 +1.310763E+02 +3.373368E+01 +1.140458E+02 +2.836844E+01 +8.075759E+01 +2.158837E+01 +4.674848E+01 +1.141868E+01 +1.310648E+01 +tally 2: +1.126626E+00 +1.269287E+00 +7.749042E-01 +6.004765E-01 +1.991608E+00 +3.966503E+00 +1.411775E+00 +1.993108E+00 +2.978264E+00 +8.870057E+00 +2.130066E+00 +4.537180E+00 +3.708857E+00 +1.375562E+01 +2.698010E+00 +7.279259E+00 +4.233192E+00 +1.791991E+01 +3.023990E+00 +9.144518E+00 +4.062113E+00 +1.650076E+01 +2.910472E+00 +8.470848E+00 +3.506681E+00 +1.229681E+01 +2.497751E+00 +6.238760E+00 +2.974675E+00 +8.848690E+00 +2.121163E+00 +4.499332E+00 +2.329248E+00 +5.425398E+00 +1.658233E+00 +2.749736E+00 +1.158552E+00 +1.342242E+00 +8.282698E-01 +6.860309E-01 +tally 3: +7.459301E-01 +5.564117E-01 +4.877614E-02 +2.379112E-03 +1.356702E+00 +1.840641E+00 +8.361624E-02 +6.991675E-03 +2.047332E+00 +4.191570E+00 +1.521351E-01 +2.314509E-02 +2.610287E+00 +6.813596E+00 +1.718778E-01 +2.954199E-02 +2.911379E+00 +8.476127E+00 +1.823299E-01 +3.324418E-02 +2.806920E+00 +7.878801E+00 +2.090406E-01 +4.369797E-02 +2.415727E+00 +5.835736E+00 +1.486511E-01 +2.209715E-02 +2.051064E+00 +4.206862E+00 +1.196177E-01 +1.430839E-02 +1.593746E+00 +2.540026E+00 +1.126497E-01 +1.268994E-02 +7.994935E-01 +6.391898E-01 +5.806683E-02 +3.371757E-03 +tally 4: +1.341719E-01 +1.800210E-02 +0.000000E+00 +0.000000E+00 +1.420707E-01 +2.018410E-02 +2.633150E-01 +6.933479E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.633150E-01 +6.933479E-02 +1.420707E-01 +2.018410E-02 +2.628613E-01 +6.909608E-02 +3.590382E-01 +1.289084E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.590382E-01 +1.289084E-01 +2.628613E-01 +6.909608E-02 +3.851599E-01 +1.483482E-01 +4.595809E-01 +2.112146E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.595809E-01 +2.112146E-01 +3.851599E-01 +1.483482E-01 +4.679967E-01 +2.190209E-01 +4.970187E-01 +2.470276E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.970187E-01 +2.470276E-01 +4.679967E-01 +2.190209E-01 +4.909661E-01 +2.410477E-01 +4.838785E-01 +2.341384E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.838785E-01 +2.341384E-01 +4.909661E-01 +2.410477E-01 +5.152690E-01 +2.655021E-01 +4.788649E-01 +2.293116E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.788649E-01 +2.293116E-01 +5.152690E-01 +2.655021E-01 +4.266876E-01 +1.820623E-01 +3.401342E-01 +1.156913E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.401342E-01 +1.156913E-01 +4.266876E-01 +1.820623E-01 +3.724186E-01 +1.386956E-01 +2.560013E-01 +6.553669E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.560013E-01 +6.553669E-02 +3.724186E-01 +1.386956E-01 +2.892134E-01 +8.364439E-02 +1.556176E-01 +2.421685E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.556176E-01 +2.421685E-02 +2.892134E-01 +8.364439E-02 +1.497744E-01 +2.243237E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +tally 5: +7.459301E-01 +5.564117E-01 +1.149820E-01 +1.322085E-02 +1.356702E+00 +1.840641E+00 +1.801102E-01 +3.243968E-02 +2.047332E+00 +4.191570E+00 +2.627497E-01 +6.903740E-02 +2.609217E+00 +6.808012E+00 +3.360314E-01 +1.129171E-01 +2.909457E+00 +8.464941E+00 +4.095451E-01 +1.677272E-01 +2.805131E+00 +7.868760E+00 +3.957627E-01 +1.566281E-01 +2.415727E+00 +5.835736E+00 +3.196414E-01 +1.021706E-01 +2.049859E+00 +4.201923E+00 +3.162399E-01 +1.000077E-01 +1.593746E+00 +2.540026E+00 +2.169985E-01 +4.708836E-02 +7.994935E-01 +6.391898E-01 +1.002481E-01 +1.004969E-02 +cmfd indices +1.000000E+01 +1.000000E+00 +1.000000E+00 +1.000000E+00 +k cmfd +1.143597E+00 +1.163387E+00 +1.173384E+00 +1.171035E+00 +1.147196E+00 +1.122260E+00 +1.106380E+00 +1.124693E+00 +1.133192E+00 +1.134435E+00 +1.142380E+00 +1.132168E+00 +1.132560E+00 +1.153781E+00 +1.170308E+00 +1.184540E+00 +cmfd entropy +3.212002E+00 +3.206393E+00 +3.223984E+00 +3.222764E+00 +3.232123E+00 +3.242083E+00 +3.246067E+00 +3.238869E+00 +3.235585E+00 +3.234611E+00 +3.233575E+00 +3.236922E+00 +3.229545E+00 +3.225232E+00 +3.221485E+00 +3.219108E+00 +cmfd balance +8.26180E-03 +4.27338E-03 +2.22686E-03 +1.93026E-03 +1.96979E-03 +2.13756E-03 +2.01479E-03 +1.74519E-03 +2.09248E-03 +1.25545E-03 +1.48370E-03 +1.75963E-03 +1.98194E-03 +1.87306E-03 +1.24780E-03 +1.15560E-03 +cmfd dominance ratio +5.404E-01 +5.406E-01 +5.449E-01 +5.473E-01 +5.534E-01 +5.623E-01 +5.738E-01 +5.611E-01 +5.569E-01 +5.556E-01 +5.555E-01 +5.583E-01 +5.544E-01 +5.486E-01 +5.412E-01 +5.383E-01 +cmfd openmc source comparison +1.575499E-02 +1.293688E-02 +3.531746E-03 +8.281178E-03 +5.771681E-03 +7.459013E-03 +5.012869E-03 +1.770224E-03 +5.242540E-03 +3.888027E-03 +6.653433E-03 +8.839928E-03 +5.456904E-03 +5.668412E-03 +4.016377E-03 +4.179381E-03 +cmfd source +4.116210E-02 +7.797480E-02 +1.062822E-01 +1.333719E-01 +1.481091E-01 +1.370422E-01 +1.299765E-01 +9.887040E-02 +8.228753E-02 +4.492330E-02 diff --git a/tests/regression_tests/cmfd_feed_expanding_window/settings.xml b/tests/regression_tests/cmfd_feed_expanding_window/settings.xml new file mode 100644 index 000000000..24b0b6ab5 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_expanding_window/settings.xml @@ -0,0 +1,26 @@ + + + + + eigenvalue + 20 + 10 + 1000 + + + + + box + -10 -1 -1 10 1 1 + + + + + + 10 1 1 + -10.0 -1.0 -1.0 + 10.0 1.0 1.0 + + 10 + + diff --git a/tests/regression_tests/cmfd_feed_expanding_window/tallies.xml b/tests/regression_tests/cmfd_feed_expanding_window/tallies.xml new file mode 100644 index 000000000..c86971114 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_expanding_window/tallies.xml @@ -0,0 +1,21 @@ + + + + + regular + -10 -1 -1 + 10 1 1 + 10 1 1 + + + + mesh + 1 + + + + 1 + flux + + + diff --git a/tests/regression_tests/cmfd_feed_expanding_window/test.py b/tests/regression_tests/cmfd_feed_expanding_window/test.py new file mode 100644 index 000000000..e8671e95c --- /dev/null +++ b/tests/regression_tests/cmfd_feed_expanding_window/test.py @@ -0,0 +1,26 @@ +from tests.testing_harness import CMFDTestHarness +from openmc import cmfd + + +def test_cmfd_feed_rolling_window(): + """Test 1 group CMFD solver with CMFD feedback""" + # Initialize and set CMFD mesh + cmfd_mesh = cmfd.CMFDMesh() + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) + + # Initialize and run CMFDRun object + cmfd_run = cmfd.CMFDRun() + cmfd_run.mesh = cmfd_mesh + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 10 + cmfd_run.feedback = True + cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] + cmfd_run.window_type = 'expanding' + cmfd_run.run() + + # Initialize and run CMFD test harness + harness = CMFDTestHarness('statepoint.20.h5', cmfd_run) + harness.main() diff --git a/tests/regression_tests/cmfd_feed_ng/results_true.dat b/tests/regression_tests/cmfd_feed_ng/results_true.dat index 707411459..d62fb5b4b 100644 --- a/tests/regression_tests/cmfd_feed_ng/results_true.dat +++ b/tests/regression_tests/cmfd_feed_ng/results_true.dat @@ -222,7 +222,7 @@ tally 4: 2.662637E-01 2.719284E+01 4.625227E+01 -7.106614E+00 +7.106615E+00 3.182962E+00 2.092906E+00 2.757959E-01 @@ -276,7 +276,7 @@ tally 4: 0.000000E+00 0.000000E+00 0.000000E+00 -7.106614E+00 +7.106615E+00 3.182962E+00 2.092906E+00 2.757959E-01 @@ -572,7 +572,7 @@ cmfd entropy 1.999693E+00 cmfd balance 8.98944E-04 -4.45875E-04 +4.45874E-04 2.18562E-04 2.83412E-04 3.60924E-04 @@ -599,13 +599,13 @@ cmfd openmc source comparison 2.585546E-05 2.217204E-05 2.121913E-05 -9.253920E-06 -2.940945E-05 -3.083595E-05 -2.547490E-05 -2.602689E-05 -2.561168E-05 -2.816824E-05 +9.253928E-06 +2.940947E-05 +3.083596E-05 +2.547491E-05 +2.602691E-05 +2.561169E-05 +2.816825E-05 cmfd source 2.417661E-01 2.547768E-01 diff --git a/tests/regression_tests/cmfd_feed_ng/test.py b/tests/regression_tests/cmfd_feed_ng/test.py index db0b44f3e..dce674f90 100644 --- a/tests/regression_tests/cmfd_feed_ng/test.py +++ b/tests/regression_tests/cmfd_feed_ng/test.py @@ -7,17 +7,18 @@ def test_cmfd_feed_ng(): """Test n group CMFD solver with CMFD feedback""" # Initialize and set CMFD mesh cmfd_mesh = cmfd.CMFDMesh() - cmfd_mesh.lower_left = -1.25984, -1.25984, -1.0 - cmfd_mesh.upper_right = 1.25984, 1.25984, 1.0 - cmfd_mesh.dimension = 2, 2, 1 - cmfd_mesh.energy = [0.0, 0.625, 5.53080, 20000000] - cmfd_mesh.albedo = 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 + cmfd_mesh.lower_left = (-1.25984, -1.25984, -1.0) + cmfd_mesh.upper_right = (1.25984, 1.25984, 1.0) + cmfd_mesh.dimension = (2, 2, 1) + cmfd_mesh.energy = (0.0, 0.625, 5.53080, 20000000) + cmfd_mesh.albedo = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0) # Initialize and run CMFDRun object cmfd_run = cmfd.CMFDRun() cmfd_run.mesh = cmfd_mesh cmfd_run.reset = [5] - cmfd_run.begin = 10 + cmfd_run.tally_begin = 10 + cmfd_run.feedback_begin = 10 cmfd_run.display = {'dominance': True} cmfd_run.feedback = True cmfd_run.downscatter = True diff --git a/tests/regression_tests/cmfd_feed_ref_d/__init__.py b/tests/regression_tests/cmfd_feed_ref_d/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/regression_tests/cmfd_feed_ref_d/geometry.xml b/tests/regression_tests/cmfd_feed_ref_d/geometry.xml new file mode 100644 index 000000000..73ea679c4 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_ref_d/geometry.xml @@ -0,0 +1,43 @@ + + + + + + 0 + -1 2 -3 4 -5 6 + 1 + + + + + x-plane + 10 + vacuum + + + x-plane + -10 + vacuum + + + y-plane + 1 + reflective + + + y-plane + -1 + reflective + + + z-plane + 1 + reflective + + + z-plane + -1 + reflective + + + diff --git a/tests/regression_tests/cmfd_feed_ref_d/materials.xml b/tests/regression_tests/cmfd_feed_ref_d/materials.xml new file mode 100644 index 000000000..70580e3a8 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_ref_d/materials.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/regression_tests/cmfd_feed_ref_d/results_true.dat b/tests/regression_tests/cmfd_feed_ref_d/results_true.dat new file mode 100644 index 000000000..06440d81f --- /dev/null +++ b/tests/regression_tests/cmfd_feed_ref_d/results_true.dat @@ -0,0 +1,488 @@ +k-combined: +1.165408E+00 1.127320E-02 +tally 1: +1.141009E+01 +1.305436E+01 +2.074878E+01 +4.311543E+01 +2.834824E+01 +8.065180E+01 +3.513901E+01 +1.238542E+02 +3.699846E+01 +1.372507E+02 +3.612638E+01 +1.310741E+02 +3.373329E+01 +1.140431E+02 +2.836806E+01 +8.075546E+01 +2.158796E+01 +4.674672E+01 +1.141841E+01 +1.310586E+01 +tally 2: +1.126662E+00 +1.269368E+00 +7.749275E-01 +6.005127E-01 +1.991651E+00 +3.966673E+00 +1.411802E+00 +1.993185E+00 +2.978294E+00 +8.870233E+00 +2.130084E+00 +4.537258E+00 +3.708845E+00 +1.375553E+01 +2.698001E+00 +7.279210E+00 +4.233143E+00 +1.791950E+01 +3.023958E+00 +9.144324E+00 +4.062060E+00 +1.650033E+01 +2.910435E+00 +8.470632E+00 +3.506628E+00 +1.229644E+01 +2.497713E+00 +6.238573E+00 +2.974637E+00 +8.848463E+00 +2.121135E+00 +4.499215E+00 +2.329228E+00 +5.425303E+00 +1.658218E+00 +2.749687E+00 +1.158542E+00 +1.342220E+00 +8.282626E-01 +6.860190E-01 +tally 3: +7.459525E-01 +5.564451E-01 +4.877161E-02 +2.378670E-03 +1.356729E+00 +1.840713E+00 +8.360848E-02 +6.990377E-03 +2.047350E+00 +4.191641E+00 +1.521210E-01 +2.314079E-02 +2.610278E+00 +6.813552E+00 +1.718619E-01 +2.953650E-02 +2.911348E+00 +8.475950E+00 +1.823129E-01 +3.323800E-02 +2.806884E+00 +7.878600E+00 +2.090212E-01 +4.368986E-02 +2.415690E+00 +5.835559E+00 +1.486373E-01 +2.209304E-02 +2.051037E+00 +4.206752E+00 +1.196066E-01 +1.430573E-02 +1.593732E+00 +2.539980E+00 +1.126392E-01 +1.268759E-02 +7.994865E-01 +6.391786E-01 +5.806144E-02 +3.371131E-03 +tally 4: +1.341763E-01 +1.800329E-02 +0.000000E+00 +0.000000E+00 +1.420749E-01 +2.018527E-02 +2.633206E-01 +6.933776E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.633206E-01 +6.933776E-02 +1.420749E-01 +2.018527E-02 +2.628684E-01 +6.909981E-02 +3.590428E-01 +1.289117E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.590428E-01 +1.289117E-01 +2.628684E-01 +6.909981E-02 +3.851638E-01 +1.483512E-01 +4.595776E-01 +2.112116E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.595776E-01 +2.112116E-01 +3.851638E-01 +1.483512E-01 +4.679953E-01 +2.190196E-01 +4.970127E-01 +2.470216E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.970127E-01 +2.470216E-01 +4.679953E-01 +2.190196E-01 +4.909606E-01 +2.410423E-01 +4.838733E-01 +2.341333E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.838733E-01 +2.341333E-01 +4.909606E-01 +2.410423E-01 +5.152620E-01 +2.654949E-01 +4.788580E-01 +2.293049E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.788580E-01 +2.293049E-01 +5.152620E-01 +2.654949E-01 +4.266812E-01 +1.820568E-01 +3.401298E-01 +1.156883E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.401298E-01 +1.156883E-01 +4.266812E-01 +1.820568E-01 +3.724142E-01 +1.386923E-01 +2.559996E-01 +6.553579E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.559996E-01 +6.553579E-02 +3.724142E-01 +1.386923E-01 +2.892105E-01 +8.364271E-02 +1.556166E-01 +2.421652E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.556166E-01 +2.421652E-02 +2.892105E-01 +8.364271E-02 +1.497731E-01 +2.243198E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +tally 5: +7.459525E-01 +5.564451E-01 +1.149859E-01 +1.322177E-02 +1.356729E+00 +1.840713E+00 +1.801152E-01 +3.244149E-02 +2.047350E+00 +4.191641E+00 +2.627538E-01 +6.903954E-02 +2.609208E+00 +6.807967E+00 +3.360312E-01 +1.129170E-01 +2.909427E+00 +8.464765E+00 +4.095398E-01 +1.677229E-01 +2.805095E+00 +7.868559E+00 +3.957580E-01 +1.566244E-01 +2.415690E+00 +5.835559E+00 +3.196366E-01 +1.021676E-01 +2.049833E+00 +4.201813E+00 +3.162366E-01 +1.000056E-01 +1.593732E+00 +2.539980E+00 +2.169968E-01 +4.708761E-02 +7.994865E-01 +6.391786E-01 +1.002479E-01 +1.004964E-02 +cmfd indices +1.000000E+01 +1.000000E+00 +1.000000E+00 +1.000000E+00 +k cmfd +1.143785E+00 +1.163460E+00 +1.173453E+00 +1.171056E+00 +1.147214E+00 +1.122230E+00 +1.106385E+00 +1.124706E+00 +1.133207E+00 +1.134453E+00 +1.142355E+00 +1.132121E+00 +1.132479E+00 +1.153657E+00 +1.170183E+00 +1.184408E+00 +cmfd entropy +3.211758E+00 +3.206356E+00 +3.223933E+00 +3.222754E+00 +3.232110E+00 +3.242098E+00 +3.246062E+00 +3.238858E+00 +3.235577E+00 +3.234604E+00 +3.233582E+00 +3.236922E+00 +3.229563E+00 +3.225265E+00 +3.221498E+00 +3.219126E+00 +cmfd balance +8.26180E-03 +4.27338E-03 +2.22686E-03 +1.93026E-03 +1.96979E-03 +2.13756E-03 +2.01521E-03 +1.74538E-03 +2.09240E-03 +1.25495E-03 +1.49542E-03 +1.76968E-03 +1.99174E-03 +1.87753E-03 +1.24170E-03 +1.15645E-03 +cmfd dominance ratio +5.408E-01 +5.374E-01 +5.420E-01 +5.444E-01 +5.513E-01 +5.613E-01 +5.722E-01 +5.592E-01 +5.542E-01 +5.537E-01 +5.541E-01 +5.579E-01 +5.543E-01 +5.487E-01 +5.413E-01 +5.381E-01 +cmfd openmc source comparison +1.597982E-02 +1.276493E-02 +3.495229E-03 +8.157807E-03 +5.715330E-03 +7.433111E-03 +5.006211E-03 +1.766072E-03 +5.184425E-03 +3.864321E-03 +6.617152E-03 +8.841210E-03 +5.454747E-03 +5.652690E-03 +4.006767E-03 +4.167617E-03 +cmfd source +4.116746E-02 +7.798354E-02 +1.062881E-01 +1.333681E-01 +1.481008E-01 +1.370408E-01 +1.299726E-01 +9.886814E-02 +8.228698E-02 +4.492338E-02 diff --git a/tests/regression_tests/cmfd_feed_ref_d/settings.xml b/tests/regression_tests/cmfd_feed_ref_d/settings.xml new file mode 100644 index 000000000..24b0b6ab5 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_ref_d/settings.xml @@ -0,0 +1,26 @@ + + + + + eigenvalue + 20 + 10 + 1000 + + + + + box + -10 -1 -1 10 1 1 + + + + + + 10 1 1 + -10.0 -1.0 -1.0 + 10.0 1.0 1.0 + + 10 + + diff --git a/tests/regression_tests/cmfd_feed_ref_d/tallies.xml b/tests/regression_tests/cmfd_feed_ref_d/tallies.xml new file mode 100644 index 000000000..c86971114 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_ref_d/tallies.xml @@ -0,0 +1,21 @@ + + + + + regular + -10 -1 -1 + 10 1 1 + 10 1 1 + + + + mesh + 1 + + + + 1 + flux + + + diff --git a/tests/regression_tests/cmfd_feed_ref_d/test.py b/tests/regression_tests/cmfd_feed_ref_d/test.py new file mode 100644 index 000000000..d033ab8dd --- /dev/null +++ b/tests/regression_tests/cmfd_feed_ref_d/test.py @@ -0,0 +1,27 @@ +from tests.testing_harness import CMFDTestHarness +from openmc import cmfd + + +def test_cmfd_feed_rolling_window(): + """Test 1 group CMFD solver with CMFD feedback""" + # Initialize and set CMFD mesh + cmfd_mesh = cmfd.CMFDMesh() + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) + + # Initialize and run CMFDRun object + cmfd_run = cmfd.CMFDRun() + cmfd_run.mesh = cmfd_mesh + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 10 + cmfd_run.feedback = True + cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] + cmfd_run.window_type = 'expanding' + cmfd_run.ref_d = [0.542] + cmfd_run.run() + + # Initialize and run CMFD test harness + harness = CMFDTestHarness('statepoint.20.h5', cmfd_run) + harness.main() diff --git a/tests/regression_tests/cmfd_feed_rolling_window/__init__.py b/tests/regression_tests/cmfd_feed_rolling_window/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/regression_tests/cmfd_feed_rolling_window/geometry.xml b/tests/regression_tests/cmfd_feed_rolling_window/geometry.xml new file mode 100644 index 000000000..73ea679c4 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_rolling_window/geometry.xml @@ -0,0 +1,43 @@ + + + + + + 0 + -1 2 -3 4 -5 6 + 1 + + + + + x-plane + 10 + vacuum + + + x-plane + -10 + vacuum + + + y-plane + 1 + reflective + + + y-plane + -1 + reflective + + + z-plane + 1 + reflective + + + z-plane + -1 + reflective + + + diff --git a/tests/regression_tests/cmfd_feed_rolling_window/materials.xml b/tests/regression_tests/cmfd_feed_rolling_window/materials.xml new file mode 100644 index 000000000..70580e3a8 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_rolling_window/materials.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/regression_tests/cmfd_feed_rolling_window/results_true.dat b/tests/regression_tests/cmfd_feed_rolling_window/results_true.dat new file mode 100644 index 000000000..518052683 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_rolling_window/results_true.dat @@ -0,0 +1,488 @@ +k-combined: +1.172120E+00 9.761693E-03 +tally 1: +1.131066E+01 +1.287315E+01 +2.035268E+01 +4.162146E+01 +2.839961E+01 +8.098764E+01 +3.405187E+01 +1.164951E+02 +3.712390E+01 +1.380899E+02 +3.687780E+01 +1.363090E+02 +3.380903E+01 +1.147695E+02 +2.903657E+01 +8.489183E+01 +2.121421E+01 +4.519765E+01 +1.112628E+01 +1.245629E+01 +tally 2: +1.114845E+00 +1.242879E+00 +8.000235E-01 +6.400375E-01 +1.852141E+00 +3.430427E+00 +1.324803E+00 +1.755104E+00 +2.585263E+00 +6.683587E+00 +1.840969E+00 +3.389167E+00 +3.737263E+00 +1.396714E+01 +2.674345E+00 +7.152122E+00 +3.989056E+00 +1.591257E+01 +2.843382E+00 +8.084820E+00 +3.951710E+00 +1.561601E+01 +2.838216E+00 +8.055468E+00 +3.734018E+00 +1.394289E+01 +2.676071E+00 +7.161356E+00 +3.241209E+00 +1.050543E+01 +2.315684E+00 +5.362392E+00 +2.459493E+00 +6.049108E+00 +1.734344E+00 +3.007949E+00 +1.079306E+00 +1.164902E+00 +7.536940E-01 +5.680547E-01 +tally 3: +7.728275E-01 +5.972624E-01 +5.550061E-02 +3.080318E-03 +1.272034E+00 +1.618070E+00 +7.284456E-02 +5.306329E-03 +1.779821E+00 +3.167762E+00 +1.110012E-01 +1.232127E-02 +2.586020E+00 +6.687502E+00 +1.618768E-01 +2.620410E-02 +2.726552E+00 +7.434084E+00 +1.965647E-01 +3.863767E-02 +2.741747E+00 +7.517178E+00 +1.907834E-01 +3.639829E-02 +2.564084E+00 +6.574527E+00 +1.503142E-01 +2.259435E-02 +2.233122E+00 +4.986832E+00 +1.456891E-01 +2.122532E-02 +1.682929E+00 +2.832250E+00 +9.828234E-02 +9.659418E-03 +7.232788E-01 +5.231322E-01 +6.128193E-02 +3.755475E-03 +tally 4: +1.326662E-01 +1.760031E-02 +0.000000E+00 +0.000000E+00 +1.369313E-01 +1.875018E-02 +2.569758E-01 +6.603657E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.569758E-01 +6.603657E-02 +1.369313E-01 +1.875018E-02 +2.494513E-01 +6.222596E-02 +3.551002E-01 +1.260962E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.551002E-01 +1.260962E-01 +2.494513E-01 +6.222596E-02 +3.610027E-01 +1.303230E-01 +4.252566E-01 +1.808432E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.252566E-01 +1.808432E-01 +3.610027E-01 +1.303230E-01 +4.673502E-01 +2.184162E-01 +5.073957E-01 +2.574504E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +5.073957E-01 +2.574504E-01 +4.673502E-01 +2.184162E-01 +4.818855E-01 +2.322136E-01 +4.949753E-01 +2.450006E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.949753E-01 +2.450006E-01 +4.818855E-01 +2.322136E-01 +5.176611E-01 +2.679730E-01 +4.756654E-01 +2.262576E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +4.756654E-01 +2.262576E-01 +5.176611E-01 +2.679730E-01 +4.591191E-01 +2.107904E-01 +3.930251E-01 +1.544688E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.930251E-01 +1.544688E-01 +4.591191E-01 +2.107904E-01 +4.201532E-01 +1.765287E-01 +3.188250E-01 +1.016494E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +3.188250E-01 +1.016494E-01 +4.201532E-01 +1.765287E-01 +2.898817E-01 +8.403142E-02 +1.509185E-01 +2.277639E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +1.509185E-01 +2.277639E-02 +2.898817E-01 +8.403142E-02 +1.482175E-01 +2.196844E-02 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +tally 5: +7.719619E-01 +5.959252E-01 +8.168322E-02 +6.672148E-03 +1.272034E+00 +1.618070E+00 +1.458271E-01 +2.126554E-02 +1.779821E+00 +3.167762E+00 +2.705917E-01 +7.321987E-02 +2.584069E+00 +6.677414E+00 +3.176497E-01 +1.009013E-01 +2.726552E+00 +7.434084E+00 +3.562714E-01 +1.269293E-01 +2.740788E+00 +7.511919E+00 +3.690107E-01 +1.361689E-01 +2.563145E+00 +6.569715E+00 +3.296244E-01 +1.086523E-01 +2.233122E+00 +4.986832E+00 +3.106254E-01 +9.648813E-02 +1.682929E+00 +2.832250E+00 +2.709632E-01 +7.342104E-02 +7.232788E-01 +5.231322E-01 +9.343486E-02 +8.730073E-03 +cmfd indices +1.000000E+01 +1.000000E+00 +1.000000E+00 +1.000000E+00 +k cmfd +1.143597E+00 +1.163387E+00 +1.162391E+00 +1.163351E+00 +1.145721E+00 +1.134785E+00 +1.119048E+00 +1.116124E+00 +1.109085E+00 +1.126581E+00 +1.158559E+00 +1.163719E+00 +1.162162E+00 +1.160856E+00 +1.166709E+00 +1.167223E+00 +cmfd entropy +3.212002E+00 +3.206393E+00 +3.222109E+00 +3.221996E+00 +3.229978E+00 +3.234615E+00 +3.246512E+00 +3.244634E+00 +3.244312E+00 +3.236922E+00 +3.232693E+00 +3.221849E+00 +3.215716E+00 +3.215968E+00 +3.203758E+00 +3.201798E+00 +cmfd balance +8.26180E-03 +4.27338E-03 +2.62159E-03 +2.40301E-03 +2.08484E-03 +1.58351E-03 +1.59196E-03 +1.87591E-03 +1.94451E-03 +1.91803E-03 +1.90044E-03 +1.87968E-03 +2.55363E-03 +2.39932E-03 +2.25515E-03 +1.53613E-03 +cmfd dominance ratio +5.404E-01 +5.406E-01 +5.432E-01 +5.454E-01 +5.507E-01 +5.578E-01 +5.679E-01 +5.671E-01 +5.690E-01 +5.637E-01 +5.575E-01 +5.474E-01 +5.480E-01 +5.467E-01 +5.374E-01 +5.321E-01 +cmfd openmc source comparison +1.575499E-02 +1.293688E-02 +5.920734E-03 +9.746850E-03 +7.183896E-03 +7.693485E-03 +4.158805E-03 +2.962505E-03 +4.415044E-03 +2.304495E-03 +7.921580E-03 +8.609203E-03 +8.945198E-03 +8.054204E-03 +1.164189E-02 +5.945645E-03 +cmfd source +4.077779E-02 +6.659143E-02 +1.017198E-01 +1.172269E-01 +1.458410E-01 +1.559801E-01 +1.337001E-01 +1.137262E-01 +8.397376E-02 +4.046290E-02 diff --git a/tests/regression_tests/cmfd_feed_rolling_window/settings.xml b/tests/regression_tests/cmfd_feed_rolling_window/settings.xml new file mode 100644 index 000000000..24b0b6ab5 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_rolling_window/settings.xml @@ -0,0 +1,26 @@ + + + + + eigenvalue + 20 + 10 + 1000 + + + + + box + -10 -1 -1 10 1 1 + + + + + + 10 1 1 + -10.0 -1.0 -1.0 + 10.0 1.0 1.0 + + 10 + + diff --git a/tests/regression_tests/cmfd_feed_rolling_window/tallies.xml b/tests/regression_tests/cmfd_feed_rolling_window/tallies.xml new file mode 100644 index 000000000..c86971114 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_rolling_window/tallies.xml @@ -0,0 +1,21 @@ + + + + + regular + -10 -1 -1 + 10 1 1 + 10 1 1 + + + + mesh + 1 + + + + 1 + flux + + + diff --git a/tests/regression_tests/cmfd_feed_rolling_window/test.py b/tests/regression_tests/cmfd_feed_rolling_window/test.py new file mode 100644 index 000000000..802b5b700 --- /dev/null +++ b/tests/regression_tests/cmfd_feed_rolling_window/test.py @@ -0,0 +1,27 @@ +from tests.testing_harness import CMFDTestHarness +from openmc import cmfd + + +def test_cmfd_feed_rolling_window(): + """Test 1 group CMFD solver with CMFD feedback""" + # Initialize and set CMFD mesh + cmfd_mesh = cmfd.CMFDMesh() + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) + + # Initialize and run CMFDRun object + cmfd_run = cmfd.CMFDRun() + cmfd_run.mesh = cmfd_mesh + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 10 + cmfd_run.feedback = True + cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] + cmfd_run.window_type = 'rolling' + cmfd_run.window_size = 5 + cmfd_run.run() + + # Initialize and run CMFD test harness + harness = CMFDTestHarness('statepoint.20.h5', cmfd_run) + harness.main() diff --git a/tests/regression_tests/cmfd_nofeed/test.py b/tests/regression_tests/cmfd_nofeed/test.py index 36f693026..7d0895c2f 100644 --- a/tests/regression_tests/cmfd_nofeed/test.py +++ b/tests/regression_tests/cmfd_nofeed/test.py @@ -7,15 +7,15 @@ def test_cmfd_nofeed(): """Test 1 group CMFD solver without CMFD feedback""" # Initialize and set CMFD mesh cmfd_mesh = cmfd.CMFDMesh() - cmfd_mesh.lower_left = -10.0, -1.0, -1.0 - cmfd_mesh.upper_right = 10.0, 1.0, 1.0 - cmfd_mesh.dimension = 10, 1, 1 - cmfd_mesh.albedo = 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) # Initialize and run CMFDRun object cmfd_run = cmfd.CMFDRun() cmfd_run.mesh = cmfd_mesh - cmfd_run.begin = 5 + cmfd_run.tally_begin = 5 cmfd_run.display = {'dominance': True} cmfd_run.feedback = False cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] diff --git a/tests/regression_tests/cmfd_restart/__init__.py b/tests/regression_tests/cmfd_restart/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/regression_tests/cmfd_restart/geometry.xml b/tests/regression_tests/cmfd_restart/geometry.xml new file mode 100644 index 000000000..73ea679c4 --- /dev/null +++ b/tests/regression_tests/cmfd_restart/geometry.xml @@ -0,0 +1,43 @@ + + + + + + 0 + -1 2 -3 4 -5 6 + 1 + + + + + x-plane + 10 + vacuum + + + x-plane + -10 + vacuum + + + y-plane + 1 + reflective + + + y-plane + -1 + reflective + + + z-plane + 1 + reflective + + + z-plane + -1 + reflective + + + diff --git a/tests/regression_tests/cmfd_restart/materials.xml b/tests/regression_tests/cmfd_restart/materials.xml new file mode 100644 index 000000000..70580e3a8 --- /dev/null +++ b/tests/regression_tests/cmfd_restart/materials.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/regression_tests/cmfd_restart/results_true.dat b/tests/regression_tests/cmfd_restart/results_true.dat new file mode 100644 index 000000000..4a2c6eea2 --- /dev/null +++ b/tests/regression_tests/cmfd_restart/results_true.dat @@ -0,0 +1,488 @@ +k-combined: +1.169891E+00 6.289489E-03 +tally 1: +1.173922E+01 +1.385461E+01 +2.164076E+01 +4.699368E+01 +2.906462E+01 +8.464937E+01 +3.382312E+01 +1.147095E+02 +3.632006E+01 +1.323878E+02 +3.655413E+01 +1.341064E+02 +3.347757E+01 +1.124264E+02 +2.931336E+01 +8.607239E+01 +2.182947E+01 +4.789565E+01 +1.147668E+01 +1.325716E+01 +tally 2: +2.298190E+01 +2.667071E+01 +1.600292E+01 +1.293670E+01 +4.268506E+01 +9.161216E+01 +3.022909E+01 +4.598915E+01 +5.680399E+01 +1.623879E+02 +4.033805E+01 +8.196263E+01 +6.814742E+01 +2.331778E+02 +4.851618E+01 +1.182330E+02 +7.392923E+01 +2.740255E+02 +5.253586E+01 +1.384152E+02 +7.332860E+01 +2.698608E+02 +5.227405E+01 +1.371810E+02 +6.830172E+01 +2.340687E+02 +4.867159E+01 +1.188724E+02 +5.885634E+01 +1.736180E+02 +4.170434E+01 +8.719622E+01 +4.371848E+01 +9.592893E+01 +3.106403E+01 +4.844308E+01 +2.338413E+01 +2.752467E+01 +1.636713E+01 +1.347770E+01 +tally 3: +1.538752E+01 +1.196478E+01 +1.079685E+00 +6.010786E-02 +2.911906E+01 +4.269070E+01 +1.822657E+00 +1.671850E-01 +3.885421E+01 +7.608218E+01 +2.541516E+00 +3.262451E-01 +4.673300E+01 +1.097036E+02 +2.885307E+00 +4.214444E-01 +5.059247E+01 +1.283984E+02 +3.222796E+00 +5.237329E-01 +5.034856E+01 +1.272538E+02 +3.230225E+00 +5.273424E-01 +4.688476E+01 +1.103152E+02 +2.941287E+00 +4.363749E-01 +4.013746E+01 +8.077506E+01 +2.634234E+00 +3.520270E-01 +2.996887E+01 +4.509953E+01 +1.946504E+00 +1.919104E-01 +1.575260E+01 +1.248707E+01 +1.020705E+00 +5.413569E-02 +tally 4: +3.049469E+00 +4.677325E-01 +0.000000E+00 +0.000000E+00 +2.770358E+00 +3.879191E-01 +5.514939E+00 +1.528899E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +5.514939E+00 +1.528899E+00 +2.770358E+00 +3.879191E-01 +5.032131E+00 +1.275040E+00 +7.294002E+00 +2.675589E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +7.294002E+00 +2.675589E+00 +5.032131E+00 +1.275040E+00 +7.036008E+00 +2.490718E+00 +8.668860E+00 +3.776102E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +8.668860E+00 +3.776102E+00 +7.036008E+00 +2.490718E+00 +8.352414E+00 +3.501945E+00 +9.345868E+00 +4.380719E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.345868E+00 +4.380719E+00 +8.352414E+00 +3.501945E+00 +9.093766E+00 +4.158282E+00 +9.223771E+00 +4.270120E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +9.223771E+00 +4.270120E+00 +9.093766E+00 +4.158282E+00 +9.219150E+00 +4.264346E+00 +8.530966E+00 +3.651778E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +8.530966E+00 +3.651778E+00 +9.219150E+00 +4.264346E+00 +8.690373E+00 +3.785262E+00 +7.204424E+00 +2.604203E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +7.204424E+00 +2.604203E+00 +8.690373E+00 +3.785262E+00 +7.513640E+00 +2.833028E+00 +5.326721E+00 +1.426975E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +5.326721E+00 +1.426975E+00 +7.513640E+00 +2.833028E+00 +5.662215E+00 +1.607757E+00 +2.848381E+00 +4.093396E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +2.848381E+00 +4.093396E-01 +5.662215E+00 +1.607757E+00 +3.025812E+00 +4.597241E-01 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +0.000000E+00 +tally 5: +1.538652E+01 +1.196332E+01 +2.252427E+00 +2.605738E-01 +2.911344E+01 +4.267319E+01 +3.873926E+00 +7.615035E-01 +3.884516E+01 +7.604619E+01 +5.280610E+00 +1.414008E+00 +4.672391E+01 +1.096625E+02 +6.261805E+00 +1.983205E+00 +5.058447E+01 +1.283588E+02 +6.733810E+00 +2.278242E+00 +5.033589E+01 +1.271898E+02 +6.714658E+00 +2.273652E+00 +4.687563E+01 +1.102719E+02 +6.215002E+00 +1.956978E+00 +4.013134E+01 +8.075062E+01 +5.253064E+00 +1.396224E+00 +2.996497E+01 +4.508839E+01 +3.818076E+00 +7.509442E-01 +1.574994E+01 +1.248291E+01 +2.219928E+00 +2.515492E-01 +cmfd indices +1.000000E+01 +1.000000E+00 +1.000000E+00 +1.000000E+00 +k cmfd +1.170416E+00 +1.172966E+00 +1.165537E+00 +1.170979E+00 +1.161922E+00 +1.157523E+00 +1.158873E+00 +1.162877E+00 +1.167101E+00 +1.168130E+00 +1.170570E+00 +1.168115E+00 +1.174081E+00 +1.169458E+00 +1.167848E+00 +1.165116E+00 +cmfd entropy +3.203643E+00 +3.207943E+00 +3.213367E+00 +3.214360E+00 +3.219634E+00 +3.222232E+00 +3.221744E+00 +3.224544E+00 +3.225990E+00 +3.227769E+00 +3.227417E+00 +3.230728E+00 +3.231662E+00 +3.233316E+00 +3.233193E+00 +3.232564E+00 +cmfd balance +4.00906E-03 +4.43177E-03 +3.15267E-03 +3.51038E-03 +2.05209E-03 +2.06865E-03 +1.50243E-03 +1.58983E-03 +1.56602E-03 +1.17001E-03 +9.50759E-04 +9.07259E-04 +1.00900E-03 +1.06470E-03 +1.16361E-03 +9.75631E-04 +cmfd dominance ratio +5.397E-01 +5.425E-01 +5.481E-01 +5.473E-01 +5.503E-01 +5.502E-01 +5.483E-01 +5.520E-01 +5.505E-01 +3.216E-01 +5.373E-01 +5.517E-01 +5.508E-01 +5.524E-01 +5.524E-01 +5.523E-01 +cmfd openmc source comparison +6.959834E-03 +5.655657E-03 +3.886186E-03 +4.035116E-03 +3.043277E-03 +5.455474E-03 +4.515310E-03 +2.439840E-03 +2.114032E-03 +2.673132E-03 +2.431749E-03 +4.330928E-03 +3.404647E-03 +3.680298E-03 +3.309620E-03 +3.705541E-03 +cmfd source +4.697085E-02 +7.920706E-02 +1.107968E-01 +1.250932E-01 +1.383930E-01 +1.380648E-01 +1.246874E-01 +1.113705E-01 +8.203754E-02 +4.337882E-02 diff --git a/tests/regression_tests/cmfd_restart/settings.xml b/tests/regression_tests/cmfd_restart/settings.xml new file mode 100644 index 000000000..ba5495911 --- /dev/null +++ b/tests/regression_tests/cmfd_restart/settings.xml @@ -0,0 +1,28 @@ + + + + + eigenvalue + 20 + 10 + 1000 + + + + + box + -10 -1 -1 10 1 1 + + + + + + 10 1 1 + -10.0 -1.0 -1.0 + 10.0 1.0 1.0 + + 10 + + + + diff --git a/tests/regression_tests/cmfd_restart/tallies.xml b/tests/regression_tests/cmfd_restart/tallies.xml new file mode 100644 index 000000000..c86971114 --- /dev/null +++ b/tests/regression_tests/cmfd_restart/tallies.xml @@ -0,0 +1,21 @@ + + + + + regular + -10 -1 -1 + 10 1 1 + 10 1 1 + + + + mesh + 1 + + + + 1 + flux + + + diff --git a/tests/regression_tests/cmfd_restart/test.py b/tests/regression_tests/cmfd_restart/test.py new file mode 100644 index 000000000..7ed92d024 --- /dev/null +++ b/tests/regression_tests/cmfd_restart/test.py @@ -0,0 +1,72 @@ +import glob +import os +import copy + +from tests.testing_harness import CMFDTestHarness +from openmc import cmfd +import numpy as np + + +class CMFDRestartTestHarness(CMFDTestHarness): + def __init__(self, final_sp, restart_sp, cmfd_run1, cmfd_run2): + super().__init__(final_sp, cmfd_run1) + self._cmfd_restart_run = cmfd_run2 + self._restart_sp = restart_sp + + def execute_test(self): + try: + # Compare results from first CMFD run + self._test_output_created() + results = self._get_results() + results += self._cmfdrun_results + self._write_results(results) + self._compare_results() + + # Run CMFD from restart file + statepoint = glob.glob(os.path.join(os.getcwd(), self._restart_sp)) + assert len(statepoint) == 1 + statepoint = statepoint[0] + self._cmfd_restart_run.run(args=['-r', statepoint]) + + # Compare results from second CMFD run + self._test_output_created() + self._create_cmfd_result_str(self._cmfd_restart_run) + results = self._get_results() + results += self._cmfdrun_results + self._write_results(results) + self._compare_results() + finally: + self._cleanup() + + +def test_cmfd_restart(): + """Test 1 group CMFD solver with restart run""" + # Initialize and set CMFD mesh, create a copy for second run + cmfd_mesh = cmfd.CMFDMesh() + cmfd_mesh.lower_left = (-10.0, -1.0, -1.0) + cmfd_mesh.upper_right = (10.0, 1.0, 1.0) + cmfd_mesh.dimension = (10, 1, 1) + cmfd_mesh.albedo = (0.0, 0.0, 1.0, 1.0, 1.0, 1.0) + cmfd_mesh2 = copy.deepcopy(cmfd_mesh) + + # Initialize and run first CMFDRun object + cmfd_run = cmfd.CMFDRun() + cmfd_run.mesh = cmfd_mesh + cmfd_run.tally_begin = 5 + cmfd_run.feedback_begin = 5 + cmfd_run.feedback = True + cmfd_run.gauss_seidel_tolerance = [1.e-15, 1.e-20] + cmfd_run.run() + + # Initialize second CMFDRun object which will be run from restart file + cmfd_run2 = cmfd.CMFDRun() + cmfd_run2.mesh = cmfd_mesh2 + cmfd_run2.tally_begin = 5 + cmfd_run2.feedback_begin = 5 + cmfd_run2.feedback = True + cmfd_run2.gauss_seidel_tolerance = [1.e-15, 1.e-20] + + # Initialize and run CMFD restart test harness + harness = CMFDRestartTestHarness('statepoint.20.h5', 'statepoint.15.h5', + cmfd_run, cmfd_run2) + harness.main()