diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ce866819..77d2e96de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Rename `sparse_to_dense` as `to_dense` and `dense_to_sparse` as `to_sparse`. ([#392]) - Fix erroneous definition of the stochastic term in `smesolve`. ([#393]) - Change name of `MultiSiteOperator` to `multisite_operator`. ([#394]) +- Fix `smesolve` for specifying initial state as density matrix. ([#395]) ## [v0.26.0] Release date: 2025-02-09 @@ -122,3 +123,4 @@ Release date: 2024-11-13 [#392]: https://github.com/qutip/QuantumToolbox.jl/issues/392 [#393]: https://github.com/qutip/QuantumToolbox.jl/issues/393 [#394]: https://github.com/qutip/QuantumToolbox.jl/issues/394 +[#395]: https://github.com/qutip/QuantumToolbox.jl/issues/395 diff --git a/docs/src/users_guide/time_evolution/intro.md b/docs/src/users_guide/time_evolution/intro.md index aabbb25a0..b8ad2ca0f 100644 --- a/docs/src/users_guide/time_evolution/intro.md +++ b/docs/src/users_guide/time_evolution/intro.md @@ -5,8 +5,8 @@ - [Introduction](@ref doc-TE:Introduction) - [Time Evolution Solutions](@ref doc-TE:Time-Evolution-Solutions) - [Solution](@ref doc-TE:Solution) - - [Multiple trajectories solution](@ref doc-TE:Multiple-trajectories-solution) - [Accessing data in solutions](@ref doc-TE:Accessing-data-in-solutions) + - [Multiple trajectories solution](@ref doc-TE:Multiple-trajectories-solution) - [Schrödinger Equation Solver](@ref doc-TE:Schrödinger-Equation-Solver) - [Unitary evolution](@ref doc-TE:Unitary-evolution) - [Example: Spin dynamics](@ref doc-TE:Example:Spin-dynamics) @@ -16,8 +16,11 @@ - [Example: Dissipative Spin dynamics](@ref doc-TE:Example:Dissipative-Spin-dynamics) - [Example: Harmonic oscillator in thermal bath](@ref doc-TE:Example:Harmonic-oscillator-in-thermal-bath) - [Example: Two-level atom coupled to dissipative single-mode cavity](@ref doc-TE:Example:Two-level-atom-coupled-to-dissipative-single-mode-cavity) -- [Monte-Carlo Solver](@ref doc-TE:Monte-Carlo-Solver) +- [Monte Carlo Solver](@ref doc-TE:Monte-Carlo-Solver) - [Stochastic Solver](@ref doc-TE:Stochastic-Solver) + - [Stochastic Schrödinger equation](@ref doc-TE:Stochastic-Schrödinger-equation) + - [Stochastic master equation](@ref doc-TE:Stochastic-master-equation) + - [Example: Homodyne detection](@ref doc-TE:Example:Homodyne-detection) - [Solving Problems with Time-dependent Hamiltonians](@ref doc-TE:Solving-Problems-with-Time-dependent-Hamiltonians) - [Generate QobjEvo](@ref doc-TE:Generate-QobjEvo) - [QobjEvo fields (attributes)](@ref doc-TE:QobjEvo-fields-(attributes)) diff --git a/docs/src/users_guide/time_evolution/mcsolve.md b/docs/src/users_guide/time_evolution/mcsolve.md index b0cfa5591..d62540830 100644 --- a/docs/src/users_guide/time_evolution/mcsolve.md +++ b/docs/src/users_guide/time_evolution/mcsolve.md @@ -1,3 +1,3 @@ -# [Monte-Carlo Solver](@id doc-TE:Monte-Carlo-Solver) +# [Monte Carlo Solver](@id doc-TE:Monte-Carlo-Solver) This page is still under construction, please visit [API](@ref doc-API) first. \ No newline at end of file diff --git a/docs/src/users_guide/time_evolution/solution.md b/docs/src/users_guide/time_evolution/solution.md index 5294ef214..b6a694837 100644 --- a/docs/src/users_guide/time_evolution/solution.md +++ b/docs/src/users_guide/time_evolution/solution.md @@ -89,4 +89,7 @@ Some other solvers can have other output. ## [Multiple trajectories solution](@id doc-TE:Multiple-trajectories-solution) -This part is still under construction, please visit [API](@ref doc-API) first. \ No newline at end of file +This part is still under construction, please read the docstrings for the following functions first: + +- [`TimeEvolutionMCSol`](@ref) +- [`TimeEvolutionStochasticSol`](@ref) \ No newline at end of file diff --git a/docs/src/users_guide/time_evolution/stochastic.md b/docs/src/users_guide/time_evolution/stochastic.md index 2006195ab..3687001ce 100644 --- a/docs/src/users_guide/time_evolution/stochastic.md +++ b/docs/src/users_guide/time_evolution/stochastic.md @@ -1,5 +1,148 @@ # [Stochastic Solver](@id doc-TE:Stochastic-Solver) -This page is still under construction, please visit [API](@ref doc-API) first. +When a quantum system is subjected to continuous measurement, through homodyne detection for example, it is possible to simulate the conditional quantum state using stochastic Schrödinger and master equations. The solution of these stochastic equations are quantum trajectories, which represent the conditioned evolution of the system given a specific measurement record. -## Stochastic Schrodinger equation \ No newline at end of file +## [Stochastic Schrödinger equation](@id doc-TE:Stochastic-Schrödinger-equation) + +The stochastic Schrödinger time evolution of a quantum system is defined by the following stochastic differential equation [Wiseman2009Quantum; section 4.4](@cite): + +```math +d|\psi(t)\rangle = -i \hat{K} |\psi(t)\rangle dt + \sum_n \hat{M}_n |\psi(t)\rangle dW_n(t) +``` + +where + +```math +\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{S}_n - \frac{1}{2} \hat{S}_n^\dagger \hat{S}_n - \frac{e_n^2}{8}\right), +``` +```math +\hat{M}_n = \hat{S}_n - \frac{e_n}{2}, +``` +and +```math +e_n = \langle \psi(t) | \hat{S}_n + \hat{S}_n^\dagger | \psi(t) \rangle. +``` + +Above, ``\hat{H}`` is the Hamiltonian, ``\hat{S}_n`` are the stochastic collapse operators, and ``dW_n(t)`` is the real Wiener increment (associated to ``\hat{S}_n``) which has the expectation values of ``E[dW_n]=0`` and ``E[dW_n^2]=dt``. + +The solver [`ssesolve`](@ref) will construct the operators ``\hat{K}`` and ``\hat{M}_n``. Once the user passes the Hamiltonian (``\hat{H}``) and the stochastic collapse operators list (`sc_ops`; ``\{\hat{S}_n\}_n``). As with the [`mcsolve`](@ref), the number of trajectories and the random number generator for the noise realization can be fixed using the arguments: `ntraj` and `rng`, respectively. + +## [Stochastic master equation](@id doc-TE:Stochastic-master-equation) + +When the initial state of the system is a density matrix ``\rho(0)``, or when additional loss channels are included, the stochastic master equation solver [`smesolve`](@ref) must be used. The stochastic master equation is given by [Wiseman2009Quantum; section 4.4](@cite): + +```math +d \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_i \mathcal{D}[\hat{C}_i] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t), +``` + +where + +```math +\mathcal{D}[\hat{O}] \rho = \hat{O} \rho \hat{O}^\dagger - \frac{1}{2} \{\hat{O}^\dagger \hat{O}, \rho\}, +``` + +is the Lindblad superoperator, and + +```math +\mathcal{H}[\hat{O}] \rho = \hat{O} \rho + \rho \hat{O}^\dagger - \mathrm{Tr}[\hat{O} \rho + \rho \hat{O}^\dagger] \rho, +``` + +The above implementation takes into account 2 types of collapse operators. ``\hat{C}_i`` (`c_ops`) represent the collapse operators related to pure dissipation, while ``\hat{S}_n`` (`sc_ops`) are the stochastic collapse operators. The first three terms on the right-hand side of the above equation is the deterministic part of the evolution which takes into account all operators ``\hat{C}_i`` and ``\hat{S}_n``. The last term (``\mathcal{H}[\hat{S}_n] \rho(t)``) is the stochastic part given solely by the operators ``\hat{S}_n``. + + +## [Example: Homodyne detection](@id doc-TE:Example:Homodyne-detection) + +First, we solve the dynamics for an optical cavity at absolute zero (``0K``) whose output is monitored using homodyne detection. The cavity decay rate is given by ``\kappa`` and the ``\Delta`` is the cavity detuning with respect to the driving field. The homodyne current ``J_x`` is calculated using + +```math +J_x = \langle \hat{x} \rangle + dW/dt, +``` + +where ``\hat{x}`` is the operator build from the `sc_ops` as + +```math +\hat{x} = \hat{S} + \hat{S}^\dagger +``` + +```@setup stochastic-solve +using QuantumToolbox + +using CairoMakie +CairoMakie.enable_only_mime!(MIME"image/svg+xml"()) +``` + +```@example stochastic-solve +# parameters +N = 20 # Fock space dimension +Δ = 5 * 2 * π # cavity detuning +κ = 2 # cavity decay rate +α = 4 # intensity of initial state +ntraj = 500 # number of trajectories + +tlist = 0:0.0025:1 + +# operators +a = destroy(N) +x = a + a' +H = Δ * a' * a + +# initial state +ψ0 = coherent(N, √α) + +# temperature with average of 0 excitations (absolute zero) +n_th = 0 +# c_ops = [√(κ * n_th) * a'] -> nothing +sc_ops = [√(κ * (n_th + 1)) * a] +``` + +In this case, there is no additional dissipation (`c_ops = nothing`), and thus, we can use the [`ssesolve`](@ref): + +```@example stochastic-solve +sse_sol = ssesolve( + H, + ψ0, + tlist, + sc_ops, + e_ops = [x], + ntraj = ntraj, +) + +# plot by CairoMakie.jl +fig = Figure(size = (500, 350)) +ax = Axis(fig[1, 1], xlabel = "Time") +#lines!(ax, tlist, real(sse_sol.xxxxxx), label = L"J_x", color = :red, linestyle = :solid) TODO: add this in the future +lines!(ax, tlist, real(sse_sol.expect[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid) + +axislegend(ax, position = :rt) + +fig +``` + +Next, we consider the same model but at a finite temperature to demonstrate [`smesolve`](@ref): + +```@example stochastic-solve +# temperature with average of 1 excitations +n_th = 1 +c_ops = [√(κ * n_th) * a'] +sc_ops = [√(κ * (n_th + 1)) * a] + +sme_sol = smesolve( + H, + ψ0, + tlist, + c_ops, + sc_ops, + e_ops = [x], + ntraj = ntraj, +) + +# plot by CairoMakie.jl +fig = Figure(size = (500, 350)) +ax = Axis(fig[1, 1], xlabel = "Time") +#lines!(ax, tlist, real(sme_sol.xxxxxx), label = L"J_x", color = :red, linestyle = :solid) TODO: add this in the future +lines!(ax, tlist, real(sme_sol.expect[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid) + +axislegend(ax, position = :rt) + +fig +``` diff --git a/src/time_evolution/mesolve.jl b/src/time_evolution/mesolve.jl index 5b640bc25..de4b7c335 100644 --- a/src/time_evolution/mesolve.jl +++ b/src/time_evolution/mesolve.jl @@ -7,8 +7,8 @@ c_ops are Nothing. You are probably running the wrong function.")) @doc raw""" mesolveProblem( - H::Union{AbstractQuantumObject{HOpType},Tuple}, - ψ0::QuantumObject{StateOpType}, + H::Union{AbstractQuantumObject,Tuple}, + ψ0::QuantumObject, tlist, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing; e_ops::Union{Nothing,AbstractVector,Tuple} = nothing, @@ -94,8 +94,8 @@ end @doc raw""" mesolve( - H::Union{AbstractQuantumObject{HOpType},Tuple}, - ψ0::QuantumObject{StateOpType}, + H::Union{AbstractQuantumObject,Tuple}, + ψ0::QuantumObject, tlist::AbstractVector, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing; alg::OrdinaryDiffEqAlgorithm = Tsit5(), diff --git a/src/time_evolution/smesolve.jl b/src/time_evolution/smesolve.jl index f571ac4d3..1a6aa8879 100644 --- a/src/time_evolution/smesolve.jl +++ b/src/time_evolution/smesolve.jl @@ -12,7 +12,7 @@ _smesolve_ScalarOperator(op_vec) = @doc raw""" smesolveProblem( H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple}, - ψ0::QuantumObject{KetQuantumObject}, + ψ0::QuantumObject, tlist::AbstractVector, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing, sc_ops::Union{Nothing,AbstractVector,Tuple} = nothing; @@ -26,7 +26,7 @@ _smesolve_ScalarOperator(op_vec) = Generate the SDEProblem for the Stochastic Master Equation time evolution of an open quantum system. This is defined by the following stochastic differential equation: ```math -d| \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_n \mathcal{D}[\hat{C}_n] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t), +d \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_i \mathcal{D}[\hat{C}_i] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t), ``` where @@ -41,15 +41,15 @@ is the Lindblad superoperator, and \mathcal{H}[\hat{O}] \rho = \hat{O} \rho + \rho \hat{O}^\dagger - \mathrm{Tr}[\hat{O} \rho + \rho \hat{O}^\dagger] \rho, ``` -Above, ``\hat{C}_n`` represent the operators related to pure dissipation, while ``\hat{S}_n`` are the measurement operators. The ``dW_n(t)`` term is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. +Above, ``\hat{C}_i`` represent the collapse operators related to pure dissipation, while ``\hat{S}_n`` are the stochastic collapse operators. The ``dW_n(t)`` term is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. # Arguments - `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs. - `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref) or a [`Operator`](@ref). - `tlist`: List of times at which to save either the state or the expectation values of the system. -- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`. -- `sc_ops`: List of measurement collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. +- `c_ops`: List of collapse operators ``\{\hat{C}_i\}_i``. It can be either a `Vector` or a `Tuple`. +- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. - `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`. - `params`: `NamedTuple` of parameters to pass to the solver. - `rng`: Random number generator for reproducibility. @@ -69,7 +69,7 @@ Above, ``\hat{C}_n`` represent the operators related to pure dissipation, while """ function smesolveProblem( H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple}, - ψ0::QuantumObject{KetQuantumObject}, + ψ0::QuantumObject{StateOpType}, tlist::AbstractVector, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing, sc_ops::Union{Nothing,AbstractVector,Tuple} = nothing; @@ -78,12 +78,12 @@ function smesolveProblem( rng::AbstractRNG = default_rng(), progress_bar::Union{Val,Bool} = Val(true), kwargs..., -) +) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject}} haskey(kwargs, :save_idxs) && throw(ArgumentError("The keyword argument \"save_idxs\" is not supported in QuantumToolbox.")) isnothing(sc_ops) && - throw(ArgumentError("The list of measurement collapse operators must be provided. Use mesolveProblem instead.")) + throw(ArgumentError("The list of stochastic collapse operators must be provided. Use mesolveProblem instead.")) tlist = _check_tlist(tlist, _FType(ψ0)) @@ -131,7 +131,7 @@ end @doc raw""" smesolveEnsembleProblem( H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple}, - ψ0::QuantumObject{KetQuantumObject}, + ψ0::QuantumObject, tlist::AbstractVector, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing, sc_ops::Union{Nothing,AbstractVector,Tuple} = nothing; @@ -149,7 +149,7 @@ end Generate the SDEProblem for the Stochastic Master Equation time evolution of an open quantum system. This is defined by the following stochastic differential equation: ```math -d| \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_n \mathcal{D}[\hat{C}_n] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t), +d \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_i \mathcal{D}[\hat{C}_i] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t), ``` where @@ -164,15 +164,15 @@ is the Lindblad superoperator, and \mathcal{H}[\hat{O}] \rho = \hat{O} \rho + \rho \hat{O}^\dagger - \mathrm{Tr}[\hat{O} \rho + \rho \hat{O}^\dagger] \rho, ``` -Above, ``\hat{C}_n`` represent the operators related to pure dissipation, while ``\hat{S}_n`` are the measurement operators. The ``dW_n(t)`` term is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. +Above, ``\hat{C}_i`` represent the collapse operators related to pure dissipation, while ``\hat{S}_n`` are the stochastic collapse operators. The ``dW_n(t)`` term is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. # Arguments - `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs. - `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref) or a [`Operator`](@ref). - `tlist`: List of times at which to save either the state or the expectation values of the system. -- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`. -- `sc_ops`: List of measurement collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. +- `c_ops`: List of collapse operators ``\{\hat{C}_i\}_i``. It can be either a `Vector` or a `Tuple`. +- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. - `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`. - `params`: `NamedTuple` of parameters to pass to the solver. - `rng`: Random number generator for reproducibility. @@ -196,7 +196,7 @@ Above, ``\hat{C}_n`` represent the operators related to pure dissipation, while """ function smesolveEnsembleProblem( H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple}, - ψ0::QuantumObject{KetQuantumObject}, + ψ0::QuantumObject{StateOpType}, tlist::AbstractVector, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing, sc_ops::Union{Nothing,AbstractVector,Tuple} = nothing; @@ -209,7 +209,7 @@ function smesolveEnsembleProblem( output_func::Union{Tuple,Nothing} = nothing, progress_bar::Union{Val,Bool} = Val(true), kwargs..., -) +) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject}} _prob_func = isnothing(prob_func) ? _ensemble_dispatch_prob_func(rng, ntraj, tlist, _stochastic_prob_func) : prob_func _output_func = @@ -242,7 +242,7 @@ end @doc raw""" smesolve( H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple}, - ψ0::QuantumObject{KetQuantumObject}, + ψ0::QuantumObject, tlist::AbstractVector, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing, sc_ops::Union{Nothing,AbstractVector,Tuple} = nothing; @@ -261,7 +261,7 @@ end Stochastic Master Equation time evolution of an open quantum system. This is defined by the following stochastic differential equation: ```math -d| \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_n \mathcal{D}[\hat{C}_n] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t), +d \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_i \mathcal{D}[\hat{C}_i] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t), ``` where @@ -276,15 +276,15 @@ is the Lindblad superoperator, and \mathcal{H}[\hat{O}] \rho = \hat{O} \rho + \rho \hat{O}^\dagger - \mathrm{Tr}[\hat{O} \rho + \rho \hat{O}^\dagger] \rho, ``` -Above, ``\hat{C}_n`` represent the operators related to pure dissipation, while ``\hat{S}_n`` are the measurement operators. The ``dW_n(t)`` term is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. +Above, ``\hat{C}_i`` represent the collapse operators related to pure dissipation, while ``\hat{S}_n`` are the stochastic co operators. The ``dW_n(t)`` term is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. # Arguments - `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs. - `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref) or a [`Operator`](@ref). - `tlist`: List of times at which to save either the state or the expectation values of the system. -- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`. -- `sc_ops`: List of measurement collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`. +- `c_ops`: List of collapse operators ``\{\hat{C}_i\}_i``. It can be either a `Vector` or a `Tuple`. +- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. - `alg`: The algorithm to use for the stochastic differential equation. Default is `SRA1()`. - `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`. - `params`: `NamedTuple` of parameters to pass to the solver. @@ -309,7 +309,7 @@ Above, ``\hat{C}_n`` represent the operators related to pure dissipation, while """ function smesolve( H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple}, - ψ0::QuantumObject{KetQuantumObject}, + ψ0::QuantumObject{StateOpType}, tlist::AbstractVector, c_ops::Union{Nothing,AbstractVector,Tuple} = nothing, sc_ops::Union{Nothing,AbstractVector,Tuple} = nothing; @@ -323,7 +323,7 @@ function smesolve( output_func::Union{Tuple,Nothing} = nothing, progress_bar::Union{Val,Bool} = Val(true), kwargs..., -) +) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject}} ensemble_prob = smesolveEnsembleProblem( H, ψ0, diff --git a/src/time_evolution/ssesolve.jl b/src/time_evolution/ssesolve.jl index 22227e939..e2c5accc2 100644 --- a/src/time_evolution/ssesolve.jl +++ b/src/time_evolution/ssesolve.jl @@ -108,24 +108,24 @@ d|\psi(t)\rangle = -i \hat{K} |\psi(t)\rangle dt + \sum_n \hat{M}_n |\psi(t)\ran where ```math -\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{C}_n - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n - \frac{e_n^2}{8}\right), +\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{S}_n - \frac{1}{2} \hat{S}_n^\dagger \hat{S}_n - \frac{e_n^2}{8}\right), ``` ```math -\hat{M}_n = \hat{C}_n - \frac{e_n}{2}, +\hat{M}_n = \hat{S}_n - \frac{e_n}{2}, ``` and ```math -e_n = \langle \hat{C}_n + \hat{C}_n^\dagger \rangle. +e_n = \langle \hat{S}_n + \hat{S}_n^\dagger \rangle. ``` -Above, ``\hat{C}_n`` is the `n`-th collapse operator and ``dW_n(t)`` is the real Wiener increment associated to ``\hat{C}_n``. See [Wiseman2009Quantum](@cite) for more details. +Above, ``\hat{S}_n`` are the stochastic collapse operators and ``dW_n(t)`` is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. # Arguments - `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs. - `ψ0`: Initial state of the system ``|\psi(0)\rangle``. - `tlist`: List of times at which to save either the state or the expectation values of the system. -- `sc_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`. +- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. - `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`. - `params`: `NamedTuple` of parameters to pass to the solver. - `rng`: Random number generator for reproducibility. @@ -158,7 +158,7 @@ function ssesolveProblem( throw(ArgumentError("The keyword argument \"save_idxs\" is not supported in QuantumToolbox.")) sc_ops isa Nothing && - throw(ArgumentError("The list of collapse operators must be provided. Use sesolveProblem instead.")) + throw(ArgumentError("The list of stochastic collapse operators must be provided. Use sesolveProblem instead.")) tlist = _check_tlist(tlist, _FType(ψ0)) @@ -227,24 +227,24 @@ d|\psi(t)\rangle = -i \hat{K} |\psi(t)\rangle dt + \sum_n \hat{M}_n |\psi(t)\ran where ```math -\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{C}_n - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n - \frac{e_n^2}{8}\right), +\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{S}_n - \frac{1}{2} \hat{S}_n^\dagger \hat{S}_n - \frac{e_n^2}{8}\right), ``` ```math -\hat{M}_n = \hat{C}_n - \frac{e_n}{2}, +\hat{M}_n = \hat{S}_n - \frac{e_n}{2}, ``` and ```math -e_n = \langle \hat{C}_n + \hat{C}_n^\dagger \rangle. +e_n = \langle \hat{S}_n + \hat{S}_n^\dagger \rangle. ``` -Above, ``\hat{C}_n`` is the `n`-th collapse operator and ``dW_n(t)`` is the real Wiener increment associated to ``\hat{C}_n``. See [Wiseman2009Quantum](@cite) for more details. +Above, ``\hat{S}_n`` are the stochastic collapse operators and ``dW_n(t)`` is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. # Arguments - `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs. - `ψ0`: Initial state of the system ``|\psi(0)\rangle``. - `tlist`: List of times at which to save either the state or the expectation values of the system. -- `sc_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`. +- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. - `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`. - `params`: `NamedTuple` of parameters to pass to the solver. - `rng`: Random number generator for reproducibility. @@ -340,7 +340,7 @@ end ) -Stochastic Schrödinger equation evolution of a quantum system given the system Hamiltonian ``\hat{H}`` and a list of stochadtic collapse (jump) operators ``\{\hat{C}_n\}_n``. +Stochastic Schrödinger equation evolution of a quantum system given the system Hamiltonian ``\hat{H}`` and a list of stochastic collapse (jump) operators ``\{\hat{S}_n\}_n``. The stochastic evolution of the state ``|\psi(t)\rangle`` is defined by: ```math @@ -350,17 +350,17 @@ d|\psi(t)\rangle = -i \hat{K} |\psi(t)\rangle dt + \sum_n \hat{M}_n |\psi(t)\ran where ```math -\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{C}_n - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n - \frac{e_n^2}{8}\right), +\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{S}_n - \frac{1}{2} \hat{S}_n^\dagger \hat{S}_n - \frac{e_n^2}{8}\right), ``` ```math -\hat{M}_n = \hat{C}_n - \frac{e_n}{2}, +\hat{M}_n = \hat{S}_n - \frac{e_n}{2}, ``` and ```math -e_n = \langle \hat{C}_n + \hat{C}_n^\dagger \rangle. +e_n = \langle \hat{S}_n + \hat{S}_n^\dagger \rangle. ``` -Above, ``\hat{C}_n`` is the `n`-th collapse operator and ``dW_n(t)`` is the real Wiener increment associated to ``\hat{C}_n``. See [Wiseman2009Quantum](@cite) for more details. +Above, ``\hat{S}_n`` are the stochastic collapse operators and ``dW_n(t)`` is the real Wiener increment associated to ``\hat{S}_n``. See [Wiseman2009Quantum](@cite) for more details. # Arguments @@ -368,7 +368,7 @@ Above, ``\hat{C}_n`` is the `n`-th collapse operator and ``dW_n(t)`` is the real - `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs. - `ψ0`: Initial state of the system ``|\psi(0)\rangle``. - `tlist`: List of times at which to save either the state or the expectation values of the system. -- `sc_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`. +- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector` or a `Tuple`. - `alg`: The algorithm to use for the stochastic differential equation. Default is `SRA1()`. - `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`. - `params`: `NamedTuple` of parameters to pass to the solver.