From c5f2ccb4ecf6b5e15a6145a19d297ba126db32ff Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Sun, 18 May 2025 01:12:44 +0000 Subject: [PATCH 1/6] CompatHelper: bump compat for SciMLOperators to 1, (keep existing compat) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index cdff9028e..2536184ab 100644 --- a/Project.toml +++ b/Project.toml @@ -59,7 +59,7 @@ OrdinaryDiffEqTsit5 = "1" Pkg = "1" Random = "1" SciMLBase = "2" -SciMLOperators = "0.3, 0.4" +SciMLOperators = "0.3, 0.4, 1" SparseArrays = "1" SpecialFunctions = "2" StaticArraysCore = "1" From 6fc4aab3c823ca6ab5bea6e160e7e2e2bcaa3da3 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang <44385685+ytdHuang@users.noreply.github.com> Date: Sat, 24 May 2025 17:34:42 +0800 Subject: [PATCH 2/6] bump compat version of `SciMLOperators` --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2536184ab..112848e58 100644 --- a/Project.toml +++ b/Project.toml @@ -59,7 +59,7 @@ OrdinaryDiffEqTsit5 = "1" Pkg = "1" Random = "1" SciMLBase = "2" -SciMLOperators = "0.3, 0.4, 1" +SciMLOperators = "1" SparseArrays = "1" SpecialFunctions = "2" StaticArraysCore = "1" From 0dbf43a01f420fa62efee861107f8b71b05af0a5 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang <44385685+ytdHuang@users.noreply.github.com> Date: Thu, 29 May 2025 19:29:01 +0800 Subject: [PATCH 3/6] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 112848e58..e9c19683c 100644 --- a/Project.toml +++ b/Project.toml @@ -59,7 +59,7 @@ OrdinaryDiffEqTsit5 = "1" Pkg = "1" Random = "1" SciMLBase = "2" -SciMLOperators = "1" +SciMLOperators = "0.3 - 1" SparseArrays = "1" SpecialFunctions = "2" StaticArraysCore = "1" From a39687c515607288807a9e05c0f95955216ec8c7 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Sat, 14 Jun 2025 23:13:40 +0800 Subject: [PATCH 4/6] try to fix `QobjEvo` in `SciMLOperators v1` --- Project.toml | 2 +- src/qobj/quantum_object_evo.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 0cce0ba8c..151b878f9 100644 --- a/Project.toml +++ b/Project.toml @@ -61,7 +61,7 @@ OrdinaryDiffEqTsit5 = "1" Pkg = "1" Random = "1" SciMLBase = "2" -SciMLOperators = "0.3 - 1" +SciMLOperators = "1" SparseArrays = "1" SpecialFunctions = "2" StaticArraysCore = "1" diff --git a/src/qobj/quantum_object_evo.jl b/src/qobj/quantum_object_evo.jl index f1c4c58dc..32a06bcde 100644 --- a/src/qobj/quantum_object_evo.jl +++ b/src/qobj/quantum_object_evo.jl @@ -512,7 +512,8 @@ function (A::QuantumObjectEvolution)( ) end - A.data(ψout.data, ψin.data, p, t) + # We put `nothing` in the place of `u` because the time-dependence doesn't depend on the state + A.data(ψout.data, ψin.data, nothing, p, t) return ψout end From 29542d8ef50fbcb2164b84a5298867e9e1a97ed1 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 16 Jun 2025 22:05:18 +0800 Subject: [PATCH 5/6] try to make `SciMLOperator v1` work in `sprepost` --- src/qobj/superoperators.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qobj/superoperators.jl b/src/qobj/superoperators.jl index 6bc9a71c3..c0ab35a1c 100644 --- a/src/qobj/superoperators.jl +++ b/src/qobj/superoperators.jl @@ -15,8 +15,11 @@ _sprepost(A::AbstractMatrix, B::AbstractSparseMatrix) = kron(transpose(B), spars _sprepost(A::AbstractSparseMatrix, B::AbstractMatrix) = kron(transpose(sparse(B)), A) _sprepost(A::AbstractSparseMatrix, B::AbstractSparseMatrix) = kron(transpose(B), A) function _sprepost(A, B) # for any other input types - Id_cache = I(size(A, 1)) - return _spre(A, Id_cache) * _spost(B, Id_cache) + # TODO: use the commented code (since it is optimized for certain types of SciMLOperators, and was able to give correct results before `SciMLOperators v1.0.0`) + # Id_cache = I(size(A, 1)) + # return _spre(A, Id_cache) * _spost(B, Id_cache) + + return kron(transpose(B), A) end ## if input is AbstractSciMLOperator From c23a50880b728fb967afdb71b8ffaef351182d39 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Mon, 16 Jun 2025 22:34:25 +0800 Subject: [PATCH 6/6] try to use `IdentityOperator` --- src/qobj/superoperators.jl | 16 +++++++--------- test/core-test/quantum_objects_evo.jl | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/qobj/superoperators.jl b/src/qobj/superoperators.jl index c0ab35a1c..6e17c904a 100644 --- a/src/qobj/superoperators.jl +++ b/src/qobj/superoperators.jl @@ -14,13 +14,6 @@ _sprepost(A::AbstractMatrix, B::AbstractMatrix) = kron(transpose(sparse(B)), spa _sprepost(A::AbstractMatrix, B::AbstractSparseMatrix) = kron(transpose(B), sparse(A)) _sprepost(A::AbstractSparseMatrix, B::AbstractMatrix) = kron(transpose(sparse(B)), A) _sprepost(A::AbstractSparseMatrix, B::AbstractSparseMatrix) = kron(transpose(B), A) -function _sprepost(A, B) # for any other input types - # TODO: use the commented code (since it is optimized for certain types of SciMLOperators, and was able to give correct results before `SciMLOperators v1.0.0`) - # Id_cache = I(size(A, 1)) - # return _spre(A, Id_cache) * _spost(B, Id_cache) - - return kron(transpose(B), A) -end ## if input is AbstractSciMLOperator ## some of them are optimized to speed things up @@ -28,7 +21,7 @@ end _spre(A::MatrixOperator, Id::AbstractMatrix) = MatrixOperator(_spre(A.A, Id)) _spre(A::ScaledOperator, Id::AbstractMatrix) = ScaledOperator(A.λ, _spre(A.L, Id)) _spre(A::AddedOperator, Id::AbstractMatrix) = AddedOperator(map(op -> _spre(op, Id), A.ops)) -function _spre(A::AbstractSciMLOperator, Id::AbstractMatrix) +function _spre(A::AbstractSciMLOperator, Id::Union{AbstractMatrix,AbstractSciMLOperator}) _lazy_tensor_warning(Id, A) return kron(Id, A) end @@ -36,12 +29,17 @@ end _spost(B::MatrixOperator, Id::AbstractMatrix) = MatrixOperator(_spost(B.A, Id)) _spost(B::ScaledOperator, Id::AbstractMatrix) = ScaledOperator(B.λ, _spost(B.L, Id)) _spost(B::AddedOperator, Id::AbstractMatrix) = AddedOperator(map(op -> _spost(op, Id), B.ops)) -function _spost(B::AbstractSciMLOperator, Id::AbstractMatrix) +function _spost(B::AbstractSciMLOperator, Id::Union{AbstractMatrix,AbstractSciMLOperator}) B_T = transpose(B) _lazy_tensor_warning(B_T, Id) return kron(B_T, Id) end +function _sprepost(A::AbstractSciMLOperator, B::AbstractSciMLOperator) + Id_cache = IdentityOperator(size(A, 1)) + return _spre(A, Id_cache) * _spost(B, Id_cache) +end + ## intrinsic liouvillian _liouvillian(H::MT, Id::AbstractMatrix) where {MT<:Union{AbstractMatrix,AbstractSciMLOperator}} = -1im * (_spre(H, Id) - _spost(H, Id)) diff --git a/test/core-test/quantum_objects_evo.jl b/test/core-test/quantum_objects_evo.jl index a417f52ac..d726a3252 100644 --- a/test/core-test/quantum_objects_evo.jl +++ b/test/core-test/quantum_objects_evo.jl @@ -215,7 +215,7 @@ coef2(p, t) * conj(coef3(p, t)) * (spre(a) * spost(X') - 0.5 * spre(X' * a) - 0.5 * spost(X' * a)) + # cross terms conj(coef2(p, t)) * coef3(p, t) * (spre(X) * spost(a') - 0.5 * spre(a' * X) - 0.5 * spost(a' * X)) # cross terms L_ti = liouvillian(H_ti) + D1_ti + D2_ti - L_td = @test_logs (:warn,) (:warn,) liouvillian(H_td, c_ops) # warnings from lazy tensor in `lindblad_dissipator(c_op2)` + L_td = @test_logs (:warn,) (:warn,) (:warn,) (:warn,) liouvillian(H_td, c_ops) # warnings from lazy tensor in `lindblad_dissipator(c_op2)` ρvec = mat2vec(rand_dm(N)) @test L_td(p, t) ≈ L_ti @test iscached(L_td) == false