mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
Use tally mean in helpers rather than direct access to results
This commit is contained in:
parent
baecead5da
commit
06e598f38e
2 changed files with 12 additions and 13 deletions
|
|
@ -83,7 +83,7 @@ class DirectReactionRateHelper(ReactionRateHelper):
|
|||
reaction rates in this material
|
||||
"""
|
||||
self._results_cache.fill(0.0)
|
||||
full_tally_res = self._rate_tally.results[mat_id, :, 1]
|
||||
full_tally_res = self._rate_tally.mean[mat_id]
|
||||
for i_tally, (i_nuc, i_react) in enumerate(
|
||||
product(nuc_index, react_index)):
|
||||
self._results_cache[i_nuc, i_react] = full_tally_res[i_tally]
|
||||
|
|
@ -203,7 +203,7 @@ class EnergyScoreHelper(NormalizationHelper):
|
|||
"""
|
||||
super().reset()
|
||||
if comm.rank == 0:
|
||||
self._energy = self._tally.results[0, 0, 1]
|
||||
self._energy = self._tally.mean[0, 0]
|
||||
|
||||
|
||||
class SourceRateHelper(NormalizationHelper):
|
||||
|
|
@ -450,7 +450,7 @@ class FissionYieldCutoffHelper(TalliedFissionYieldHelper):
|
|||
if not self._tally_nucs or self._local_indexes.size == 0:
|
||||
self.results = None
|
||||
return
|
||||
fission_rates = self._fission_rate_tally.results[..., 1].reshape(
|
||||
fission_rates = self._fission_rate_tally.mean.reshape(
|
||||
self.n_bmats, 2, len(self._tally_nucs))
|
||||
self.results = fission_rates[self._local_indexes]
|
||||
total_fission = self.results.sum(axis=1)
|
||||
|
|
@ -612,9 +612,9 @@ class AveragedFissionYieldHelper(TalliedFissionYieldHelper):
|
|||
self.results = None
|
||||
return
|
||||
fission_results = (
|
||||
self._fission_rate_tally.results[self._local_indexes, :, 1])
|
||||
self._fission_rate_tally.mean[self._local_indexes])
|
||||
self.results = (
|
||||
self._weighted_tally.results[self._local_indexes, :, 1]).copy()
|
||||
self._weighted_tally.mean[self._local_indexes]).copy()
|
||||
nz_mat, nz_nuc = fission_results.nonzero()
|
||||
self.results[nz_mat, nz_nuc] /= fission_results[nz_mat, nz_nuc]
|
||||
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ def materials(tmpdir_factory):
|
|||
def proxy_tally_data(tally, fill=None):
|
||||
"""Construct an empty matrix built from a C tally
|
||||
|
||||
The shape of tally.results will be
|
||||
``(n_bins, n_nuc * n_scores, 3)``
|
||||
The shape of tally.mean will be ``(n_bins, n_nuc * n_scores)``
|
||||
"""
|
||||
n_nucs = max(len(tally.nuclides), 1)
|
||||
n_scores = max(len(tally.scores), 1)
|
||||
|
|
@ -67,7 +66,7 @@ def proxy_tally_data(tally, fill=None):
|
|||
if isinstance(tfilter, lib.EnergyFilter):
|
||||
this_bins -= 1
|
||||
n_bins *= max(this_bins, 1)
|
||||
data = np.empty((n_bins, n_nucs * n_scores, 3))
|
||||
data = np.empty((n_bins, n_nucs * n_scores))
|
||||
if fill is not None:
|
||||
data.fill(fill)
|
||||
return data
|
||||
|
|
@ -203,9 +202,9 @@ def test_cutoff_helper(materials, nuclide_bundle, therm_frac):
|
|||
tally_data = proxy_tally_data(fission_tally)
|
||||
helper._fission_rate_tally = Mock()
|
||||
helper_flux = 1e6
|
||||
tally_data[0, :, 1] = therm_frac * helper_flux
|
||||
tally_data[1, :, 1] = (1 - therm_frac) * helper_flux
|
||||
helper._fission_rate_tally.results = tally_data
|
||||
tally_data[0] = therm_frac * helper_flux
|
||||
tally_data[1] = (1 - therm_frac) * helper_flux
|
||||
helper._fission_rate_tally.mean = tally_data
|
||||
|
||||
helper.unpack()
|
||||
# expected results of shape (n_mats, 2, n_tnucs)
|
||||
|
|
@ -261,8 +260,8 @@ def test_averaged_helper(materials, nuclide_bundle, avg_energy):
|
|||
|
||||
helper._fission_rate_tally = Mock()
|
||||
helper._weighted_tally = Mock()
|
||||
helper._fission_rate_tally.results = fission_results
|
||||
helper._weighted_tally.results = weighted_results
|
||||
helper._fission_rate_tally.mean = fission_results
|
||||
helper._weighted_tally.mean = weighted_results
|
||||
|
||||
helper.unpack()
|
||||
expected_results = np.ones((1, len(tallied_nucs))) * avg_energy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue