# The modes of a shape This page explains how pdemagic computes the lowest modes of a region of the plane for an eigenproblem: by a block iteration on the stationary solve of [spectral elements](spectral-elements.md). They are the modes in which a problem in time is propagated, which are explained under [shapes in time](elements-in-time.md). ## Asking for the modes The modes are also what an eigenproblem on a shape asks for: $-\nabla\cdot(\varepsilon\nabla u) + V u = E\,\rho\,u$, with a condition that gives zero on each piece of the boundary. The equation is read as the one in time whose modes these are, $\rho\,u_t = \nabla\cdot(\varepsilon\nabla u) - V u$, so that everything a problem in time may have in its modes, a medium, a potential and a density, an eigenproblem may have too. The lowest eigenvalues are returned with their modes, each with the integral of its square equal to one. A problem in time needs every mode that its elements hold, from one dense eigenproblem. An eigenproblem asks for the lowest few, and they follow from the stationary solve, which is sparse. With the stiffness $K$ of $-\nabla\cdot(\varepsilon\nabla u) + V u$ and the mass $M$ of the density on the elements, the modes solve $K u = E\,M u$. The lowest of them are the eigenvectors of $(K + \sigma M)^{-1} M$ with the largest eigenvalues, $1/(E + \sigma)$, and those lie far apart: the [block iteration](subspace.md) arrives in about a dozen steps, with no preconditioner. A step is one stationary solve for each function of the block. The system is factorized once, and the solves that follow cost little and run side by side on all cores. The shift $\sigma$ makes $K + \sigma M$ positive, also where the potential is negative and where no piece of the boundary holds the mode: it is how far the potential reaches below zero, and the energy of a wave as long as the shape. A condition $a\,u + b\,\partial u/\partial n = 0$ with $a$ and $b$ of opposite signs adds negative energy along the boundary, and can pull modes below that shift. Cholesky's method, by which the shifted operator is factorized, shows it: it ends at a pivot that is not positive. The shift is then raised fourfold and the operator factorized again, until it is positive. The iteration needs a symmetric operator, which it has in the variable $\sqrt{M}\,u$. A point whose value is given as zero takes no part. The planner computes the modes on elements of the degrees 4, 6, 8, …, on the coarsest mesh that follows the boundary, and takes the first degree at which the Legendre coefficients of every mode that is asked for have fallen to $10^{-8}$. An eigenvalue is more accurate than its mode: its error is the square of that of the mode. The mesh shrinks towards each corner at which a mode has a singularity, in the layers of a [stationary problem](element-corners.md). There the coefficients of a mode stop falling at what the innermost layer leaves, about $10^{-6}$, and the planner takes the first degree at which no eigenvalue differs from the one at the degree before by more than $10^{-9}$ of its size. | Shape | Modes | Degree | Points | Error of the eigenvalues | Time | |---|---|---|---|---|---| | The unit square, fixed | 4 | 12 | 3 553 | $3\cdot10^{-12}$ | 0.2 s | | The unit disk, fixed | 6 | 12 | 3 553 | $10^{-12}$ | 0.2 s | | The unit disk, free | 4 | 10 | 2 481 | $2\cdot10^{-13}$ | 0.1 s | | The ring between the radii ½ and 1, fixed | 6 | 14 | 9 632 | $10^{-12}$ | 0.6 s | | The unit square with four round holes, fixed | 6 | 16 | 35 965 | $2\cdot10^{-11}$ | 2.9 s | | The L-shape, fixed, with 18 layers | 1 | 8 | 62 945 | $5\cdot10^{-10}$ | 0.6 s | | The L-shape, fixed, with 18 layers | 6 | 10 | 98 241 | | 3.7 s | | A rectangle with a ridge, free, with 18 layers | 2 | 8 | 145 105 | $10^{-11}$ | 1.7 s | | The unit disk, fixed | 40 | 16 | 6 273 | | 4.0 s | The times are for `pm.solve` without a plan, with all degrees that the planner tries. The ring has the zeros of products of Bessel functions, the L-shape the value $E = 9.6397238440219$ that is known for its lowest mode, and the square with holes and the rectangle with a ridge are compared with higher degrees. Where a higher degree gains little, the planner goes on to a mesh of half the spacing. That is what the rectangle with a ridge needs: its two corners with a singularity lie half a unit apart, and on the coarsest mesh their layers get in each other's way. The planner solves with up to 60 000 points on the sides of elements, about a gigabyte. The solves of a mesh with many layers are right to ten or eleven digits, and the iteration cannot do better than they do. It ends where its residual no longer falls: the diagnostic `residual` says where that was, and the eigenvalues are right to the square of it. For many modes the work between the solves counts. The iteration holds three functions for each mode and needs the products of every pair of them, so that part grows with the square of the number of modes. It runs on all cores. ## Limits The region, its conditions and the elements are those of a stationary problem: see the limits of [spectral elements](spectral-elements.md#limits).