mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Merge pull request #660 from wbinventor/exact-get-tally
New Optional Strictly Exact Option for StatePoint.get_tally(...)
This commit is contained in:
commit
f9c44a99c1
2 changed files with 25 additions and 9 deletions
|
|
@ -691,11 +691,11 @@ class MGXS(object):
|
|||
# Find, slice and store Tallies from StatePoint
|
||||
# The tally slicing is needed if tally merging was used
|
||||
for tally_type, tally in self.tallies.items():
|
||||
sp_tally = statepoint.get_tally(tally.scores, tally.filters,
|
||||
tally.nuclides,
|
||||
estimator=tally.estimator)
|
||||
sp_tally = sp_tally.get_slice(tally.scores, filters,
|
||||
filter_bins, tally.nuclides)
|
||||
sp_tally = statepoint.get_tally(
|
||||
tally.scores, tally.filters, tally.nuclides,
|
||||
estimator=tally.estimator, exact=True)
|
||||
sp_tally = sp_tally.get_slice(
|
||||
tally.scores, filters, filter_bins, tally.nuclides)
|
||||
sp_tally.sparse = self.sparse
|
||||
self.tallies[tally_type] = sp_tally
|
||||
|
||||
|
|
|
|||
|
|
@ -497,13 +497,17 @@ class StatePoint(object):
|
|||
self.tallies[tally_id].sparse = self.sparse
|
||||
|
||||
def get_tally(self, scores=[], filters=[], nuclides=[],
|
||||
name=None, id=None, estimator=None):
|
||||
name=None, id=None, estimator=None, exact=False):
|
||||
"""Finds and returns a Tally object with certain properties.
|
||||
|
||||
This routine searches the list of Tallies and returns the first Tally
|
||||
found which satisfies all of the input parameters.
|
||||
NOTE: The input parameters do not need to match the complete Tally
|
||||
specification and may only represent a subset of the Tally's properties.
|
||||
|
||||
NOTE: If the "exact" parameter is False (default), the input parameters
|
||||
do not need to match the complete Tally specification and may only
|
||||
represent a subset of the Tally's properties. If the "exact" parameter
|
||||
is True then the scores, filters, nuclides and estimator parameters
|
||||
must precisely match those of any matching Tally.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
|
@ -519,6 +523,9 @@ class StatePoint(object):
|
|||
The id specified for the Tally (default is None).
|
||||
estimator: str, optional
|
||||
The type of estimator ('tracklength', 'analog'; default is None).
|
||||
exact : bool
|
||||
Whether to strictly enforce the match between the parameters and
|
||||
the returned tally
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
|
@ -547,9 +554,18 @@ class StatePoint(object):
|
|||
continue
|
||||
|
||||
# Determine if Tally has queried estimator
|
||||
if estimator and not estimator == test_tally.estimator:
|
||||
if (estimator or exact) and estimator != test_tally.estimator:
|
||||
continue
|
||||
|
||||
# The number of filters, nuclides and scores must exactly match
|
||||
if exact:
|
||||
if len(scores) != test_tally.num_scores:
|
||||
continue
|
||||
if len(nuclides) != test_tally.num_nuclides:
|
||||
continue
|
||||
if len(filters) != test_tally.num_filters:
|
||||
continue
|
||||
|
||||
# Determine if Tally has the queried score(s)
|
||||
if scores:
|
||||
contains_scores = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue