# Self-consistent field expansions (`biff.scf`

)¶

## Introduction¶

The two main uses of `biff.scf`

are:

- to compute the expansion coefficients given a continuous density distribution or discrete samples from a density distribution, or
- to evaluate the density, potential, and gradients of a basis function expansion representation of a density distribution given a set of coefficients.

To compute expansion coefficients, the relevant functions are
`compute_coeffs`

and `compute_coeffs_discrete`

. This
implementation uses the notation from [L11]: all expansion coefficients are
real, \(S_{nlm}\) are the cosine coefficients, and \(T_{nlm}\) are the
sine coefficients.

Once you have coefficients, there are two ways to evaluate properties of the
potential or the density of the expansion representation. Biff provides a
class-based interface `SCFPotential`

that utilizes the
gravitational potential machinery implemented in `gala.potential`

(and supports
all of the `gala`

functionality, such as orbit integration and plotting). The
examples below use this interface.

As an alternate, there is also a functional interface to each relevant function:
`density`

, `potential`

, and `gradient`

.

## API¶

### biff.scf Package¶

Implementation of the Self-Consistent Field (SCF) expansion method.

#### Functions¶

`compute_coeffs` (density_func, nmax, lmax, M, r_s) |
Compute the expansion coefficients for representing the input density function using a basis function expansion. |

`compute_coeffs_discrete` (xyz, mass, nmax, …) |
Compute the expansion coefficients for representing the density distribution of input points as a basis function expansion. |

`density` (xyz, Snlm, Tnlm[, M, r_s]) |
Compute the density of the basis function expansion at a set of positions given the expansion coefficients. |

`gradient` (xyz, Snlm, Tnlm[, G, M, r_s]) |
Compute the gradient of the gravitational potential of the basis function expansion at a set of positions given the expansion coefficients. |

`potential` (xyz, Snlm, Tnlm[, G, M, r_s]) |
Compute the gravitational potential of the basis function expansion at a set of positions given the expansion coefficients. |

#### Classes¶

`SCFPotential` (m, r_s, Snlm, Tnlm[, units]) |
An SCF / basis function expansion potential. |