Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ parts:
- caption: Use-Cases
chapters:
- file: use-cases/ssh_model
- file: use-cases/adiabatic
# - file: ../examples/pulser-myqlm-conversion
- caption: Theory
chapters:
Expand Down
163 changes: 163 additions & 0 deletions docs/use-cases/adiabatic.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quantum Adiabatic Pulses\n",
"\n",
"Here we prepare a ground state of a Hamiltonian using an adiabatic pulse. See [...] for more details on the adiabatic theorem."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Recall the Rydberg Hamiltonian is\n",
"\n",
"$$\n",
"H = \\frac{\\hbar \\Omega(t)}{2} \\sum_i X_i - \\hbar \\delta(t) \\sum_i N_i + \\sum_{i<j} \\frac{C_6}{r_{ij}^6}N_i N_j \n",
"$$\n",
"\n",
"where $\\Omega$ is the Rabi frequency, $\\delta$ is the detuning, $C_6$ is a device specific constant and $r_{ij}$ is the distance between qubits $i$ and $j$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will choose the signals so that the initial Hamiltonian will be\n",
"\n",
"$$\n",
"H_i = - \\hbar \\delta_i \\sum_i N_i + \\sum_{i<j} \\frac{C_6}{r_{ij}^6}N_i N_j \n",
"$$\n",
"by choosing a suitably negative value for $\\delta_i$ we ensure the ground state of the $H_i$ is the all $0$ state, which is the state we start in.\n",
"\n",
"\n",
"We will choose the signals so that the final Hamiltonian will be\n",
"\n",
"$$\n",
"H_f = \\frac{\\hbar \\Omega_f}{2} \\sum_i X_i + \\sum_{i<j} \\frac{C_6}{r_{ij}^6}N_i N_j \n",
"$$\n",
"and this is the Hamiltonian's whose ground state we want to prepare."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import qse\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"delta_initial = -2.0\n",
"omega_final = 2.0\n",
"\n",
"r_b = qse.calc.blockade_radius(omega_final * 0.5)\n",
"qbits = qse.lattices.ring(r_b, 8)\n",
"qbits.draw(radius=\"nearest\", units=\"µm\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"duration = 5000 # ns\n",
"amplitude = qse.Signal(np.linspace(0, omega_final, duration))\n",
"detuning = qse.Signal(np.linspace(delta_initial, 0, duration))\n",
"\n",
"plt.plot(amplitude.values, label=\"Amplitude\")\n",
"plt.plot(detuning.values, label=\"Detuning\")\n",
"plt.xlabel(\"Time (ns)\")\n",
"plt.ylabel(\"Signal (rad/µs)\")\n",
"plt.axhline(y=0, ls=\"--\", c=\"k\")\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"calc = qse.calc.Qutip(qbits, amplitude, detuning)\n",
"\n",
"# We get the initial and final hamiltonians\n",
"h_i = calc.get_hamiltonian(amplitude[0], detuning[0])\n",
"h_f = calc.get_hamiltonian(amplitude[-1], detuning[-1])\n",
"\n",
"# We compute the expectations of both Hamiltonians\n",
"results = calc.calculate(e_ops=[h_i, h_f])\n",
"\n",
"# Let's compute the groun-state energies of the initial and final hamiltonians\n",
"e_i = h_i.eigenenergies()[0]\n",
"e_f = h_f.eigenenergies()[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.plot(results[\"expectations\"][:, 0], label=r\"$\\langle H_i \\rangle$\")\n",
"plt.axhline(e_i, ls=\"--\", label=r\"$e_i$\")\n",
"\n",
"plt.plot(results[\"expectations\"][:, 1], label=r\"$\\langle H_f \\rangle$\")\n",
"plt.axhline(e_f, ls=\"--\", c=\"C1\", label=r\"$e_f$\")\n",
"\n",
"plt.ylabel(\"Energy\")\n",
"plt.xlabel(\"Time (ns)\")\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"probs = np.real(np.conj(results[\"state\"]) * results[\"state\"]).flatten()\n",
"probs_dict = {f\"{np.binary_repr(c, qbits.nqbits)}\": p for c, p in enumerate(probs)}\n",
"probs_dict = {\n",
" w: probs_dict[w] for w in sorted(probs_dict, key=probs_dict.get, reverse=True)\n",
"}\n",
"fig = qse.vis.bar(probs_dict, ylabel=\"Probability\", cutoff=0.011)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "qse",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 1 addition & 1 deletion qse/calc/qutip.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def calculate(self, e_ops=None):

result = {"state": state.full()}
if e_ops is not None:
result["expectations" : np.array(exps)]
result["expectations"] = np.array(exps)

return result

Expand Down
Loading