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:
rlbarker 2023-08-19 06:20:22 +01:00 committed by GitHub
parent 471caa5810
commit b62b62ac31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -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

View 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)