Skip to content

Commit

Permalink
Fix bug for classical nondiagonal noise
Browse files Browse the repository at this point in the history
  • Loading branch information
david-pl committed May 28, 2018
1 parent 3509e66 commit 44f6326
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/timeevolution_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function integrate_stoch(tspan::Vector{Float64}, df::Function, dg::Function, x0:
noise_ = noise
end
if isa(noise_rate_prototype, Void)
if n > 1 || (n > 0 && nc > 0)
if n > 1 || nc > 1 || (n > 0 && nc > 0)
noise_rate_prototype = zeros(Complex128, length(x0), n + nc)
end
end
Expand All @@ -147,7 +147,7 @@ function integrate_stoch(tspan::Vector{Float64}, df::Function, dg::Function, x0:
noise_rate_prototype=noise_rate_prototype)

if isa(alg, Void)
if n > 1 || (n > 0 && nc > 0)
if n > 1 || nc > 1 || (n > 0 && nc > 0)
alg_ = StochasticDiffEq.LambaEulerHeun()
else
alg_ = StochasticDiffEq.RKMil{:Stratonovich}()
Expand Down
10 changes: 9 additions & 1 deletion test/test_stochastic_semiclassical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ function fclassical_stoch2(t, psi, u, du)
du[1,1] = 0.2*u[1]
du[2,2] = 0.2*u[2]
end

function fclassical_stoch_ndiag(t, psi, u, du)
du[1,1] = 0.2*u[1]
du[1,2] = 0.1*u[1]
du[2,3] = -0.1u[2]
end

# Function definitions for master_semiclassical
function fquantum_master(t, rho, u)
Expand Down Expand Up @@ -80,6 +84,10 @@ tout, ψt_sc = stochastic.schroedinger_semiclassical(T_short, ψ_sc, fquantum, f
fstoch_quantum=fquantum_stoch, fstoch_classical=fclassical_stoch2,
noise_processes=1,
noise_prototype_classical=zeros(Complex128, 2,2))
tout, ψt_sc = stochastic.schroedinger_semiclassical(T_short, ψ_sc, fquantum, fclassical;
fstoch_classical=fclassical_stoch_ndiag,
noise_prototype_classical=zeros(Complex128, 2, 3))


# Semiclassical master
tout, ρt = stochastic.master_semiclassical(T_short, ρ_sc, fquantum_master, fclassical;
Expand Down

0 comments on commit 44f6326

Please sign in to comment.