Last active
August 29, 2015 14:23
-
-
Save amitjamadagni/2123d3b44f14b57b653a to your computer and use it in GitHub Desktop.
Quantum Equation Addition : ODE Solvers
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
################################################## | |
##### ##### | |
##### propodesolvers.jl ##### | |
##### ##### | |
################################################## | |
abstract QuODESolvers <: QuPropagatorMethod | |
const type_to_method_ode = @compat Dict{Any, Any}(:QuODE45 => ODE.ode45, :QuODE78 => ODE.ode78, :QuODE23s => ODE.ode23s) | |
for op in keys(type_to_method_ode) | |
text = type_to_method_ode[op] | |
@eval begin | |
immutable $op <: QuODESolvers | |
options::Dict{Symbol, Any} | |
end | |
$op() = $op(Dict()) | |
end | |
end | |
for (key,value) in type_to_method_ode | |
@eval begin | |
function propagate(prob::$key, eq::QuEquation, t, current_t, current_qustate) | |
next_state = $value((t,y)-> -im*coeffs(operator(eq))*y, coeffs(vec(current_qustate)), [current_t, t], points=:specified, | |
reltol = get(prob.options, :reltol, 1.0e-5), abstol = get(prob.options, :abstol, 1.0e-8))[2][end] | |
return QuArray(next_state) | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment