-
Notifications
You must be signed in to change notification settings - Fork 121
Spurious results with steadystate.iterative for non-linear system #428
Description
Considering the steady state of non-linear systems, e.g. a quartic Harmonic oscillator
where we are interested in steadystate.master and steadystate.eigenvector produce accurate and coinciding results for the steady state, while the iterative solver fails to find the appropriate nullspace. The result of the iterative solver depends strongly on the random seed. I'm not sure if I'm missing something or if this is a bug or something else, but everything seems to work fine for linear systems, viz. without the
Please find a code snippet below for reproducing these results. (The last section checks if a given density matrix indeed has (approximately) zero eigenvalue
using QuantumOptics
using Random; Random.seed!(2)
basis = FockBasis(10)
f = 0.5
Ω = 0.5
nl = 0.5
n = number(basis)
b = destroy(basis)
bt = create(basis)
H(x::Integer) = dense(Ω * n + f * (b + bt) + nl * (b + bt)^x)
J = [b, ]
# Works for linear systems
H_linear = H(2)
tout, ρ_master = steadystate.master(H_linear, J)
ρ_eig = steadystate.eigenvector(H_linear, J)
ρ_it = steadystate.iterative(H_linear,J)
println("--Linear Systems")
println("n_master = ", real(expect(n, ρ_master[end])))
println("n_eig = ", real(expect(n, ρ_eig)))
println("n_it = ", real(expect(n, ρ_it)))
# Doesn't work for non-linear systems
H_non_linear = H(4)
tout, ρ_master = steadystate.master(H_non_linear, J)
ρ_eig = steadystate.eigenvector(H_non_linear, J)
ρ_it = steadystate.iterative(H_non_linear,J)
println("\n--Non-Linear Systems")
println("n_master = ", real(expect(n, ρ_master[end])))
println("n_eig = ", real(expect(n, ρ_eig)))
println("n_it = ", real(expect(n, ρ_it)))
# Nullspace structure
L = liouvillian(H_non_linear, J).data
M = size(ρ_eig, 1)
vec_master = reshape(ρ_master[end].data, M^2)
vec_eig = reshape(ρ_eig.data, M^2)
vec_it = reshape(ρ_it.data, M^2)
println("\n--Null-space deviation (Should be Δmax ≈ 0)")
println("Δmax_master = ", maximum(abs.(L * vec_master)))
println("Δmax_eigen = ", maximum(abs.(L * vec_eig)))
println("Δmax_iter = ", maximum(abs.(L * vec_it)))VersionInfo
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 8 × Apple M3
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 8 default, 0 interactive, 4 GC (on 4 virtual cores)
Environment:
JULIA_NUM_THREADS = 8
JULIA_EDITOR = code
and [6e0679c1] QuantumOptics v1.2.1