compute_coeffs#

gala.potential.scf.compute_coeffs(density_func, nmax, lmax, M, r_s, args=(), skip_odd=False, skip_even=False, skip_m=False, S_only=False, progress=False, **nquad_opts)[source]#

Compute the expansion coefficients for representing the input density function using a basis function expansion.

Computing the coefficients involves computing triple integrals which are computationally expensive. For an example of how to parallelize the computation of the coefficients, see examples/parallel_compute_Anlm.py.

Parameters
density_funcfunction, callable()

A function or callable object that evaluates the density at a given position. The call format must be of the form: density_func(x, y, z, M, r_s, args) where x, y, z are cartesian coordinates, M is a scale mass, r_s a scale radius, and args is an iterable containing any other arguments needed by the density function.

nmaxint

Maximum value of n for the radial expansion.

lmaxint

Maximum value of l for the spherical harmonics.

Mnumeric

Scale mass.

r_snumeric

Scale radius.

argsiterable (optional)

A list or iterable of any other arguments needed by the density function.

skip_oddbool (optional)

Skip the odd terms in the angular portion of the expansion. For example, only take \(l=0, 2, 4, ...\)

skip_evenbool (optional)

Skip the even terms in the angular portion of the expansion. For example, only take \(l=1, 3, 5, ...\)

skip_mbool (optional)

Ignore terms with \(m > 0\).

S_onlybool (optional)

Only compute the S coefficients.

progressbool (optional)

If tqdm is installed, display a progress bar.

**nquad_opts

Any additional keyword arguments are passed through to nquad as options, opts.

Returns
Snlmfloat, ndarray

The value of the cosine expansion coefficient.

Snlm_err, ndarray

An estimate of the uncertainty in the coefficient value (from nquad).

Tnlm, ndarray

The value of the sine expansion coefficient.

Tnlm_err, ndarray

An estimate of the uncertainty in the coefficient value. (from nquad).