mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -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
|
|
@ -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