Skip to content

Error handling and warnings for `TDVP` solver

Vicentini Filippo requested to merge tevo-errors into master

Created by: femtobit

This PR does the following:

  1. Add a way to signal warnings and errors to the RK solvers. This is done by adding a field .flags to the RK state, which is set by the step methods. Right now, the possible flags are the following:
class SolverFlags(IntFlag):
    NONE = 0
    INFO_STEP_ACCEPTED = auto()
    WARN_MIN_DT = auto()
    WARN_MAX_DT = auto()
    ERROR_INVALID_DT = auto()

The TDVP driver looks for these flags after each step, raising a warning or an exception if appropriate. The reason these (integer-valued) flags are used is that the RK solver function should be jitable (even though they are not jit-compiled at this time), preventing us from raising an exception directly.

This also catches errors arising from invalid dt values (such as NaN), which may be related to the issues in #1017.

  1. Fix the handling of dt_limits. If a minimum for dt was set previously, the solver ended up in an infinite loop, because the step was not lowered but also not accepted. This is now fixed and steps are accepted (with a warning) if dt has reached the lower bound.

  2. Split runge_kutta.py into separate files for tableaus and solvers for readability.

  3. Accept an RK step only iff all MPI ranks agree it should be accepted. This should always be the case in a deterministic setting, but explicitly checking this might prevent potential rare MPI deadlocks (e.g., when different MPI processes run on hosts with slightly different floating-point handling).

Merge request reports