What sphericart computes¶
In the most basic form, spherical harmonics are defined as complex-valued functions of the polar coordinates \((\theta,\phi)\)
where \(P^m_l(x)\) are the associated Legendre polynomials. There are multiple conventions for choosing normalization and phases, and it is possible to reformulate the spherical harmonics in a real-valued form, which leads to even further ambiguity in the definitions.
Within sphericart, we compute only real-valued spherical harmonics and we express them as a function of the full Cartesian coordinates of a point in three dimensions. These correspond to the real spherical harmonics as defined in the corresponding Wikipedia article, which we refer to as \(Y^m_l\). If you need complex spherical harmonics, or use a different convention for normalization and storage order it is usually simple - if tedious and inefficient - to perform the conversion manually, see Spherical coordinates and/or complex harmonics for a simple example.
We also offer the possibility to compute “solid” harmonics, which are given by \(\tilde{Y}^m_l = r^l\,{Y}_l^m\). Since these can be expressed as homogeneous polynomials of the Cartesian coordinates \((x,y,z)\), as opposed to \((x/r,y/r,z/r)\), they are less computationally expensive to evaluate. Besides being slightly faster, they can also provide a more natural scaling if used together with a radial expansion, and we recommend using them unless you need the normalized version.
The formulas used to compute the solid harmonics (and, with few modifications, also for the spherical harmonics) are:
where
If we neglect some constant normalization factors, these correspond to the
regular solid harmonics:
the functions computed by sphericart
should be multiplied by
\(\sqrt{4\pi/(2l+1)}\) to recover the usual definition.
See also the reference paper for further implementation details.
The \(\tilde{Y}^m_l(x)\) are stored contiguously in memory, e.g. as
\(\{ (l,m)=(0,0), (1,-1), (1,0), (1,1), (2,-2), \ldots \}\).
With zero-based indexing of the arrays, the (l,m)
term is stored at
position l(l+1)+m
.