mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Add check for equal value bins in an EnergyFilter (#3372)
This commit is contained in:
parent
cdc254ccf4
commit
bd95b52f4d
2 changed files with 20 additions and 2 deletions
|
|
@ -1238,7 +1238,7 @@ class RealFilter(Filter):
|
|||
cv.check_type('filter value', v1, Real)
|
||||
|
||||
# Make sure that each tuple has values that are increasing
|
||||
if v1 < v0:
|
||||
if v1 <= v0:
|
||||
raise ValueError(f'Values {v0} and {v1} appear to be out of '
|
||||
'order')
|
||||
|
||||
|
|
@ -1384,7 +1384,7 @@ class EnergyFilter(RealFilter):
|
|||
----------
|
||||
values : Iterable of Real
|
||||
A list of values for which each successive pair constitutes a range of
|
||||
energies in [eV] for a single bin
|
||||
energies in [eV] for a single bin. Entries must be positive and ascending.
|
||||
filter_id : int
|
||||
Unique identifier for the filter
|
||||
|
||||
|
|
|
|||
|
|
@ -294,3 +294,21 @@ def test_tabular_from_energyfilter():
|
|||
|
||||
tab = efilter.get_tabular(values=np.array([10, 10, 5]), interpolation='linear-linear')
|
||||
assert tab.interpolation == 'linear-linear'
|
||||
|
||||
|
||||
def test_energy_filter():
|
||||
|
||||
# testing that bins descending value raises error
|
||||
msg = "Values 1.0 and 0.5 appear to be out of order"
|
||||
with raises(ValueError, match=msg):
|
||||
openmc.EnergyFilter([0.0, 1.0, 0.5])
|
||||
|
||||
# testing that bins with same value raises error
|
||||
msg = "Values 0.25 and 0.25 appear to be out of order"
|
||||
with raises(ValueError, match=msg):
|
||||
openmc.EnergyFilter([0.0, 0.25, 0.25])
|
||||
|
||||
# testing that negative bins values raises error
|
||||
msg = 'Unable to set "filter value" to "-1.2" since it is less than "0.0"'
|
||||
with raises(ValueError, match=msg):
|
||||
openmc.EnergyFilter([-1.2, 0.25, 0.5])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue