From 40696b3fb4fc337ba780aab649e40f1af10da014 Mon Sep 17 00:00:00 2001 From: sd109 <49713135+sd109@users.noreply.github.com> Date: Mon, 16 Sep 2019 17:55:22 +0100 Subject: [PATCH 1/2] Made bloch_redfield_tensor function type-stable --- src/bloch_redfield_master.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bloch_redfield_master.jl b/src/bloch_redfield_master.jl index 10e2ba76..a4f7a2d7 100644 --- a/src/bloch_redfield_master.jl +++ b/src/bloch_redfield_master.jl @@ -31,7 +31,8 @@ function bloch_redfield_tensor(H::AbstractOperator, a_ops::Array; J=[], use_secu # use the eigenbasis H_evals, transf_mat = eigen(DenseOperator(H).data) - H_ekets = [Ket(H.basis_l, transf_mat[:, i]) for i in 1:length(H_evals)] + H_ekets = [Ket(H.basis_l, transf_mat[:, i]) for i in 1:length(H_evals)]::Array{Ket{typeof(H.basis_l), Array{Complex{Float64}, 1}}, 1} + #Define function for transforming to Hamiltonian eigenbasis function to_Heb(op) @@ -49,11 +50,12 @@ function bloch_redfield_tensor(H::AbstractOperator, a_ops::Array; J=[], use_secu if K==0 Heb = to_Heb(H) L = liouvillian(Heb, to_Heb.(J)) + L = sparse(L) return L, H_ekets end #Transform interaction operators to Hamiltonian eigenbasis - A = Array{Complex}(undef, N, N, K) + A = Array{Complex{Float64}}(undef, N, N, K) for k in 1:K A[:, :, k] = to_Heb(a_ops[k][1]).data end @@ -87,6 +89,7 @@ function bloch_redfield_tensor(H::AbstractOperator, a_ops::Array; J=[], use_secu # Calculate Liouvillian for Lindblad temrs (unitary part + dissipation from J (if given)): Heb = to_Heb(H) L = liouvillian(Heb, to_Heb.(J)) + L = sparse(L) # Main Bloch-Redfield operators part rows = Int[] @@ -126,7 +129,7 @@ function bloch_redfield_tensor(H::AbstractOperator, a_ops::Array; J=[], use_secu elem = 0.5 * sum(view(A, c, a, :) .* view(A, b, d, :) .* (view(Jw, c, a, :) + view(Jw, d, b, :) )) if b == d - elem -= 0.5 * sum(transpose(view(A, a, :, :)) .* transpose(view(A, c, :, :)) .* transpose(view(Jw, c, :, :) )) + elem -= 0.5 * sum(transpose(view(A, a, :, :)) .* transpose(view(A, c, :, :)) .* transpose(view(Jw, c, :, :) )) end if a == c From eeb21efb6d1737fc71bb7d6fff942c0495ed0c0d Mon Sep 17 00:00:00 2001 From: David Plankensteiner Date: Tue, 26 Nov 2019 13:59:48 +0100 Subject: [PATCH 2/2] Quick patch failing tests --- test/test_timecorrelations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_timecorrelations.jl b/test/test_timecorrelations.jl index 566c5039..0075d971 100644 --- a/test/test_timecorrelations.jl +++ b/test/test_timecorrelations.jl @@ -52,7 +52,7 @@ omega_sample = mod(n, 2) == 0 ? [-n/2:n/2-1;] : [-(n-1)/2:(n-1)/2;] omega_sample .*= 2pi/tspan[end] omega, S = timecorrelations.spectrum(omega_sample, H, J, op; rho_ss=ρ₀) -omega2, S2 = timecorrelations.spectrum(H, J, op) +omega2, S2 = timecorrelations.spectrum(H, J, op; tol=1e-3) @test length(omega2) == length(S2) omegaFFT, SFFT = timecorrelations.correlation2spectrum(tspan, exp_values)