diff --git a/docs/source/usersguide/random_ray.rst b/docs/source/usersguide/random_ray.rst index 138ae910c..d5d752a83 100644 --- a/docs/source/usersguide/random_ray.rst +++ b/docs/source/usersguide/random_ray.rst @@ -765,7 +765,7 @@ energy decomposition:: # Create a "tallies.xml" file for the MGXS Library tallies = openmc.Tallies() - mgxs_lib.add_to_tallies_file(tallies, merge=True) + mgxs_lib.add_to_tallies(tallies, merge=True) # Export tallies.export_to_xml() diff --git a/openmc/deplete/chain.py b/openmc/deplete/chain.py index f34416d56..873d7ca89 100644 --- a/openmc/deplete/chain.py +++ b/openmc/deplete/chain.py @@ -630,7 +630,7 @@ class Chain: n = len(self) - # we accumulate indices and value entries for everything and create the matrix + # we accumulate indices and value entries for everything and create the matrix # in one step at the end to avoid expensive index checks scipy otherwise does. rows, cols, vals = [], [], [] def setval(i, j, val): @@ -716,14 +716,17 @@ class Chain: return sp.csc_matrix((vals, (rows, cols)), shape=(n, n)) def add_redox_term(self, matrix, buffer, oxidation_states): - """Adds a redox term to the depletion matrix from data contained in + r"""Adds a redox term to the depletion matrix from data contained in the matrix itself and a few user-inputs. The redox term to add to the buffer nuclide :math:`N_j` can be written - as: :math:`\frac{dN_j(t)}{dt} = - \cdots - \frac{1}{OS_j}\sum_i N_i a_{ij} \cdot OS_i ` + as: - where :math:`OS` is the oxidation states vector and `a_{ij}` the + .. math:: + \frac{dN_j(t)}{dt} = \cdots - \frac{1}{OS_j}\sum_i N_i a_{ij} + \cdot OS_i + + where :math:`OS` is the oxidation states vector and :math:`a_{ij}` the corresponding term in the Bateman matrix. Parameters diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index f782cbe9e..b476de902 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -556,14 +556,14 @@ class Library: self.all_mgxs[domain.id][mgxs_type] = mgxs - def add_to_tallies_file(self, tallies_file, merge=True): - """Add all tallies from all MGXS objects to a tallies file. + def add_to_tallies(self, tallies, merge=True): + """Add tallies from all MGXS objects to a tallies object. NOTE: This assumes that :meth:`Library.build_library` has been called Parameters ---------- - tallies_file : openmc.Tallies + tallies : openmc.Tallies A Tallies collection to add each MGXS' tallies to generate a 'tallies.xml' input file for OpenMC merge : bool @@ -572,7 +572,7 @@ class Library: """ - cv.check_type('tallies_file', tallies_file, openmc.Tallies) + cv.check_type('tallies', tallies, openmc.Tallies) # Add tallies from each MGXS for each domain and mgxs type for domain in self.domains: @@ -587,7 +587,15 @@ class Library: = list(range(1, self.num_delayed_groups + 1)) for tally in mgxs.tallies.values(): - tallies_file.append(tally, merge=merge) + tallies.append(tally, merge=merge) + + def add_to_tallies_file(self, tallies_file, merge=True): + warn( + "The Library.add_to_tallies_file(...) method has been renamed to" + "add_to_tallies(...) and will be removed in a future version of " + "OpenMC.", FutureWarning + ) + self.add_to_tallies(tallies_file, merge=merge) def load_from_statepoint(self, statepoint): """Extracts tallies in an OpenMC StatePoint with the data needed to diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 533ab0ad3..f621db092 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -2127,8 +2127,8 @@ class MGXS: df['std. dev.'] /= np.tile(densities, tile_factor) # Replace NaNs by zeros (happens if nuclide density is zero) - df['mean'].replace(np.nan, 0.0, inplace=True) - df['std. dev.'].replace(np.nan, 0.0, inplace=True) + df['mean'] = df['mean'].replace(np.nan, 0.0) + df['std. dev.'] = df['std. dev.'].replace(np.nan, 0.0) # Sort the dataframe by domain type id (e.g., distribcell id) and # energy groups such that data is from fast to thermal diff --git a/openmc/model/model.py b/openmc/model/model.py index 64294c23c..10e5cbfc7 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -1791,7 +1791,7 @@ class Model: mgxs_lib.build_library() # Create a "tallies.xml" file for the MGXS Library - mgxs_lib.add_to_tallies_file(model.tallies, merge=True) + mgxs_lib.add_to_tallies(model.tallies, merge=True) # Run statepoint_filename = model.run(cwd=directory) @@ -1980,7 +1980,7 @@ class Model: mgxs_lib.build_library() # Create a "tallies.xml" file for the MGXS Library - mgxs_lib.add_to_tallies_file(model.tallies, merge=True) + mgxs_lib.add_to_tallies(model.tallies, merge=True) # Run statepoint_filename = model.run(cwd=directory) @@ -2075,7 +2075,7 @@ class Model: mgxs_lib.build_library() # Create a "tallies.xml" file for the MGXS Library - mgxs_lib.add_to_tallies_file(model.tallies, merge=True) + mgxs_lib.add_to_tallies(model.tallies, merge=True) # Run statepoint_filename = model.run(cwd=directory) diff --git a/openmc/tallies.py b/openmc/tallies.py index 25ec29a58..add356579 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -738,13 +738,9 @@ class Tally(IDManagerMixin): Notes ----- - This test is based on D'Agostino and Pearson's test [1]_. The test - requires at least 8 realizations to produce valid results. - - References - ---------- - .. [1] D'Agostino, R. B. (1971), "An omnibus test of normality for - moderate and large sample size", Biometrika, 58, 341-348 + This test is based on `D'Agostino and Pearson's test + `_. The test requires at least + 8 realizations to produce valid results. """ n = self.num_realizations @@ -788,8 +784,8 @@ class Tally(IDManagerMixin): Parameters ---------- alternative : {'two-sided', 'less', 'greater'}, optional - Defines the alternative hypothesis. Default is 'two-sided'. - The following options are available: + Defines the alternative hypothesis. Default is 'two-sided'. The + following options are available: * 'two-sided': the kurtosis of the distribution is different from that of the normal distribution @@ -813,14 +809,9 @@ class Tally(IDManagerMixin): Notes ----- - This test is based on D'Agostino and Pearson's test [1]_. The test - is typically recommended for at least 20 realizations to produce - valid results. - - References - ---------- - .. [1] D'Agostino, R. B. (1971), "An omnibus test of normality for - moderate and large sample size", Biometrika, 58, 341-348 + This test is based on `D'Agostino and Pearson's test + `_. The test is typically + recommended for at least 20 realizations to produce valid results. """ n = self.num_realizations @@ -855,9 +846,9 @@ class Tally(IDManagerMixin): def normaltest(self, alternative: str = "two-sided"): """Perform D'Agostino and Pearson's omnibus test for normality. - This method tests the null hypothesis that a sample comes from a - normal distribution. It combines skewness and kurtosis to produce an - omnibus test of normality. + This method tests the null hypothesis that a sample comes from a normal + distribution. It combines skewness and kurtosis to produce an omnibus + test of normality. Parameters ---------- @@ -886,23 +877,19 @@ class Tally(IDManagerMixin): Notes ----- This test combines a test for skewness and a test for kurtosis to - produce an omnibus test [1]_. The test statistic is: + produce an `omnibus test `_. + The test statistic is: .. math:: K^2 = Z_1^2 + Z_2^2 - where :math:`Z_1` is the z-score from the skewness test and - :math:`Z_2` is the z-score from the kurtosis test. This statistic - follows a chi-square distribution with 2 degrees of freedom. + where :math:`Z_1` is the z-score from the skewness test and :math:`Z_2` + is the z-score from the kurtosis test. This statistic follows a + chi-square distribution with 2 degrees of freedom. The test requires at least 20 realizations to produce valid results. - References - ---------- - .. [1] D'Agostino, R. B. and Pearson, E. S. (1973), "Tests for - departure from normality", Biometrika, 60, 613-622 - """ n = self.num_realizations if n < 20: diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/test.py b/tests/regression_tests/mgxs_library_ce_to_mg/test.py index 48a715997..075167f58 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg/test.py +++ b/tests/regression_tests/mgxs_library_ce_to_mg/test.py @@ -28,7 +28,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _run_openmc(self): # Initial run diff --git a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py index a77ad2429..489105f8f 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_ce_to_mg_nuclides/test.py @@ -28,7 +28,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _run_openmc(self): # Initial run diff --git a/tests/regression_tests/mgxs_library_condense/test.py b/tests/regression_tests/mgxs_library_condense/test.py index a7e60617f..bbc4c11bf 100644 --- a/tests/regression_tests/mgxs_library_condense/test.py +++ b/tests/regression_tests/mgxs_library_condense/test.py @@ -36,7 +36,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_correction/test.py b/tests/regression_tests/mgxs_library_correction/test.py index 05eedfef8..64e638e44 100644 --- a/tests/regression_tests/mgxs_library_correction/test.py +++ b/tests/regression_tests/mgxs_library_correction/test.py @@ -29,7 +29,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_distribcell/test.py b/tests/regression_tests/mgxs_library_distribcell/test.py index fd6c8e938..464b309c0 100644 --- a/tests/regression_tests/mgxs_library_distribcell/test.py +++ b/tests/regression_tests/mgxs_library_distribcell/test.py @@ -36,7 +36,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) self._model.tallies.export_to_xml() def _get_results(self, hash_output=False): diff --git a/tests/regression_tests/mgxs_library_hdf5/test.py b/tests/regression_tests/mgxs_library_hdf5/test.py index 06625c25f..4fb4bf093 100644 --- a/tests/regression_tests/mgxs_library_hdf5/test.py +++ b/tests/regression_tests/mgxs_library_hdf5/test.py @@ -40,7 +40,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_histogram/test.py b/tests/regression_tests/mgxs_library_histogram/test.py index b9905910a..42fc1957a 100644 --- a/tests/regression_tests/mgxs_library_histogram/test.py +++ b/tests/regression_tests/mgxs_library_histogram/test.py @@ -30,7 +30,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_mesh/test.py b/tests/regression_tests/mgxs_library_mesh/test.py index 89c68a75a..c1a5980b5 100644 --- a/tests/regression_tests/mgxs_library_mesh/test.py +++ b/tests/regression_tests/mgxs_library_mesh/test.py @@ -57,7 +57,7 @@ def model(): model.mgxs_lib.build_library() # Add tallies - model.mgxs_lib.add_to_tallies_file(model.tallies, merge=False) + model.mgxs_lib.add_to_tallies(model.tallies, merge=False) return model diff --git a/tests/regression_tests/mgxs_library_no_nuclides/test.py b/tests/regression_tests/mgxs_library_no_nuclides/test.py index af14a5dc8..a02086af3 100644 --- a/tests/regression_tests/mgxs_library_no_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_no_nuclides/test.py @@ -39,7 +39,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_nuclides/test.py b/tests/regression_tests/mgxs_library_nuclides/test.py index 8a7673565..a10070358 100644 --- a/tests/regression_tests/mgxs_library_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_nuclides/test.py @@ -36,7 +36,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=False) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=False) def _get_results(self, hash_output=True): """Digest info in the statepoint and return as a string.""" diff --git a/tests/regression_tests/mgxs_library_specific_nuclides/test.py b/tests/regression_tests/mgxs_library_specific_nuclides/test.py index 61910e539..0ccbb83bd 100644 --- a/tests/regression_tests/mgxs_library_specific_nuclides/test.py +++ b/tests/regression_tests/mgxs_library_specific_nuclides/test.py @@ -37,7 +37,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Add tallies - self.mgxs_lib.add_to_tallies_file(self._model.tallies, merge=True) + self.mgxs_lib.add_to_tallies(self._model.tallies, merge=True) def _get_results(self, hash_output=True): """Digest info in the statepoint and return as a string."""