Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement OrdinaryDiffEq interface for dense operators.
The following works now: ```julia ℋ = SpinBasis(20//1) const σx = sigmax(ℋ) const iσx = im * σx const σ₋ = sigmam(ℋ) const σ₊ = σ₋' const mhalfσ₊σ₋ = -σ₊*σ₋/2 ↓ = spindown(ℋ) ρ = dm(↓) lind(ρ,p,t) = - iσx * ρ + ρ * iσx + σ₋*ρ*σ₊ + mhalfσ₊σ₋ * ρ + ρ * mhalfσ₊σ₋ t₀, t₁ = (0.0, pi) Δt = 0.1 prob = ODEProblem(lind, ρ, (t₀, t₁)) sol = solve(prob,Tsit5()) ``` Works in-place as well. It is slightly slower than `timeevolution.master`: ```julia function makelind!() tmp = zero(ρ) # this is the global rho function lind!(dρ,ρ,p,t) # TODO this can be much better with a good Tullio kernel mul!(tmp, ρ, σ₊) mul!(dρ, σ₋, ρ) mul!(dρ, ρ, mhalfσ₊σ₋, true, true) mul!(dρ, mhalfσ₊σ₋, ρ, true, true) mul!(dρ, iσx, ρ, -ComplexF64(1), ComplexF64(1)) mul!(dρ, ρ, iσx, true, true) return dρ end end lind! = makelind!() prob! = ODEProblem(lind!, ρ, (t₀, t₁)) julia> @benchmark sol = solve($prob!,DP5(),save_everystep=false) BenchmarkTools.Trial: memory estimate: 408.94 KiB allocs estimate: 213 -------------- minimum time: 126.334 ms (0.00% GC) median time: 127.359 ms (0.00% GC) mean time: 127.876 ms (0.00% GC) maximum time: 138.660 ms (0.00% GC) -------------- samples: 40 evals/sample: 1 julia> @benchmark timeevolution.master([$t₀,$t₁], $ρ, $σx, [$σ₋]) BenchmarkTools.Trial: memory estimate: 497.91 KiB allocs estimate: 210 -------------- minimum time: 97.902 ms (0.00% GC) median time: 98.469 ms (0.00% GC) mean time: 98.655 ms (0.00% GC) maximum time: 104.850 ms (0.00% GC) -------------- samples: 51 evals/sample: 1 ```
- Loading branch information