Skip to content

Commit

Permalink
jw transformation explained
Browse files Browse the repository at this point in the history
  • Loading branch information
Jue-Xu committed Jan 17, 2025
1 parent 1d1df48 commit 09a6cf2
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 7 deletions.
108 changes: 101 additions & 7 deletions fermion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,106 @@
"id": "f8592aaf",
"metadata": {},
"source": [
"### Jordan-Wigner transformation: fermion and spin (qubit)"
"### Jordan-Wigner transformation: fermion and spin (qubit)\n",
"\n",
"Define raising and lowering operator $S_j^{\\pm}:=S_j^{X}\\pm i S_j^Y$, then $S_j^{+}|\\downarrow\\rangle=|\\uparrow\\rangle$, $S_j^{+}|\\uparrow\\rangle=0$, $S_j^{-}|\\downarrow\\rangle=0$, and $S_j^-|\\uparrow\\rangle = |\\downarrow\\rangle$.\n",
"Then, $S_j^Z = S_j^+S_j^- - 1/2$.\n",
"\n",
"They satisfy the anti-commutation relation when on the same site, $\\{S_j^+,S_j^-\\}= S_j^+S_j^-+S_j^-S_j^+ = 1$. \n",
"\n",
"And commute with each other for different sites, $[S_j^{\\pm},S_k^{\\pm}]=0$, $j\\neq k$\n",
"\n",
"Fermion operators: $f_j^\\dagger |0\\rangle=|1\\rangle$, $f_j^\\dagger |1\\rangle=0$, $f_j |0\\rangle=0$, and $f_j |1\\rangle=|0\\rangle$. \n",
"Then, the number operator $n_j=f_j^\\dagger f_j$ and $f_j^2 = (f_j^\\dagger)^2 = 0$. \n",
"$[n_k, n_j]=0$, $(n_k)^n=n_k$, $(n_k)^0=1$.\n",
"\n",
"The `anticommutation relation of fermion`: not only $\\{f_j, f_j^\\dagger \\}=1$, but also (different site) $\\{f_j, f_k\\}=\\{f_j^\\dagger, f_k^\\dagger\\} = \\{f_j, f_k^\\dagger\\}=0$. \n",
"also written as $\\{f_j,f_k^\\dagger\\}=\\delta_{j,k}$.\n",
"\n",
"`Jordan-Wigner transformation` (non-local): $S_j^- = \\exp(i\\pi \\sum_{l=1}^{j-1} f_l^\\dagger f_l) f_j$ and $S_j^\\dagger = f_j^\\dagger \\exp(-i\\pi \\sum_{l=1}^{j-1}f_l^\\dagger f_l)$."
]
},
{
"cell_type": "markdown",
"id": "83929dbd",
"metadata": {},
"source": [
"Reference: \n",
"- Jordan-Wigner (Zeitschrift für Physik, 47, 631-651 (1928))\n",
"- Parity (The Journal of chemical physics, 137(22), 224109 (2012))\n",
"- Bravyi-Kitaev (Annals of Physics, 298(1), 210-226 (2002))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "35db77fb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fermionic Operator\n",
"number spin orbitals=4, number terms=36\n",
" -1.25633907300325 * ( +_0 -_0 )\n",
"+ -0.471896007281142 * ( +_1 -_1 )\n",
"+ -1.25633907300325 * ( +_2 -_2 )\n",
"+ -0.471896007281142 * ( +_3 -_3 )\n",
"+ 0.3378550774017582 * ( +_0 +_0 -_0 -_0 )\n",
"+ 0.3322908651276483 * ( +_0 +_1 -_1 -_0 )\n",
"+ 0.3378550774017582 * ( +_0 +_2 -_2 -_0 )\n",
"+ 0.3322908651276483 * ( +_0 +_3 -_3 -_0 )\n",
"+ 0.09046559989211571 * ( +_0 +_0 -_1 -_1 )\n",
"+ 0.09046559989211571 * ( +_0 +_1 -_0 -_1 )\n",
"+ 0.09046559989211571 * ( +_0 +_2 -_3 -_1 )\n",
"+ 0.09046559989211571 * ( +_0 +_3 -_2 -_1 )\n",
"+ 0.09046559989211571 * ( +_1 +_0 -_1 -_0 )\n",
"+ 0.09046559989211571 * ( +_1 +_1 -_0 -_0 )\n",
"+ 0.09046559989211571 * ( +_1 +_2 -_3 -_0 )\n",
"+ 0.09046559989211571 * ( +_1 +_3 -_2 -_0 )\n",
"+ 0.3322908651276483 * ( +_1 +_0 -_0 -_1 )\n",
"+ 0.3492868613660083 * ( +_1 +_1 -_1 -_1 )\n",
"+ 0.3322908651276483 * ( +_1 +_2 -_2 -_1 )\n",
"+ 0.3492868613660083 * ( +_1 +_3 -_3 -_1 )\n",
"+ 0.3378550774017582 * ( +_2 +_0 -_0 -_2 )\n",
"+ 0.3322908651276483 * ( +_2 +_1 -_1 -_2 )\n",
"+ 0.3378550774017582 * ( +_2 +_2 -_2 -_2 )\n",
"+ 0.3322908651276483 * ( +_2 +_3 -_3 -_2 )\n",
"+ 0.09046559989211571 * ( +_2 +_0 -_1 -_3 )\n",
"+ 0.09046559989211571 * ( +_2 +_1 -_0 -_3 )\n",
"+ 0.09046559989211571 * ( +_2 +_2 -_3 -_3 )\n",
"+ 0.09046559989211571 * ( +_2 +_3 -_2 -_3 )\n",
"+ 0.09046559989211571 * ( +_3 +_0 -_1 -_2 )\n",
"+ 0.09046559989211571 * ( +_3 +_1 -_0 -_2 )\n",
"+ 0.09046559989211571 * ( +_3 +_2 -_3 -_2 )\n",
"+ 0.09046559989211571 * ( +_3 +_3 -_2 -_2 )\n",
"+ 0.3322908651276483 * ( +_3 +_0 -_0 -_3 )\n",
"+ 0.3492868613660083 * ( +_3 +_1 -_1 -_3 )\n",
"+ 0.3322908651276483 * ( +_3 +_2 -_2 -_3 )\n",
"+ 0.3492868613660083 * ( +_3 +_3 -_3 -_3 )\n",
"SparsePauliOp(['IIII', 'IIIZ', 'IIZI', 'IZII', 'ZIII', 'IIZZ', 'IZIZ', 'ZIIZ', 'YYYY', 'XXYY', 'YYXX', 'XXXX', 'IZZI', 'ZIZI', 'ZZII'],\n",
" coeffs=[-0.81054798+0.j, 0.17218393+0.j, -0.22575349+0.j, 0.17218393+0.j,\n",
" -0.22575349+0.j, 0.12091263+0.j, 0.16892754+0.j, 0.16614543+0.j,\n",
" 0.0452328 +0.j, 0.0452328 +0.j, 0.0452328 +0.j, 0.0452328 +0.j,\n",
" 0.16614543+0.j, 0.17464343+0.j, 0.12091263+0.j])\n"
]
}
],
"source": [
"# https://qiskit-community.github.io/qiskit-nature/tutorials/06_qubit_mappers.html\n",
"from qiskit_nature.second_q.drivers import PySCFDriver\n",
"\n",
"driver = PySCFDriver()\n",
"problem = driver.run()\n",
"fermionic_op = problem.hamiltonian.second_q_op()\n",
"\n",
"from qiskit_nature.second_q.mappers import JordanWignerMapper\n",
"\n",
"mapper = JordanWignerMapper()\n",
"print(fermionic_op)\n",
"qubit_jw_op = mapper.map(fermionic_op)\n",
"print(qubit_jw_op)"
]
},
{
Expand Down Expand Up @@ -248,7 +347,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.8 ('base')",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -263,11 +362,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
},
"vscode": {
"interpreter": {
"hash": "4e8ef2f9fcac0817bca9a7ca376f64f20b4df5ea3bf7af756a50bda7d3557ea6"
}
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions phase_transition.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"one-dimensional cluster-Ising model \n",
"$$H = -\\sum_{i=1}^{N-2} Z_i X_{i+1} Z_{i+2} - h_1 \\sum_{i=1}^N X_i - h_2 \\sum_{i=1}^{N-1} X_iX_{i+1} $$\n",
"\n",
"<!-- https://link.aps.org/doi/10.1103/PhysRevA.84.022304 -->\n",
"https://arxiv.org/abs/1810.03787"
]
},
Expand Down

0 comments on commit 09a6cf2

Please sign in to comment.