[Tutorials] More examples
Hello! Thank you for your wonderful work on solving DE on quantum device.
I have never had experience with Julia, so I use Python JuliaCall. Could you please provide more examples how to submit DE to the QuDiffEq solver? I tried a really straightforward example such as dx/dt = 3x+4, but could not figure out a correct way of creating the M, b and x_initial matrices (I follow the notation dx/dt=Mx+b). What data types should I use for this matrices if M, x,b are numbers?
Hi, thanks for your interest, to clarify, this currently does not run a real quantum device, but only through a simulator as some of the protocols are not compatible with existing quantum devices due to various reasons.
On the other hand, this package has been maintained for a while, so the algorithms implemented in this package are not the state of the art anymore. If you are working on research on solving ODEs with the quantum device, this package could be a playground, but using it for solving real problems is not something I'd recommend.
regarding the examples, you can find them in the tests and examples folder, it accepts standard Julia DiffEq interface/definition of problems (you can refer to DiffEq.jl documentation for the interface definition)
for example, the QuLDE solver is a very simple one uses the standard DiffEq interface of an ODE by just
function f(du,u,p,t)
du[1] = -2*(u[2]^2)*u[1]
du[2] = 3*(u[1]^(1.5)) - 0.1*u[2]
end
Regarding using DiffEq from Python, I'd recommend you ask at julia discourse or Julia slack's diffeq channel with more specific error reports or things you are trying. But I'd still recommend you to just program Julia - it's way easier than python for these tasks especially if you are using a Julia package.
Hi @Roger-luo. Thanks for the help. I consulted the classical OrdinaryDiffEq Julia package and was able to solve the following DE: dx/dt = 3*x+4, x_initial=2, tspan = (0.0, 1.0). The code I used is (please note, I use the Python JuliaCall to manipulate Julia packages)
x_0 = 2.0
tspan = (0.0, 1.0)
f(x, p, t) = 3*x + 4
problem = jl.ODEProblem(f, x_0, tspan)
sol = jl.OrdinaryDiffEq.solve(problem, jl.OrdinaryDiffEq.Tsit5())
However, the same approach does not work with the QuDiffEq package.
x_0 = 2.0
tspan = (0.0, 1.0)
f(x, p, t) = 3*x + 4
qprob = jl.QuLDEProblem(f, x_0, tspan)
qsol = jl.QuDiffEq.solve(qprob, jl.QuDiffEq.QuLDE(3), dt = 0.1)
Could you please point out my mistake?
Hii @olgOk . I would suggest taking a look at QuLDE_tests.jl to see how QuLDEProblem is used. The intput is always of the form
# dx/dt = M*x + b
# typeof(Au) -> Matrix{ComplexF64}
# typeof(b) and typeof(x_0) -> Vector{ComplexF64}
qprob = QuLDEProblem(M,b,x_0, tspan)
So you could try something like this
# dx/dt = 3*x + 4
M = hcat(3.0)
b = [4.0]
x_0 = [2.0]
tspan = (0.0, 1.0)
qprob = QuLDEProblem(M,b, x_0, tspan)
sol = solve(qprob, QuLDE(5))
I noticed there is a big issue with the solve function that it doesn't run without calling OrdinaryDiffEq. I'll open a separate issue for that.