{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# This cell is added by sphinx-gallery\n# It can be customized to whatever you like\n%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\nQuantum information with polarized light\n=================================================\n\n*Author: Nicol\u00e1s Quesada*\n\nIn this tutorial we will explore how to model quantum photonic\nexperiments involving \"internal\" degrees of freedom of light, such as\npolarization. Note that by default Strawberry Fields deals with\nqumodes without an explicit commitment to what degree of freedom those\nqumodes correspond to. Using polarization degrees of freedom allows us\nto encode quantum information more densely. For example, one can use\nthe two orthogonal polarizations of a single photon to encode a single qubit.\n\nPolarization is the ability of fields to oscillate in more than one\ndirection as they propagate. One can think of light as a transverse\nfield, meaning that it does not oscillate in the direction of\npropagation. This implies that in our three-dimensional world light has\ntwo directions in which it can oscillate that are perpendicular to its direction of propagation.\nBecause of this, a photon propagating in a certain direction $k$\ncan have two orthogonal polarizations. This is schematically shown below:\n\n![](/tutorials/images/polarization.svg)\n\n :align: center\n :width: 75%\n :target: javascript:void(0);\n\n|\n\nIn this tutorial, we will show how polarization \"gates\" implemented by half-wave plates\nand polarizing beamsplitters can be mapped into the usual quantum\noperations from Strawberry Fields. Then we will use this knowledge to simulate the generation\nof a maximally entangled Bell state encoded in polarization degrees of\nfreedom.\n\n\n\nManipulating polarization degrees of freedom\n--------------------------------------------\n\nIt turns out that the polarization degree of freedom of photons can be used\nto encode information, and this information is typically manipulated\nusing so-called half-wave plates and polarizing beamsplitters.\n\nHalf-wave plates\n~~~~~~~~~~~~~~~~\n\nA half-wave plate (HWP) allows us to rotate the polarization of a photon. For\nexample,\n\n\\begin{align}\\text{HWP} |1_H 0_V \\rangle &= \\frac{1}{\\sqrt{2}} \\left( |1_H 0_V \\rangle + |0_H 1_V \\rangle \\right), \\quad \\text{(A)}\\\\\n \\text{HWP} |0_H 1_V \\rangle &= \\frac{1}{\\sqrt{2}} \\left( |1_H 0_V \\rangle - |0_H 1_V \\rangle \\right), \\quad \\text{(B)}\\end{align}\n\nwhere $\\text{HWP}$ is a unitary operator representing\na half-wave plate, $|1_H \\rangle$ is a single horizontally-polarized photon\nand, similarly, $|1_V \\rangle$ is a single vertically-polarized photon\nThe states in the right hand sides of the last\nequation can be understood as single photons polarized along the diagonal\n($+45^\\circ$) and antidiagonal ($-45^\\circ$) directions, as depicted below:\n\n![](/tutorials/images/HWP.svg)\n\n :align: center\n :width: 75%\n :target: javascript:void(0);\n\n|\n\nThe transformation above is written in the Schr\u00f6dinger picture for\nsingle photon inputs. It is often more fruitful to write it in the\nHeisenberg picture as follows:\n\n\\begin{align}\\text{HWP} ^\\dagger a_H^\\dagger \\text{HWP} &= \\frac{1}{\\sqrt{2}}\\left( a_H^\\dagger + a_V^\\dagger \\right),\\\\\n \\text{HWP} ^\\dagger a_V^\\dagger \\text{HWP} &= \\frac{1}{\\sqrt{2}}\\left( a_H^\\dagger - a_V^\\dagger \\right),\\end{align}\n\nwhere we transformed the creation operators $a_{H/V}^\\dagger$ of the modes.\n\nPolarizing beamsplitters\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nA polarizing beamsplitter (PBS) will transmit light of a certain\npolarization while reflecting light from the orthogonal polarization.\nThis operation acts on two paths each having two polarizations. For two\nspatial modes with two polarizations (a total of $4 = 2 \\times 2$\ncreation operators) we can write its Heisenberg action as\n\n\\begin{align}\\text{PBS}^\\dagger a_{1,H}^\\dagger \\text{PBS} &= a_{1,H}^\\dagger, \\quad \\text{(a)}\\\\\n \\text{PBS}^\\dagger a_{1,V}^\\dagger \\text{PBS} &= a_{2,V}^\\dagger, \\quad \\text{(b)}\\\\\n \\text{PBS}^\\dagger a_{2,H}^\\dagger \\text{PBS} &= a_{2,H}^\\dagger, \\quad \\text{(c)}\\\\\n \\text{PBS}^\\dagger a_{2,V}^\\dagger \\text{PBS} &= a_{1,V}^\\dagger. \\quad \\text{(d)}\\end{align}\n\nNote that the horizontal polarizations of both modes are\nunaffected (they are \"transmitted\") and that the vertical polarizations\nare swapped (they are \"reflected\"). The action of the PBS is schematically shown below\nfor the different path and polarization modes:\n\n![](/tutorials/images/PBS.svg)\n\n :align: center\n :width: 75%\n :target: javascript:void(0);\n\n|\n\nWe can use a PBS to separate two photons with orthogonal polarizations\nin the same path into two photons in different paths:\n\n\\begin{align}\\text{PBS}|1_H 1_V, 0_H 0_V \\rangle = |1_H 0_V, 0_H 1_V \\rangle,\\end{align}\n\nwhere we used the notation $|x_H y_V,a_H b_V \\rangle$\nto indicate $x$ ($y$) horizontal (vertical) photons in mode\n1, $a$ ($b$) horizontal (vertical) photons in mode 2.\n\nMapping to Strawberry Fields gates\n----------------------------------\n\nWith the notation we developed above we are ready to simulate basic\npolarization optical primitives using Strawberry Fields. We simply need\nto recall that each optical path with two polarizations can be\nrepresented using 2 qumodes.\nFor each path $i$, we associate qumodes $2i$ and $2i+1$ to its horizontal and vertical polarization respectively.\n\nWe can the associate Strawberry Fields gates with the polarization primitives discussed\nabove as follows:\n\n\\begin{align}\\text{HWP}_i &\\leftrightarrow \\text{BSgate}_{2i,2i+1}\\\\\n \\text{PBS}_{i,j} &\\leftrightarrow \\text{Permute}_{2i+1,2j+1} = \\text{Interferometer}\\left(\\left[\\begin{smallmatrix} 0&1 \\\\1&0 \\end{smallmatrix} \\right]\\right)_{2i+1,2j+1}\\end{align}\n\nTo see why the first association is true recall that a\nHWP maps the creation operators of two polarizations in the same path to\nlinear combinations of the same operators, which is precisely what the\n``BSgate`` does when applied to modes $2i$ and $2i+1$\nrepresenting the two orthogonal polarizations of path $i$.\n\nTo understand the second expression recall that a\n$\\text{PBS}$ simply swaps the vertical polarization of the two\npaths, which correspond precisely to qumodes $2i+1$ and\n$2j+1$. Finally, note that a swap is readily implemented in Strawberry Fields by\nusing the ``Interferometer`` gate with argument\n$\\left[\\begin{smallmatrix} 0&1 \\\\1&0 \\end{smallmatrix} \\right]$.\n\nSimulating the generation of event-ready photon pairs\n-----------------------------------------------------\n\nZhang et al. [[#zhang]_] propose a method for generating postselected photonic maximally\nentangled Bell states by using single photons input into an\ninterferometer. Their method uses a 4 spatial-path interferometer where\neach path takes advantage of the two polarizations (vertical and\nhorizontal) of a photon. The circuit starts with four horizontal photons\nin each of the paths and then proceeds as shown below\n\n![](/tutorials/images/circuit_path.svg)\n\n :align: center\n :width: 75%\n :target: javascript:void(0);\n\n|\n\nConditioned in two of the detectors collecting a single photon each and\nthe other two measuring vacuum, Zhang et al.\u00a0show that the state of\nmodes 1 and 4 collapses to a two-photon maximally entangled Bell\nstate of the form\n\n\\begin{align}|\\phi^+ \\rangle \\propto \\left( |1_H 0_V, 1_H 0_V \\rangle + |0_H 1_V, 0_H 1_V \\rangle \\right).\\end{align}\n\nWith the rules established in the last section we can translate the\n2-polarization 4-path circuit into a circuit with 8 qumodes as shown below\n\n![](/tutorials/images/circuit.svg)\n\n :align: center\n :width: 75%\n :target: javascript:void(0);\n\n|\n\nWe are now ready to do the simulations!\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Import and preliminaries\nimport strawberryfields as sf\nfrom strawberryfields.ops import Ket, BSgate, Interferometer\nimport numpy as np\n\ncutoff_dim = 5 # (1+ total number of photons)\npaths = 4\nmodes = 2 * paths\n\ninitial_state = np.zeros([cutoff_dim] * modes, dtype=np.complex)\n# The ket below corresponds to a single horizontal photon in each of the modes\ninitial_state[1, 0, 1, 0, 1, 0, 1, 0] = 1\n# Permutation matrix\nX = np.array([[0, 1], [1, 0]])\n\n# Here is the main program\n# We create the input state and then send it through a network of beamsplitters and swaps.\nprog = sf.Program(8)\nwith prog.context as q:\n Ket(initial_state) | q # Initial state preparation\n for i in range(paths):\n BSgate() | (q[2 * i], q[2 * i + 1]) # First layer of beamsplitters\n Interferometer(X) | (q[1], q[3])\n Interferometer(X) | (q[5], q[7])\n BSgate() | (q[2], q[3])\n BSgate() | (q[4], q[5])\n Interferometer(X) | (q[3], q[5])\n BSgate().H | (q[2], q[3])\n BSgate().H | (q[4], q[5])\n\n# We run the simulation\neng = sf.Engine(\"fock\", backend_options={\"cutoff_dim\": cutoff_dim})\nresult = eng.run(prog)\nstate = result.state\nket = state.ket()\n\n# Check the normalization of the ket.\n# This does give the exact answer because of the cutoff we chose.\nprint(\"The norm of the ket is \", np.linalg.norm(ket))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Postselection\n-------------\n\nLet's consider the case where one horizontally-polarized photon is detected in both paths\n2 and 3.\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"sub_ket1 = np.round(ket[:, :, 1, 0, 1, 0, :, :], 14) # postselect on correct pattern\np1 = np.round(np.linalg.norm(sub_ket1) ** 2, 14) # Check the probability of this event\nprint(\"The probability is \", p1)\nprint(\"The expected probability is \", 1 / 32)\n\n# These are the only nonzero components\nind1 = np.array(np.nonzero(np.real_if_close(sub_ket1))).T\nprint(\"The indices of the nonzero components are \\n \", ind1)\n\n# And these are their coefficients\nprint(\"The nonzero components have values \", [sub_ket1[tuple(ind)] for ind in ind1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Thus up to normalization the postselected state is indeed $|\\phi^+ \\rangle$.\n\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can study all the successful postselections. To simplify tensor\nmanipulation we will move the modes in which we measure to be the first\n4 modes of the tensor by using a transposition:\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Transpose the ket\nket_t = ket.transpose(2, 3, 4, 5, 0, 1, 6, 7)\n# Postselection patterns:\npatterns = [\n [1, 1, 0, 0],\n [1, 0, 1, 0],\n [1, 0, 0, 1],\n [0, 1, 1, 0],\n [0, 1, 0, 1],\n [0, 0, 1, 1],\n]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For each pattern we can construct the postselected ket, and find which\ncomponents are nonzero. Note that for each postselection there are only\ntwo nonzero components, as expected for a Bell state.\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"sub_kets = [np.round(ket_t[tuple(ind)], 15) for ind in patterns]\nps = np.array(list(map(np.linalg.norm, sub_kets))) ** 2\nindices = np.array([np.array(np.nonzero(sub_ket)).T for sub_ket in sub_kets])\nprint(\n \"The indices of the nonzero components for the six different postselections are \\n\",\n indices,\n)\n\n# The successful postselection events occur with the same probability\nprint(\"The success probabilities for each pattern are the same \\n\", ps)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Conclusion\n----------\n\nWe have examined how to map the evolution of photonic systems with path\nand polarization degrees of freedom into qumodes evolving under unitary\noperations. The main takeaway is that a system with $N$ paths and\n2 polarization degrees of freedom can be mapped into a system of\n$2N$ qumodes. We have also explored in detail how the typical\noptical elements used to couple path and polarization can be mapped to\nqumode simulations. Finally, we used these identifications to\nsimulate the generation of event-ready (i.e.\u00a0postselected) Bell states.\n\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"References\n----------\n\n.. [#zhang]\n\n Q. Zhang, X.-H. Bao, C.-Y. Lu, X.-Q. Zhou, T. Yang, T. Rudolph, and J.-W. Pan\n Physical Review A 77, 062316, 2008. doi:10.1103/PhysRevA.77.062316 .\n\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}