Ask for more modes

Use this when an eigenproblem should return more of its lowest eigenvalues, and you want to find each eigenfunction in the result.

Steps

  1. Give the number with the symbol of the eigenvalue: eigenvalue=(E, 12) asks for the lowest twelve.

  2. Solve. solution.eigenvalues holds the eigenvalues, from the lowest.

  3. Index the solution with the unknown for the eigenfunctions. The first axis counts them: solution[w][i] belongs to solution.eigenvalues[i].

  4. Draw one of them with solution.plot(state=i).

Example

A drum in the shape of a rectangle, two by one. Its tones are \(\pi^2 (m^2/4 + n^2)\) for whole numbers \(m\) and \(n\) from one:

import numpy as np
import sympy as sp
import pdemagic as pm

x, y = sp.symbols("x y", real=True)
E = sp.Symbol("E")
w = sp.Function("w")(x, y)

drum = pm.Problem(
    sp.Eq(-pm.laplacian(w), E * w),
    domain=pm.Box({x: (0, 2), y: (0, 1)}),
    boundary=sp.Eq(w, 0),
    eigenvalue=(E, 12),
)
tones = pm.solve(drum)

expected = [1.25, 2, 3.25, 4.25, 5, 5, 6.25, 7.25, 8, 9.25, 10, 10]
assert np.allclose(tones.eigenvalues / np.pi**2, expected, atol=1e-9)

# Twelve functions on the grid: the first axis counts them.
xs, ys = tones.axes
assert tones[w].shape == (12, len(xs), len(ys))

# The fourth mode, counted from zero as the third.
tones.plot(state=3)
assert abs(tones.eigenvalues[3] - 4.25 * np.pi**2) < 1e-8
The figure that the example above draws. The figure that the example above draws.

Notes

  • Only the lowest eigenvalues are found. To reach a higher one, ask for all up to it.

  • Each eigenfunction has the integral of its square over the domain equal to one, and its largest value positive.

  • Modes that share an eigenvalue, like the fifth and sixth here, are returned as functions that are orthogonal to each other. Any combination of them is a mode as well, so another program may show other ones.

  • The planner takes a grid that resolves every mode that is asked for, so more modes may mean a finer grid.

  • In free space only bound states are found. A potential that binds fewer states than you ask for is refused, with the eigenvalue at which the states stop fading.

  • In one dimension plot draws the lowest states together, up to five, and state=[0, 4] chooses others. animate leafs through all of them.

  • Many modes at once cost more than their number: on a shape in the plane forty modes of a disk take five seconds.

  • Eigenproblems and Modes of cavities, drums and waveguides explain what can be asked. The gallery has a drum and the states of an oscillator.