Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Quantum Equation Addition : ODE Solvers
##################################################
##### #####
##### 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