Hamiltonians

Quantum Hamiltonians encode the essential physical properties of a quantum system. For the analog mode of neutral-atom quantum computers, the quantum dynamics is governed by the Rydberg Hamiltonian $\hat{\mathcal{H}}$:

\[i \hbar \dfrac{\partial}{\partial t} | \psi \rangle = \hat{\mathcal{H}}(t) | \psi \rangle, \\ \frac{\mathcal{H}(t)}{\hbar} = \sum_j \frac{\Omega_j(t)}{2} \left( e^{i \phi_j(t) } | g_j \rangle \langle r_j | + e^{-i \phi_j(t) } | r_j \rangle \langle g_j | \right) - \sum_j \Delta_j(t) \hat{n}_j + \sum_{j < k} V_{jk} \hat{n}_j \hat{n}_k,\]

where $\Omega_j$, $\phi_j$, and $\Delta_j$ denote the Rabi frequency, laser phase, and the detuning of the driving laser field on atom (qubit) $j$ coupling the two states $| g_j \rangle$ (ground state) and $| r_j \rangle$ (Rydberg state); $\hat{n}_j = |r_j\rangle \langle r_j|$ is the number operator, and $V_{jk} = C_6/|\mathbf{x}_j - \mathbf{x}_k|^6$ describes the Rydberg interaction (van der Waals interaction) between atoms $j$ and $k$ where $\mathbf{x}_j$ denotes the position of the atom $j$; $C_6$ is the Rydberg interaction constant that depends on the particular Rydberg state used. For Bloqade, the default $C_6 = 862690 \times 2\pi \text{ MHz μm}^6$ for $|r \rangle = \lvert 70S_{1/2} \rangle$ of the $^{87}$Rb atoms; $\hbar$ is the reduced Planck's constant.

One can use the Rydberg Hamiltonian to understand the ground state properties of the corresponding system and to generate interesting quantum dynamics. The Rydberg Hamiltonian is generally specified by atom positions $\mathbf{x}_j$, Rabi frequencies $\Omega_j$, laser phase $\phi_j$, and detunings $\Delta_j$. In Bloqade, we can easily create a Hamiltonian by inputting these variable parameters into the function rydberg_h. Furthermore, by inputting waveforms for the Rabi frequency and detuning, we can easily generate time-dependent Hamiltonians.

Building Time-Independent Hamiltonians

To specify the Hamiltonian, we first need to specify the atom positions, which determine the Rydberg interactions strengths $V_{jk}$ between pairs of atoms. Here, we generate a square lattice by using the code below:

julia> using Bloqade
julia> atoms = generate_sites(SquareLattice(), 3, 3, scale=6.3)9-element AtomList{2, Float64}: (0.0, 0.0) (6.3, 0.0) (12.6, 0.0) (0.0, 6.3) (6.3, 6.3) (12.6, 6.3) (0.0, 12.6) (6.3, 12.6) (12.6, 12.6)

Please refer to the Lattices page for more details on how to generate lattices and the relevant operations.

Then, the Hamiltonian can be simply built by inputting the generated atom positions atoms and by specifying the strength of the detuning Δ, Rabi frequency Ω, and laser phase ϕ:

julia> h0 = rydberg_h(atoms; Δ=1.2*2π, Ω=1.1*2π, ϕ=2.1)nqubits: 9
+
├─ [+] ∑ 2π ⋅ 8.627e5.0/|x_i-x_j|^6 n_i n_j
├─ [+] 2π ⋅ 0.55 ⋅ ∑ e^{2.1 ⋅ im} |0⟩⟨1| + e^{-2.1 ⋅ im} |1⟩⟨0|
└─ [-] 2π ⋅ 1.2 ⋅ ∑ n_i

Note that the default value for the Rydberg interaction constant is $C_6 = 2\pi \times 862690 \text{ MHz μm}^6$ to match the default unit used on the hardware. For more information about units, please refer to Bloqade. Instead of using the default value for $C_6$, the users are free to set their own values. For instance, if the users would like to have a chain lattice with nearest-neighbor atoms separated by 1 μm, and interaction strength to be a particular value, say, $2\pi * 10.0^6 \text{ MHz μm}^6$, it can be done with the following code:

julia> atoms = generate_sites(ChainLattice(), 9, scale=1.0)9-element AtomList{1, Float64}:
 (0.0,)
 (1.0,)
 (2.0,)
 (3.0,)
 (4.0,)
 (5.0,)
 (6.0,)
 (7.0,)
 (8.0,)
julia> h0 = rydberg_h(atoms; C=2π*10.0^6, Δ=1.2*2π, Ω=1.1*2π, ϕ=2.1)nqubits: 9 + ├─ [+] ∑ 2π ⋅ 10.0e5.0/|x_i-x_j|^6 n_i n_j ├─ [+] 2π ⋅ 0.55 ⋅ ∑ e^{2.1 ⋅ im} |0⟩⟨1| + e^{-2.1 ⋅ im} |1⟩⟨0| └─ [-] 2π ⋅ 1.2 ⋅ ∑ n_i

Building Time-Dependent Hamiltonians

One can also directly use waveforms (instead of constant values of detuning, Rabi frequency, and laser phase) to build a time-dependent Hamiltonian. First, let us again use the generate_sites to create a list of atom coordinates:

julia> atoms = generate_sites(ChainLattice(), 5, scale=5.72)5-element AtomList{1, Float64}:
 (0.0,)
 (5.72,)
 (11.44,)
 (17.16,)
 (22.88,)

Then, we generate the time-dependent pulses for $\Omega$ and $\Delta$ by using piecewise_linear. For details on how to create waveforms and the built-in functions, please refer to the page Waveforms.

julia> Ω1 = piecewise_linear(clocks=[0.0, 0.1, 2.1, 2.2], values=2π*[0.0, 6.0, 6.0, 0]);
julia> Δ1 = piecewise_linear(clocks=[0.0, 0.6, 2.1, 2.2], values=2π*[-10.1, -10.1, 10.1, 10.1]);

The time-dependent Hamiltonian can then be easily generated by inputting the waveforms into the function rydberg_h:

julia> h1 = rydberg_h(atoms; Δ=Δ1, Ω=Ω1)nqubits: 5
+
├─ [+] ∑ 2π ⋅ 8.627e5.0/|x_i-x_j|^6 n_i n_j
├─ [+] Ω(t) ⋅ ∑ σ^x_i
└─ [-] Δ(t) ⋅ ∑ n_i

By specifying the time of h1, we can access the Hamiltonian at a particular time, e.g.:

julia> ht= h1 |> attime(0.5)nqubits: 5
+
├─ [+] ∑ 2π ⋅ 8.627e5.0/|x_i-x_j|^6 n_i n_j
├─ [+] 2π ⋅ 3.0 ⋅ ∑ σ^x_i
└─ [-] 2π ⋅ -10.1 ⋅ ∑ n_i

Building Hamiltonians with Site-Dependent Waveforms

In certain cases, the user may want to build a Hamiltonian that has site-dependent $\Omega_j$, $\phi_j$, and $\Delta_j$, which may or may not have time dependence.

For the time-independent Hamiltonian, one can for example build a Hamiltonian like:

julia> h0 = rydberg_h(atoms; Δ=1.2*2π*rand(length(atoms)), Ω=1.1*2π*rand(length(atoms)), ϕ=2.1)nqubits: 5
+
├─ [+] ∑ 2π ⋅ 8.627e5.0/|x_i-x_j|^6 n_i n_j
├─ [+] ∑ Ω_i ⋅ (e^{2.1 ⋅ im} |0⟩⟨1| + e^{-2.1 ⋅ im} |1⟩⟨0|)
└─ [-] ∑ Δ_i ⋅ n_i

For time-dependent Hamiltonians, here is an example:

julia> atoms = generate_sites(ChainLattice(), 5, scale=5.72)5-element AtomList{1, Float64}:
 (0.0,)
 (5.72,)
 (11.44,)
 (17.16,)
 (22.88,)
julia> Δ1 = map(1:length(atoms)) do idx Waveform(t-> idx*sin(2π*t), duration = 2) end5-element Vector{Waveform{Main.var"#2#4"{Int64}, Int64}}: Waveform(_, 2) Waveform(_, 2) Waveform(_, 2) Waveform(_, 2) Waveform(_, 2)
julia> h =rydberg_h(atoms; Δ=Δ1)nqubits: 5 + ├─ [+] ∑ 2π ⋅ 8.627e5.0/|x_i-x_j|^6 n_i n_j └─ [-] ∑ Δ_i ⋅ n_i

Hamiltonian Expressions

Bloqade uses "block"s from Yao to build symbolic hamiltonian expressions. This gives users the flexibility to define various kinds of Hamiltonians by simply writing down the expression.

Please refer to the References section below for the types of operators supported by Bloqade.

As an example, we can explicitly add up some Hamiltonian terms to compose a new Hamiltonian, e.g.:

julia> using Bloqade
julia> h = 2π*1.1*SumOfX(5, 1.0) + 2π*1.2*SumOfZ(5, 1.0)nqubits: 5 + ├─ [scale: 6.911503837897546] ∑ σ^x_i └─ [scale: 7.5398223686155035] ∑ σ^z_i

Convert Hamiltonians to Matrices

An Hamiltonian expression can be converted to a matrix via the mat interface from Yao:

YaoAPI.matFunction
mat([T=ComplexF64], blk)

Returns the most compact matrix form of given block, e.g

Examples

julia> mat(X)
2×2 LuxurySparse.SDPermMatrix{ComplexF64, Int64, Vector{ComplexF64}, Vector{Int64}}:
 0.0+0.0im  1.0+0.0im
 1.0+0.0im  0.0+0.0im

julia> mat(Float64, X)
2×2 LuxurySparse.SDPermMatrix{Float64, Int64, Vector{Float64}, Vector{Int64}}:
 0.0  1.0
 1.0  0.0

julia> mat(kron(X, X))
4×4 LuxurySparse.SDPermMatrix{ComplexF64, Int64, Vector{ComplexF64}, Vector{Int64}}:
 0.0+0.0im  0.0+0.0im  0.0+0.0im  1.0+0.0im
 0.0+0.0im  0.0+0.0im  1.0+0.0im  0.0+0.0im
 0.0+0.0im  1.0+0.0im  0.0+0.0im  0.0+0.0im
 1.0+0.0im  0.0+0.0im  0.0+0.0im  0.0+0.0im

julia> mat(kron(X, X) + put(2, 1=>X))
4×4 SparseMatrixCSC{ComplexF64, Int64} with 8 stored entries:
     ⋅      1.0+0.0im      ⋅      1.0+0.0im
 1.0+0.0im      ⋅      1.0+0.0im      ⋅
     ⋅      1.0+0.0im      ⋅      1.0+0.0im
 1.0+0.0im      ⋅      1.0+0.0im      ⋅    

This method will return the most compact matrix representation of the operator, e.g.:

julia> mat(X) # will return a PermMatrix2×2 LuxurySparse.SDPermMatrix{ComplexF64, Int64, Vector{ComplexF64}, Vector{Int64}}:
 0.0+0.0im  1.0+0.0im
 1.0+0.0im  0.0+0.0im
julia> mat(ht) # will return a SparseMatrixCSC32×32 SparseMatrixCSC{ComplexF64, Int64} with 191 stored entries: ⎡⢞⣵⠑⢄⠑⢄⠀⠀⠑⢄⠀⠀⠀⠀⠀⠀⎤ ⎢⠑⢄⢟⣵⠀⠀⠑⢄⠀⠀⠑⢄⠀⠀⠀⠀⎥ ⎢⠑⢄⠀⠀⢟⣵⠑⢄⠀⠀⠀⠀⠑⢄⠀⠀⎥ ⎢⠀⠀⠑⢄⠑⢄⢟⣵⠀⠀⠀⠀⠀⠀⠑⢄⎥ ⎢⠑⢄⠀⠀⠀⠀⠀⠀⢟⣵⠑⢄⠑⢄⠀⠀⎥ ⎢⠀⠀⠑⢄⠀⠀⠀⠀⠑⢄⢟⣵⠀⠀⠑⢄⎥ ⎢⠀⠀⠀⠀⠑⢄⠀⠀⠑⢄⠀⠀⢟⣵⠑⢄⎥ ⎣⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠑⢄⠑⢄⢟⣵⎦

The Hamiltonian matrix can also be created in a subspace, such as the blockade subspace (see also Working with Subspace). This will allow one to simulate larger system sizes because of the smaller truncated Hilbert space.

For the Rydberg Hamiltonian, we can create a subspace via the blockade_subspace method, e.g.:

julia> space = blockade_subspace(atoms, 7.5)5-qubits 13-elements Subspace{Int64, Vector{Int64}}:
───┬───
  1│ 0
  2│ 1
  3│ 2
   ⋮│ ⋮
 11│ 18
 12│ 20
 13│ 21

The above code means that the blockade subspace only includes states where there is only one Rydberg excitation within the distance of 7.5 μm, which we call the subspace radius $R_s$. If we have a chain of atoms separated by 5.72 μm, the blockade subspace does not contain states with nearest-neighbor atoms being simultaneously excited to the Rydberg state $| r \rangle$.

Once we have defined the space, we can convert the Hamiltonian to a matrix in a subspace basis via the codes below:

julia> h_m = mat(ht, space)13×13 SparseMatrixCSC{ComplexF64, Int64} with 52 stored entries:
         ⋅      18.8496+0.0im  18.8496+0.0im  …          ⋅              ⋅
 18.8496+0.0im  63.4602+0.0im          ⋅                 ⋅              ⋅
 18.8496+0.0im          ⋅      63.4602+0.0im             ⋅              ⋅
 18.8496+0.0im          ⋅              ⋅         18.8496+0.0im          ⋅
         ⋅      18.8496+0.0im          ⋅                 ⋅      18.8496+0.0im
 18.8496+0.0im          ⋅              ⋅      …          ⋅              ⋅
         ⋅      18.8496+0.0im          ⋅                 ⋅              ⋅
         ⋅              ⋅      18.8496+0.0im             ⋅              ⋅
 18.8496+0.0im          ⋅              ⋅         18.8496+0.0im          ⋅
         ⋅      18.8496+0.0im          ⋅                 ⋅      18.8496+0.0im
         ⋅              ⋅      18.8496+0.0im  …          ⋅              ⋅
         ⋅              ⋅              ⋅         129.338+0.0im  18.8496+0.0im
         ⋅              ⋅              ⋅         18.8496+0.0im  195.255+0.0im

We can see that the size of the Hamiltonian matrix in the blockade subspace is much smaller than that in the full Hilbert space.

Diagonalization of the Hamiltonian

Bloqade doesn't provide any built-in diagonalization tool, as there are many existing tools in the Julia ecosystem. Here, we demonstrate how to use the KrylovKit package for this purpose as follows:

julia> using KrylovKit
julia> vals, vecs, info = KrylovKit.eigsolve(h_m, 1, :SR)([-23.531833672850894, 49.369907160338045, 51.29063792209698, 55.89104071504431, 61.44324863140744, 65.27248354593036, 124.97072996229845, 130.65930913081706, 133.5372339586212, 135.9516391216485, 139.9982481558148, 146.74962587152322, 210.19192698918917], Vector{ComplexF64}[[0.8638542911758462 - 0.044856933677591686im, -0.22346087078713064 + 0.011603541896853198im, -0.2101667568166254 + 0.010913225028871014im, -0.21118264445146978 + 0.010965976522642168im, 0.055384115129779796 - 0.0028759034996366432im, -0.21016675681662492 + 0.010913225028871255im, 0.05425093486240586 - 0.002817061409463114im, 0.05182890364631126 - 0.0026912937947910606im, -0.2234608707871304 + 0.01160354189685307im, 0.05779804466046237 - 0.0030012504221052245im, 0.05425093486240582 - 0.002817061409463075im, 0.055384115129779664 - 0.002875903499636611im, -0.014522839327447558 + 0.0007541202806727323im], [0.08840280609274985 + 0.058926926443334963im, 0.31436087509377275 + 0.2095444814713026im, -0.36220032437583155 - 0.2414329682007387im, 0.32721954321800334 + 0.21811572286290035im, -0.1665016289450986 - 0.11098549554240933im, -0.3622003243758321 - 0.24143296820073337im, 0.011596203122780632 + 0.00772971626852068im, 0.17074998735184715 + 0.1138173366841551im, 0.31436087509376565 + 0.20954448147129315im, -0.1684858266180554 - 0.11230810820020842im, 0.011596203122782176 + 0.007729716268523648im, -0.16650162894509804 - 0.11098549554240633im, 0.0647967234768331 + 0.04319174839407706im], [-7.954872654689082e-15 - 5.692139650217401e-15im, 0.26227647242404306 + 0.4910354976221661im, -0.16416341334062298 - 0.3073476725382262im, 1.0947406176020635e-14 + 7.395668279175371e-15im, -0.0633431462244785 - 0.11859139723749884im, 0.1641634133406086 + 0.30734767253821543im, -0.10598616731643876 - 0.1984279029235719im, 3.833738881908744e-15 + 2.9351521213527576e-15im, -0.26227647242406427 - 0.49103549762218135im, 5.8904704031137456e-15 + 3.9126688000656884e-15im, 0.10598616731644973 + 0.19842790292358026im, 0.06334314622447926 + 0.11859139723749922im, -7.836613302725226e-16 - 4.1049249503016805e-16im], [0.13643578210862403 + 0.09431559192488609im, 0.36689979513089743 + 0.2536312015812727im, 0.1045917098794257 + 0.07230235994732714im, -0.5384356623502954 - 0.37221084837997503im, 0.039887838857171815 + 0.027573742564272294im, 0.10459170987942402 + 0.07230235994734255im, -0.12475023500434612 - 0.08623758427123349im, -0.053684857067706225 - 0.03711137205716597im, 0.3668997951308743 + 0.25363120158124275im, -0.19890378374329853 - 0.13749859318366392im, -0.12475023500434167 - 0.08623758427122248im, 0.0398878388571766 + 0.02757374256427976im, 0.016112625085966076 + 0.01113836670234172im], [1.3798641049223015e-15 + 1.6881976502500229e-15im, -0.36286853357970283 - 0.07314483315446403im, -0.5786373876789181 - 0.11663820712472601im, -2.2197955279468218e-15 - 1.072492789022661e-15im, 0.1007421568934327 + 0.02030699158424734im, 0.5786373876789148 + 0.11663820712472478im, -0.06191482940014888 - 0.012480414935917292im, 4.2240516640035253e-16 + 6.461844948013606e-16im, 0.36286853357971394 + 0.07314483315447148im, -2.5032059758345326e-15 - 2.022253892119963e-15im, 0.0619148294001471 + 0.012480414935915524im, -0.10074215689343366 - 0.020306991584248642im, 3.8033812210791496e-16 + 5.159176037772273e-16im], [-0.3483706714567186 - 0.2671113415465079im, -0.0756531536643223 - 0.05800664930547458im, -0.32883660409317317 - 0.2521337002958291im, -0.39736290523987267 - 0.3046758737054797im, 0.15508288201447287 + 0.11890896697063504im, -0.32883660409318394 - 0.25213370029583837im, 0.12325305170718426 + 0.09450361551258626im, 0.19350125130503373 + 0.14836604531285041im, -0.07565315366432124 - 0.0580066493054654im, 0.06276097942937083 + 0.04812164394336713im, 0.12325305170718054 + 0.09450361551258173im, 0.15508288201447257 + 0.11890896697063262im, -0.05408056637013982 - 0.04146598384507705im], [-0.019873974910583302 - 0.026328409721523748im, -0.054352469225148345 - 0.07200442214376462im, 0.022025556949719704 + 0.029178757159855483im, -0.067108704081979 - 0.08890347627489174im, -0.0995587979113845 - 0.13189232826280714im, 0.02202555694971951 + 0.02917875715985563im, 0.281857086194493 + 0.37339530122338926im, -0.19010851053459513 - 0.2518497069369786im, -0.05435246922514818 - 0.07200442214376292im, -0.3397892732786426 - 0.4501420197071255im, 0.2818570861944938 + 0.3733953012233857im, -0.09955879791138922 - 0.13189232826280378im, 0.14453050320799743 + 0.19146941277920965im], [6.591949208711867e-17 - 2.804221156497977e-16im, 0.02809213212821024 - 0.027090104078095333im, 0.08436118058604938 - 0.08135207223848412im, 1.8041124150158794e-16 - 2.130240428499519e-15im, 0.40089886775337574 - 0.38659906633872265im, -0.0843611805860503 + 0.0813520722384846im, -0.3007497152638079 + 0.2900221688681599im, -2.6367796834847468e-15 + 1.8596235662471372e-15im, -0.028092132128208103 + 0.027090104078095922im, 4.954370247389761e-15 + 6.938893903907228e-15im, 0.30074971526380845 - 0.2900221688681622im, -0.4008988677533746 + 0.3865990663387154im, -1.7208456881689926e-15 + 2.498001805406602e-16im], [0.011675533211618992 + 0.028232514394218488im, -0.016590233491696638 - 0.040116712219309736im, 0.00452845785598468 + 0.010950228078262292im, 0.10683735188091528 + 0.25834255448104104im, 0.192757038515445 + 0.46610426828798185im, 0.004528457855982361 + 0.010950228078263808im, -0.035499346063445826 - 0.08584068757765949im, 0.04065927703313757 + 0.0983178757911951im, -0.016590233491695063 - 0.04011671221930953im, -0.23061079683502134 - 0.5576381414963222im, -0.035499346063436577 - 0.08584068757766425im, 0.19275703851544312 + 0.4661042682879884im, -0.047310195302772834 - 0.11440040858687958im], [0.04101577741299004 - 0.014734549029185202im, 0.19690035391438243 - 0.0707346806913586im, -0.11569231471587269 + 0.04156142321323643im, 0.13340851250344804 - 0.04792580788118837im, 0.23602279273701296 - 0.08478906486573012im, -0.1156923147158706 + 0.04156142321323495im, 0.17357235145400796 - 0.06235430568239014im, -0.659516683648268 + 0.23692543513035244im, 0.19690035391437907 - 0.07073468069135902im, 0.3066268440868275 - 0.11015293511008717im, 0.17357235145399577 - 0.06235430568238623im, 0.23602279273701327 - 0.0847890648657364im, -0.24750270276962505 + 0.08891311926371351im], [7.546047120499111e-17 - 3.4704040991840115e-16im, -0.224968506022502 - 0.030619968644462224im, 0.12699737371706357 + 0.017285333266855225im, -5.984795992119984e-16 - 2.2620794126737565e-15im, -0.3978089486892855 - 0.05414490121623829im, -0.12699737371706554 - 0.017285333266855843im, -0.515669162291402 - 0.07018659571264271im, -3.8441472227646045e-15 - 7.112366251504909e-16im, 0.22496850602250404 + 0.030619968644462384im, 1.7746221159242737e-15 + 2.5431046157819992e-15im, 0.5156691622914028 + 0.07018659571264282im, 0.3978089486892855 + 0.05414490121623164im, -4.961309141293668e-16 + 1.3070057189312756e-15im], [0.09338564308547775 + 0.08519184696997355im, 0.1497576885103233 + 0.13661772474459288im, 0.18358059028434726 + 0.16747295448665878im, 0.060359572153423253 + 0.055063532939008106im, 0.0866608724513178 + 0.0790571177777273im, 0.18358059028434634 + 0.16747295448665808im, 0.3202977567470556 + 0.2921943521087609im, 0.397493650853002 + 0.3626169629094842im, 0.14975768851032437 + 0.1366177247445934im, 0.1613814575175836 + 0.14722160685925936im, 0.3202977567470573 + 0.29219435210876166im, 0.08666087245132026 + 0.07905711777772667im, -0.13006942047797798 - 0.11865693482124101im], [0.015789818256351933 + 0.009307625914911103im, 0.05634694538956243 + 0.03321484013427261im, 0.0040299845663444465 + 0.0023755554482907193im, 0.05531884651833875 + 0.03260880657888064im, 0.20741603743706447 + 0.1222655545411801im, 0.004029984566344259 + 0.002375555448290581im, 0.013701998597165732 + 0.0080769186293672im, 0.0018790394182317729 + 0.0011076375738041486im, 0.05634694538956245 + 0.03321484013427283im, 0.20171713200101396 + 0.11890622012313702im, 0.013701998597165624 + 0.008076918629367118im, 0.2074160374370644 + 0.12226555454118011im, 0.7780264855113519 + 0.4586233585126446im]], ConvergenceInfo: 13 converged values after 1 iterations and 13 applications of the linear map; norms of residuals are given by (2.6137825643928436e-38, 9.998772819409518e-32, 3.8524306176537453e-32, 4.5903621622939074e-32, 6.070828439924351e-32, 2.1813866339225488e-32, 1.4118470661037655e-31, 3.132529623762058e-30, 1.4095544931634795e-30, 1.823758856018857e-30, 4.519764799256165e-31, 4.090645096752917e-33, 3.4870464574311516e-38). )

where the vals and vecs store the calculated eigenvalues and eigenvectors respectively.

Low-Level Representation of the Hamiltonian

Besides the symbolic representation, in order to achieve the best possible performance, we use a lower-level representation of the Hamiltonian in Bloqade, which is the Hamiltonian and StepHamiltonian type:

BloqadeExpr.Lowlevel.HamiltonianType
struct Hamiltonian

Hamiltonian stores the dynamic prefactors of each term. The actual hamiltonian is the sum of f_i(t) * t_i where f_i and t_i are entries of fs and ts.

source
Missing docstring.

Missing docstring for BloqadeExpr.StepHamiltonian. Check Documenter's build log for details.

The Hamiltonian type represents the following Hamiltonian expression

\[f_1(t) H_1 + f_2(t) H_2 + \cdots + f_n(t) H_n + H_c,\]

where $f_i(t)$ are time-dependent parameters of the Hamiltonian, $H_i$ are time-independent local terms of the Hamiltonian as linear operators (in Julia, this means objects that support LinearAlgebra.mul! interface), and $H_c$ is the constant component of the Hamiltonian.

A Hamiltonian object supports callable methods, which will produce a StepHamiltonian that is time-independent, e.g.:

julia> using BloqadeExpr
julia> h = BloqadeExpr.Hamiltonian(Float64, SumOfX(5, sin) + SumOfZ(5, cos))Hamiltonian number of dynamic terms: 2 storage size: 48 bytes
julia> h(0.1)BloqadeExpr.Lowlevel.SumOfLinop{Vector{Float64}, Tuple{typeof(sin), typeof(cos), typeof(one)}, Tuple{SparseMatrixCSC{Float64, Int64}, Diagonal{Float64, Vector{Float64}}}}([0.09983341664682815, 0.9950041652780258, 1.0], BloqadeExpr.Lowlevel.Hamiltonian{Tuple{typeof(sin), typeof(cos), typeof(one)}, Tuple{SparseMatrixCSC{Float64, Int64}, Diagonal{Float64, Vector{Float64}}}}((sin, cos, one), (sparse([2, 3, 5, 9, 17, 1, 4, 6, 10, 18 … 15, 23, 27, 29, 32, 16, 24, 28, 30, 31], [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 … 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 32, 32), [5.0 0.0 … 0.0 0.0; 0.0 3.0 … 0.0 0.0; … ; 0.0 0.0 … -3.0 0.0; 0.0 0.0 … 0.0 -5.0])))

Here, we see that the Hamiltonian expression written as Yao blocks are automatically analyzed into time-dependent terms and constant terms. A more complicated example can be SumOfXPhase:

julia> using BloqadeExpr
julia> h = BloqadeExpr.Hamiltonian(Float64, SumOfXPhase(5, sin, cos) + SumOfZ(5, cos))Hamiltonian number of dynamic terms: 3 storage size: 88 bytes
julia> h(0.1)BloqadeExpr.Lowlevel.SumOfLinop{Vector{Number}, Tuple{BloqadeExpr.var"#67#101", BloqadeExpr.var"#69#103", typeof(cos), typeof(one)}, Tuple{SparseMatrixCSC{Float64, Int64}, SparseMatrixCSC{Float64, Int64}, Diagonal{Float64, Vector{Float64}}}}(Number[0.0543592350476218 + 0.08373639975791049im, 0.0543592350476218 - 0.08373639975791049im, 0.9950041652780258, 1.0], BloqadeExpr.Lowlevel.Hamiltonian{Tuple{BloqadeExpr.var"#67#101", BloqadeExpr.var"#69#103", typeof(cos), typeof(one)}, Tuple{SparseMatrixCSC{Float64, Int64}, SparseMatrixCSC{Float64, Int64}, Diagonal{Float64, Vector{Float64}}}}((BloqadeExpr.var"#67#101"(Core.Box(cos), Core.Box(sin)), BloqadeExpr.var"#69#103"(Core.Box(cos), Core.Box(sin)), cos, one), (sparse([1, 1, 2, 3, 1, 2, 5, 3, 5, 4 … 29, 15, 23, 27, 29, 16, 24, 28, 30, 31], [2, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 8, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 17, 18, 18, 19, 19, 20, 20, 20, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 32], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 … 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 32, 32), sparse([2, 3, 5, 9, 17, 4, 6, 10, 18, 4 … 29, 28, 30, 28, 31, 32, 30, 31, 32, 32], [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 17, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23, 24, 25, 25, 25, 26, 26, 27, 27, 28, 29, 29, 30, 31], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 … 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 32, 32), [5.0 0.0 … 0.0 0.0; 0.0 3.0 … 0.0 0.0; … ; 0.0 0.0 … -3.0 0.0; 0.0 0.0 … 0.0 -5.0])))

References

BloqadeExpr.rydberg_hFunction
rydberg_h(atoms; [C=2π * 862690 * MHz*µm^6], Ω[, ϕ, Δ])

Create a rydberg hamiltonian

\[∑ \frac{C}{|x_i - x_j|^6} n_i n_j + \frac{Ω}{2} σ_x - Δ σ_n\]

shorthand for

RydInteract(C, atoms) + SumOfXPhase(length(atoms), Ω, ϕ) - SumOfN(length(atoms), Δ)

Arguments

  • atoms: a collection of atom positions.

Keyword Arguments

  • C: optional, default unit is MHz*µm^6, interation parameter, see also RydInteract.
  • Ω: optional, default unit is MHz, Rabi frequencies, divided by 2, see also SumOfX.
  • Δ: optional, default unit is MHz, detuning parameter, see SumOfN.
  • ϕ: optional, does not have unit, the phase, see SumOfXPhase.
Tips

The rabi frequencies are divided by two in the Rydberg hamiltonian unlike directly constructing via SumOfX or SumOfXPhase.

Tips

The parameters of Hamiltonian have their own default units to match hardware, one can use Unitful.jl to specify their units explicitly. If the units are specified explicitly, they will be converted to default units automatically.

Example

julia> using Bloqade

julia> atoms = [(1, ), (2, ), (3, ), (4, )]
4-element Vector{Tuple{Int64}}:
 (1,)
 (2,)
 (3,)
 (4,)

julia> rydberg_h(atoms)
∑ 5.42e6/|x_i-x_j|^6 n_i n_j
julia> rydberg_h(atoms; Ω=0.1)
nqubits: 4
+
├─ ∑ 5.42e6/|x_i-x_j|^6 n_i n_j
└─ 0.05 ⋅ ∑ σ^x_i
source

Except the standard operators from Yao, the following operators are also supported by Bloqade:

BloqadeExpr.RydInteractType
struct RydInteract{D} <: AbstractTerm{D}
RydInteract(;atoms, C=2π * 862690MHz⋅μm^6)

Type for Rydberg interactive term.

Expression

\[\sum_{i, j} \frac{C}{|x_i - x_j|^6} n_i n_j\]

Keyword Arguments

  • atoms: a list of atom positions, must be type RydAtom, default unit is μm.
  • C: the interaction strength, default unit is MHz⋅μm^6. default value is 2π * 862690 * MHz*µm^6.
source
BloqadeExpr.SumOfXType
struct SumOfX <: AbstractTerm{2}
SumOfX(nsites, Ω)

Term for sum of X operators.

The following two expressions are equivalent

julia> SumOfX(nsites=5)
∑ σ^x_i

julia> sum([X for _ in 1:5])
nqudits: 1
+
├─ X
├─ X
├─ X
├─ X
└─ X

Expression

\[\sum_i Ω σ^x_i\]

source
BloqadeExpr.SumOfXPhaseType
struct SumOfXPhase <: AbstractTerm{2}
SumOfXPhase(;nsites, Ω=1, ϕ)

Sum of XPhase operators.

The following two expressions are equivalent

julia> SumOfXPhase(nsites=5, ϕ=0.1)
1.0 ⋅ ∑ e^{0.1 ⋅ im} |0⟩⟨1| + e^{-0.1 ⋅ im} |1⟩⟨0|

julia> sum([XPhase(0.1) for _ in 1:5])
nqudits: 1
+
├─ XPhase(0.1)
├─ XPhase(0.1)
├─ XPhase(0.1)
├─ XPhase(0.1)
└─ XPhase(0.1)

But may provide extra speed up.

Expression

\[\sum_i Ω ⋅ (e^{ϕ ⋅ i} |0⟩⟨1| + e^{-ϕ ⋅ i} |1⟩⟨0|)\]

source
BloqadeExpr.SumOfZType
struct SumOfZ <: AbstractTerm{2}
SumOfZ(;nsites, Δ=1)

Sum of Pauli Z operators.

The following two expression are equivalent

julia> SumOfZ(nsites=5)
∑ σ^z_i

julia> sum([Z for _ in 1:5])
nqudits: 1
+
├─ Z
├─ Z
├─ Z
├─ Z
└─ Z

Expression

\[\sum_i Δ ⋅ σ^z_i\]

source
BloqadeExpr.SumOfNType
struct SumOfN <: AbstractTerm{2}
SumOfN(;nsites[, Δ=1])

Sum of N operators.

The following two expression are equivalent

julia> SumOfN(nsites=5)
∑ n_i

julia> sum([Op.n for _ in 1:5])
nqudits: 1
+
├─ P1
├─ P1
├─ P1
├─ P1
└─ P1

But may provide extra speed up.

Expression

\[\sum_i Δ ⋅ n_i\]

source
BloqadeExpr.XPhaseType
XPhase{T} <: PrimitiveBlock{2}

XPhase operator for 2-level Rydberg system.

\[e^{ϕ ⋅ i} |0⟩⟨1| + e^{-ϕ ⋅ i} |1⟩⟨0|\]

source