JuliaQuantumControl / QuantumPropagators.jl

Propagators for Quantum Dynamics and Optimal Control
https://juliaquantumcontrol.github.io/QuantumPropagators.jl/
MIT License
16 stars 4 forks source link

Newton Propagator is still buggy #1

Closed goerz closed 2 years ago

goerz commented 2 years ago

Looks like the Newton propagator still has some subtle bug.

See https://github.com/QuantumControl-jl/QuantumPropagators.jl/runs/3295191405?check_suite_focus=true

The propagator works for small dimensions (N=10), but not for N=1000. Interestingly, the reference implementation at https://github.com/qucontrol/newtonprop works perfectly for this test case! Thus, it shouldn't be too hard to figure out what is different between the Julia and the Python implementation.

@alastair-marshall Just raising this issue in case you had planned to use the Newton propagator for GRAPE.jl (which I would definitely recommend, once it actually works)

alastair-marshall commented 2 years ago

@alastair-marshall Just raising this issue in case you had planned to use the Newton propagator for GRAPE.jl (which I would definitely recommend, once it actually works)

Thanks for bringing it up, I'll use expv from ExponentialUtilities for now just so that I can slowly build up my code

goerz commented 2 years ago

That sounds good! It would actually like to have an exp-propagator available in QuantumPropagators.jl as well, with the same interface as the other propagators, so e.g. expv!(Psi, H, dt, wrk) where wrk might be necessary to hold a temporary state to enable in-place propagation and/or expv(Psi, H, dt, wrk=nothing) for something not in-place that works with AD. Should be a fairly simple wrapper. For small Hamiltonians (dimension < 10), exponentiation is actually faster and safer than polynomial expansion. So if you like, feel free to add it.

alastair-marshall commented 2 years ago

Ah I think that expv uses Arnoldi under the hood but I do want to dispatch to StaticArrays when possible and then, as you say, its definitely faster to actually do a full exp

goerz commented 2 years ago

Oh, I see... If you can get expv into the same interface as newton!, that would be an extremely interesting thing to benchmark! I just wonder how my handwritten Arnoldi-based Newton propagator compares to other Arnoldi/Krylov Julia packages that evaluate exp(A) Ψ. I'd be very open to wrapping any of those packages in QuantumPropagators.jl

goerz commented 2 years ago

Ok, I added the standard exponentiation

I also marked the failing newton tests as @test_broken, just so that the CI pipeline runs through (while still showing the tests as "broken")