Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

num_expect=0 although evolution can run #332

Closed
ferrispnugraha opened this issue Dec 4, 2024 · 2 comments · Fixed by #335
Closed

num_expect=0 although evolution can run #332

ferrispnugraha opened this issue Dec 4, 2024 · 2 comments · Fixed by #335
Labels
bug Something isn't working

Comments

@ferrispnugraha
Copy link

Bug Description

Run a simple evolution, not recording the expectation value

Code to Reproduce the Bug

using QuantumToolbox

H = 2 * π * 0.1 * sigmax()
ψ0 = basis(2, 0) # spin-up
tlist = LinRange(0.0, 10.0, 20)

prob = sesolveProblem(H, ψ0, tlist, e_ops = [sigmaz()])
sol = sesolve(prob)

Code Output

Progress: [==============================] 100.0% --- Elapsed Time: 0h 00m 02s (ETA: 0h 00m 00s)

Solution of time evolution
(return code: Success)
--------------------------
num_states = 1
num_expect = 0
ODE alg.: OrdinaryDiffEqTsit5.Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}(OrdinaryDiffEqCore.trivial_limiter!, OrdinaryDiffEqCore.trivial_limiter!, static(false))
abstol = 1.0e-8
reltol = 1.0e-6

Expected Behaviour

As in https://qutip.org/QuantumToolbox.jl/stable/users_guide/time_evolution/sesolve

Solution of time evolution
(return code: Success)

num_states = 1
num_expect = 1
ODE alg.: OrdinaryDiffEqTsit5.Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}(OrdinaryDiffEqCore.trivial_limiter!, OrdinaryDiffEqCore.trivial_limiter!, static(false))
abstol = 1.0e-8
reltol = 1.0e-6

Your Environment

QuantumToolbox.jl: Quantum Toolbox in Julia
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Copyright © QuTiP team 2022 and later.
Current admin team:
    Alberto Mercurio and Yi-Te Huang

Package information:
====================================
Julia              Ver. 1.11.1
QuantumToolbox     Ver. 0.22.0
SciMLOperators     Ver. 0.3.12
LinearSolve        Ver. 2.38.0
OrdinaryDiffEqCore Ver. 1.13.0

System information:
====================================
OS       : Windows (x86_64-w64-mingw32)
CPU      : 20 × 12th Gen Intel(R) Core(TM) i7-12700H
Memory   : 31.679 GB
WORD_SIZE: 64
LIBM     : libopenlibm
LLVM     : libLLVM-16.0.6 (ORCJIT, alderlake)
BLAS     : libopenblas64_.dll (ilp64)
Threads  : 1 (on 20 virtual cores)

Additional Context

expt_z = real(sol.expect[1,:]) 
expt_y = real(sol.expect[2,:])

returns the following error (expect is empty):

MethodError: no method matching getindex(::Nothing, ::Int64, ::Colon)
The function `getindex` exists, but no method is defined for this combination of argument types.
@ferrispnugraha ferrispnugraha added the bug Something isn't working label Dec 4, 2024
@albertomercurio
Copy link
Member

Very strange, the code works for me.

julia> sol = sesolve(prob)
Progress: [==============================] 100.0% --- Elapsed Time: 0h 00m 04s (ETA: 0h 00m 00s)
Solution of time evolution
(return code: Success)
--------------------------
num_states = 1
num_expect = 1
ODE alg.: OrdinaryDiffEqTsit5.Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}(OrdinaryDiffEqCore.trivial_limiter!, OrdinaryDiffEqCore.trivial_limiter!, static(false))
abstol = 1.0e-8
reltol = 1.0e-6
julia> QuantumToolbox.versioninfo()

 QuantumToolbox.jl: Quantum Toolbox in Julia
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Copyright © QuTiP team 2022 and later.
Current admin team:
    Alberto Mercurio and Yi-Te Huang

Package information:
====================================
Julia              Ver. 1.11.2
QuantumToolbox     Ver. 0.23.0
SciMLOperators     Ver. 0.3.11
LinearSolve        Ver. 2.38.0
OrdinaryDiffEqCore Ver. 1.13.0

System information:
====================================
OS       : Linux (x86_64-linux-gnu)
CPU      : 32 × 13th Gen Intel(R) Core(TM) i9-13900KF
Memory   : 62.514 GB
WORD_SIZE: 64
LIBM     : libopenlibm
LLVM     : libLLVM-16.0.6 (ORCJIT, alderlake)
BLAS     : libopenblas64_.so (ilp64)
Threads  : 16 (on 32 virtual cores)

I see that you are using Windows. Maybe it's related to that. But I doubt because we should have runtests also for windows machines.

@ytdHuang
Copy link
Member

ytdHuang commented Dec 5, 2024

@ferrispnugraha

Thank you for reporting this bug.

There is an incompatibility issue between QuantumToolbox>=0.22.0 and DiffEqCallbacks.jl<4.2.1

Solution 1

This issue can be solved quickly by updating DiffEqCallbacks.jl>=4.2.1 in your local Julia environment:

just open Julia, change to package mode by ], and then

pkg> update DiffEqCallbacks

or

using Pkg; Pkg.update("DiffEqCallbacks")

Solution 2

We will also update the [compat] of DiffEqCallbacks.jl in the next patch release (v0.23.1).

So you can also solve this problem by updating QuantumToolbox.jl to v0.23.1 (but this needs to wait PR #335 to be merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants