|
11 | 11 | "$$\n", |
12 | 12 | "\\nabla^2 u = b,\n", |
13 | 13 | "$$\n", |
14 | | - "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." |
| 14 | + "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." |
15 | 15 | ] |
16 | 16 | }, |
17 | 17 | { |
18 | 18 | "cell_type": "markdown", |
19 | 19 | "id": "1", |
20 | 20 | "metadata": {}, |
21 | 21 | "source": [ |
22 | | - "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", |
| 22 | + "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", |
23 | 23 | "$$\n", |
24 | 24 | "u(0) = u(L_x)=f_0,\\,\\,\\,\\, \\partial_y u|_{y=0} = \\partial_y u|_{y=L_y} = g_0.\n", |
25 | 25 | "$$\n", |
26 | | - "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", |
| 26 | + "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", |
27 | 27 | "$$\n", |
28 | 28 | "\\mathcal{L}\\cdot \\vec{u} = \\vec{b}, \\,\\,\\,\\,\\,\\,\\, \\mathcal{L} = \\mathcal{L}_{xx} \\otimes I_y + I_x \\otimes \\mathcal{L}_{yy},\n", |
29 | 29 | "$$\n", |
|
46 | 46 | "0 & 0 & \\cdots & -1 & 1 \\\\\n", |
47 | 47 | "\\end{pmatrix}\n", |
48 | 48 | "$$\n", |
49 | | - "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." |
| 49 | + "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." |
50 | 50 | ] |
51 | 51 | }, |
52 | 52 | { |
|
56 | 56 | "source": [ |
57 | 57 | "<center>\n", |
58 | 58 | "<img src=\"https://docs.classiq.io/resources/poisson_grid.png\" style=\"width:100%\">\n", |
59 | | - "<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", |
| 59 | + "<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", |
60 | 60 | "</center>" |
61 | 61 | ] |
62 | 62 | }, |
|
75 | 75 | "id": "4", |
76 | 76 | "metadata": {}, |
77 | 77 | "source": [ |
78 | | - "## How to Build the Algorithm with Classiq" |
| 78 | + "## Building the Algorithm with Classiq" |
79 | 79 | ] |
80 | 80 | }, |
81 | 81 | { |
82 | 82 | "cell_type": "markdown", |
83 | 83 | "id": "5", |
84 | 84 | "metadata": {}, |
85 | 85 | "source": [ |
86 | | - "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", |
| 86 | + "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", |
87 | 87 | "1. Prepare the amplitudes of the source term on a quantum variable.\n", |
88 | 88 | "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", |
89 | 89 | "3. Perform matrix inversion for a diagonal matrix.\n", |
|
97 | 97 | "source": [ |
98 | 98 | "<center>\n", |
99 | 99 | "<img src=\"https://docs.classiq.io/resources/poisson_circuit.png\" style=\"width:100%\">\n", |
100 | | - "<figcaption align = \"middle\"> Figure 2. The quantum circuit that for solving the Poisson equation. </figcaption>\n", |
| 100 | + "<figcaption align = \"middle\"> Figure 2. The quantum circuit for solving the Poisson equation. </figcaption>\n", |
101 | 101 | "</center>" |
102 | 102 | ] |
103 | 103 | }, |
|
136 | 136 | "id": "10", |
137 | 137 | "metadata": {}, |
138 | 138 | "source": [ |
139 | | - "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", |
| 139 | + "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", |
140 | 140 | "$$\n", |
141 | 141 | "\\lambda_{k,j} \\equiv \\lambda_{x,k} +\\lambda_{y,j}\n", |
142 | 142 | "$$\n", |
|
204 | 204 | "source": [ |
205 | 205 | "### Hamiltonian Evolution for QPE\n", |
206 | 206 | "\n", |
207 | | - "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}$." |
| 207 | + "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}$." |
208 | 208 | ] |
209 | 209 | }, |
210 | 210 | { |
|
312 | 312 | "id": "20", |
313 | 313 | "metadata": {}, |
314 | 314 | "source": [ |
315 | | - "## Example: non-separable source term" |
| 315 | + "## Example: Non-separable Source Term" |
316 | 316 | ] |
317 | 317 | }, |
318 | 318 | { |
319 | 319 | "cell_type": "markdown", |
320 | 320 | "id": "21", |
321 | 321 | "metadata": {}, |
322 | 322 | "source": [ |
323 | | - "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", |
| 323 | + "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", |
324 | 324 | "$$\n", |
325 | 325 | "b = F\\left[xy(x-L_x)(y-L_y)\\right].\n", |
326 | 326 | "$$\n", |
|
446 | 446 | { |
447 | 447 | "name": "stdout", |
448 | 448 | "output_type": "stream", |
449 | | - "text": [ |
450 | | - "" |
451 | | - ] |
| 449 | + "text": [] |
452 | 450 | } |
453 | 451 | ], |
454 | 452 | "source": [ |
|
533 | 531 | "id": "34", |
534 | 532 | "metadata": {}, |
535 | 533 | "source": [ |
536 | | - "We define a postprocess function that gets the quantum solution out of the execution and returns solution" |
| 534 | + "We define a postprocess function that gets the quantum solution out of the execution and returns a solution." |
537 | 535 | ] |
538 | 536 | }, |
539 | 537 | { |
|
607 | 605 | "id": "39", |
608 | 606 | "metadata": {}, |
609 | 607 | "source": [ |
610 | | - "Finally, we print the result and compare it to the classical solution" |
| 608 | + "Finally, we print the result and compare it to the classical solution:" |
611 | 609 | ] |
612 | 610 | }, |
613 | 611 | { |
|
688 | 686 | "source": [ |
689 | 687 | "## References\n", |
690 | 688 | "\n", |
691 | | - "<a id='CST'>[1]</a>: [Strang, Gilbert, 1999 SIAM Review 41 135. The Discrete Cosine Transform.](https://doi.org/10.1137/S0036144598336745)\n", |
| 689 | + "<a id='CST'>[1]</a>: [Strang, G., 1999 SIAM Review 41 135. The discrete cosine transform.](https://doi.org/10.1137/S0036144598336745)\n", |
692 | 690 | "\n", |
693 | | - "<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", |
| 691 | + "<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", |
694 | 692 | "\n", |
695 | | - "<a id='QCST'>[3]</a>: [Klappenecker, A., & Rotteler M., \"Discrete Cosine Transforms on Quantum Computers\".](https://arxiv.org/abs/quant-ph/0111038)\n" |
| 693 | + "<a id='QCST'>[3]</a>: [Klappenecker, A., & Rotteler M., Discrete cosine transforms on quantum computers.](https://arxiv.org/abs/quant-ph/0111038)\n" |
696 | 694 | ] |
697 | 695 | } |
698 | 696 | ], |
|
0 commit comments