Indeed, reltol
fixes the problem. I don’t think I have a good grasp on setting abstol
and reltol
reliably. The way I’d usually think about errors in propagators would for the norm(Ψ - Ψ_exact) < err
, where Ψ
is the result of the propagator at final time T
, Ψ_exact
is the hypothetical analytic solution (in practice, obtained from a solver with all precisions cranked up to the max), and err
is the error I’d like to prescribe (typically something like 1e-12
). It’s a little non-ideal that there are two error parameters abstol
, reltol
that I have to tweak, and I have to get a better understanding of how to connect my err
with abstol
and reltol
.
I suppose the key is the equation given in the “Basic step size control” of the CommonSolve.Solve
docstring, but I have to have a closer look (Unless someone with more experience can give me some guidelines )
there’s also no need to include the saveat = tlist
Yeah, but there are reasons I need the states exactly on that time grid. But this is really just for the sake of the MWE / comparing with my normal solver. In my actual code, I use the integrator interface. But I do have to work on a specific time grid (because that’s how gradients in quantum control work).
This is not my area, but Tsit5()
is probably not the best choice for solver for this problem
That’s interesting… I’m very much not an expert in general ODE solver methods. But to my knowledge when people have “traditionally” used ODE solvers for quantum dynamics (as an upgrade from something low-precision like Crank-Nicholson), they’ve typically used RK45. So I just sort of assumed Tsit5
would be the equivalent-but-better default.
The title of the post may be a bit misleading, in that I care about “norm-preserving” only in so far as I care about “correct” in terms of the aforementioned norm(Ψ - Ψ_exact) < err
, and that I know Ψ_exact
to have norm 1. It’s not necessarily a problem that errors are reflected in a deviation of the norm. At least that’s pretty easy to detect, and thus possibly preferable to “grossly wrong, but with the correct norm”.
That’s not to say that I wouldn’t want to try solvers that inherently norm-preserving. My “workhorse propagator” of expanding exp(-i*H*dt)
in Chebychev polynomials (the “correct” solution in my OP) is norm-preserving, after all. But that propagator is piecewise-constant, and the reason I ran into this whole issue was that I wanted to double-check with OrdinaryDiffEq
that I wasn’t running into time-discretization errors. That is, compare with the solution for the time-continuous (adaptive time step) ODE solver. Which then, with the ill-advised approach of using OrdinaryDiffEq
as a black box, gave me wildly inaccurate results.
That’s weird, and a little concerning. But ultimately, I’m really just going to have to nail down how to reliably choose abstol
and reltol
based on my more general notion of “error”, and then see what is a good default ODE method for quantum dynamics.
This particular ODE might also be a bit pathological. I’m actually probing here a parameter regime where the adiabatic Landau-Zener transition (where everything would evolve very smoothly) breaks down. Still, it would be good to have a reliable ODE solver in my toolbox that doesn’t require much handholding.
I’ll definitely have a look at Vern8
and the other solvers Chris mentioned.
Thanks!