-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the OrdinaryDiffEq interface for Kets
The following now works ```julia using QuantumOptics using DifferentialEquations ℋ = SpinBasis(1//2) σx = sigmax(ℋ) ↓ = s = spindown(ℋ) schrod(ψ,p,t) = im * σx * ψ t₀, t₁ = (0.0, pi) Δt = 0.1 prob = ODEProblem(schrod, ↓, (t₀, t₁)) sol = solve(prob,Tsit5()) ``` It works for Bras as well. It works for in-place operations and in some situations it is faster than the standard `timeevolution.schroedinger`. ```julia ℋ = SpinBasis(20//1) ↓ = spindown(ℋ) t₀, t₁ = (0.0, pi) const σx = sigmax(ℋ) const iσx = im * σx schrod!(dψ,ψ,p,t) = mul!(dψ, iσx, ψ) prob! = ODEProblem(schrod!, ↓, (t₀, t₁)) julia> @benchmark sol = solve($prob!,DP5(),save_everystep=false) BenchmarkTools.Trial: memory estimate: 22.67 KiB allocs estimate: 178 -------------- minimum time: 374.463 μs (0.00% GC) median time: 397.327 μs (0.00% GC) mean time: 406.738 μs (0.37% GC) maximum time: 4.386 ms (89.76% GC) -------------- samples: 10000 evals/sample: 1 julia> @benchmark timeevolution.schroedinger([$t₀,$t₁], $↓, $σx) BenchmarkTools.Trial: memory estimate: 23.34 KiB allocs estimate: 161 -------------- minimum time: 748.106 μs (0.00% GC) median time: 774.601 μs (0.00% GC) mean time: 786.933 μs (0.14% GC) maximum time: 4.459 ms (80.46% GC) -------------- samples: 6350 evals/sample: 1 ```
- Loading branch information
Showing
5 changed files
with
61 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters