From 3d5a0406b12c1d96ca808cc5849c18584f35b665 Mon Sep 17 00:00:00 2001 From: Alberto Mercurio Date: Wed, 10 Dec 2025 10:48:48 +0100 Subject: [PATCH 1/2] Support time-dependent operators on dsf_mesolve --- src/time_evolution/time_evolution_dynamical.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/time_evolution/time_evolution_dynamical.jl b/src/time_evolution/time_evolution_dynamical.jl index bbe70a9f2..505769e2c 100644 --- a/src/time_evolution/time_evolution_dynamical.jl +++ b/src/time_evolution/time_evolution_dynamical.jl @@ -332,8 +332,10 @@ function _DSF_mesolve_Affect!(integrator) op_l2 = op_list .+ αt_list e_ops2 = e_ops(op_l2, dsf_params) _mesolve_callbacks_new_e_ops!(integrator, [_generate_mesolve_e_op(op) for op in e_ops2]) - # By doing this, we are assuming that the system is time-independent and f is a MatrixOperator - copyto!(integrator.f.f.A, liouvillian(H(op_l2, dsf_params), c_ops(op_l2, dsf_params)).data) + + # By doing this, we are assuming that all the arguments of ODEFunction are the default ones + integrator.f = + ODEFunction{true,FullSpecialize}(_mesolve_make_L_QobjEvo(H(op_l2, dsf_params), c_ops(op_l2, dsf_params)).data) return u_modified!(integrator, true) end @@ -360,9 +362,12 @@ function dsf_mesolveProblem( αt_list = convert(Vector{T}, α0_l) op_l_vec = map(op -> mat2vec(get_data(op)'), op_list) - # Create the Krylov subspace with kron(H₀.data, H₀.data) just for initialize - expv_cache = arnoldi(kron(H₀.data, H₀.data), mat2vec(ket2dm(ψ0).data), krylov_dim) + dsf_identity = Eye(prod(H₀.dimensions)) + + # Create the Krylov subspace just for initialize + expv_cache = arnoldi(kron(dsf_identity, dsf_identity), mat2vec(ket2dm(ψ0).data), krylov_dim) + dsf_displace_cache_left = sum(op -> ScalarOperator(one(T)) * MatrixOperator(kron(op.data, dsf_identity)), op_list) dsf_displace_cache_left_dag = sum(op -> ScalarOperator(one(T)) * MatrixOperator(kron(sparse(op.data'), dsf_identity)), op_list) From 130aa781504d0a4e84826bc52672347faf24661a Mon Sep 17 00:00:00 2001 From: Alberto Mercurio Date: Wed, 10 Dec 2025 10:52:40 +0100 Subject: [PATCH 2/2] Make changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84bc5139e..edd8b42f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/qutip/QuantumToolbox.jl/tree/main) - Add error message for bad input in state/operator generating functions ([#603]) +- Support time-dependent operators on `dsf_mesolve` ([#610]) ## [v0.39.1] Release date: 2025-11-19 @@ -383,3 +384,4 @@ Release date: 2024-11-13 [#591]: https://github.com/qutip/QuantumToolbox.jl/issues/591 [#596]: https://github.com/qutip/QuantumToolbox.jl/issues/596 [#603]: https://github.com/qutip/QuantumToolbox.jl/issues/603 +[#610]: https://github.com/qutip/QuantumToolbox.jl/issues/610