mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Added inf check in VolumeCalculation. (#2634)
Co-authored-by: Rosie Barker <rbarker@FL000139.firstlightfusion.local> Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
471caa5810
commit
b62b62ac31
2 changed files with 19 additions and 0 deletions
|
|
@ -122,6 +122,10 @@ class VolumeCalculation:
|
|||
raise ValueError('Could not automatically determine bounding box '
|
||||
'for stochastic volume calculation.')
|
||||
|
||||
if np.isinf(self.lower_left).any() or np.isinf(self.upper_right).any():
|
||||
raise ValueError('Lower-left and upper-right bounding box '
|
||||
'coordinates must be finite.')
|
||||
|
||||
@property
|
||||
def ids(self):
|
||||
return self._ids
|
||||
|
|
|
|||
15
tests/unit_tests/test_volume.py
Normal file
15
tests/unit_tests/test_volume.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import openmc
|
||||
|
||||
|
||||
def test_infinity_handling():
|
||||
surf1 = openmc.Sphere(boundary_type="vacuum")
|
||||
cell1 = openmc.Cell(region=-surf1)
|
||||
|
||||
lower_left = (-2, -np.inf, -2)
|
||||
upper_right = (np.inf, 2, 2)
|
||||
|
||||
with pytest.raises(ValueError, match="must be finite"):
|
||||
openmc.VolumeCalculation([cell1], 100, lower_left, upper_right)
|
||||
Loading…
Add table
Add a link
Reference in a new issue