diff --git a/openmc/stats/univariate.py b/openmc/stats/univariate.py index 28d5e87ef9..d6cf19f2b8 100644 --- a/openmc/stats/univariate.py +++ b/openmc/stats/univariate.py @@ -480,6 +480,9 @@ class PowerLaw(Univariate): """ def __init__(self, a: float = 0.0, b: float = 1.0, n: float = 0.): + if a >= b: + raise ValueError( + "Lower bound of sampling interval must be less than upper bound.") self.a = a self.b = b self.n = n @@ -494,6 +497,9 @@ class PowerLaw(Univariate): @a.setter def a(self, a): cv.check_type('interval lower bound', a, Real) + if a < 0: + raise ValueError( + "PowerLaw sampling is restricted to positive-valued intervals.") self._a = a @property @@ -503,6 +509,9 @@ class PowerLaw(Univariate): @b.setter def b(self, b): cv.check_type('interval upper bound', b, Real) + if b < 0: + raise ValueError( + "PowerLaw sampling is restricted to positive-valued intervals.") self._b = b @property