sundials icon indicating copy to clipboard operation
sundials copied to clipboard

CVode returns wrong yout if h becomes zero

Open dweindl opened this issue 4 years ago • 1 comments

Hi, I stumbled across a problem in CVode which seems to yield a wrong yout if h becomes zero.

After CVode: Internal t = 0 and h = 0 are such that t + h = t on the next step. The solver will continue anyway. and CVodeGetDky: Illegal value for t.t = 900 is not between tcur - hu = 0 and tcur = 0, CVode still returns CV_SUCCESS, but yout is not the correct value for tout, but for the time when h became zero.

The problem seems to be the multiplication with cv_mem->cv_h for checking whether tout was reached and subsequently ignoring the return value of CVodeGetDky (CV_BAD_T), here: https://github.com/LLNL/sundials/blob/a9bc74f6f188cd513521cbbdace3d0a85a8d76b9/src/cvodes/cvodes.c#L3298-L3305

Similar checks exist in CVodeF here: https://github.com/LLNL/sundials/blob/a9bc74f6f188cd513521cbbdace3d0a85a8d76b9/src/cvodes/cvodea.c#L560-L561 and here: https://github.com/LLNL/sundials/blob/a9bc74f6f188cd513521cbbdace3d0a85a8d76b9/src/cvodes/cvodea.c#L472-L473

CVodeF leads to the same warnings, but returns CV_BAD_T. That is at least not CV_SUCCESS, but it is somewhat misleading, as CVodeGetDky should not have been called in the first place.

This happens in a more complex application and I am not sure I can easily provide a minimal reproducible example.

dweindl avatar Oct 08 '21 22:10 dweindl

This issue still persists at least with SUNDIALS 7.1.1. I can reproduce it, but unfortunately, I cannot provide a self-contained example. I'm happy to provide more information if needed.

dweindl avatar Feb 18 '25 13:02 dweindl