Skip to content

Commit e70a26c

Browse files
Replace n_traj with ntraj
1 parent bdac5f4 commit e70a26c

File tree

8 files changed

+44
-44
lines changed

8 files changed

+44
-44
lines changed

benchmarks/timeevolution.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function benchmark_timeevolution!(SUITE)
4747
$ψ0,
4848
$tlist,
4949
$c_ops,
50-
n_traj = 100,
50+
ntraj = 100,
5151
e_ops = $e_ops,
5252
progress_bar = Val(false),
5353
ensemble_method = EnsembleSerial(),
@@ -57,7 +57,7 @@ function benchmark_timeevolution!(SUITE)
5757
$ψ0,
5858
$tlist,
5959
$c_ops,
60-
n_traj = 100,
60+
ntraj = 100,
6161
e_ops = $e_ops,
6262
progress_bar = Val(false),
6363
ensemble_method = EnsembleThreads(),

docs/src/users_guide/steadystate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ exp_ss = real(expect(e_ops[1], ρ_ss))
9494
tlist = LinRange(0, 50, 100)
9595
9696
# monte-carlo
97-
sol_mc = mcsolve(H, ψ0, tlist, c_op_list, e_ops=e_ops, n_traj=100, progress_bar=false)
97+
sol_mc = mcsolve(H, ψ0, tlist, c_op_list, e_ops=e_ops, ntraj=100, progress_bar=false)
9898
exp_mc = real(sol_mc.expect[1, :])
9999
100100
# master eq.

src/time_evolution/mcsolve.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ end
402402
e_ops::Union{Nothing,AbstractVector}=nothing,
403403
H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
404404
params::NamedTuple=NamedTuple(),
405-
n_traj::Int=1,
405+
ntraj::Int=1,
406406
ensemble_method=EnsembleThreads(),
407407
jump_callback::TJC=ContinuousLindbladJumpCallback(),
408408
kwargs...)
@@ -452,7 +452,7 @@ If the environmental measurements register a quantum jump, the wave function und
452452
- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: Time-dependent part of the Hamiltonian.
453453
- `params::NamedTuple`: Dictionary of parameters to pass to the solver.
454454
- `seeds::Union{Nothing, Vector{Int}}`: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
455-
- `n_traj::Int`: Number of trajectories to use.
455+
- `ntraj::Int`: Number of trajectories to use.
456456
- `ensemble_method`: Ensemble method to use.
457457
- `jump_callback::LindbladJumpCallbackType`: The Jump Callback type: Discrete or Continuous.
458458
- `prob_func::Function`: Function to use for generating the ODEProblem.
@@ -482,15 +482,15 @@ function mcsolve(
482482
H_t::Union{Nothing,Function,TimeDependentOperatorSum} = nothing,
483483
params::NamedTuple = NamedTuple(),
484484
seeds::Union{Nothing,Vector{Int}} = nothing,
485-
n_traj::Int = 1,
485+
ntraj::Int = 1,
486486
ensemble_method = EnsembleThreads(),
487487
jump_callback::TJC = ContinuousLindbladJumpCallback(),
488488
prob_func::Function = _mcsolve_prob_func,
489489
output_func::Function = _mcsolve_output_func,
490490
kwargs...,
491491
) where {MT1<:AbstractMatrix,T2,TJC<:LindbladJumpCallbackType}
492-
if !isnothing(seeds) && length(seeds) != n_traj
493-
throw(ArgumentError("Length of seeds must match n_traj ($n_traj), but got $(length(seeds))"))
492+
if !isnothing(seeds) && length(seeds) != ntraj
493+
throw(ArgumentError("Length of seeds must match ntraj ($ntraj), but got $(length(seeds))"))
494494
end
495495

496496
ens_prob_mc = mcsolveEnsembleProblem(
@@ -509,16 +509,16 @@ function mcsolve(
509509
kwargs...,
510510
)
511511

512-
return mcsolve(ens_prob_mc; alg = alg, n_traj = n_traj, ensemble_method = ensemble_method)
512+
return mcsolve(ens_prob_mc; alg = alg, ntraj = ntraj, ensemble_method = ensemble_method)
513513
end
514514

515515
function mcsolve(
516516
ens_prob_mc::EnsembleProblem;
517517
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
518-
n_traj::Int = 1,
518+
ntraj::Int = 1,
519519
ensemble_method = EnsembleThreads(),
520520
)
521-
sol = solve(ens_prob_mc, alg, ensemble_method, trajectories = n_traj)
521+
sol = solve(ens_prob_mc, alg, ensemble_method, trajectories = ntraj)
522522
_sol_1 = sol[:, 1]
523523

524524
expvals_all = Array{ComplexF64}(undef, length(sol), size(_sol_1.prob.p.expvals)...)
@@ -536,7 +536,7 @@ function mcsolve(
536536
expvals = dropdims(sum(expvals_all, dims = 1), dims = 1) ./ length(sol)
537537

538538
return TimeEvolutionMCSol(
539-
n_traj,
539+
ntraj,
540540
times,
541541
states,
542542
expvals,

src/time_evolution/ssesolve.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ end
293293
e_ops::Union{Nothing,AbstractVector}=nothing,
294294
H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
295295
params::NamedTuple=NamedTuple(),
296-
n_traj::Int=1,
296+
ntraj::Int=1,
297297
ensemble_method=EnsembleThreads(),
298298
prob_func::Function=_mcsolve_prob_func,
299299
output_func::Function=_mcsolve_output_func,
@@ -334,7 +334,7 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
334334
- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: Time-dependent part of the Hamiltonian.
335335
- `params::NamedTuple`: Dictionary of parameters to pass to the solver.
336336
- `seeds::Union{Nothing, Vector{Int}}`: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
337-
- `n_traj::Int`: Number of trajectories to use.
337+
- `ntraj::Int`: Number of trajectories to use.
338338
- `ensemble_method`: Ensemble method to use.
339339
- `prob_func::Function`: Function to use for generating the SDEProblem.
340340
- `output_func::Function`: Function to use for generating the output of a single trajectory.
@@ -362,7 +362,7 @@ function ssesolve(
362362
e_ops::Union{Nothing,AbstractVector} = nothing,
363363
H_t::Union{Nothing,Function,TimeDependentOperatorSum} = nothing,
364364
params::NamedTuple = NamedTuple(),
365-
n_traj::Int = 1,
365+
ntraj::Int = 1,
366366
ensemble_method = EnsembleThreads(),
367367
prob_func::Function = _ssesolve_prob_func,
368368
output_func::Function = _ssesolve_output_func,
@@ -382,16 +382,16 @@ function ssesolve(
382382
kwargs...,
383383
)
384384

385-
return ssesolve(ens_prob; alg = alg, n_traj = n_traj, ensemble_method = ensemble_method)
385+
return ssesolve(ens_prob; alg = alg, ntraj = ntraj, ensemble_method = ensemble_method)
386386
end
387387

388388
function ssesolve(
389389
ens_prob::EnsembleProblem;
390390
alg::StochasticDiffEqAlgorithm = SRA1(),
391-
n_traj::Int = 1,
391+
ntraj::Int = 1,
392392
ensemble_method = EnsembleThreads(),
393393
)
394-
sol = solve(ens_prob, alg, ensemble_method, trajectories = n_traj)
394+
sol = solve(ens_prob, alg, ensemble_method, trajectories = ntraj)
395395
_sol_1 = sol[:, 1]
396396

397397
expvals_all = Array{ComplexF64}(undef, length(sol), size(_sol_1.prob.p.expvals)...)
@@ -403,7 +403,7 @@ function ssesolve(
403403
expvals = dropdims(sum(expvals_all, dims = 1), dims = 1) ./ length(sol)
404404

405405
return TimeEvolutionSSESol(
406-
n_traj,
406+
ntraj,
407407
_sol_1.t,
408408
states,
409409
expvals,

src/time_evolution/time_evolution.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ A structure storing the results and some information from solving quantum trajec
5050
5151
# Fields (Attributes)
5252
53-
- `n_traj::Int`: Number of trajectories
53+
- `ntraj::Int`: Number of trajectories
5454
- `times::AbstractVector`: The time list of the evolution in each trajectory.
5555
- `states::Vector{Vector{QuantumObject}}`: The list of result states in each trajectory.
5656
- `expect::Matrix`: The expectation values (averaging all trajectories) corresponding to each time point in `times`.
@@ -70,7 +70,7 @@ struct TimeEvolutionMCSol{
7070
TJT<:Vector{<:Vector{<:Real}},
7171
TJW<:Vector{<:Vector{<:Integer}},
7272
}
73-
n_traj::Int
73+
ntraj::Int
7474
times::TT
7575
states::TS
7676
expect::TE
@@ -87,7 +87,7 @@ function Base.show(io::IO, sol::TimeEvolutionMCSol)
8787
print(io, "Solution of quantum trajectories\n")
8888
print(io, "(converged: $(sol.converged))\n")
8989
print(io, "--------------------------------\n")
90-
print(io, "num_trajectories = $(sol.n_traj)\n")
90+
print(io, "num_trajectories = $(sol.ntraj)\n")
9191
print(io, "num_states = $(length(sol.states[1]))\n")
9292
print(io, "num_expect = $(size(sol.expect, 1))\n")
9393
print(io, "ODE alg.: $(sol.alg)\n")
@@ -100,7 +100,7 @@ end
100100
struct TimeEvolutionSSESol
101101
A structure storing the results and some information from solving trajectories of the Stochastic Shrodinger equation time evolution.
102102
# Fields (Attributes)
103-
- `n_traj::Int`: Number of trajectories
103+
- `ntraj::Int`: Number of trajectories
104104
- `times::AbstractVector`: The time list of the evolution in each trajectory.
105105
- `states::Vector{Vector{QuantumObject}}`: The list of result states in each trajectory.
106106
- `expect::Matrix`: The expectation values (averaging all trajectories) corresponding to each time point in `times`.
@@ -118,7 +118,7 @@ struct TimeEvolutionSSESol{
118118
T1<:Real,
119119
T2<:Real,
120120
}
121-
n_traj::Int
121+
ntraj::Int
122122
times::TT
123123
states::TS
124124
expect::TE
@@ -133,7 +133,7 @@ function Base.show(io::IO, sol::TimeEvolutionSSESol)
133133
print(io, "Solution of quantum trajectories\n")
134134
print(io, "(converged: $(sol.converged))\n")
135135
print(io, "--------------------------------\n")
136-
print(io, "num_trajectories = $(sol.n_traj)\n")
136+
print(io, "num_trajectories = $(sol.ntraj)\n")
137137
print(io, "num_states = $(length(sol.states[1]))\n")
138138
print(io, "num_expect = $(size(sol.expect, 1))\n")
139139
print(io, "SDE alg.: $(sol.alg)\n")

src/time_evolution/time_evolution_dynamical.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ end
687687
H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
688688
params::NamedTuple=NamedTuple(),
689689
δα_list::Vector{<:Real}=fill(0.2, length(op_list)),
690-
n_traj::Int=1,
690+
ntraj::Int=1,
691691
ensemble_method=EnsembleThreads(),
692692
jump_callback::LindbladJumpCallbackType=ContinuousLindbladJumpCallback(),
693693
krylov_dim::Int=max(6, min(10, cld(length(ket2dm(ψ0).data), 4))),
@@ -712,7 +712,7 @@ function dsf_mcsolve(
712712
H_t::Union{Nothing,Function,TimeDependentOperatorSum} = nothing,
713713
params::NamedTuple = NamedTuple(),
714714
δα_list::Vector{<:Real} = fill(0.2, length(op_list)),
715-
n_traj::Int = 1,
715+
ntraj::Int = 1,
716716
ensemble_method = EnsembleThreads(),
717717
jump_callback::TJC = ContinuousLindbladJumpCallback(),
718718
krylov_dim::Int = min(5, cld(length(ψ0.data), 3)),
@@ -736,5 +736,5 @@ function dsf_mcsolve(
736736
kwargs...,
737737
)
738738

739-
return mcsolve(ens_prob_mc; alg = alg, n_traj = n_traj, ensemble_method = ensemble_method)
739+
return mcsolve(ens_prob_mc; alg = alg, ntraj = ntraj, ensemble_method = ensemble_method)
740740
end

test/core-test/dynamical-shifted-fock.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
dsf_params,
6161
e_ops = e_ops_dsf,
6262
progress_bar = Val(false),
63-
n_traj = 500,
63+
ntraj = 500,
6464
)
6565
val_ss = abs2(sol0.expect[1, end])
6666
@test sum(abs2.(sol0.expect[1, :] .- sol_dsf_me.expect[1, :])) / (val_ss * length(tlist)) < 0.1
@@ -140,7 +140,7 @@
140140
dsf_params,
141141
e_ops = e_ops_dsf2,
142142
progress_bar = Val(false),
143-
n_traj = 500,
143+
ntraj = 500,
144144
)
145145

146146
val_ss = abs2(sol0.expect[1, end])

test/core-test/time_evolution.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
sol_me = mesolve(H, psi0, t_l, c_ops, e_ops = e_ops, progress_bar = Val(false))
5555
sol_me2 = mesolve(H, psi0, t_l, c_ops, progress_bar = Val(false))
5656
sol_me3 = mesolve(H, psi0, t_l, c_ops, e_ops = e_ops, saveat = t_l, progress_bar = Val(false))
57-
sol_mc = mcsolve(H, psi0, t_l, c_ops, n_traj = 500, e_ops = e_ops, progress_bar = Val(false))
58-
sol_mc_states = mcsolve(H, psi0, t_l, c_ops, n_traj = 500, saveat = t_l, progress_bar = Val(false))
59-
sol_sse = ssesolve(H, psi0, t_l, c_ops, n_traj = 500, e_ops = e_ops, progress_bar = Val(false))
57+
sol_mc = mcsolve(H, psi0, t_l, c_ops, ntraj = 500, e_ops = e_ops, progress_bar = Val(false))
58+
sol_mc_states = mcsolve(H, psi0, t_l, c_ops, ntraj = 500, saveat = t_l, progress_bar = Val(false))
59+
sol_sse = ssesolve(H, psi0, t_l, c_ops, ntraj = 500, e_ops = e_ops, progress_bar = Val(false))
6060

6161
ρt_mc = [ket2dm.(normalize.(states)) for states in sol_mc_states.states]
6262
expect_mc_states = mapreduce(states -> expect.(Ref(e_ops[1]), states), hcat, ρt_mc)
@@ -87,7 +87,7 @@
8787
"Solution of quantum trajectories\n" *
8888
"(converged: $(sol_mc.converged))\n" *
8989
"--------------------------------\n" *
90-
"num_trajectories = $(sol_mc.n_traj)\n" *
90+
"num_trajectories = $(sol_mc.ntraj)\n" *
9191
"num_states = $(length(sol_mc.states[1]))\n" *
9292
"num_expect = $(size(sol_mc.expect, 1))\n" *
9393
"ODE alg.: $(sol_mc.alg)\n" *
@@ -97,7 +97,7 @@
9797
"Solution of quantum trajectories\n" *
9898
"(converged: $(sol_sse.converged))\n" *
9999
"--------------------------------\n" *
100-
"num_trajectories = $(sol_sse.n_traj)\n" *
100+
"num_trajectories = $(sol_sse.ntraj)\n" *
101101
"num_states = $(length(sol_sse.states[1]))\n" *
102102
"num_expect = $(size(sol_sse.expect, 1))\n" *
103103
"SDE alg.: $(sol_sse.alg)\n" *
@@ -119,14 +119,14 @@
119119
psi0,
120120
t_l,
121121
c_ops,
122-
n_traj = 500,
122+
ntraj = 500,
123123
e_ops = e_ops,
124124
progress_bar = Val(false),
125125
)
126-
@inferred mcsolve(H, psi0, t_l, c_ops, n_traj = 500, e_ops = e_ops, progress_bar = Val(false))
127-
@inferred mcsolve(H, psi0, t_l, c_ops, n_traj = 500, progress_bar = Val(true))
128-
@inferred mcsolve(H, psi0, [0, 10], c_ops, n_traj = 500, progress_bar = Val(false))
129-
@inferred mcsolve(H, Qobj(zeros(Int64, N)), t_l, c_ops, n_traj = 500, progress_bar = Val(false))
126+
@inferred mcsolve(H, psi0, t_l, c_ops, ntraj = 500, e_ops = e_ops, progress_bar = Val(false))
127+
@inferred mcsolve(H, psi0, t_l, c_ops, ntraj = 500, progress_bar = Val(true))
128+
@inferred mcsolve(H, psi0, [0, 10], c_ops, ntraj = 500, progress_bar = Val(false))
129+
@inferred mcsolve(H, Qobj(zeros(Int64, N)), t_l, c_ops, ntraj = 500, progress_bar = Val(false))
130130
end
131131

132132
@testset "Type Inference ssesolve" begin
@@ -135,12 +135,12 @@
135135
psi0,
136136
t_l,
137137
c_ops,
138-
n_traj = 500,
138+
ntraj = 500,
139139
e_ops = e_ops,
140140
progress_bar = Val(false),
141141
)
142-
@inferred ssesolve(H, psi0, t_l, c_ops, n_traj = 500, e_ops = e_ops, progress_bar = Val(false))
143-
@inferred ssesolve(H, psi0, t_l, c_ops, n_traj = 500, progress_bar = Val(true))
142+
@inferred ssesolve(H, psi0, t_l, c_ops, ntraj = 500, e_ops = e_ops, progress_bar = Val(false))
143+
@inferred ssesolve(H, psi0, t_l, c_ops, ntraj = 500, progress_bar = Val(true))
144144
end
145145
end
146146

@@ -179,7 +179,7 @@
179179
psi0 = kron(psi0_1, psi0_2)
180180
t_l = LinRange(0, 20 / γ1, 1000)
181181
sol_me = mesolve(H, psi0, t_l, c_ops, e_ops = [sp1 * sm1, sp2 * sm2], progress_bar = false) # Here we don't put Val(false) because we want to test the support for Bool type
182-
sol_mc = mcsolve(H, psi0, t_l, c_ops, n_traj = 500, e_ops = [sp1 * sm1, sp2 * sm2], progress_bar = Val(false))
182+
sol_mc = mcsolve(H, psi0, t_l, c_ops, ntraj = 500, e_ops = [sp1 * sm1, sp2 * sm2], progress_bar = Val(false))
183183
@test sum(abs.(sol_mc.expect[1:2, :] .- sol_me.expect[1:2, :])) / length(t_l) < 0.1
184184
@test expect(sp1 * sm1, sol_me.states[end]) expect(sigmap() * sigmam(), ptrace(sol_me.states[end], 1))
185185
end

0 commit comments

Comments
 (0)