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
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
"$$\n",
"\\nabla^2 u = b,\n",
"$$\n",
"where the $\\nabla^2$ is the Laplacian (second derivatives) operator. One approach for numerically solving the Poisson equation is by moving from the continuos description to a discrete one, namely, by using the finite difference method that casts the problem into a set of linear equations. Then, the solution can be obtained by a linear solver."
"where the $\\nabla^2$ is the Laplacian (second derivatives) operator. One approach for numerically solving the Poisson equation is to move from the continuous description to a discrete one, using the finite difference method that casts the problem into a set of linear equations. Then, the solution can be obtained by a linear solver."
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"In this notebook we treat the Poisson equation on a rectangular geometry, $L_x\\times L_y$, with Dirichlet boundary condition on the $x$ axis and a Neumann boundary condition on the $y$ axis:\n",
"In this notebook we treat the Poisson equation on a rectangular geometry, $L_x\\times L_y$, with a Dirichlet boundary condition on the $x$ axis and a Neumann boundary condition on the $y$ axis:\n",
"$$\n",
"u(0) = u(L_x)=f_0,\\,\\,\\,\\, \\partial_y u|_{y=0} = \\partial_y u|_{y=L_y} = g_0.\n",
"$$\n",
"Furthermore, we will assume that $f_0=g_0=0$. The discritezation of space, including the treatment of the above boundary conditions, is given in Figure 1. The resulting linear equation reads:\n",
"Furthermore, we assume that $f_0=g_0=0$. The discretization of space, including the treatment of the above boundary conditions, is given in Figure 1. The resulting linear equation reads:\n",
"$$\n",
"\\mathcal{L}\\cdot \\vec{u} = \\vec{b}, \\,\\,\\,\\,\\,\\,\\, \\mathcal{L} = \\mathcal{L}_{xx} \\otimes I_y + I_x \\otimes \\mathcal{L}_{yy},\n",
"$$\n",
Expand All @@ -46,7 +46,7 @@
"0 & 0 & \\cdots & -1 & 1 \\\\\n",
"\\end{pmatrix}\n",
"$$\n",
"and $\\Delta x$ and $\\Delta y$ are the discretization of the $x$ and $y$ axes, respectively. The above square matrices, which are of dimensions $N_x$ and $N_y$ respectively, represent the solution at the inner part of our geometry."
"and $\\Delta x$ and $\\Delta y$ are the discretization of the $x$ and $y$ axes, respectively. The above square matrices, which are of dimensions $N_x$ and $N_y$, respectively, represent the solution at the inner part of our geometry."
]
},
{
Expand All @@ -56,7 +56,7 @@
"source": [
"<center>\n",
"<img src=\"https://docs.classiq.io/resources/poisson_grid.png\" style=\"width:100%\">\n",
"<figcaption align = \"middle\"> Figure 1. A schematic description of discrediting the Poisson equation. The area in which we would like to solve the problem is designated by the blue line. The linear equations are written only for the inner filled grid points. The unfilled ghost points are used to impose the boundary conditions. In the example above, a Dirichlet boundary condition is given by setting $u_{0,k}=-u_{-1,k}$, and $u_{3,k}=-u_{4,k}$, whereas a Neumann boundary condition reads $u_{j,0}=u_{j,-1}$, and $u_{j,3}=u_{j,4}$. </figcaption>\n",
"<figcaption align = \"middle\"> Figure 1. A schematic description of discrediting the Poisson equation. The blue line designates the area for solving the problem. The linear equations are written only for the inner filled grid points. The unfilled ghost points are used to impose the boundary conditions. In the example above, a Dirichlet boundary condition is given by setting $u_{0,k}=-u_{-1,k}$ and $u_{3,k}=-u_{4,k}$, whereas a Neumann boundary condition reads $u_{j,0}=u_{j,-1}$ and $u_{j,3}=u_{j,4}$. </figcaption>\n",
"</center>"
]
},
Expand All @@ -75,15 +75,15 @@
"id": "4",
"metadata": {},
"source": [
"## How to Build the Algorithm with Classiq"
"## Building the Algorithm with Classiq"
]
},
{
"cell_type": "markdown",
"id": "5",
"metadata": {},
"source": [
"The HHL algorithm essentially applies a matrix inversion. Here we treat the Laplacian matrix, which can be diagonalized by a quantum sine and cosine transforms, thus, the matrix we need to invert is a diagonal one. The main four quantum blocks of the algorithm are thus (see Figure 2):\n",
"The HHL algorithm essentially applies a matrix inversion. Here we treat the Laplacian matrix, which can be diagonalized by quantum sine and cosine transforms. Thus, the matrix to invert is diagonal. The four main quantum blocks of the algorithm are thus (see Figure 2):\n",
"1. Prepare the amplitudes of the source term on a quantum variable.\n",
"2. Perform QST and QCT at the beginning of the computation. This is done by applying the QST to the x qubits and the QCT to the y qubits.\n",
"3. Perform matrix inversion for a diagonal matrix.\n",
Expand All @@ -97,7 +97,7 @@
"source": [
"<center>\n",
"<img src=\"https://docs.classiq.io/resources/poisson_circuit.png\" style=\"width:100%\">\n",
"<figcaption align = \"middle\"> Figure 2. The quantum circuit that for solving the Poisson equation. </figcaption>\n",
"<figcaption align = \"middle\"> Figure 2. The quantum circuit for solving the Poisson equation. </figcaption>\n",
"</center>"
]
},
Expand Down Expand Up @@ -136,7 +136,7 @@
"id": "10",
"metadata": {},
"source": [
"The eigenvalues of the Poisson equation with Dirichlet boundary conditions in the x direction and Neumann boundary conditions in the y direction are given by:\n",
"The eigenvalues of the Poisson equation with Dirichlet boundary conditions in the x direction and Neumann boundary conditions in the y direction are given by\n",
"$$\n",
"\\lambda_{k,j} \\equiv \\lambda_{x,k} +\\lambda_{y,j}\n",
"$$\n",
Expand Down Expand Up @@ -204,7 +204,7 @@
"source": [
"### Hamiltonian Evolution for QPE\n",
"\n",
"The HHL is based on a [QPE](https://github.com/Classiq/classiq-library/blob/main/tutorials/advanced_tutorials/high_level_modeling_flexible_qpe/high_level_modeling_flexible_qpe.ipynb) applied on $e^{iHt}$. For this, we need to define a function implementing $\\left(e^{iHt}\\right)^p$ for an integer power $p$. Since in our case the Hamiltonian is diagonal, an exact implementation is given by the fisrt order Suzuki-Trotter formula, where in addition $\\left(e^{iHt}\\right)^p = e^{ipHt}$."
"The HHL is based on a [QPE](https://github.com/Classiq/classiq-library/blob/main/tutorials/advanced_tutorials/high_level_modeling_flexible_qpe/high_level_modeling_flexible_qpe.ipynb) applied on $e^{iHt}$. For this, we need to define a function implementing $\\left(e^{iHt}\\right)^p$ for an integer power $p$. Since in our case the Hamiltonian is diagonal, an exact implementation is given by the first order Suzuki-Trotter formula, where in addition $\\left(e^{iHt}\\right)^p = e^{ipHt}$."
]
},
{
Expand Down Expand Up @@ -312,15 +312,15 @@
"id": "20",
"metadata": {},
"source": [
"## Example: non-separable source term"
"## Example: Non-separable Source Term"
]
},
{
"cell_type": "markdown",
"id": "21",
"metadata": {},
"source": [
"We solve an example with a square grid of $N_x,\\, N_y=2^3$. For the source term we take a non-seperable $2^{N_x+N_y}$ vector that represents the function\n",
"We solve an example with a square grid of $N_x,\\, N_y=2^3$. For the source term we take a non-separable $2^{N_x+N_y}$ vector that represents the function\n",
"$$\n",
"b = F\\left[xy(x-L_x)(y-L_y)\\right].\n",
"$$\n",
Expand Down Expand Up @@ -446,9 +446,7 @@
{
"name": "stdout",
"output_type": "stream",
"text": [
""
]
"text": []
}
],
"source": [
Expand Down Expand Up @@ -533,7 +531,7 @@
"id": "34",
"metadata": {},
"source": [
"We define a postprocess function that gets the quantum solution out of the execution and returns solution"
"We define a postprocess function that gets the quantum solution out of the execution and returns a solution."
]
},
{
Expand Down Expand Up @@ -607,7 +605,7 @@
"id": "39",
"metadata": {},
"source": [
"Finally, we print the result and compare it to the classical solution"
"Finally, we print the result and compare it to the classical solution:"
]
},
{
Expand Down Expand Up @@ -688,11 +686,11 @@
"source": [
"## References\n",
"\n",
"<a id='CST'>[1]</a>: [Strang, Gilbert, 1999 SIAM Review 41 135. The Discrete Cosine Transform.](https://doi.org/10.1137/S0036144598336745)\n",
"<a id='CST'>[1]</a>: [Strang, G., 1999 SIAM Review 41 135. The discrete cosine transform.](https://doi.org/10.1137/S0036144598336745)\n",
"\n",
"<a id='PoissonQuantum'>[2]</a>: [Yudong Cao et al 2013 New J. Phys. 15 013021. Quantum algorithm and circuit design solving the Poisson equation.](https://iopscience.iop.org/article/10.1088/1367-2630/15/1/013021/pdf)\n",
"<a id='PoissonQuantum'>[2]</a>: [Yudong Cao et al., 2013 New J. Phys. 15 013021. Quantum algorithm and circuit design solving the Poisson equation.](https://iopscience.iop.org/article/10.1088/1367-2630/15/1/013021/pdf)\n",
"\n",
"<a id='QCST'>[3]</a>: [Klappenecker, A., & Rotteler M., \"Discrete Cosine Transforms on Quantum Computers\".](https://arxiv.org/abs/quant-ph/0111038)\n"
"<a id='QCST'>[3]</a>: [Klappenecker, A., & Rotteler M., Discrete cosine transforms on quantum computers.](https://arxiv.org/abs/quant-ph/0111038)\n"
]
}
],
Expand Down
1 change: 1 addition & 0 deletions tests/resources/timeouts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ hhl.ipynb: 312
hhl_exact.qmod: 100
hhl_example.ipynb: 800
hhl_lanchester.ipynb: 450
hhl_lanchester.qmod: 450
hhl_trotter.qmod: 100
hhl_workshop.ipynb: 300
hidden_shift.ipynb: 272
Expand Down
1 change: 1 addition & 0 deletions tests/test_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
URL_IN_MARKDOWN_REGEX = re.compile(r"(?<=\]\()%s(?=\s*\))" % URL_REGEX)
SKIPPED_URLS = [
"https://journals.aps.org/rmp/abstract/10.1103/RevModPhys.69.607", # From date: 19.12.24, notebook: hamiltonian_simulation_guide.ipynb
"https://doi.org/10.1137/S0036144598336745", # From date: 5.1.25, notebook: algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.ipynb
]


Expand Down
Loading