Skip to content

Commit 8fe048a

Browse files
committed
update documentation
1 parent d789c87 commit 8fe048a

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

docs/src/users_guide/steadystate.md

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

docs/src/users_guide/time_evolution/mcsolve.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ c_ops = [sqrt(0.1) * a]
7070
e_ops = [a' * a, σm' * σm]
7171
7272
sol_500 = mcsolve(H, ψ0, times, c_ops, e_ops=e_ops)
73+
expect_avg = average_expect(sol_500)
7374
7475
# plot by CairoMakie.jl
7576
fig = Figure(size = (500, 350))
@@ -78,8 +79,8 @@ ax = Axis(fig[1, 1],
7879
ylabel = "Expectation values",
7980
title = "Monte Carlo time evolution (500 trajectories)",
8081
)
81-
lines!(ax, times, real(sol_500.expect[1,:]), label = "cavity photon number", linestyle = :solid)
82-
lines!(ax, times, real(sol_500.expect[2,:]), label = "atom excitation probability", linestyle = :dash)
82+
lines!(ax, times, real(expect_avg[1,:]), label = "cavity photon number", linestyle = :solid)
83+
lines!(ax, times, real(expect_avg[2,:]), label = "atom excitation probability", linestyle = :dash)
8384
8485
axislegend(ax, position = :rt)
8586
@@ -104,9 +105,9 @@ ax = Axis(fig[1, 1],
104105
ylabel = "Expectation values",
105106
title = "Monte Carlo time evolution",
106107
)
107-
lines!(ax, times, real(sol_1.expect[1,:]), label = "1 trajectory", linestyle = :dashdot)
108-
lines!(ax, times, real(sol_10.expect[1,:]), label = "10 trajectories", linestyle = :dash)
109-
lines!(ax, times, real(sol_100.expect[1,:]), label = "100 trajectories", linestyle = :solid)
108+
lines!(ax, times, real(average_expect(sol_1)[1,:]), label = "1 trajectory", linestyle = :dashdot)
109+
lines!(ax, times, real(average_expect(sol_10)[1,:]), label = "10 trajectories", linestyle = :dash)
110+
lines!(ax, times, real(average_expect(sol_100)[1,:]), label = "100 trajectories", linestyle = :solid)
110111
111112
axislegend(ax, position = :rt)
112113

docs/src/users_guide/time_evolution/solution.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,23 @@ Some other solvers can have other output.
8989

9090
## [Multiple trajectories solution](@id doc-TE:Multiple-trajectories-solution)
9191

92-
This part is still under construction, please read the docstrings for the following functions first:
92+
The solutions are different for solvers which compute multiple trajectories, such as the [`TimeEvolutionMCSol`](@ref) (Monte Carlo) or the [`TimeEvolutionStochasticSol`](@ref) (stochastic methods). The expectation values and states for all trajectories at each time points will be stored in these solutions. The index-order of the elements in fields `states` and `expect` are:
9393

94-
- [`TimeEvolutionMCSol`](@ref)
95-
- [`TimeEvolutionStochasticSol`](@ref)
94+
```julia
95+
sol.states[trajectory][time]
96+
sol.expect[e_op,trajectory,time]
97+
```
98+
99+
We also provide the following functions for statistical analysis of multi-trajectory `sol`utions:
100+
101+
| **Functions** | **Description** |
102+
|:------------|:----------------|
103+
| [`average_states(sol)`](@ref average_states) | Return the trajectory-averaged result states (as density [`Operator`](@ref)) at each time point. |
104+
| [`average_expect(sol)`](@ref average_expect) | Return the trajectory-averaged expectation values at each time point. |
105+
| [`std_expect(sol)`](@ref std_expect) | Return the trajectory-wise standard deviation of the expectation values at each time point. |
106+
107+
Multi-trajectory solutions also keep the random number generator (`rng`) to allow recomputing the results:
108+
109+
```julia
110+
rng = sol.rng # this can be specified as a keyword argument (`rng = rng`) to the solvers
111+
```

docs/src/users_guide/time_evolution/stochastic.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ sse_sol = ssesolve(
111111
measurement_avg = sum(sse_sol.measurement, dims=2) / size(sse_sol.measurement, 2)
112112
measurement_avg = dropdims(measurement_avg, dims=2)
113113
114+
expect_avg = average_expect(sse_sol)
115+
114116
# plot by CairoMakie.jl
115117
fig = Figure(size = (500, 350))
116118
ax = Axis(fig[1, 1], xlabel = "Time")
117119
lines!(ax, tlist[1:end-1], real(measurement_avg[1,:]), label = L"J_x", color = :red, linestyle = :solid)
118-
lines!(ax, tlist, real(sse_sol.expect[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid)
120+
lines!(ax, tlist, real(expect_avg[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid)
119121
120122
axislegend(ax, position = :rt)
121123
@@ -141,14 +143,16 @@ sme_sol = smesolve(
141143
store_measurement = Val(true),
142144
)
143145
146+
expect_avg = average_expect(sme_sol)
147+
144148
measurement_avg = sum(sme_sol.measurement, dims=2) / size(sme_sol.measurement, 2)
145149
measurement_avg = dropdims(measurement_avg, dims=2)
146150
147151
# plot by CairoMakie.jl
148152
fig = Figure(size = (500, 350))
149153
ax = Axis(fig[1, 1], xlabel = "Time")
150154
lines!(ax, tlist[1:end-1], real(measurement_avg[1,:]), label = L"J_x", color = :red, linestyle = :solid)
151-
lines!(ax, tlist, real(sme_sol.expect[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid)
155+
lines!(ax, tlist, real(expect_avg[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid)
152156
153157
axislegend(ax, position = :rt)
154158

docs/src/users_guide/time_evolution/time_dependent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ e_ops = [
132132
133133
# solve dynamics
134134
exp_me = mesolve(H_t, ψ0, tlist, c_ops; e_ops = e_ops, progress_bar = Val(false)).expect
135-
exp_mc = mcsolve(H_t, ψ0, tlist, c_ops; e_ops = e_ops, ntraj = 100, progress_bar = Val(false)).expect
135+
exp_mc = average_expect(mcsolve(H_t, ψ0, tlist, c_ops; e_ops = e_ops, ntraj = 100, progress_bar = Val(false)))
136136
137137
# plot by CairoMakie.jl
138138
fig = Figure(size = (500, 350))

0 commit comments

Comments
 (0)