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/|\overrightarrow{\mathbf{r}_j} - \overrightarrow{\mathbf{r}_k}|^6$ describes the Rydberg interaction (van der Waals interaction) between atoms $j$ and $k$ where $\overrightarrow{\mathbf{r}_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 $\overrightarrow{\mathbf{r}_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.627e6.0/|r_i-r_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.0e6.0/|r_i-r_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.627e6.0/|r_i-r_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.627e6.0/|r_i-r_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.627e6.0/|r_i-r_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) end
5-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.627e6.0/|r_i-r_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.mat
— Functionmat([T=ComplexF64], blk)
Returns the matrix form of given block.
This method will return the most compact matrix representation of the operator, e.g.:
julia> mat(X) # will return a PermMatrix
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(ht) # will return a SparseMatrixCSC
32×32 SparseArrays.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{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 simutaneously 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 SparseArrays.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.53183367285098, 49.36990716033799, 51.29063792209698, 55.89104071504431, 61.44324863140747, 65.27248354593053, 124.97072996229844, 130.65930913081704, 133.53723395862136, 135.95163912164833, 139.99824815581474, 146.7496258715232, 210.19192698918917], Vector{ComplexF64}[[0.663500759617689 - 0.5549983088880804im, -0.17163364125942668 + 0.14356634753842962im, -0.16142282815358638 + 0.1350253113391964im, -0.16220310119765277 + 0.135677986130673im, 0.04253888975806687 - 0.035582494119987505im, -0.1614228281535867 + 0.13502531133919674im, 0.04166852773536632 - 0.03485446262384086im, 0.039808237674748545 - 0.033298386277705296im, -0.17163364125942696 + 0.1435663475384299im, 0.04439295715534906 - 0.03713336539653146im, 0.04166852773536618 - 0.03485446262384086im, 0.04253888975806681 - 0.035582494119987595im, -0.011154560466963545 + 0.009330452310442707im], [0.1031387794092721 - 0.025491782344436737im, 0.3667620789908627 - 0.09064892122415913im, -0.4225759453673081 + 0.1044438773174799im, 0.38176417444210425 - 0.09435683937234961im, -0.19425599184075504 + 0.0480123140051579im, -0.4225759453672918 + 0.10444387731747173im, 0.013529188593973866 - 0.003343874466127212im, 0.19921251437585874 - 0.04923736819305448im, 0.36676207899084645 - 0.09064892122415696im, -0.1965709378830885 + 0.04858447610546859im, 0.01352918859398248 - 0.0033438744661305623im, -0.19425599184075162 + 0.048012314005158443im, 0.07559776962406617 - 0.018684745931830674im], [6.8924358408162245e-15 + 1.8257693534112773e-15im, -0.5380495905846677 + 0.1428546323501975im, 0.33677461237962003 - 0.08941520313042446im, 1.0535409350476144e-14 + 1.1553258350005535e-15im, 0.1299459062318053 - 0.03450123368737638im, -0.3367746123796432 + 0.08941520313043652im, 0.21742634177286413 - 0.05772769027379007im, 4.5185751841592126e-15 - 3.2185625692404685e-15im, 0.5380495905847006 - 0.14285463235020385im, -8.64109131470947e-15 + 1.3938503129473645e-15im, -0.21742634177286738 + 0.05772769027378828im, -0.12994590623181912 + 0.03450123368737639im, 2.7598366300618515e-15 - 1.5981140022436335e-16im], [-0.1615246797642013 + 0.037681976418555134im, -0.4343682500158328 + 0.10133345676934245im, -0.12382486605173826 + 0.028887013980796353im, 0.6374474979408912 - 0.1487096685196655im, -0.04722273217710959 + 0.011016557240142975im, -0.12382486605174281 + 0.028887013980798237im, 0.14769030124034677 - 0.03445456419856497im, 0.06355685592174663 - 0.014827133225565513im, -0.4343682500158266 + 0.10133345676934057im, 0.235479794790519 - 0.05493491203509624im, 0.14769030124034332 - 0.03445456419856538im, -0.04722273217711276 + 0.011016557240144324im, -0.019075542844759808 + 0.004450119676427796im], [-6.3988256967378865e-15 - 8.955184684078521e-15im, 0.24339066731575776 - 0.27889912574814135im, 0.38811560355391667 - 0.44473809827709493im, -2.456043181331413e-15 - 1.1683362610703796e-14im, -0.06757185736452129 + 0.07742996948890983im, -0.3881156035539336 + 0.44473809827707883im, 0.04152879142146286 - 0.047587459899583im, 5.8015454961792e-15 + 4.793312014667039e-15im, -0.24339066731575879 + 0.27889912574813686im, 1.3357370765021415e-15 + 1.5599500857721438e-15im, -0.0415287914214581 + 0.04758745989958996im, 0.06757185736452427 - 0.07742996948890064im, -6.370229864438581e-16 - 1.3737925727563827e-15im], [-0.24855125776569204 - 0.361846467133604im, -0.0539760893722286 - 0.07857959531000874im, -0.2346143296305424 - 0.34155677617111635im, -0.2835056391912068 - 0.41273383557162985im, 0.11064664319027508 + 0.16108185208353726im, -0.23461432963052475 - 0.34155677617114294im, 0.08793708407536083 + 0.1280207691915885im, 0.1380569127417956 + 0.2009863341189942im, -0.05397608937220296 - 0.07857959531002924im, 0.044777938138555066 + 0.06518872150000365im, 0.08793708407535872 + 0.12802076919158673im, 0.11064664319026835 + 0.16108185208354228im, -0.038584742899775044 - 0.056172529678781im], [-0.03034152030987577 + 0.012944194934268403im, -0.08297970367309669 + 0.03540051549700365im, 0.03362633225275866 - 0.014345550096332975im, -0.10245459788662609 + 0.043708827817864344im, -0.15199603010701168 + 0.06484402306959083im, 0.03362633225275674 - 0.014345550096330336im, 0.43031011882269216 - 0.18357742141273878im, -0.29023792469385024 + 0.12382030419655864im, -0.08297970367309719 + 0.035400515497004875im, -0.5187549638483027 + 0.22130945669806953im, 0.43031011882269526 - 0.18357742141274455im, -0.15199603010701573 + 0.06484402306959906im, 0.22065415792321857 - 0.0941347171811107im], [5.4643789493269423e-17 + 1.5612511283791264e-16im, -0.0190805988119262 + 0.034043683341394716im, -0.05729938314103835 + 0.1022337964619553im, 1.2836953722228372e-15 + 4.787836793695988e-16im, -0.2722965428486061 + 0.48583261830861596im, 0.05729938314103538 - 0.10223379646195489im, 0.2042737316470019 - 0.36446603713551434im, -9.336281747707176e-15 + 1.807581861967833e-15im, 0.019080598811928078 - 0.03404368334139524im, -1.429412144204889e-15 - 1.3877787807814457e-16im, -0.20427373164699217 + 0.36446603713550974im, 0.27229654284860694 - 0.48583261830861424im, -2.949029909160572e-16 - 3.469446951953614e-16im], [-0.017789452174682842 + 0.02483804211527318im, 0.025277746199507442 - 0.03529337039259827im, -0.006899794895352543 + 0.009633652262848551im, -0.16278296907791567 + 0.22728132389374892im, -0.29369469092779776 + 0.410063279670768im, -0.0068997948953528985 + 0.009633652262849315im, 0.0540886576725718 - 0.07551982736949026im, -0.06195059798366605 + 0.08649684918202719im, 0.025277746199507137 - 0.035293370392598306im, 0.35137065407675483 - 0.4905917854204469im, 0.05408865767257326 - 0.07551982736949332im, -0.2936946909278015 + 0.4100632796707714im, 0.0720842844141856 - 0.1006457351551813im], [0.042868479937353245 - 0.00785457572030906im, 0.20579443823398752 - 0.037706678666689135im, -0.12091819258636712 + 0.022155231559884657im, 0.13943463960566027 - 0.025547906910091553im, 0.24668405656015702 - 0.04519867753828636im, -0.12091819258637039 + 0.02215523155988613im, 0.1814126986077455 - 0.03323933528602667im, -0.689307371567039 + 0.12629831877528327im, 0.20579443823399027 - 0.03770667866668672im, 0.32047732709383175 - 0.05871944692181343im, 0.18141269860775908 - 0.03323933528603039im, 0.24668405656015954 - 0.04519867753827525im, -0.2586825196871762 + 0.04739709552035259im], [-7.263070353480394e-16 - 9.345822726825048e-17im, -0.21577690517107287 - 0.07063100152609922im, 0.12180860668017714 + 0.039872033003247216im, -9.610368056911511e-16 + 3.8163916471489756e-17im, -0.3815555577763645 - 0.12489590191419217im, -0.12180860668017585 - 0.03987203300324807im, -0.4946003238349616 - 0.1618992366208061im, 5.699623715701985e-15 - 1.4116312285761268e-15im, 0.21577690517106754 + 0.07063100152609966im, -3.028827189055505e-15 + 2.7755575615628914e-17im, 0.4946003238349578 + 0.16189923662080605im, 0.38155555777635947 + 0.1248959019141931im, 2.637647045222735e-15 - 3.7470027081099033e-16im], [0.10929267006532145 + 0.06351095491831595im, 0.17526695859579536 + 0.10184920818015618im, 0.21485115079176564 + 0.12485193877987386im, 0.07064103845823268 + 0.04105014367589744im, 0.10142242241374914 + 0.05893748312468007im, 0.21485115079176562 + 0.124851938779873im, 0.3748563043976354 + 0.21783237462508603im, 0.46520151278470245 + 0.27033278891204654im, 0.17526695859579686 + 0.10184920818015582im, 0.18887068513289695 + 0.10975445619269274im, 0.37485630439763606 + 0.21783237462508756im, 0.10142242241375067 + 0.05893748312467925im, -0.15222505074870588 - 0.08845934800349495im], [0.009987866518169679 + 0.015368564772150789im, 0.035642320900757946 + 0.054843676214190916im, 0.002549171071221184 + 0.0039224693934466716im, 0.03499199585416448 + 0.05384300579240046im, 0.1312012375326545 + 0.20188242539472326im, 0.0025491710712212375 + 0.003922469393446547im, 0.008667213947544028 + 0.013336445646784904im, 0.0011885884046911551 + 0.0018289088917730332im, 0.03564232090075822 + 0.05484367621419082im, 0.12759638877057033 + 0.19633555994622032im, 0.008667213947544062 + 0.013336445646784897im, 0.1312012375326545 + 0.20188242539472326im, 0.49214149008725694 + 0.7572696685232134im]], ConvergenceInfo: 13 converged values after 1 iterations and 13 applications of the linear map; norms of residuals are given by (3.448525890996599e-38, 3.5233720978488097e-32, 9.496515273923442e-32, 1.1287525009605575e-31, 5.032738384700319e-32, 1.5024095040284225e-32, 3.11032420371034e-31, 2.9258924974985455e-30, 1.0488093830945329e-29, 9.113312141437794e-31, 5.236151683155359e-31, 5.047297801679032e-33, 4.176267687019367e-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.Hamiltonian
— Typestruct 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
.
BloqadeExpr.StepHamiltonian
— Typestruct StepHamiltonian
A low-level linear-map object that encodes time-dependent hamiltonian at time step t
. This object supports the linear map interface mul!(Y, H, X)
.
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.StepHamiltonian{Float64, Tuple{typeof(sin), typeof(cos), typeof(one)}, Tuple{SparseArrays.SparseMatrixCSC{Float64, Int64}, LinearAlgebra.Diagonal{Float64, Vector{Float64}}}}(0.1, BloqadeExpr.Hamiltonian{Tuple{typeof(sin), typeof(cos), typeof(one)}, Tuple{SparseArrays.SparseMatrixCSC{Float64, Int64}, LinearAlgebra.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 … 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.StepHamiltonian{Float64, Tuple{BloqadeExpr.var"#60#94", BloqadeExpr.var"#62#96", typeof(cos), typeof(one)}, Tuple{SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, LinearAlgebra.Diagonal{Float64, Vector{Float64}}}}(0.1, BloqadeExpr.Hamiltonian{Tuple{BloqadeExpr.var"#60#94", BloqadeExpr.var"#62#96", typeof(cos), typeof(one)}, Tuple{SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, LinearAlgebra.Diagonal{Float64, Vector{Float64}}}}((BloqadeExpr.var"#60#94"(Core.Box(cos), Core.Box(sin)), BloqadeExpr.var"#62#96"(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 … 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 … 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_h
— Functionrydberg_h(atoms; [C=2π * 862690 * MHz*µm^6], Ω[, ϕ, Δ])
Create a rydberg hamiltonian
\[∑ \frac{C}{|r_i - r_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 isMHz*µm^6
, interation parameter, see alsoRydInteract
.Ω
: optional, default unit isMHz
, Rabi frequencies, divided by 2, see alsoSumOfX
.Δ
: optional, default unit isMHz
, detuning parameter, seeSumOfN
.ϕ
: optional, does not have unit, the phase, seeSumOfXPhase
.
The rabi frequencies are divided by two in the Rydberg hamiltonian unlike directly constructing via SumOfX
or SumOfXPhase
.
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/|r_i-r_j|^6 n_i n_j
julia> rydberg_h(atoms; Ω=0.1)
nqubits: 4
+
├─ ∑ 5.42e6/|r_i-r_j|^6 n_i n_j
└─ 0.05 ⋅ ∑ σ^x_i
Except the standard operators from Yao, the following operators are also supported by Bloqade:
BloqadeExpr.RydInteract
— Typestruct RydInteract <: AbstractTerm
RydInteract(;atoms, C=2π * 862690MHz⋅μm^6)
Type for Rydberg interactive term.
Expression
\[\sum_{i, j} \frac{C}{|r_i - r_j|^6} n_i n_j\]
Keyword Arguments
atoms
: a list of atom positions, must be typeRydAtom
, default unit isμm
.C
: the interaction strength, default unit isMHz⋅μm^6
. default value is2π * 862690 * MHz*µm^6
.
BloqadeExpr.SumOfX
— Typestruct SumOfX <: AbstractTerm
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\]
BloqadeExpr.SumOfXPhase
— Typestruct SumOfXPhase <: AbstractTerm
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^{ϕ ⋅ im} |0⟩⟨1| + e^{-ϕ ⋅ im} |1⟩⟨0|)\]
BloqadeExpr.SumOfZ
— Typestruct SumOfZ <: AbstractTerm
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\]
BloqadeExpr.SumOfN
— Typestruct SumOfN <: AbstractTerm
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\]
BloqadeExpr.XPhase
— TypeXPhase{T} <: PrimitiveBlock{2}
XPhase operator.
\[e^{ϕ ⋅ im} |0⟩⟨1| + e^{-ϕ ⋅ im} |1⟩⟨0|\]