mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Address comments by @smharper on #892.
This commit is contained in:
parent
3a8205c6d9
commit
002c7651c2
5 changed files with 12 additions and 8 deletions
|
|
@ -25,6 +25,10 @@ class EqualityMixin(object):
|
|||
return not self.__eq__(other)
|
||||
|
||||
|
||||
class IDWarning(UserWarning):
|
||||
pass
|
||||
|
||||
|
||||
class IDManagerMixin(object):
|
||||
"""A Class which automatically manages unique IDs.
|
||||
|
||||
|
|
@ -52,8 +56,9 @@ class IDManagerMixin(object):
|
|||
cv.check_type('{} ID'.format(name), uid, Integral)
|
||||
cv.check_greater_than('{} ID'.format(name), uid, 0, equality=True)
|
||||
if uid in cls.used_ids:
|
||||
warn('Another {} instance already exists with id={}.'.format(
|
||||
name, uid))
|
||||
msg = 'Another {} instance already exists with id={}.'.format(
|
||||
name, uid)
|
||||
warn(msg, IDWarning)
|
||||
else:
|
||||
cls.used_ids.add(uid)
|
||||
self._id = uid
|
||||
|
|
@ -74,8 +79,8 @@ def reserve_ids(ids, cls=None):
|
|||
ids : iterable of int
|
||||
IDs to reserve
|
||||
cls : type or None
|
||||
Class for which IDs should be reserved. If None, all classes that have
|
||||
auto-generated IDs will be used.
|
||||
Class for which IDs should be reserved (e.g., :class:`openmc.Cell`). If
|
||||
None, all classes that have auto-generated IDs will be used.
|
||||
|
||||
"""
|
||||
if cls is None:
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ class StatePoint(object):
|
|||
|
||||
# Ignore warnings about duplicate IDs
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', UserWarning)
|
||||
warnings.simplefilter('ignore', openmc.IDWarning)
|
||||
|
||||
# Iterate over all tallies
|
||||
for tally_id in tally_ids:
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Summary(object):
|
|||
|
||||
self._read_nuclides()
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", UserWarning)
|
||||
warnings.simplefilter("ignore", openmc.IDWarning)
|
||||
self._read_geometry()
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ class VolumeCalculation(object):
|
|||
# Instantiate some throw-away domains that are used by the constructor
|
||||
# to assign IDs
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', UserWarning)
|
||||
warnings.simplefilter('ignore', openmc.IDWarning)
|
||||
if domain_type == 'cell':
|
||||
domains = [openmc.Cell(uid) for uid in ids]
|
||||
elif domain_type == 'material':
|
||||
|
|
|
|||
|
|
@ -818,7 +818,6 @@ contains
|
|||
real(8) :: xs_low ! 0K xs at lowest practical relative energy
|
||||
real(8) :: xs_up ! 0K xs at highest practical relative energy
|
||||
real(8) :: m ! slope for interpolation
|
||||
real(8) :: xi ! pseudorandom number on [0,1)
|
||||
real(8) :: R ! rejection criterion for DBRC / target speed
|
||||
real(8) :: cdf_low ! xs cdf at lowest practical relative energy
|
||||
real(8) :: cdf_up ! xs cdf at highest practical relative energy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue