Skip to content

CompatHelper: bump compat for SciMLOperators to 1, (keep existing compat) #470

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ OrdinaryDiffEqTsit5 = "1"
Pkg = "1"
Random = "1"
SciMLBase = "2"
SciMLOperators = "0.3, 0.4"
SciMLOperators = "1"
SparseArrays = "1"
SpecialFunctions = "2"
StaticArraysCore = "1"
Expand Down
3 changes: 2 additions & 1 deletion src/qobj/quantum_object_evo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@
)
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)

Check warning on line 516 in src/qobj/quantum_object_evo.jl

View check run for this annotation

Codecov / codecov/patch

src/qobj/quantum_object_evo.jl#L516

Added line #L516 was not covered by tests

return ψout
end
Expand Down
13 changes: 7 additions & 6 deletions src/qobj/superoperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,32 @@
_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
Id_cache = I(size(A, 1))
return _spre(A, Id_cache) * _spost(B, Id_cache)
end

## if input is AbstractSciMLOperator
## some of them are optimized to speed things up
## the rest of the SciMLOperators will just use lazy tensor (and prompt a warning)
_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})

Check warning on line 24 in src/qobj/superoperators.jl

View check run for this annotation

Codecov / codecov/patch

src/qobj/superoperators.jl#L24

Added line #L24 was not covered by tests
_lazy_tensor_warning(Id, A)
return kron(Id, A)
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})

Check warning on line 32 in src/qobj/superoperators.jl

View check run for this annotation

Codecov / codecov/patch

src/qobj/superoperators.jl#L32

Added line #L32 was not covered by tests
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)

Check warning on line 40 in src/qobj/superoperators.jl

View check run for this annotation

Codecov / codecov/patch

src/qobj/superoperators.jl#L38-L40

Added lines #L38 - L40 were not covered by tests
end

## intrinsic liouvillian
_liouvillian(H::MT, Id::AbstractMatrix) where {MT<:Union{AbstractMatrix,AbstractSciMLOperator}} =
-1im * (_spre(H, Id) - _spost(H, Id))
Expand Down
2 changes: 1 addition & 1 deletion test/core-test/quantum_objects_evo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading