Skip to content

Instantly share code, notes, and snippets.

@amitjamadagni
Last active August 29, 2015 14:23
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/2123d3b44f14b57b653a to your computer and use it in GitHub Desktop.
Save amitjamadagni/2123d3b44f14b57b653a to your computer and use it in GitHub Desktop.
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