diff --git a/algorithms/discrete_poisson_solver/discrete_poisson_solver.ipynb b/algorithms/discrete_poisson_solver/discrete_poisson_solver.ipynb new file mode 100644 index 00000000..6ef8f9ba --- /dev/null +++ b/algorithms/discrete_poisson_solver/discrete_poisson_solver.ipynb @@ -0,0 +1,720 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0", + "metadata": {}, + "source": [ + "# Quantum Algorithm for Solving the Poisson Equation\n", + "\n", + "The Poisson equation is a partial differential equation that appears in various research areas, such as physics and engineering. It describes the distribution of a potential field, $u$, under some source term $b$:\n", + "$$\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." + ] + }, + { + "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", + "$$\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", + "$$\n", + "\\mathcal{L}\\cdot \\vec{u} = \\vec{b}, \\,\\,\\,\\,\\,\\,\\, \\mathcal{L} = \\mathcal{L}_{xx} \\otimes I_y + I_x \\otimes \\mathcal{L}_{yy},\n", + "$$\n", + "where $\\mathcal{L}_{xx}$ and $\\mathcal{L}_{yy}$ are the Laplacian operators [[1](#CST)]:\n", + "$$\n", + "\\mathcal{L}_{xx} = \\frac{1}{\\Delta x^2}\n", + "\\begin{pmatrix}\n", + "3 & -1 & 0 & \\cdots & 0 \\\\\n", + "-1 & 2 & -1 & \\cdots & 0 \\\\\n", + "0 & -1 & 2 & \\cdots & 0 \\\\\n", + "\\vdots & \\vdots & \\vdots & \\ddots & -1 \\\\\n", + "0 & 0 & \\cdots & -1 & 3 \\\\\n", + "\\end{pmatrix},\\,\\,\\,\n", + "\\mathcal{L}_{yy} = \\frac{1}{\\Delta y^2}\n", + "\\begin{pmatrix}\n", + "1 & -1 & 0 & \\cdots & 0 \\\\\n", + "-1 & 2 & -1 & \\cdots & 0 \\\\\n", + "0 & -1 & 2 & \\cdots & 0 \\\\\n", + "\\vdots & \\vdots & \\vdots & \\ddots & -1 \\\\\n", + "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." + ] + }, + { + "cell_type": "markdown", + "id": "2", + "metadata": {}, + "source": [ + "
(target) { + powered_hamiltonian_evolution<[ + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=2.25 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::Z + ], + coefficient=-0.25 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::Z, + Pauli::I + ], + coefficient=-0.520598050073 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::Z, + Pauli::Z + ], + coefficient=-0.020598050073 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::Z, + Pauli::I, + Pauli::I + ], + coefficient=-1.256834873031 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::Z, + Pauli::I, + Pauli::Z + ], + coefficient=-0.049728091845 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::Z, + Pauli::Z, + Pauli::I + ], + coefficient=-0.103553390593 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::Z, + Pauli::Z, + Pauli::Z + ], + coefficient=0.103553390593 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=1.75 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::I, + Pauli::Z, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=-0.25 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::Z, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=-0.520598050073 + }, + PauliTerm { + pauli=[ + Pauli::I, + Pauli::Z, + Pauli::Z, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=0.020598050073 + }, + PauliTerm { + pauli=[ + Pauli::Z, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=-1.256834873031 + }, + PauliTerm { + pauli=[ + Pauli::Z, + Pauli::I, + Pauli::Z, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=0.049728091845 + }, + PauliTerm { + pauli=[ + Pauli::Z, + Pauli::Z, + Pauli::I, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=0.103553390593 + }, + PauliTerm { + pauli=[ + Pauli::Z, + Pauli::Z, + Pauli::Z, + Pauli::I, + Pauli::I, + Pauli::I + ], + coefficient=0.103553390593 + } + ], 0.101321183642, p>(target); + }>(xy_variable, phase, indicator); + } + xy_variable -> {x_variable, y_variable}; +} + diff --git a/algorithms/discrete_poisson_solver/discrete_poisson_solver.synthesis_options.json b/algorithms/discrete_poisson_solver/discrete_poisson_solver.synthesis_options.json new file mode 100644 index 00000000..f28ff899 --- /dev/null +++ b/algorithms/discrete_poisson_solver/discrete_poisson_solver.synthesis_options.json @@ -0,0 +1,5 @@ +{ + "constraints": { + "max_width": 18 + } +} \ No newline at end of file