Conversation
CRAM rational approximation can produce tiny negative atom densities as numerical artifacts. These propagate to depletion_results.h5 and to subsequent timesteps. Clip all CRAM outputs to non-negative in _timed_deplete(), the single funnel point all integrators pass through.
CRAM rational approximations can undershoot zero for nearly-depleted nuclides. Add clip_negative_densities parameter (default False) to Integrator and SIIntegrator that clips results to zero with a one-time warning reporting the worst nuclide. - New bool param on Integrator.__init__ and SIIntegrator.__init__ - Warning identifies nuclide with most negative density
|
On further reflection, this may be the ideal location to implement a minimum number density filter (clip). Here is an augmented method The other alternative is to perform the clipping after integration is complete (after openmc deplete finalizes all time-steps). I already have a workflow (processing script) that does this but it is rather cumbersome as you have to batch-wise sweep through the depletion_results.h5 file to do it effectively. |
|
Trimming negatives makes a lot of sense. They're non-physical, but they can be an artifact of some CRAM workflows (decay or low flux, insufficient order) |
|
Another examples of CRAM clipping: in-case it inspires another possible location for clipping would be on step_result.py
This has the advantage of allowing CRAM to do it's numerical thing undisturbed. |
Description
CRAM does not guarantee positivity of nuclide concentrations.
When atom densities get very low, the solver can start to oscillate about zero.
This PR addresses that by clipping to zero any negative value that the solver produces. This then propagates to the next step and the depletion_results.h5 file.
No impact is expected on Bateman solutions as this behaviour arises when concentrations are already infinitesimally low.
The new behaviour is made opt-in with
clip_negative_densities=TrueThe attached sample script demonstrates the negative solutions.
demo.py
No clipping:
With Clipping
Checklist