|
| 1 | +--- |
| 2 | +title: "Adiabatic sweep (with `QuantumObjectEvolution`)" |
| 3 | +author: Li-Xun Cai |
| 4 | +date: 2025-04-20 # last update (keep this comment as a reminder) |
| 5 | + |
| 6 | +engine: julia |
| 7 | +--- |
| 8 | + |
| 9 | +Inspirations taken from [the QuTiP tutorial](https://nbviewer.org/urls/qutip.org/qutip-tutorials/tutorials-v5/lectures/Lecture-8-Adiabatic-quantum-computing.ipynb) by J. R. Johansson. |
| 10 | + |
| 11 | +This tutorial mainly demonstrates the use of [`QuantumObjectEvolution`](https://qutip.org/QuantumToolbox.jl/stable/resources/api#QuantumToolbox.QuantumObjectEvolution). |
| 12 | + |
| 13 | +## Introduction |
| 14 | + |
| 15 | +The quantum adiabatic theorem is a fundamental principle in quantum mechanics that describes how quantum systems evolve when subjected to time-dependent conditions. This theorem states that if a quantum system is initialized in an eigenstate (typically the ground state) of its initial Hamiltonian, and if the Hamiltonian changes sufficiently slow, the system will remain in the corresponding eigenstate of the evolving Hamiltonian throughout the process. |
| 16 | + |
| 17 | +For this theorem to hold, certain conditions must be satisfied: the system must evolve slow enough compared to the energy gap between the relevant eigenstate and other energy levels, and this gap must remain non-zero throughout the evolution. |
| 18 | + |
| 19 | +Here, we will demonstrate the well-known application of the adiabatic theorem in quantum computing called $\text{\emph{adiabatic sweep}}$. This is a method for preparing some desired quantum state by slowly evolving a quantum system with a time-dependent Hamiltonian. Essentially, the adiabatic theorem allows us to prepare the ground state of the final Hamiltonian $H_1$ from the ground state of the initial Hamiltonian $H_0$. |
| 20 | + |
| 21 | +## Model |
| 22 | + |
| 23 | +We consider a chain of $N$-identical spin-$1/2$ particles to study their spin dynamics and set our interest in finding the ground state of the condition that the spin chain has some random gap, leading to the random magnitude $g_i$ of $\hat{\sigma}^i_x \hat{\sigma}^{i+1}_x$ interaction with the neighboring spin. |
| 24 | + |
| 25 | +Initially, we prepare the system such that the spins are free from interaction with each other and are all in the ground state, i.e., |
| 26 | + |
| 27 | +$$H_0 = \sum_i^N \frac{\varepsilon_0}{2} \hat{\sigma}^i_z,$$ |
| 28 | +$$|\psi(0)\rangle = \bigotimes_{i=1}^N |g\rangle$$ |
| 29 | + |
| 30 | +Then, gradually, the Hamiltonian evolves to: |
| 31 | + |
| 32 | +$$H_1 = \sum_{i=1}^N \frac{\varepsilon_0}{2} \hat{\sigma}^i_z + \sum_{i=1}^{N-1} g_i \hat{\sigma}^i_x \hat{\sigma}^{i+1}_x,$$ |
| 33 | + |
| 34 | +whose ground state are desired. By gradual change, we are subject to the simplest form of adiabatic sweep, i.e., |
| 35 | + |
| 36 | +$$H(t,T) = H_0 * (1-t/T) + H_1 * t/T,$$ |
| 37 | + |
| 38 | +where the parameter $T$ determines how slow the Hamiltonian changes in time. |
| 39 | + |
| 40 | +## Code demonstration |
| 41 | + |
| 42 | +```{julia} |
| 43 | +using QuantumToolbox |
| 44 | +using CairoMakie |
| 45 | +``` |
| 46 | + |
| 47 | +```{julia} |
| 48 | +N = 8 # number of spins |
| 49 | +ε0 = 1 # energy gap of the spins |
| 50 | +
|
| 51 | +gs = rand(N-1) # use rand function for the random interaction strengths |
| 52 | +``` |
| 53 | + |
| 54 | +```{julia} |
| 55 | +H0 = sum(1:N) do i |
| 56 | + ε0/2 * multisite_operator(Val(N), i=>sigmaz()) |
| 57 | +end |
| 58 | +
|
| 59 | +ψ0 = kron(fill(basis(2,1), N)...) |
| 60 | +print(H0) |
| 61 | +``` |
| 62 | + |
| 63 | +```{julia} |
| 64 | +Hint = sum(1:N-1) do i |
| 65 | + gs[i] * multisite_operator(Val(N), i=>sigmax(), i+1=>sigmax()) |
| 66 | +end |
| 67 | +
|
| 68 | +H1 = H0 + Hint |
| 69 | +
|
| 70 | +print(H1) |
| 71 | +``` |
| 72 | + |
| 73 | +Here, we define the time-dependent Hamiltonian with `QuantumObjectEvolution`. |
| 74 | +```{julia} |
| 75 | +H = QuantumObjectEvolution(( |
| 76 | + (H0, (p,t) -> 1 - t/p.T), |
| 77 | + (H1, (p,t) -> t/p.T), |
| 78 | +)) |
| 79 | +``` |
| 80 | +We will show below the usage of field `p` in solving the eigen problems and the dynamics. |
| 81 | + |
| 82 | +```{julia} |
| 83 | +function ψg(H) |
| 84 | + _, vecs = eigenstates(H) |
| 85 | + return vecs[1] |
| 86 | +end |
| 87 | +
|
| 88 | +ψf_truth = ψg(H1) |> to_sparse |
| 89 | +print(ψf_truth) |
| 90 | +``` |
| 91 | + |
| 92 | +We can see that the truthful ground state we are preparing is indeed very complex. |
| 93 | + |
| 94 | +For the adiabatic theorem to apply, we have to check for the gap between the ground state and first excited state remaining non-zero throughout the evolution. |
| 95 | +```{julia} |
| 96 | +T = 10 |
| 97 | +tlist = 0:0.1:T |
| 98 | +eigs = Array{Float64}(undef, length(tlist), 2^N) |
| 99 | +
|
| 100 | +params = (T=T,) |
| 101 | +for (idx, t) in enumerate(tlist) |
| 102 | + # passing `params` and `t` to `H` can yield the `QuantumObject` with `p = params` at time `t` |
| 103 | + vals, _ = eigenstates(H(params, t)) |
| 104 | + eigs[idx,:] = vals |
| 105 | +end |
| 106 | +``` |
| 107 | + |
| 108 | +```{julia} |
| 109 | +fig = Figure(size=(800, 400)) |
| 110 | +ax = Axis(fig[1,1], xticks = (0:0.25:1, ["$(t)T" for t in 0:0.25:1])) |
| 111 | +
|
| 112 | +for idx in 1:20 # only check for the lowest 20 eigenvalues |
| 113 | + color = (idx == 1) ? :magenta : (:gray,0.5) |
| 114 | + lines!(ax, range(0,1,length(tlist)), eigs[:,idx], label = string(idx), color = color) |
| 115 | +end |
| 116 | +
|
| 117 | +display(fig) |
| 118 | +``` |
| 119 | + |
| 120 | +The plot shows that the gap is nonvanishing and thus validates the evolution. So we proceed to check the expectation value dynamics of the final Hamiltonian and the fidelity dynamics to the truthful ground state throughout the evolution. |
| 121 | +```{julia} |
| 122 | +Tlist = 10 .^ (0:0.25:1.25) |
| 123 | +results = map(Tlist) do T |
| 124 | + tlist = range(0,T, 101) |
| 125 | + params = (T=T,) |
| 126 | + sesolve(H, ψ0, tlist, e_ops = [H1, ket2dm(ψf_truth)], params=params) |
| 127 | + # for solving dynamics, we can pass `params` to the keyword argument `params` for its reference |
| 128 | +end; |
| 129 | +``` |
| 130 | + |
| 131 | +```{julia} |
| 132 | +fig = Figure(size=(800, 400)) |
| 133 | +axs = Axis.([fig[1,1], fig[1,2]]) |
| 134 | +axs[1].title = L"\langle H_f \rangle" |
| 135 | +axs[1].xticks = (0:0.25:1, ["$(t)T" for t in 0:0.25:1]) |
| 136 | +axs[2].title = L"|\langle \psi_G^f |\psi(t)\rangle|^2" |
| 137 | +axs[2].xticks = (0:0.25:1, ["$(t)T" for t in 0:0.25:1]) |
| 138 | +
|
| 139 | +for ax_idx in 1:2, T_idx in 1:length(Tlist) |
| 140 | + T = Tlist[T_idx] |
| 141 | + exps = results[T_idx].expect |
| 142 | + tlist = range(0,1,101) |
| 143 | + lines!(axs[ax_idx], tlist, real(exps[ax_idx,:]), label = L"10^{%$(string(log10(T)))}") |
| 144 | +end |
| 145 | +
|
| 146 | +Legend(fig[1,3], axs[1], L"T") |
| 147 | +
|
| 148 | +display(fig) |
| 149 | +``` |
| 150 | +As the plot showed, the fidelity between the prepared final state and the truthful ground state reaches 1 as the total evolution time $T$ increases, showcasing the requirement of the adiabatic theorem that the change has to be gradual. |
| 151 | + |
| 152 | + |
| 153 | +## Version Information |
| 154 | +```{julia} |
| 155 | +QuantumToolbox.versioninfo() |
| 156 | +``` |
0 commit comments