Skip to content

Instantly share code, notes, and snippets.

@amitjamadagni
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitjamadagni/2b6c8aaf12c62e476288 to your computer and use it in GitHub Desktop.
Save amitjamadagni/2b6c8aaf12c62e476288 to your computer and use it in GitHub Desktop.
Attempt at integrating ODE.jl
using QuBase
using ODE
immutable QuODE45 <: QuPropagatorMethod
end
function propagate(prob::QuODE45, op, t, current_t, current_qustate)
next_state = ODE.ode45((t,y)->coeffs(op)*y, coeffs(current_qustate), [current_t, t], points=:specified)[2][2]
return QuArray(next_state)
end
# Example :
t = [0.:0.1:2*pi]
qv = normalize!(QuArray([0.5+0.1im, 0.2+0.2im]))
qode = QuPropagator(sigmax, qv, t, QuODE45())
star_ode = start(qode)
qq = next(qode, star_ode)
println(qq)
((0.1,2-element QuVector in FiniteBasis{Orthonormal}:
...coefficients: Array{Complex{Float64},1}
Complex{Float64}[0.8961408762348902 + 0.2067137046977604im,0.43060586530225986 + 0.3618920416753039im]),QuPropagatorState(2-element QuVector in FiniteBasis{Orthonormal}:
...coefficients: Array{Complex{Float64},1}
Complex{Float64}[0.8961408762348902 + 0.2067137046977604im,0.43060586530225986 + 0.3618920416753039im],0.1,3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment