Skip to content

Incorrect return state and expectation value for time evolution solvers with trivial tlist #377

@ytdHuang

Description

@ytdHuang

Bug Description

Usually no one will specify tlist = [0, 0], but somehow this is still a bug because the number of states and the values of expect will be incorrect.

Code to Reproduce the Bug

tlist = [0, 0]
sol = sesolve(sigmax(), basis(2, 0), tlist)
println(sol.states, "\n")

sol = sesolve(sigmax(), basis(2, 0), tlist, e_ops = [sigmaz()])
println(sol.expect)

Code Output

QuantumObject{KetQuantumObject, Dimensions{1, Tuple{Space}}, Vector{ComplexF64}}[
Quantum Object:   type=Ket   dims=[2]   size=(2,)
2-element Vector{ComplexF64}:
 1.0 + 0.0im
 0.0 + 0.0im]

ComplexF64[1.0 + 0.0im 6.93949973204724e-310 + 6.93949973206147e-310im]

Expected Behaviour

QuantumObject{KetQuantumObject, Dimensions{1, Tuple{Space}}, Vector{ComplexF64}}[
Quantum Object:   type=Ket   dims=[2]   size=(2,)
2-element Vector{ComplexF64}:
 1.0 + 0.0im
 0.0 + 0.0im, 
Quantum Object:   type=Ket   dims=[2]   size=(2,)
2-element Vector{ComplexF64}:
 1.0 + 0.0im
 0.0 + 0.0im]

ComplexF64[1.0 + 0.0im 1.0 + 0.0im]

Your Environment

Julia              Ver. 1.10.5
QuantumToolbox     Ver. 0.25.0
SciMLOperators     Ver. 0.3.12
LinearSolve        Ver. 2.38.0
OrdinaryDiffEqCore Ver. 1.12.1

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions