Skip to content

Commit 5213402

Browse files
authored
work towards MTKV10 (#243)
1 parent b99c9ae commit 5213402

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+315
-277
lines changed

.github/workflows/Documenter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- uses: actions/checkout@v4
4141
- uses: julia-actions/setup-julia@v2
4242
with:
43-
version: 'lts'
43+
version: '1'
4444
- uses: julia-actions/cache@v2
4545
- uses: julia-actions/julia-buildpkg@v1
4646
- uses: julia-actions/julia-docdeploy@v1

.github/workflows/Tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
fail-fast: false
4747
matrix:
4848
version:
49-
- 'pre'
49+
# - 'pre'
5050
- 'lts'
5151
- '1'
5252
os:

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ LaTeXStrings = "1"
2727
Latexify = "0.13, 0.14, 0.15, 0.16"
2828
LinearAlgebra = "1.10"
2929
MacroTools = "0.5"
30-
ModelingToolkit = "~9.70"
30+
ModelingToolkit = "10"
3131
OrdinaryDiffEq = "6"
3232
OrderedCollections = "1.8"
3333
QuantumOptics = "1"
3434
QuantumOpticsBase = "0.4, 0.5"
3535
Random = "1.10"
3636
SciMLBase = "1, 2"
37-
SecondQuantizedAlgebra = "0.3.1"
37+
SecondQuantizedAlgebra = "=0.4.1"
3838
SteadyStateDiffEq = "2"
3939
SymbolicUtils = "3.6"
4040
Symbolics = "6"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ rates = [κ,γ,ν]
4444
eqs = meanfield([a,σ(:g,:e),σ(:e,:e)], H, J; rates=rates, order=1)
4545

4646
using ModelingToolkit, OrdinaryDiffEq
47-
@named sys = ODESystem(eqs)
48-
p0 ==>0, g=>1.5, κ=>1, γ=>0.25, ν=>4)
49-
u0 = ComplexF64[1e-2, 0, 0]
50-
prob = ODEProblem(sys,u0,(0.0,50.0),p0)
47+
@named sys = System(eqs)
48+
p0 = Dict=>0, g=>1.5, κ=>1, γ=>0.25, ν=>4)
49+
u0 = Dict(unknowns(sys) => ComplexF64[1e-2, 0, 0])
50+
prob = ODEProblem(sys,merge(u0, p0),(0.0,50.0))
5151
sol = solve(prob,RK4())
5252

5353
using Plots
@@ -58,7 +58,7 @@ plot(sol.t, n, xlabel="t", label="n")
5858
![photon-number](https://user-images.githubusercontent.com/18166442/114183684-3ae76080-9944-11eb-9d21-94bf4069bb60.png)
5959

6060

61-
The above code implements the Jaynes-Cummings Hamiltonian describing an optical cavity mode that couples to a two-level atom. Additionally, the decay processes are specified. Then, mean-field equations for the average values of the operators `[a,σ(:g,:e),σ(:e,:e)]` are derived and expanded to first order (average values of products are factorized). For the numerical solution an `ODESystem` (from [ModelingToolkit.jl](https://github.com/SciML/ModelingToolkit.jl)) is created and solved with the [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl) library. Finally, the time dynamics of the photon number `n` is plotted.
61+
The above code implements the Jaynes-Cummings Hamiltonian describing an optical cavity mode that couples to a two-level atom. Additionally, the decay processes are specified. Then, mean-field equations for the average values of the operators `[a,σ(:g,:e),σ(:e,:e)]` are derived and expanded to first order (average values of products are factorized). For the numerical solution an `System` (from [ModelingToolkit.jl](https://github.com/SciML/ModelingToolkit.jl)) is created and solved with the [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl) library. Finally, the time dynamics of the photon number `n` is plotted.
6262

6363

6464
## Citing

docs/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1717
Documenter = "1"
1818
Latexify = "0.13, 0.14, 0.15, 0.16"
1919
MacroTools = "0.5"
20-
ModelingToolkit = "9"
2120
OrdinaryDiffEq = "6"
2221
Plots = "1"
2322
QuantumOptics = "1"
2423
QuantumOpticsBase = "0.4.21"
2524
StochasticDiffEq = "6"
26-
SymbolicUtils = "3.6.0 - 3.20.0"
25+
SymbolicUtils = "3.26.0"
2726
Symbolics = "6"

docs/src/correlation.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,27 @@ nothing # hide
4747
```
4848
When the [`CorrelationFunction`](@ref) is constructed, an additional Hilbert space is added internally which represents the system at the time ``t``. In our case, this means that another [`FockSpace`](@ref) is added. Note that all operators involved in the correlation function are defined on the [`ProductSpace`](@ref) including this additional Hilbert space.
4949

50-
The equation for ``g(t,\tau)`` is now stored in the first entry of `c.de`. To solve the above numerically, we need to convert to an `ODESystem` and solve numerically.
50+
The equation for ``g(t,\tau)`` is now stored in the first entry of `c.de`. To solve the above numerically, we need to convert to an `System` and solve numerically.
5151
```@example correlation
5252
using ModelingToolkit, OrdinaryDiffEq
5353
54-
@named sys = ODESystem(me)
54+
@named sys = System(me)
5555
n0 = 20.0 # Initial number of photons in the cavity
56-
u0 = [n0]
57-
p0 = (ωc => 1, κ => 1)
58-
prob = ODEProblem(sys,u0,(0.0,2.0),p0) # End time not in steady state
56+
n_avg = unknowns(sys) |> first
57+
p0 = (ωc => 1, κ => 1, n_avg => n0) # Initial values and parameters
58+
prob = ODEProblem(sys,Dict(p0),(0.0,2.0)) # End time not in steady state
5959
sol = solve(prob,RK4())
6060
nothing # hide
6161
```
6262
Numerically computing the correlation function works in the same way. Note, the initial state of the correlation function depends on the final state of the system. However, in general it does not depend on *all* the final values of the system. The correct values can be picked out automatically using the [`correlation_u0`](@ref) function.
6363
```@example correlation
64-
@named csys = ODESystem(c)
64+
@named csys = System(c)
6565
u0_c = correlation_u0(c, sol.u[end])
66-
prob_c = ODEProblem(csys,u0_c,(0.0,10.0),p0)
66+
prob_c = ODEProblem(csys,merge(Dict(u0_c),Dict(p0)),(0.0,10.0))
6767
sol_c = solve(prob_c,RK4(),save_idxs=1)
6868
nothing # hide
6969
```
70-
Finally, lets check our numerical solution against the analytic one obtained above:
70+
Finally, let's check our numerical solution against the analytic one obtained above:
7171
```@example correlation
7272
using Test # hide
7373
g_analytic(τ) = @. sol.u[end] * exp((im*p0[1][2]-0.5p0[2][2])*τ)

docs/src/examples/cavity_antiresonance_indexed.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ To create the equations for a specific number of atoms we use the function $\tex
101101
```@example antiresonance_indexed
102102
N_ = 2
103103
eqs_ = evaluate(eqs;limits=(N=>N_))
104-
@named sys = ODESystem(eqs_)
104+
@named sys = System(eqs_)
105105
nothing # hide
106106
```
107107

@@ -149,7 +149,8 @@ for i=1:length(Δ_ls)
149149
p0_ = [Δc_i; η_; Δa_i; κ_; gi_; Γij_; Ωij_]
150150
151151
# create (remake) new ODEProblem
152-
prob_ = ODEProblem(sys,u0,(0.0, 20),ps.=>p0_)
152+
dict = merge(Dict(unknowns(sys) .=> u0), Dict(ps .=> p0_))
153+
prob_ = ODEProblem(sys,dict,(0.0, 20))
153154
sol_ = solve(prob_, Tsit5())
154155
n_ls[i] = abs2(sol_[a][end])
155156
end

docs/src/examples/excitation-transport-chain.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ Rather, we only need to derive the equations once and substitute the noisy posit
6464
eqs = meanfield(σ(:g,:e,1),H,c_ops;rates=[γ for i=1:N],order=2)
6565
complete!(eqs) # complete the set
6666
67-
# Generate the ODESystem
68-
@named sys = ODESystem(eqs)
67+
# Generate the System
68+
@named sys = System(eqs)
6969
nothing # hide
7070
```
7171

72-
Once we have our set of equations and converted it to an `ODESystem` we are ready to solve for the dynamics.
72+
Once we have our set of equations and converted it to an `System` we are ready to solve for the dynamics.
7373
First, let's have a look at the excitation transport for perfectly positioned atoms.
7474
We assume an equidistant chain, were neighboring atoms are separated by a distance $d$.
7575

@@ -81,7 +81,8 @@ p = [γ => 1.0; Δ => 0.0; Ω => 2.0; J0 => 1.25; x .=> x0;]
8181
8282
# Create ODEProblem
8383
u0 = zeros(ComplexF64, length(eqs)) # initial state -- all atoms in the ground state
84-
prob = ODEProblem(sys,u0,(0.0,15.0),p)
84+
dict = merge(Dict(unknowns(sys) .=> u0), Dict(p))
85+
prob = ODEProblem(sys,dict,(0.0,15.0))
8586
8687
# Solve
8788
sol = solve(prob,RK4())
@@ -112,7 +113,8 @@ function prob_func(prob,i,repeat)
112113
x_ = x0 .+ s.*randn(N)
113114
p_ = [γ => 1.0; Δ => 0.0; Ω => 2.0; J0 => 1.25; x .=> x_;]
114115
# Return new ODEProblem
115-
return ODEProblem(sys,u0,(0.0,15.0),p_)
116+
dict = merge(Dict(unknowns(sys) .=> u0), Dict(p_))
117+
return ODEProblem(sys,dict,(0.0,15.0))
116118
end
117119
118120
trajectories = 20

docs/src/examples/filter-cavity_indexed.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ To calculate the dynamics of the system we create a system of ordinary different
9999

100100

101101
```@example filter_cavity_indexed
102-
@named sys = ODESystem(eqs_eval)
102+
@named sys = System(eqs_eval)
103103
nothing # hide
104104
```
105105

@@ -124,7 +124,8 @@ gf_ = 0.1Γ_
124124
ps = [Γ, κ, g, κf, gf, R, [δ(i) for i=1:M_]..., Δ, ν, N]
125125
p0 = [Γ_, κ_, g_, κf_, gf_, R_, δ_ls..., Δ_, ν_, N_]
126126
127-
prob = ODEProblem(sys,u0,(0.0, 10.0/κf_), ps.=>p0)
127+
dict = merge(Dict(unknowns(sys) .=> u0), Dict(ps .=> p0))
128+
prob = ODEProblem(sys,dict,(0.0, 10.0/κf_))
128129
nothing # hide
129130
```
130131

docs/src/examples/heterodyne_detection.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ scaled_eqs = scale(eqs_c)
8888
```
8989

9090
# Deterministic time evolution
91-
Here we define the actual values for the system parameters. We then show that the deterministic time evolution without the noise terms is still accessible by using the constructor ODESystem for the stochastic system of equations and the syntax for the simulation of the time evolution is as usual.
91+
Here we define the actual values for the system parameters. We then show that the deterministic time evolution without the noise terms is still accessible by using the constructor System for the stochastic system of equations and the syntax for the simulation of the time evolution is as usual.
9292

9393

9494
```julia
@@ -98,9 +98,10 @@ g_ = 6.531*10^3; ωl_ = 2.0 * π * 10^3; t0=0.0;t1=20e-6
9898
p = [N,ωa,γ,η,χ,ωc,κ,g,ξ,ωl]
9999
p0 = [N_,ωa_,γ_,η_,χ_,ωc_,κ_,g_,ξ_,ωl_]
100100

101-
@named sys = ODESystem(scaled_eqs)
101+
@named sys = System(scaled_eqs)
102102
u0 = zeros(ComplexF64,length(scaled_eqs.equations))
103-
prob = ODEProblem(sys, u0,(0.0,1e-3),p.=>p0)
103+
dict = merge(Dict(unknowns(sys) .=> u0), Dict(p .=> p0))
104+
prob = ODEProblem(sys, dict,(0.0,1e-3))
104105
sol_det = solve(prob,RK4(),dt=1e-9)
105106

106107
plot(sol_det.t .* 1000, map(x -> real(x[2]), sol_det.u))
@@ -110,7 +111,7 @@ xlabel("Time (ms)")
110111
```
111112

112113
# Stochastic time evolution
113-
The stochastic time evolution is accessible via the constructor SDESystem, whose syntax is exactly the same as for the ODESystem, but with keyword args as defined in https://docs.sciml.ai/DiffEqDocs/stable/tutorials/sde_example/. We then need to provide a noise process for the measurement. If the noise is white the appropriate noise process is a Wiener process. The SDEProblem is then constructed just as the ODEProblem, but with an additional noise argument.
114+
The stochastic time evolution is accessible via the constructor SDESystem, whose syntax is exactly the same as for the System, but with keyword args as defined in https://docs.sciml.ai/DiffEqDocs/stable/tutorials/sde_example/. We then need to provide a noise process for the measurement. If the noise is white the appropriate noise process is a Wiener process. The SDEProblem is then constructed just as the ODEProblem, but with an additional noise argument.
114115

115116
We can then make use of the EnsembleProblem which automatically runs multiple instances of the stochastic equations of motion. The number of trajectories can then be set in the solve call. See the documentation cited above for more details of the function calls here.
116117

0 commit comments

Comments
 (0)