Skip to content

Commit 66585c2

Browse files
change jump_times and jump_which definitions
1 parent 28fe4a9 commit 66585c2

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

src/time_evolution/callback_helpers/mcsolve_callback_helpers.jl

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ struct LindbladJump{
2828
cache_mc::CT
2929
weights_mc::WT
3030
cumsum_weights_mc::WT
31-
jump_times::JTT
32-
jump_which::JWT
33-
jump_times_which_idx::JTWIT
31+
col_times::JTT
32+
col_which::JWT
33+
col_times_which_idx::JTWIT
3434
end
3535

3636
(f::LindbladJump)(integrator) = _lindblad_jump_affect!(
@@ -42,9 +42,9 @@ end
4242
f.cache_mc,
4343
f.weights_mc,
4444
f.cumsum_weights_mc,
45-
f.jump_times,
46-
f.jump_which,
47-
f.jump_times_which_idx,
45+
f.col_times,
46+
f.col_which,
47+
f.col_times_which_idx,
4848
)
4949

5050
##
@@ -71,9 +71,9 @@ function _generate_mcsolve_kwargs(ψ0, T, e_ops, tlist, c_ops, jump_callback, rn
7171
weights_mc = Vector{Float64}(undef, length(c_ops))
7272
cumsum_weights_mc = similar(weights_mc)
7373

74-
jump_times = Vector{Float64}(undef, JUMP_TIMES_WHICH_INIT_SIZE)
75-
jump_which = Vector{Int}(undef, JUMP_TIMES_WHICH_INIT_SIZE)
76-
jump_times_which_idx = Ref(1)
74+
col_times = Vector{Float64}(undef, COL_TIMES_WHICH_INIT_SIZE)
75+
col_which = Vector{Int}(undef, COL_TIMES_WHICH_INIT_SIZE)
76+
col_times_which_idx = Ref(1)
7777

7878
random_n = Ref(rand(rng))
7979

@@ -85,9 +85,9 @@ function _generate_mcsolve_kwargs(ψ0, T, e_ops, tlist, c_ops, jump_callback, rn
8585
cache_mc,
8686
weights_mc,
8787
cumsum_weights_mc,
88-
jump_times,
89-
jump_which,
90-
jump_times_which_idx,
88+
col_times,
89+
col_which,
90+
col_times_which_idx,
9191
)
9292

9393
if jump_callback isa DiscreteLindbladJumpCallback
@@ -129,9 +129,9 @@ function _lindblad_jump_affect!(
129129
cache_mc,
130130
weights_mc,
131131
cumsum_weights_mc,
132-
jump_times,
133-
jump_which,
134-
jump_times_which_idx,
132+
col_times,
133+
col_which,
134+
col_times_which_idx,
135135
)
136136
ψ = integrator.u
137137

@@ -147,13 +147,13 @@ function _lindblad_jump_affect!(
147147

148148
random_n[] = rand(traj_rng)
149149

150-
idx = jump_times_which_idx[]
151-
@inbounds jump_times[idx] = integrator.t
152-
@inbounds jump_which[idx] = collapse_idx
153-
jump_times_which_idx[] += 1
154-
if jump_times_which_idx[] > length(jump_times)
155-
resize!(jump_times, length(jump_times) + JUMP_TIMES_WHICH_INIT_SIZE)
156-
resize!(jump_which, length(jump_which) + JUMP_TIMES_WHICH_INIT_SIZE)
150+
idx = col_times_which_idx[]
151+
@inbounds col_times[idx] = integrator.t
152+
@inbounds col_which[idx] = collapse_idx
153+
col_times_which_idx[] += 1
154+
if col_times_which_idx[] > length(col_times)
155+
resize!(col_times, length(col_times) + COL_TIMES_WHICH_INIT_SIZE)
156+
resize!(col_which, length(col_which) + COL_TIMES_WHICH_INIT_SIZE)
157157
end
158158
u_modified!(integrator, true)
159159
return nothing
@@ -309,9 +309,9 @@ function _similar_affect!(affect::LindbladJump, traj_rng)
309309
cache_mc = similar(affect.cache_mc)
310310
weights_mc = similar(affect.weights_mc)
311311
cumsum_weights_mc = similar(affect.cumsum_weights_mc)
312-
jump_times = similar(affect.jump_times)
313-
jump_which = similar(affect.jump_which)
314-
jump_times_which_idx = Ref(1)
312+
col_times = similar(affect.col_times)
313+
col_which = similar(affect.col_which)
314+
col_times_which_idx = Ref(1)
315315

316316
return LindbladJump(
317317
affect.c_ops,
@@ -321,9 +321,9 @@ function _similar_affect!(affect::LindbladJump, traj_rng)
321321
cache_mc,
322322
weights_mc,
323323
cumsum_weights_mc,
324-
jump_times,
325-
jump_which,
326-
jump_times_which_idx,
324+
col_times,
325+
col_which,
326+
col_times_which_idx,
327327
)
328328
end
329329

src/time_evolution/mcsolve.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ end
1414

1515
# Standard output function
1616
function _mcsolve_output_func(sol, i)
17-
idx = _mc_get_jump_callback(sol).affect!.jump_times_which_idx[]
18-
resize!(_mc_get_jump_callback(sol).affect!.jump_times, idx - 1)
19-
resize!(_mc_get_jump_callback(sol).affect!.jump_which, idx - 1)
17+
idx = _mc_get_jump_callback(sol).affect!.col_times_which_idx[]
18+
resize!(_mc_get_jump_callback(sol).affect!.col_times, idx - 1)
19+
resize!(_mc_get_jump_callback(sol).affect!.col_which, idx - 1)
2020
return (sol, false)
2121
end
2222

@@ -403,8 +403,8 @@ function mcsolve(
403403
_expvals_all = _expvals_sol_1 isa Nothing ? nothing : map(i -> _mcsolve_get_expvals(sol[:, i]), eachindex(sol))
404404
expvals_all = _expvals_all isa Nothing ? nothing : stack(_expvals_all)
405405
states = map(i -> _normalize_state!.(sol[:, i].u, Ref(dims), normalize_states), eachindex(sol))
406-
jump_times = map(i -> _mc_get_jump_callback(sol[:, i]).affect!.jump_times, eachindex(sol))
407-
jump_which = map(i -> _mc_get_jump_callback(sol[:, i]).affect!.jump_which, eachindex(sol))
406+
col_times = map(i -> _mc_get_jump_callback(sol[:, i]).affect!.col_times, eachindex(sol))
407+
col_which = map(i -> _mc_get_jump_callback(sol[:, i]).affect!.col_which, eachindex(sol))
408408

409409
expvals = _expvals_sol_1 isa Nothing ? nothing : dropdims(sum(expvals_all, dims = 3), dims = 3) ./ length(sol)
410410

@@ -414,8 +414,8 @@ function mcsolve(
414414
states,
415415
expvals,
416416
expvals_all,
417-
jump_times,
418-
jump_which,
417+
col_times,
418+
col_which,
419419
sol.converged,
420420
_sol_1.alg,
421421
NamedTuple(_sol_1.prob.kwargs).abstol,

src/time_evolution/time_evolution.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export liouvillian_floquet, liouvillian_generalized
44

55
const DEFAULT_ODE_SOLVER_OPTIONS = (abstol = 1e-8, reltol = 1e-6, save_everystep = false, save_end = true)
66
const DEFAULT_SDE_SOLVER_OPTIONS = (abstol = 1e-2, reltol = 1e-2, save_everystep = false, save_end = true)
7-
const JUMP_TIMES_WHICH_INIT_SIZE = 200
7+
const COL_TIMES_WHICH_INIT_SIZE = 200
88

99
@doc raw"""
1010
struct TimeEvolutionProblem
@@ -100,8 +100,8 @@ A structure storing the results and some information from solving quantum trajec
100100
- `states::Vector{Vector{QuantumObject}}`: The list of result states in each trajectory.
101101
- `expect::Union{AbstractMatrix,Nothing}`: The expectation values (averaging all trajectories) corresponding to each time point in `times`.
102102
- `expect_all::Union{AbstractMatrix,Nothing}`: The expectation values corresponding to each trajectory and each time point in `times`
103-
- `jump_times::Vector{Vector{Real}}`: The time records of every quantum jump occurred in each trajectory.
104-
- `jump_which::Vector{Vector{Int}}`: The indices of the jump operators in `c_ops` that describe the corresponding quantum jumps occurred in each trajectory.
103+
- `col_times::Vector{Vector{Real}}`: The time records of every quantum jump occurred in each trajectory.
104+
- `col_which::Vector{Vector{Int}}`: The indices of which collapse operator was responsible for each quantum jump in `col_times`.
105105
- `converged::Bool`: Whether the solution is converged or not.
106106
- `alg`: The algorithm which is used during the solving process.
107107
- `abstol::Real`: The absolute tolerance which is used during the solving process.
@@ -123,8 +123,8 @@ struct TimeEvolutionMCSol{
123123
states::TS
124124
expect::TE
125125
expect_all::TEA
126-
jump_times::TJT
127-
jump_which::TJW
126+
col_times::TJT
127+
col_which::TJW
128128
converged::Bool
129129
alg::AlgT
130130
abstol::AT

test/core-test/time_evolution.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@
661661

662662
@test sol_mc1.expect sol_mc2.expect atol = 1e-10
663663
@test sol_mc1.expect_all sol_mc2.expect_all atol = 1e-10
664-
@test sol_mc1.jump_times sol_mc2.jump_times atol = 1e-10
665-
@test sol_mc1.jump_which sol_mc2.jump_which atol = 1e-10
664+
@test sol_mc1.col_times sol_mc2.col_times atol = 1e-10
665+
@test sol_mc1.col_which sol_mc2.col_which atol = 1e-10
666666

667667
@test sol_mc1.expect_all sol_mc3.expect_all[:, :, 1:500] atol = 1e-10
668668

0 commit comments

Comments
 (0)