Time evolution

Single mode example: harmonic oscillator

Let's compute $\langle 0 | O(t) |0\rangle$ for $O(t=0)=a^\dagger a$ and

\[H = \omega a^\dagger a + \Omega (a+a^\dagger)\]

Construct $H$ and $O$

using BosonStrings
ω = 1.0
Ω = 2.5
O = Operator(1)
O += 1, (1, 1, 1)
H = Operator(1)
H += ω, (1, 1, 1)
H += Ω, (1, 0, 1)
H += Ω, (1, 1, 0)
println(H)
(2.5 + 0.0im) (†0)(1)
(2.5 + 0.0im) (†1)(0)
(1.0 + 0.0im) (†1)(1)

Time evolve O in the Heisenberg picture using Runge-Kutta

function evolve(H, O, state, times)
    result = []
    dt = times[2] - times[1]
    for t in times
        push!(result, expect(O, state, state))  # save <0|O|0>
        O = rk4(H, O, dt)  #preform one step of rk4
    end
    return real.(result)
end

times = 0:0.1:20
state = 0
result = evolve(H, O, state, times)
201-element Vector{Real}:
 0
 0.06244791666666668
 0.2491675345052084
 0.558293214200303
 0.9867362775924167
 1.5302158686945355
 2.1833017265353907
 2.9394684424576143
 3.7911606597505823
 4.729868564165697
 ⋮
 0.7596928840471185
 1.246754666549601
 1.8462549624861457
 2.552203771489478
 3.3575474966922907
 4.254239421832854
 5.23332011126382
 6.285006929535112
 7.39879178610218

Plot the result

using Plots
plot(times, result)
xlabel!("Time")
ylabel!("<0|O|0>")
Example block output