allium
¶
allium
computes eigenfunctions and eigenfrequencies for
radially-symmetric things (currently only a sphere) assuming the
sound speed is a piecewise constant function. That is, it solves
the radial part of the Helmholtz equation
assuming that the sound speed \(c\) is of the form
with boundary conditions \(f(R_n)=0\) and regularity at \(r=0\).
You can install allium
from PyPI using e.g.
Installation¶
python -m pip install allium <--user>
Basic usage¶
The objects (e.g. Sphere
) can compute eigenfrequencies.
e.g. for a sphere with \(\vec{c}=(c_1,c_2)=(1.05, 1.0)\) and
\(\vec{R}=(R_1, R_2)=(0.1, 1.0)\), we can create an echelle diagram:
import numpy as np
import matplotlib.pyplot as pl
from allium import Sphere
s = Sphere(c=[1.05, 1.0], R=[0.1, 1.0])
s.search_eigenfrequencies([0,1,2,3], np.arange(0.5, 20.0)*np.pi)
for l in range(4):
w = np.array(s[l])/s.Delta_omega
pl.plot(np.mod(w-0.01, 1.0)+0.01, w, 'o', label='ℓ=%i' % l)
pl.xlabel('ω/Δω mod 1')
pl.ylabel('ω/Δω')
pl.xlim(-0.05, 1.05)
pl.legend()
(Source code, png, hires.png, pdf)

We can also compute wavefunctions, which only satisfy the inner boundary condition, or eigenfunctions, which satisfy both. For a more extreme sphere with \(\vec{c}=(c_1,c_2)=(2.0, 0.5)\) and \(\vec{R}=(R_1,R_2)=(0.5, 1.0)\), here’s an eigenfunction and a not-eigenfunction:
import numpy as np
import matplotlib.pyplot as pl
from allium import Sphere
s = Sphere(c=[2.0, 0.5], R=[0.5, 1.0])
s.search_eigenfrequencies(2, np.arange(10.5, 15.0, 0.5)*np.pi)
r = np.linspace(0, 1, 1001)
pl.plot(r, s.eigenfunction(2, 0)(r), label='eigenfunction')
pl.plot(r, s.wavefunction(2, s[2,0]+0.5*s.Delta_omega)(r),
label='not an eigenfunction')
pl.legend()
pl.xlabel('r')
pl.ylabel('f')
(Source code, png, hires.png, pdf)

You can read about how allium
works or why
you might use it and I created it, or go to the APIs to learn how to
use each object.
APIs