Functions common to all bases

To seamlessly allow for switching between different bases, the bases are all organised around common functions.

Common functions

The common functions are detailed in src/Basisdoc.jl. Any instantiated basis will result in a structure, with attributes name, dimension, lmax, nmax, rb (the basis scale), and G (the gravitational constant; unity by default). The following functions are also defined:

getUln(basis,l,n,r) will calculate the basis potential at location r for harmonic order l and radial order n.

getDln(basis,l,n,r) will calculate the basis density at location r for harmonic order l and radial order n.

Overloaded function tabUl!(basis,l) will fill the structure attribute tabUl table with radial potential values from the basis up to nmax.

Overloaded function tabDl!(basis,l) will fill the structure attribute tabUl table with radial density values from the basis up to nmax.

Accessing potential functions

AstroBasis.getUlnFunction
getUln(basis,l,n,r)

Definition of the potential radial basis elements (l,n) at position r.

@WARNING:: l=0 is index 1, n=0 is index 1.

source
getUln(basis::CB72Basis, l, n, r[, forD])

For Clutton-Brock (1972) basis elements.

source
getUln(basis::K76Basis, l, n, r[, forD])

For Kalnajs (1976) basis elements.

source
AstroBasis.tabUl!Function
tabUl!(basis, l, r)

Compute the basis potential elements for a given basis structure.

Arguments

  • basis: The structure containing basis parameters and prefactors. This should be a subtype of AbstractAstroBasis.
  • l::Int64: The harmonic/azimuthal index.
  • r::Float64: The radial coordinate.

Description

This function computes the basis elements for the provided structure. It updates the potential or density basis elements in-place within the given structure.

Implementation Details

  • The function initializes the recurrence relation for the adimensional subpart of the basis elements.
  • It then iterates through the radial basis numbers, updating the basis elements using a recurrence relation.
  • Finally, it multiplies the computed values by the appropriate prefactors.

Warning

l=0 is index 1, n=0 is index 1.

source
tabUl!(basis::CB72Basis, l, r[, forD])

Compute the Clutton-Brock (1972) basis elements for a given CB72Basis structure.

Arguments

  • basis::CB72Basis: The CB72Basis structure containing basis parameters and prefactors.
  • l::Int64: The harmonic/azimuthal index.
  • r::Float64: The radial coordinate.
  • forD::Bool=false: A boolean flag indicating whether to use density prefactors. Default is false.

Description

This function computes the basis elements for the Clutton-Brock (1972) model. It updates the potential or density basis elements in-place within the provided CB72Basis structure.

Implementation Details

  • The function initializes the recurrence relation for the adimensional subpart of the basis elements.
  • It then iterates through the radial basis numbers, updating the basis elements using a recurrence relation.
  • Finally, it multiplies the computed values by the appropriate prefactors.

Example

# Assuming basis is an instance of CB72Basis with appropriate parameters
tabUl!(basis, 2, 1.0)

Warning

Ensure that the tabPrefU and tabPrefD arrays in CB72Basis are correctly sized to avoid runtime errors.

source
tabUl!(basis::K76Basis, l, r)

For Kalnajs (1976) basis elements.

source

Accessing density functions

AstroBasis.getDlnFunction
getDln(basis,l,n,r)

Definition of the density radial basis elements (l,n) at position r.

@WARNING:: l=0 is index 1, n=0 is index 1.

source
getDln(basis::CB72Basis, l, n, r)

For Clutton-Brock (1972) basis elements, using getUln.

source
getDln(basis::K76Basis, l, n, r)

For Kalnajs (1976) basis elements.

source
AstroBasis.tabDl!Function
tabDl!(basis,l)

Compute density table for a given l and r, and for 0 <= n <= nmax

To avoid repeated memory allocations, this overwrites the 'basis.tabDl' table

@WARNING:: l=0 is index 1, n=0 is index 1.

source
tabDl!(basis::CB72Basis, l, r)

For Clutton-Brock (1972) basis elements, using tabUl!.

source
tabDl!(basis::K76Basis, l, r)

For Kalnajs (1976) basis elements.

source