Skip to content

Commit

Permalink
Make semiclassical normalization more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
david-pl committed Jun 21, 2018
1 parent d19673d commit e0a2b50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/stochastic_semiclassical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function schroedinger_semiclassical(tspan, state0::State{Ket}, fquantum::Functio
if normalize_state
len_q = length(state0.quantum)
function norm_func(u::Vector{Complex128}, t::Float64, integrator)
normalize!(view(u, 1:len_q))
u .= [normalize!(u[1:len_q]), u[len_q+1:end];]
end
ncb = DiffEqCallbacks.FunctionCallingCallback(norm_func;
func_everystep=true,
Expand Down
17 changes: 7 additions & 10 deletions test/test_stochastic_semiclassical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,20 @@ function fstoch_J2(t, rho, u)
end

# Test semiclassical schroedinger
tout, ψt_sc = stochastic.schroedinger_semiclassical(T_short, ψ_sc, fquantum, fclassical;
fstoch_quantum=fquantum_stoch, dt=dt)
tout, ψt_sc = stochastic.schroedinger_semiclassical(T, ψ_sc, fquantum, fclassical;
fstoch_quantum=fquantum_stoch, dt=dt, normalize_state=true)
for ψ=ψt_sc
@test norm.quantum) 1.0
end
tout, ψt_sc = stochastic.schroedinger_semiclassical(T_short, ψ_sc, fquantum, fclassical;
fstoch_classical=fclassical_stoch, dt=dt)
tout, ψt_sc = stochastic.schroedinger_semiclassical(T_short, ψ_sc, fquantum, fclassical;
fstoch_quantum=fquantum_stoch, fstoch_classical=fclassical_stoch2,
noise_processes=1,
noise_prototype_classical=zeros(Complex128, 2,2), dt=dt)
tout, ψt_sc = stochastic.schroedinger_semiclassical(T, ψ_sc, fquantum, fclassical;
tout, ψt_sc = stochastic.schroedinger_semiclassical(T_short, ψ_sc, fquantum, fclassical;
fstoch_classical=fclassical_stoch_ndiag,
noise_prototype_classical=zeros(Complex128, 2, 3), dt=dt,
normalize_state=true)

for ψ=ψt_sc
@test norm.quantum) 1.0
end

noise_prototype_classical=zeros(Complex128, 2, 3), dt=dt)

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

0 comments on commit e0a2b50

Please sign in to comment.