From 1f7ac4215f45dc0c88a36240230cf16d7cb4cc5b Mon Sep 17 00:00:00 2001 From: Perry <100789850+yrrepy@users.noreply.github.com> Date: Tue, 21 Apr 2026 13:24:53 -0700 Subject: [PATCH] Clip negative atom densities that result from CRAM (#3879) Co-authored-by: Paul Romano --- openmc/deplete/abc.py | 5 +++++ tests/dummy_operator.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openmc/deplete/abc.py b/openmc/deplete/abc.py index 80d8474ec..d2926ba7e 100644 --- a/openmc/deplete/abc.py +++ b/openmc/deplete/abc.py @@ -738,6 +738,11 @@ class Integrator(ABC): results = deplete( self._solver, self.chain, n, rates, dt, i, matrix_func, self.transfer_rates, self.external_source_rates) + + # Clip unphysical negative number densities + for r in results: + r.clip(min=0.0, out=r) + return time.time() - start, results @abstractmethod diff --git a/tests/dummy_operator.py b/tests/dummy_operator.py index 9595765d7..873633525 100644 --- a/tests/dummy_operator.py +++ b/tests/dummy_operator.py @@ -24,7 +24,7 @@ DepletionSolutionTuple = namedtuple( predictor_solution = DepletionSolutionTuple( PredictorIntegrator, np.array([1.0, 2.46847546272295, 4.11525874568034]), - np.array([1.0, 0.986431226850467, -0.0581692232513460])) + np.array([1.0, 0.986431226850467, 0.0])) cecm_solution = DepletionSolutionTuple(