mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Updated Tally.__eq__ routine to account for floating point precision
This commit is contained in:
parent
8f63112b75
commit
a614ba3a3b
1 changed files with 24 additions and 2 deletions
|
|
@ -51,8 +51,12 @@ class Filter(object):
|
|||
if self._type != filter2._type:
|
||||
return False
|
||||
|
||||
# Check number of bins
|
||||
elif len(self._bins) != len(filter2._bins):
|
||||
return False
|
||||
|
||||
# Check bin edges
|
||||
elif list(self._bins) != list(filter2._bins):
|
||||
elif not np.allclose(self._bins, filter2._bins):
|
||||
return False
|
||||
|
||||
else:
|
||||
|
|
@ -699,6 +703,24 @@ class Tally(object):
|
|||
'string'.format(score, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif 'scatter-' in score:
|
||||
|
||||
moment = score.split('-')[-1]
|
||||
|
||||
if 'p' in moment.lower() or 'y' in moment.lower():
|
||||
moment = moment[1:]
|
||||
|
||||
if int(moment) < 0 or int(moment) > 10:
|
||||
msg = 'Unable to add score {0} to Tally ID={1} since OpenMC ' \
|
||||
'can only tally the scattering moments between 0 and ' \
|
||||
'10'.format(score, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not score in SCORE_TYPES.values():
|
||||
msg = 'Unable to add score {0} to Tally ID={1} since it is not a ' \
|
||||
'supported score in OpenMC'.format(score, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
# If the score is already in the Tally, don't add it again
|
||||
if score in self._scores:
|
||||
return
|
||||
|
|
@ -1232,4 +1254,4 @@ class TalliesFile(object):
|
|||
# Write the XML Tree to the tallies.xml file
|
||||
tree = ET.ElementTree(self._tallies_file)
|
||||
tree.write("tallies.xml", xml_declaration=True,
|
||||
encoding='utf-8', method="xml")
|
||||
encoding='utf-8', method="xml")
|
||||
Loading…
Add table
Add a link
Reference in a new issue