Issue 
A&A
Volume 652, August 2021



Article Number  A36  
Number of page(s)  13  
Section  Extragalactic astronomy  
DOI  https://doi.org/10.1051/00046361/202141281  
Published online  06 August 2021 
SpheCow: Flexible dynamical models for galaxies and dark matter haloes
Sterrenkundig Observatorium, Universiteit Gent, Krijgslaan 281 S9, 9000 Gent, Belgium
email: maarten.baes@ugent.be
Received:
10
May
2021
Accepted:
25
May
2021
Simple but flexible dynamical models are useful for many purposes, including serving as the starting point for more complex models or numerical simulations of galaxies, clusters, or dark matter haloes. We present SpheCow, a new lightweight and flexible code that allows one to easily explore the structure and dynamics of any spherical model. Assuming an isotropic or OsipkovMerritt anisotropic orbital structure, the code can automatically calculate the dynamical properties of any model with either an analytical density profile or an analytical surface density profile as starting point. We have extensively validated SpheCow using a combination of comparisons to analytical and highprecision numerical calculations, as well as the calculation of inverse formulae. SpheCow contains readily usable implementations for many standard models, including the Plummer, Hernquist, NFW, Einasto, Sérsic, and Nuker models. The code is publicly available as a set of C++ routines and as a Python module, and it is designed to be easily extendable, in the sense that new models can be added in a straightforward way. We demonstrate this by adding two new families of models in which either the density slope or the surface density slope is described by an algebraic sigmoid function. We advocate the use of the SpheCow code to investigate the full dynamical structure for models for which the distribution function cannot be expressed analytically and to explore a much wider range of models than is possible using analytical models alone.
Key words: methods: numerical / galaxies: structure / galaxies: kinematics and dynamics
© ESO 2021
1. Introduction
In order to investigate the structure and evolution of selfgravitating systems such as galaxies, clusters, and dark matter haloes, a characterisation of their structure in full 6D phase space is of paramount importance. Thanks to the improving observational data, novel modelling techniques, and increasing computational power, we now have various advanced dynamical modelling tools at our disposal (e.g., Bovy 2015; Vasiliev 2019; Vasiliev & Valluri 2020; Neureiter et al. 2021). Nevertheless, relatively simple spherically symmetric models remain useful and important. They can act as an environment in which different physical processes can be investigated, or against which new modelling or data analysis techniques can be explored. Moreover, they are often the starting point for the creation of more complex and realistic models or fullscale numerical simulations.
Simple models have roughly become synonymous with analytical models, that is, models in which many properties can be calculated in terms of elementary or special functions. One approach to generate such simple models is by choosing a simple form for the distribution function. Once the distribution function is defined, the density profile ρ(r) and potential Ψ(r) of the selfconsistent model can be determined by integrating the distribution function over velocity space and solving Poisson’s equation. Famous models based on this approach include the singular isothermal sphere (Binney & Tremaine 2008), the King model (King 1966), and the Michie model (Michie 1963; Michie & Bodenheimer 1963). Models with a simple analytical distribution function are very useful for elaborate calculations in which the precise form of the distribution function is not the major uncertainty, for example to compute the rate of microlensing events in dark matter haloes (Alcock et al. 1995) or to predict the signal in direct dark matter detection experiments (Evans et al. 2019). The disadvantage of this approach is that the density and potential are often not analytically tractable and/or do not necessarily provide a realistic representation for actual galaxies or dark matter haloes.
As an alternative to this approach, it is also common to set up dynamical models with the mass density profile ρ(r) as a starting point. If the density is sufficiently simple, other quantities can often be expressed analytically as well, such as the cumulative mass profile and the gravitational potential. For a number of popular models, such as the NFW model (Navarro et al. 1997) or the Einasto model (Einasto 1965), this is how far the analyticity goes (Łokas & Mamon 2001; Cardone et al. 2005). For a fairly limited set of models, analytical expressions are also available for the phasespace distribution function, usually under the assumption of a simple orbital structure such as velocity isotropy. Some of the most popular spherical models belong to this category, such as the Plummer model (Plummer 1911), the isochrone sphere (Hénon 1959), the Jaffe model (Jaffe 1983), the Hernquist model (Hernquist 1990), and the family of γmodels (Dehnen 1993; Tremaine et al. 1994). Finally, for a very restricted subset of these models more general anisotropic distribution functions and/or line profiles can be calculated analytically (e.g., Dejonghe 1987; Baes & Dejonghe 2002; Baes & Van Hese 2007).
A disadvantage of models with a simple density profile as starting point is that their surface density profile on the plane of the sky^{1} is not necessarily equally simple (e.g., Zhao 1996; RetanaMontenegro et al. 2012). An interesting alternative is to consider models with a given surface density profile as a starting point. This approach has the advantage that specific functional forms can be chosen that closely reproduce the observed surface brightness distribution of galaxies and other systems. Examples of this type of models include the Sérsic model (Sérsic 1968; Graham & Driver 2005) and the Nuker model (Lauer et al. 1995). The disadvantage is that the density needs to be calculated through an integral along the line of sight, and that this integration does not necessarily yield a simple expression. In particular, for the models listed above, the density profile can only be expressed in terms of very special functions (Mazure & Capelato 2002; Baes & Gentile 2011; Baes & Van Hese 2011; Baes 2020). For other dynamical properties that typically require integrations of the density, finding explicit expressions is hopeless.
While completely analytical models have their obvious benefits, it would be a pity to only focus on the limited set of models that belong to this category. We advocate the use of other models as well, especially the much broader class of all models with an analytical density profile or surface density profile. Even when no analytical expressions are available for the most important dynamical properties, all of these properties can be calculated numerically in a relatively straightforward way.
In this paper we present a new lightweight and flexible code, SpheCow, that sets up a spherical dynamical model with either an analytical density profile ρ(r) or an analytical surface density profile Σ(R) as starting point. For either of these two options, the SpheCow code automatically calculates basic intrinsic and onsky properties, as well as dynamical properties assuming either an isotropic or an OsipkovMerritt type anisotropic orbital structure. This offers the possibility to easily calculate and investigate the full dynamical structure for models for which the distribution function cannot be expressed analytically, and to explore a much wider range of models than is possible using analytical models alone. In particular, such a lightweight tool can help to foster the use of more realistic models as starting points for more advanced modelling, at the expense of the simpler but often less realistic alternatives.
This paper is organised as follows. In Sect. 2 we discuss how the most important quantities, both intrinsic and on the plane of the sky, can be calculated when one has a closed expression for either the density (Sect. 2.1) or the surface density (Sect. 2.2). This section reviews many wellknown equations, but also presents some shortcuts that can be used to convert double to single integrals. In Sect. 3 we present the SpheCow code in which we have implemented these formulae. We present the numerical integration algorithm that is the core of the code, and we describe the design of the code. In Sect. 4 we discuss the validation of the code. In Sect. 5 we present a simple application of the SpheCow code. We introduce two new general families of models, in which the logarithmic slope of either the mass density or the surface density profile is characterised by a sigmoid function. We discuss and summarise our results in Sect. 6.
2. The calculation of dynamical properties
We assume that a spherically symmetric model is either characterised by an analytical density profile ρ(r) or an analytical surface density profile Σ(R). For either of these two cases, we discuss how the most important properties of the model can be calculated in an efficient way. In the remainder of this section, we assume that we have to our disposal a suitable numerical integration scheme that can efficiently calculate any integrals over semiinfinite or infinite intervals. This aspect will be discussed in Sect. 3.1 and is considered as a given for the time being.
2.1. Models defined by an analytical density profile
2.1.1. Basic properties
In most cases, the starting point of a model is the 3D mass density ρ(r). If an analytical form of ρ(r) is known, we can also directly analytically calculate the firstorder and secondorder derivatives, and therefore also the negative logarithmic density slope
$$\begin{array}{c}\hfill \gamma (r)=\frac{\mathrm{d}ln\rho}{\mathrm{d}lnr}(r)=\frac{r\phantom{\rule{0.166667em}{0ex}}{\rho}^{\prime}(r)}{\rho (r)}\xb7\end{array}$$(1)
With ρ(r) given, we can calculate the total mass
$$\begin{array}{c}\hfill M=4\pi {\displaystyle {\int}_{0}^{\infty}\rho (u)\phantom{\rule{0.166667em}{0ex}}{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u,}\end{array}$$(2)
the cumulative mass distribution
$$\begin{array}{c}\hfill M(r)=4\pi {\displaystyle {\int}_{0}^{r}\rho (u)\phantom{\rule{0.166667em}{0ex}}{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u,}\end{array}$$(3)
and the positive gravitational potential
$$\begin{array}{c}\hfill \mathrm{\Psi}(r)=\frac{GM(r)}{r}+4\pi \phantom{\rule{0.166667em}{0ex}}G{\displaystyle {\int}_{r}^{\infty}\rho (u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\end{array}$$(4)
The circular velocity curve is
$$\begin{array}{c}\hfill {v}_{\mathrm{c}}(r)=\frac{GM(r)}{r}\xb7\end{array}$$(5)
The total potential energy is calculated as (Binney & Tremaine 2008; Baes & Ciotti 2019a)
$$\begin{array}{c}\hfill {W}_{\mathrm{tot}}=4\pi G{\displaystyle {\int}_{0}^{\infty}\rho (u)\phantom{\rule{0.166667em}{0ex}}M(u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\end{array}$$(6)
The surface density profile can be calculated using an integration along the line of sight,
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)=2{\displaystyle {\int}_{R}^{\infty}\frac{\rho (u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{\sqrt{{u}^{2}{R}^{2}}}\xb7}\end{array}$$(7)
In a similar way as for the density profile, it is often interesting to characterise the negative logarithmic slope of the surface density profile (e.g., Lauer et al. 1995, 2007),
$$\begin{array}{c}\hfill {\gamma}_{\mathrm{p}}(R)=\frac{\mathrm{d}ln\mathrm{\Sigma}}{\mathrm{d}lnR}(R)=\frac{R\phantom{\rule{0.166667em}{0ex}}{\mathrm{\Sigma}}^{\prime}(R)}{\mathrm{\Sigma}(R)}\xb7\end{array}$$(8)
This expression requires the derivative of the surface density profile, for which we have, in general, no closed analytical expression. One way to automatically calculate it for an arbitrary model with a given density profile ρ(r) is to directly apply numerical differentiation to the surface density profile calculated numerically through expression (7). A more convenient and accurate way, however, is to directly take the formal derivative of expression (7). Using the substitution u = Rsecθ we have
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)=2{\displaystyle {\int}_{0}^{\pi /2}\rho (Rsec\theta )\phantom{\rule{0.166667em}{0ex}}R{sec}^{2}\theta \phantom{\rule{0.166667em}{0ex}}\mathrm{d}\theta \xb7}\end{array}$$(9)
Taking the derivative with respect to R and transforming it back to u, we find
$$\begin{array}{c}\hfill {\mathrm{\Sigma}}^{\prime}(R)=2{\displaystyle {\int}_{R}^{\infty}\frac{[\rho (u)+u\phantom{\rule{0.166667em}{0ex}}{\rho}^{\prime}(u)]\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{R\sqrt{{u}^{2}{R}^{2}}},}\end{array}$$(10)
where ρ′(r) is the firstorder derivative of the density. The cumulative surface mass profile is the mass within a circular surface density contour on the sky with radius R,
$$\begin{array}{c}\hfill {M}_{\mathrm{p}}(R)=2\pi {\displaystyle {\int}_{0}^{R}\mathrm{\Sigma}(u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\end{array}$$(11)
Inserting expression (7) and changing the order of the integration, we get (Mamon et al. 2010)
$$\begin{array}{c}\hfill {M}_{\mathrm{p}}(R)=M4\pi {\displaystyle {\int}_{R}^{\infty}\rho (u)\phantom{\rule{0.166667em}{0ex}}u\sqrt{{u}^{2}{R}^{2}}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\end{array}$$(12)
This expression involves a combination of two single integrals, one of which only needs to be calculated once, rather than a double integration.
2.1.2. Dynamical properties for an isotropic orbital structure
It is wellknown that each spherical potentialdensity pair corresponds to a unique dynamical model with an isotropic velocity distribution (Dejonghe 1986; Binney & Tremaine 2008). The velocity dispersion profile ${\sigma}_{\text{iso}}^{2}(r)$ of this model can be found through the solution of the Jeans equation,
$$\begin{array}{c}\hfill \rho (r)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{iso}}^{2}(r)=G{\displaystyle {\int}_{r}^{\infty}\frac{\rho (u)\phantom{\rule{0.166667em}{0ex}}M(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{u}^{2}}\xb7}\end{array}$$(13)
The total kinetic energy is calculated as
$$\begin{array}{c}\hfill {K}_{\mathrm{tot}}=6\pi {\displaystyle {\int}_{0}^{\infty}\rho (u)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{iso}}^{2}(u)\phantom{\rule{0.166667em}{0ex}}{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\end{array}$$(14)
The lineofsight velocity or projected dispersion ${\sigma}_{\text{p},\text{iso}}^{2}(R)$ is found as
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{p},\mathrm{iso}}^{2}(R)=2{\displaystyle {\int}_{R}^{\infty}\frac{\rho (u)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{iso}}^{2}(u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{\sqrt{{u}^{2}{R}^{2}}}\xb7}\end{array}$$(15)
We can introduce expression (13) into this equation and change the order of integration (Prugniel & Simien 1997). This yields the equivalent expression
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{p},\mathrm{iso}}^{2}(R)=2G{\displaystyle {\int}_{R}^{\infty}\frac{\rho (u)\phantom{\rule{0.166667em}{0ex}}M(u)\sqrt{{u}^{2}{R}^{2}}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{u}^{2}}\xb7}\end{array}$$(16)
The isotropic distribution function, which only depends on the (positive) binding energy per unit mass ℰ, can be found through Eddington’s formula (Eddington 1916),
$$\begin{array}{c}\hfill {f}_{\mathrm{iso}}(\mathcal{E})=\frac{1}{2\sqrt{2}\phantom{\rule{0.166667em}{0ex}}{\pi}^{2}}{\displaystyle {\int}_{0}^{\mathcal{E}}\frac{{\stackrel{\sim}{\rho}}^{\u2033}(\mathrm{\Psi})\phantom{\rule{0.166667em}{0ex}}\mathrm{d}\mathrm{\Psi}}{\sqrt{\mathcal{E}\mathrm{\Psi}}},}\end{array}$$(17)
with $\stackrel{\sim}{\rho}(\mathrm{\Psi})$ the augmented density, that is the density written as a function of the potential. Following Binney (1982), we transform this integral via the substitution Ψ = Ψ(u), where we use the identity
$$\begin{array}{c}\hfill \frac{\mathrm{d}\mathrm{\Psi}(r)}{\mathrm{d}r}=\frac{GM(r)}{{r}^{2}}\xb7\end{array}$$(18)
This results in
$$\begin{array}{c}\hfill {f}_{\mathrm{iso}}(\mathcal{E})=\frac{1}{2\sqrt{2}\phantom{\rule{0.166667em}{0ex}}{\pi}^{2}}{\displaystyle {\int}_{{r}_{\mathcal{E}}}^{\infty}\frac{\mathrm{\Delta}(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{\sqrt{\mathcal{E}\mathrm{\Psi}(u)}},}\end{array}$$(19a)
with
$$\begin{array}{c}\hfill \mathrm{\Delta}(r)=\frac{{r}^{2}}{GM(r)}[{\rho}^{\u2033}(r)+{\rho}^{\prime}(r)(\frac{2}{r}\frac{4\pi \phantom{\rule{0.166667em}{0ex}}\rho (r)\phantom{\rule{0.166667em}{0ex}}{r}^{2}}{M(r)})],\end{array}$$(19b)
and r_{ℰ} implicitly defined by the equation Ψ(r_{ℰ}) = ℰ.
The differential energy distribution represents the distribution of mass as a function of the binding energy ℰ. For isotropic systems, the differential energy distribution can be written as
$$\begin{array}{c}\hfill {\mathcal{N}}_{\mathrm{iso}}(\mathcal{E})={f}_{\mathrm{iso}}(\mathcal{E})\phantom{\rule{0.166667em}{0ex}}{g}_{\mathrm{iso}}(\mathcal{E}),\end{array}$$(20)
with g_{iso}(ℰ) the densityofstates function, defined as
$$\begin{array}{c}\hfill {g}_{\mathrm{iso}}(\mathcal{E})=16\sqrt{2}\phantom{\rule{0.166667em}{0ex}}{\pi}^{2}{\displaystyle {\int}_{\mathcal{E}}^{{\mathrm{\Psi}}_{0}}{r}^{2}\phantom{\rule{0.166667em}{0ex}}\frac{\mathrm{d}r}{\mathrm{d}\mathrm{\Psi}}\sqrt{\mathrm{\Psi}\mathcal{E}}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}\mathrm{\Psi}}\end{array}$$(21)
with r = r(Ψ) the radius written as a function of the binding potential, and Ψ_{0} the depth of the potential well. This equation can be recast in the form
$$\begin{array}{c}\hfill {g}_{\mathrm{iso}}(\mathcal{E})=16\sqrt{2}\phantom{\rule{0.166667em}{0ex}}{\pi}^{2}{\displaystyle {\int}_{0}^{{r}_{\mathcal{E}}}{u}^{2}\sqrt{\mathrm{\Psi}(u)\mathcal{E}}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\end{array}$$(22)
2.1.3. Dynamical properties for an OsipkovMerritt orbital structure
An isotropic orbital structure is the simplest option and it is interesting from a mathematical point of view. However, galaxies and dark matter haloes are not necessarily characterised by this simple orbital structure. In fact, most numerical Nbody simulations predict that dark matter haloes are roughly isotropic in the central regions, but radially anisotropic in the outer regions (Taylor & Navarro 2001; Diemand et al. 2004; Ludlow et al. 2011; Lemze et al. 2012; Wojtak et al. 2013; Butsky et al. 2016).
Osipkov (1979) and Merritt (1985a) independently discovered that dynamical systems with a spheroidal velocity distribution have the interesting property that their distribution function can be calculated in a similar way as models with an isotropic distribution function. The now socalled OsipkovMerritt models are characterised by an orbital structure that is isotropic in the centre and completely radially anisotropic at large radii. More concretely, the anisotropy profile β(r) is
$$\begin{array}{c}\hfill \beta (r)\equiv 1\frac{{\sigma}_{\theta}^{2}(r)}{{\sigma}_{\mathrm{r}}^{2}(r)}=\frac{{r}^{2}}{{r}^{2}+{r}_{\mathrm{a}}^{2}},\end{array}$$(23)
with r_{a} a freely chosen anisotropy radius. In this case, the velocity dispersions are obviously not the same in the three principle directions. For a given density profile and anisotropy radius, the radial velocity dispersion profile can be calculated as (Mamon & Łokas 2005)
$$\begin{array}{c}\hfill \rho (r)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{r},\mathrm{om}}^{2}(r)=\frac{G{r}_{\mathrm{a}}^{2}}{{r}^{2}+{r}_{\mathrm{a}}^{2}}{\displaystyle {\int}_{r}^{\infty}\frac{{\rho}_{Q}(u)\phantom{\rule{0.166667em}{0ex}}M(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{u}^{2}},}\end{array}$$(24)
with ρ_{Q}(r) defined as
$$\begin{array}{c}\hfill {\rho}_{Q}(r)=(1+\frac{{r}^{2}}{{r}_{\mathrm{a}}^{2}})\rho (r).\end{array}$$(25)
The velocity dispersions in the two tangential directions are given by
$$\begin{array}{c}\hfill {\sigma}_{\theta ,\mathrm{om}}^{2}(r)={\sigma}_{\varphi ,\mathrm{om}}^{2}(r)=\frac{{r}_{\mathrm{a}}^{2}}{{r}^{2}+{r}_{\mathrm{a}}^{2}}\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{r},\mathrm{om}}^{2}(r).\end{array}$$(26)
In this case, the total kinetic energy is calculated as
$$\begin{array}{cc}\hfill {K}_{\mathrm{tot}}& =2\pi {\displaystyle {\int}_{0}^{\infty}\rho (u)[{\sigma}_{\mathrm{r},\mathrm{om}}^{2}(u)+{\sigma}_{\theta ,\mathrm{om}}^{2}(u)+{\sigma}_{\varphi ,\mathrm{om}}^{2}(u)]{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}\hfill \\ \hfill & =2\pi {\displaystyle {\int}_{0}^{\infty}\left(\frac{{u}^{2}+3{r}_{\mathrm{a}}^{2}}{{u}^{2}+{r}_{\mathrm{a}}^{2}}\right)\phantom{\rule{0.166667em}{0ex}}\rho (u)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{r},\mathrm{om}}^{2}(u)\phantom{\rule{0.166667em}{0ex}}{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\hfill \end{array}$$(27)
The general expression for the projected velocity dispersion for an anisotropic spherical model is (Binney & Mamon 1982; Dejonghe 1987)
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{p}}^{2}(R)=2{\displaystyle {\int}_{R}^{\infty}[1\frac{{R}^{2}}{{u}^{2}}\phantom{\rule{0.166667em}{0ex}}\beta (u)]\frac{\rho (u)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{r}}^{2}(u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{\sqrt{{u}^{2}{R}^{2}}},}\end{array}$$(28)
which in the case of an OsipkovMerritt orbital structure reduces to
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{p},\mathrm{om}}^{2}(R)=2{\int}_{R}^{\infty}\left(\frac{{u}^{2}+{r}_{\mathrm{a}}^{2}{R}^{2}}{{u}^{2}+{r}_{\mathrm{a}}^{2}}\right)\frac{\rho (u)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{r},\mathrm{om}}^{2}(u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{\sqrt{{u}^{2}{R}^{2}}}\xb7\end{array}$$(29)
In principle, this expression can directly be implemented, but the integrand depends on ${\sigma}_{\text{r},\text{om}}^{2}(u)$, implying that we get at least a double integral (and a triple integral if the mass profile needs to be calculated numerically). A more convenient form can be obtained by substituting Eq. (24) and changing the order of integration in the resulting expression (Mamon & Łokas 2005; Agnello et al. 2014). This results in
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{p},\mathrm{om}}^{2}(R)=G{\displaystyle {\int}_{R}^{\infty}\frac{w(u,R)\phantom{\rule{0.166667em}{0ex}}\rho (u)\phantom{\rule{0.166667em}{0ex}}M(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{u}^{2}},}\end{array}$$(30a)
with
$$\begin{array}{cc}\hfill w(u,R)=& \left(\frac{{u}^{2}+{r}_{\mathrm{a}}^{2}}{{R}^{2}+{r}_{\mathrm{a}}^{2}}\right)\hfill \\ \hfill & \times (\frac{{R}^{2}+2{r}_{\mathrm{a}}^{2}}{\sqrt{{R}^{2}+{r}_{\mathrm{a}}^{2}}}arctan\sqrt{\frac{{u}^{2}{R}^{2}}{{R}^{2}+{r}_{\mathrm{a}}^{2}}}\frac{{R}^{2}\sqrt{{u}^{2}{R}^{2}}}{{u}^{2}+{r}_{\mathrm{a}}^{2}})\xb7\hfill \end{array}$$(30b)
The distribution function of anisotropic dynamical models can generally written as f(ℰ, L) with L the total angular momentum per unit mass. For the special case of an OsipkovMerritt orbital structure, the distribution function depends on ℰ and L only through the combination
$$\begin{array}{c}\hfill Q=\mathcal{E}\frac{{L}^{2}}{2{r}_{\mathrm{a}}^{2}},\end{array}$$(31)
that is, f_{om}(ℰ, L) = f_{om}(Q), with the additional constraint that f_{om}(Q) = 0 for Q ≤ 0. For a given density profile, the function f_{om}(Q) can be determined using a formula very similar to the Eddington relation (Osipkov 1979; Merritt 1985a),
$$\begin{array}{c}\hfill {f}_{\mathrm{om}}(Q)=\frac{1}{2\sqrt{2}\phantom{\rule{0.166667em}{0ex}}{\pi}^{2}}{\displaystyle {\int}_{0}^{Q}\frac{{\stackrel{\sim}{\rho}}_{Q}^{\u2033}(\mathrm{\Psi})\phantom{\rule{0.166667em}{0ex}}\mathrm{d}\mathrm{\Psi}}{\sqrt{Q\mathrm{\Psi}}}\xb7}\end{array}$$(32)
As for the isotropic case, this expression can be recast in a form that is more suitable for numerical integration,
$$\begin{array}{c}\hfill {f}_{\mathrm{om}}(Q)=\frac{1}{2\sqrt{2}\phantom{\rule{0.166667em}{0ex}}{\pi}^{2}}{\displaystyle {\int}_{{r}_{Q}}^{\infty}\frac{{\mathrm{\Delta}}_{Q}(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{\sqrt{Q\mathrm{\Psi}(u)}},}\end{array}$$(33a)
with r_{Q} determined implicitly by Ψ(r_{Q}) = Q, and
$$\begin{array}{c}\hfill {\mathrm{\Delta}}_{Q}(r)=\frac{{r}^{2}}{GM(r)}[{\rho}_{Q}^{\u2033}(r)+{\rho}_{Q}^{\prime}(r)(\frac{2}{r}\frac{4\pi \phantom{\rule{0.166667em}{0ex}}{\rho}_{Q}(r)\phantom{\rule{0.166667em}{0ex}}{r}^{2}}{M(r)})]\xb7\end{array}$$(33b)
A general calculation of the differential energy distribution for OsipkovMerritt orbital structure is nontrivial. However, one can define a probability density function 𝒩_{om}(Q) for the mass as a function of Q, which we refer to as the pseudodifferential energy distribution. Cuddeford (1991) demonstrated that it can be found as
$$\begin{array}{c}\hfill {\mathcal{N}}_{\mathrm{om}}(Q)={f}_{\mathrm{om}}(Q)\phantom{\rule{0.166667em}{0ex}}{g}_{\mathrm{om}}(Q),\end{array}$$(34)
with g_{om}(Q) a pseudodensityofstates function,
$$\begin{array}{c}\hfill {g}_{\mathrm{om}}(Q)=16\sqrt{2}\phantom{\rule{0.166667em}{0ex}}{\pi}^{2}{\displaystyle {\int}_{0}^{{r}_{Q}}{u}^{2}{(1+\frac{{u}^{2}}{{r}_{\mathrm{a}}^{2}})}^{1}\sqrt{\mathrm{\Psi}(u)Q}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u.}\end{array}$$(35)
2.2. Models defined by an analytical surface density profile
As discussed in the Introduction, another class of models starts from an observed surface density profile Σ(R), with R the radius on the plane of the sky. As can be seen in the previous section, the fundamental quantity that appeared in nearly all the formulae is the density ρ(r). The connection between density and surface density is given by Eq. (7), which can be inverted using the standard Abel inversion formula (Binney & Tremaine 2008; Mamon & Boué 2010)
$$\begin{array}{c}\hfill \rho (r)=\frac{1}{\pi}{\displaystyle {\int}_{r}^{\infty}}\frac{{\mathrm{\Sigma}}^{\prime}(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{\sqrt{{u}^{2}{r}^{2}}}\xb7\end{array}$$(36)
In this formula, Σ′(R) is the derivative of the surface density profile, which is also known analytically since we assumed that Σ(R) is an analytical function. For a given analytical surface density profile, we can numerically integrate expression (36) to obtain ρ(r), and subsequently use this expression in all other expression. However, we can avoid the use of numerical double integrals for the calculation of the mass profile and gravitational potential by inserting the expression (36) into the general Eqs. (3) and (4), and changing the order of integrations. After some manipulation we find for the mass profile
$$\begin{array}{c}\hfill M(r)=\pi {\displaystyle [{\int}_{0}^{r}{\mathrm{\Sigma}}^{\prime}(u)\phantom{\rule{0.166667em}{0ex}}{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u+{\int}_{r}^{\infty}{\mathrm{\Sigma}}^{\prime}(u)\phantom{\rule{0.166667em}{0ex}}{w}_{}(u,r)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u],}\end{array}$$(37a)
where we have set
$$\begin{array}{c}\hfill {w}_{}(u,r)=\frac{2}{\pi}[{u}^{2}arctan\left(\frac{r}{\sqrt{{u}^{2}{r}^{2}}}\right)r\sqrt{{u}^{2}{r}^{2}}]\xb7\end{array}$$(37b)
For the gravitational potential we find in a similar way
$$\begin{array}{c}\hfill \mathrm{\Psi}(r)=\frac{\pi \phantom{\rule{0.166667em}{0ex}}G}{r}{\displaystyle [{\int}_{0}^{r}{\mathrm{\Sigma}}^{\prime}(u)\phantom{\rule{0.166667em}{0ex}}{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u+{\int}_{r}^{\infty}{\mathrm{\Sigma}}^{\prime}(u)\phantom{\rule{0.166667em}{0ex}}{w}_{+}(u,r)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u],}\end{array}$$(38a)
with now
$$\begin{array}{c}\hfill {w}_{+}(u,r)=\frac{2}{\pi}[{u}^{2}arctan\left(\frac{r}{\sqrt{{u}^{2}{r}^{2}}}\right)+r\sqrt{{u}^{2}{r}^{2}}].\end{array}$$(38b)
For all other properties, corresponding to either an isotropic or an OsipkovMerritt orbital distribution, we directly use the expressions from the previous subsection, in which we substitute the (numerically determined) expressions (36)–(38b) for density, mass profile, and potential. The only additional quantities that we need are the first and second order derivatives of the density, which are necessary to calculate the slope of the density profile and the distribution function. Rather than applying numerical differentiation to the numerically determined density profile (36), it is more straightforward and far more accurate to use the expressions
$$\begin{array}{cc}& {\rho}^{\prime}(r)=\frac{1}{\pi}{\displaystyle {\int}_{r}^{\infty}\frac{{\mathrm{\Sigma}}^{\u2033}(u)\phantom{\rule{0.166667em}{0ex}}u\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{r\sqrt{{u}^{2}{r}^{2}}},}\hfill \end{array}$$(39)
$$\begin{array}{cc}& {\rho}^{\u2033}(r)=\frac{1}{\pi}{\displaystyle {\int}_{r}^{\infty}\frac{{\mathrm{\Sigma}}^{\u2033\prime}(u)\phantom{\rule{0.166667em}{0ex}}{u}^{2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{r}^{2}\sqrt{{u}^{2}{r}^{2}}},}\hfill \end{array}$$(40)
with Σ″(R) and Σ‴(R) the second and third order derivatives of the surface density profile, for which we assume exact expressions are available. These formulae can be obtained from Eq. (36) in a similar way as we derived Eq. (10) from Eq. (7).
3. The SpheCow code
We have designed a C++ software module called SpheCow to automatically calculate the dynamical properties as described above for any spherical model. Models can be defined either by their density profile, or by their surface density profile. In both cases, the code can be used to calculate the basic model properties and the most important dynamical properties, for both isotropic and OsipkovMerritttype anisotropic orbital structures.
3.1. Numerical integrations
At the core of the SpheCow code is a generic numerical integration scheme that is appropriate for all models, whether they are based on density or surface density. As can be seen from the set of formulae in the previous section, we essentially encounter only two types of integrals: all integrations run over the variable u, which can represent either the spherical radius or the projected radius on the plane of the sky, and they either run on an interval [0, r] or an interval [r, ∞]. So in principle we only have to implement a strategy to numerically calculate such integrals. A more refined strategy is required, however, to ensure that we get accurate results for a wide variety of galaxy models. Realistic models are typically characterised by a particular scale radius r_{b}, which often corresponds to the division between an inner and an outer profile. It therefore seems logical to split any integration over an interval that contains r_{b} into two separate integrals. This is particularly necessary for models in which there is a (relatively) sharp break in the density profile at r = r_{b}.
This implies that we need to consider four different types of integrals, namely integrals on the intervals [0, r] or [r, r_{b}] if r < r_{b}, or on the intervals [r_{b}, r] or [r, ∞] if r > r_{b}. For each of these integrals we use a substitution to turn it into an equivalent integration that is more suitable for a GaussLegendre quadrature scheme. In the case r < r_{b}, we use
$$\begin{array}{cc}& {\displaystyle {\int}_{0}^{r}X(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u=r{\int}_{0}^{\pi /2}X(rsin\theta )cos\theta \phantom{\rule{0.166667em}{0ex}}\mathrm{d}\theta ,}\hfill \end{array}$$(41)
$$\begin{array}{cc}& {\displaystyle {\int}_{r}^{{r}_{\mathrm{b}}}X(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u=r{\int}_{arcsin(r/{r}_{\mathrm{b}})}^{\pi /2}X(rcsc\theta )cos\theta {csc}^{2}\theta \phantom{\rule{0.166667em}{0ex}}\mathrm{d}\theta .}\hfill \end{array}$$(42)
For r > r_{b} we use similar transformations,
$$\begin{array}{cc}& {\displaystyle {\int}_{{r}_{b}}^{r}X(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u=r{\int}_{arcsin({r}_{\mathrm{b}}/r)}^{\pi /2}X(rsin\theta )cos\theta \phantom{\rule{0.166667em}{0ex}}\mathrm{d}\theta ,}\hfill \end{array}$$(43)
$$\begin{array}{cc}& {\displaystyle {\int}_{r}^{\infty}X(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u=r{\int}_{0}^{\pi /2}X(rcsc\theta )cos\theta {csc}^{2}\theta \phantom{\rule{0.166667em}{0ex}}\mathrm{d}\theta .}\hfill \end{array}$$(44)
For integrals covering the entire intervals [0, r_{b}] and [r_{b}, ∞], we use the transformations (41) and (44), respectively, with r → r_{b},
$$\begin{array}{cc}& {\displaystyle {\int}_{0}^{{r}_{b}}X(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u={r}_{\mathrm{b}}{\int}_{0}^{\pi /2}X({r}_{b}sin\theta )cos\theta \phantom{\rule{0.166667em}{0ex}}\mathrm{d}\theta ,}\hfill \end{array}$$(45)
$$\begin{array}{cc}& {\displaystyle {\int}_{{r}_{b}}^{\infty}X(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u={r}_{\mathrm{b}}{\int}_{0}^{\pi /2}X({r}_{\mathrm{b}}csc\theta )cos\theta {csc}^{2}\theta \phantom{\rule{0.166667em}{0ex}}\mathrm{d}\theta .}\hfill \end{array}$$(46)
To perform the actual integrations, we use a GaussLegendre quadrature formula. The integration points and the corresponding weights are precalculated, which makes the integrations fast and efficient. We use 128 integration points as our default, but this value can be chosen by the user. In general, higher orders correspond to higher accuracy but to an increased calculation time as well (see Sect. 4.1 for a discussion).
3.2. Code design
For the design of the SpheCow code we have deliberately chosen a modular and lightweight setup. The code essentially consists of a simple driver function, a GaussLegendre class that takes care of the numerical integrations, and a general abstract Model class that acts as the base class for all different models. This last class has two abstract subclasses, DensityModel and SurfaceDensityModel. The former is the base class for all different models defined by an analytical density profile, the latter for all models with an analytical surface density profile as starting point.
Once the density or surface density and their derivatives are known, the calculation of all the photometric and dynamical properties is calculated via a direct implementation of the formulae as written in the previous section. The only aspect where some special care is needed is the integrations that contain a factor Ψ(r)−Ψ(u) in the denominator in the integrand. When u − r = ϵ is very small, this difference can effectively become zero and this can cause infinities. In this case we use the first two terms in the Taylor expansion,
$$\begin{array}{c}\hfill \mathrm{\Psi}(r)\mathrm{\Psi}(r+\u03f5)\approx \frac{GM(r)}{{r}^{2}}\phantom{\rule{0.166667em}{0ex}}\u03f5+[2\pi \phantom{\rule{0.166667em}{0ex}}\rho (r)\frac{GM(r)}{{r}^{3}}]{\u03f5}^{2}.\end{array}$$(47)
We have currently implemented a suite of models, listed in Table 1. There are many other models in the literature that we have not (yet) included in the code, including the generalised isochrone sphere (An & Evans 2006a), the coreNFW model (Peñarrubia et al. 2012), the doubloon models (Evans & Williams 2014; Evans et al. 2015), or the generalised Einasto model (Fielder et al. 2020). However, the SpheCow code is modular in design, and new models can easily be added, as separate subclasses that inherit from either the DensityModel and SurfaceDensityModel base classes. To add a model with an analytical density profile, the user needs to provide an implementation of the density, and its first and second order derivatives. All other quantities can be calculated numerically using the formulae and numerical integration schemes discussed above. However, in case closed analytical expressions are available, in particular for the mass profile or the potential, these can also be provided. This will help the calculation of other properties such as the distribution function, both in speed and accuracy. Similarly, to add a new model with an analytical surface density profile, a new subclass of the SurfaceDensityModel class must be generated, and an implementation of the surface density profile Σ(R), and its first, second, and third order derivatives are required. All other quantities can be calculated automatically.
Models currently implemented in the SpheCow code.
3.3. Availability
SpheCow is publicly available on GitHub^{2} as a set of C++ files. A Makefile and a readme file are available to help users with the installation and running of the code. We have also foreseen Python bindings and a Python script to convert the SpheCow code to a Python module that can directly be used in Python code and notebooks. An Jupyter Notebook example is included to help users to get started.
4. Validation
4.1. Accuracy of the numerical integrations
We have extensively validated the SpheCow code. A first important aspect is a characterisation of the accuracy of the calculations, which we have done by comparing the results of the code against analytical results for a number of quantities and models where such analytical expressions exist. Very useful models for which analytical expressions exist for nearly all relevant quantities, both for an isotropic and an OsipkovMerritt orbital structure, are the Plummer model, the Hernquist model, and the γ–model with $\gamma ={\textstyle \frac{5}{2}}$. For most other models implemented, at least some properties can be calculated analytically: analytical formulae can be found in the articles referenced in the last column of Table 1. We have compared the numerical results against the analytical ones where possible, and generally found excellent agreement.
In Fig. 1 we illustrate the accuracy of the SpheCow code by means of the Plummer model. In the nine panels we show the absolute value of the relative errors between the SpheCow calculations and extended precision calculations based on the analytical formulae from Merritt (1985a) and Dejonghe (1987). The top row shows three basic properties: the density, the surface density, and the potential. The middle row shows the intrinsic dispersion, the projected dispersion, and the distribution function corresponding to an isotropic orbital structure, whereas the bottom row shows the same properties, but now for an OsipkovMerritt orbital structure with r_{a} = c, with c the scale radius of the Plummer model.
Fig. 1. Absolute value of the relative error of the density, surface density, potential, velocity dispersion, projected dispersion, and distribution function of the Plummer model (c represents the scale radius of the Plummer model). See text in Sect. 4.1 for the meaning of the different curves in each panel. 
The thick yellow curves correspond to the Plummer model as implemented in the SpheCow code. It is a subclass of the DensityModel class, that is, it is defined by means of its analytical density profile. Since the Plummer model also has simple analytical expressions for the mass profile and the gravitational potential, these are also implemented in the PlummerModel class, and this explains why the density and the potential have relative errors of the order of machine precision. The surface density profile, the intrinsic and projected dispersion profiles, and the distribution functions all involve just a single numerical integration. For the surface density and projected dispersion, the relative error is of the order of 10^{−12}; for the intrinsic dispersion and the distribution functions, the relative error is even smaller.
The thin black curves in Fig. 1 also represent SpheCow calculations for a Plummer model, but now we have not used the specific Plummer implementations for the potential and mass profile. Both are now calculated numerically using our standard GaussLegendre integration scheme based on Eqs. (3) and (4), and this results in a relative error of the order of 10^{−13}. This does not affect the surface density profile and it only marginally increases the relative error of the dispersion profiles for the isotropic model. It does affect the accuracy of the dispersion profiles of the models with an OsipkovMerritt orbital structure, especially at the outer, radially anisotropic regions. It also affects the relative error of the isotropic and OsipkovMerritt distribution functions. For the isotropic case, the distribution function is now characterised by a relative error of the order of 10^{−10}, especially at small radii. For the anisotropic distribution function, we see a larger loss of accuracy. In the inner, isotropic regions we have a relative error of about 10^{−9}, in the outer radially anisotropic region, the relative error increases up to 10^{−6}.
Finally, we have also implemented an alternative version of the Plummer model in SpheCow, now as subclass of the SurfaceDensityModel class. Indeed, the Plummer model is quite unique in that it also has a very simple analytical surface density profile. The results of this alternative model are shown as the blue lines in Fig. 1. In this case, the density profile, mass profile, and potential all involve a single numerical integration, as shown in Eqs. (36)–(38b). For the density, this results in a relative error of the order of 10^{−12}, for the potential the accuracy is an order of magnitude better. Both the intrinsic and the lineofsight dispersion profiles now require a double numerical integration, but still the relative error remains at the order of 10^{−12} for the intrinsic dispersion and even around 10^{−13} for the projected dispersion (except for the OsipkovMerritt case at large radii). The relative error on the distribution functions does not alter significantly.
For Fig. 1 we used our default GaussLegendre integration scheme with 128 nodes, but this number can be chosen freely by the user, as discussed in Sect. 3.1. In Fig. 2 we show how the relative error on the surface density, potential, and distribution function changes as a function of the number of integration points in the numerical integration scheme. To get a single representative relative error, we calculated the relative error corresponding to 201 points spread logarithmically between r/r_{b} = 10^{−2} and 10^{2}, and we took the average value of the absolute values. We used a Plummer model without an explicit implementation of the potential and the mass profile for the calculations, that is the model corresponding to the thin black lines in Fig. 1. The number of integration points is varied from 8 to 512.
Fig. 2. Average relative error on the calculation of the surface density, potential, and distribution function for the Plummer model as a function of the number of integration points in the GaussLegendre integration scheme. 
For the surface density and the potential, quantities that require just one and two individual integrations respectively, the accuracy of the SpheCow calculation increases spectacularly as the number of integration points increases. For example, increasing this number from 32 to 64, the relative error decreases by roughly five orders of magnitude. As soon as the number of points reaches about 128, the accuracy does not improve any further. The calculation of the distribution function, both for an isotropic and an OsipkovMerritt orbital structure, is more complex and involves nested numerical integrations. The accuracy of the calculations still increases strongly with increasing number of integration points, but not as outspoken as for the surface density and potential. The accuracy also keeps increasing beyond 128 integration points.
In general, Fig. 2 and additional tests suggest that a GaussLegendre integration scheme with 128 integration points represents a good compromise between high accuracy and reasonable computation time (for quantities that involve a double integral, such as the distribution function, the computation time scales quadratically with the number of integration points). In case a reduced accuracy is sufficient, a slightly lower order can be considered.
4.2. Consistency checks
The SpheCow code already contains a significant number of models and is designed to be extended with additional models in a straightforward way. Each new model requires the implementation of either the density and its first two derivatives, or the surface density and it first three derivatives. In order to check the consistency of the implementation of these properties, we can use the inverse formulae for many of the quantities that are being calculated. For example, the distribution function represents the density of the model in 6D phase space, and the mass density profile can be recovered by integrating the distribution function over velocity space. In the case of an isotropic orbital structure, we find
$$\begin{array}{c}\hfill \rho (r)=4\sqrt{2}\phantom{\rule{0.166667em}{0ex}}\pi {\displaystyle {\int}_{0}^{\mathrm{\Psi}(r)}{f}_{\mathrm{iso}}(\mathcal{E})\sqrt{\mathrm{\Psi}(r)\mathcal{E}}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}\mathcal{E},}\end{array}$$(48)
and for an OsipkovMerritt orbital structure we have (Merritt 1985a)
$$\begin{array}{c}\hfill \rho (r)=4\sqrt{2}\phantom{\rule{0.166667em}{0ex}}\pi {(1+\frac{{r}^{2}}{{r}_{\mathrm{a}}^{2}})}^{1}{\displaystyle {\int}_{0}^{\mathrm{\Psi}(r)}{f}_{\mathrm{om}}(Q)\sqrt{\mathrm{\Psi}(r)Q}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}Q.}\end{array}$$(49)
In a similar way, the velocity dispersion profiles can be found as the secondorder moment of the distribution function, resulting in
$$\begin{array}{c}\hfill \rho (r)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{iso}}^{2}(r)=\frac{8\sqrt{2}\pi}{3}{\displaystyle {\int}_{0}^{\mathrm{\Psi}(r)}{f}_{\mathrm{iso}}(\mathcal{E}){[\mathrm{\Psi}(r)\mathcal{E}]}^{3/2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}\mathcal{E},}\end{array}$$(50)
and
$$\begin{array}{cc}\hfill \rho (r)\phantom{\rule{0.166667em}{0ex}}{\sigma}_{\mathrm{r},\mathrm{om}}^{2}(r)=& \frac{8\sqrt{2}\phantom{\rule{0.166667em}{0ex}}\pi}{3}{(1+\frac{{r}^{2}}{{r}_{\mathrm{a}}^{2}})}^{1}\hfill \\ \hfill & \times {\displaystyle {\int}_{0}^{\mathrm{\Psi}(r)}{f}_{\mathrm{om}}(Q){[\mathrm{\Psi}(r)Q]}^{3/2}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}Q\xb7}\hfill \end{array}$$(51)
The four Eqs. (48)–(51) can easily be converted to integrations with respect to radius. For example, Eq. (48) can be transformed into
$$\begin{array}{c}\hfill \rho (r)=4\sqrt{2}\phantom{\rule{0.166667em}{0ex}}\pi G{\displaystyle {\int}_{r}^{\infty}\frac{{f}_{\mathrm{iso}}(\mathrm{\Psi}(u))\phantom{\rule{0.166667em}{0ex}}M(u)\sqrt{\mathrm{\Psi}(r)\mathrm{\Psi}(u)}\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{u}^{2}}\xb7}\end{array}$$(52)
We have implemented all of these inverse formulae in the SpheCow code to be used as a way to validate the implementation of the different models.
Moreover, they can also be used as a way to characterise the accuracy of the numerical integrations. In Fig. 3 we show the absolute value of the relative error for the density of the de Vaucouleurs model. This model is implemented in the SpheCow by means of its analytical surface density profile, and the cyan curves correspond to the density calculated via the standard deprojection formula (36). Comparing these values to the exact values, which can only be expressed exactly in terms of nonstandard special functions (Mazure & Capelato 2002; Baes & Gentile 2011), we see that the relative errors are of the order of 10^{−12}, similar to what we obtained for the Plummer model in Fig. 1. The purple lines in Fig. 3 correspond to the density as calculated by integrating the isotropic distribution function over velocity space, that is using formula (48). The orange lines are similar, but now the OsipkovMerritt distribution function is integrated over velocity according to Eq. (49), with r_{a}/R_{e} = 2. For both the isotropic and the OsipkovMerritt cases, the relative error on the density for r > R_{e} is of the same magnitude as the relative error of the density as calculated through the standard deprojection formula. This is remarkable, given that the integrands in the formulae (48) and (49) are a function of the distribution function, the mass profile and the potential, each of which are obtained via a numerical integration itself (the distribution function even via a complicated double integration). For r < R_{e}, we see that there is a systematic increase of the relative error up to about 10^{−9}, because the integration now involves a combination of two separate integrals.
Fig. 3. Absolute value of the relative error of the density of the Vaucouleurs model, as calculated by SpheCow. The cyan line corresponds to the calculation using the standard deprojection Eq. (36), the purple line to the integration of the isotropic distribution function over velocity space (48), and the orange line to the integration of the OsipkovMerritt distribution function over velocity space (49). 
Finally, we can also test the implementation of the different models through the differential energy distribution. For a model with an isotropic orbital structure, 𝒩(ℰ) represents the distribution of mass as a function of the binding energy, and it should therefore satisfy the normalisation
$$\begin{array}{c}\hfill {\displaystyle {\int}_{0}^{{\mathrm{\Psi}}_{0}}{\mathcal{N}}_{\mathrm{iso}}(\mathcal{E})\phantom{\rule{0.166667em}{0ex}}\mathrm{d}\mathcal{E}=G{\int}_{0}^{\infty}\frac{{f}_{\mathrm{iso}}(\mathrm{\Psi}(u))\phantom{\rule{0.166667em}{0ex}}{g}_{\mathrm{iso}}(\mathrm{\Psi}(u))\phantom{\rule{0.166667em}{0ex}}M(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{u}^{2}}=M.}\end{array}$$(53)
Similarly, we have
$$\begin{array}{c}\hfill {\displaystyle {\int}_{0}^{{\mathrm{\Psi}}_{0}}{\mathcal{N}}_{\mathrm{om}}(Q)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}Q=G{\int}_{0}^{\infty}\frac{{f}_{\mathrm{om}}(\mathrm{\Psi}(r))\phantom{\rule{0.166667em}{0ex}}{g}_{\mathrm{om}}(\mathrm{\Psi}(u))\phantom{\rule{0.166667em}{0ex}}M(u)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}u}{{u}^{2}}=M.}\end{array}$$(54)
All models currently in the SpheCow code have successfully passed these tests (for different parameters for those models that depend on different parameters). We strongly recommend any user who adds a new model to the SpheCow code, something we strongly encourage, to perform these basic tests as well.
5. Sigmoid models
5.1. Density sigmoid models
As an application and a demonstration of the power of the SpheCow code, we develop a number of new families of spherical models. Many models, both for galaxies and dark matter haloes, are characterised by a density profile with a powerlaw behaviour at small and large radii, that is
$$\begin{array}{cc}& \rho (r)\propto {r}^{\gamma}\phantom{\rule{2em}{0ex}}\mathrm{for}\phantom{\rule{0.277778em}{0ex}}r\ll {r}_{\mathrm{b}},\hfill \end{array}$$(55a)
$$\begin{array}{cc}& \rho (r)\propto {r}^{\beta}\phantom{\rule{2em}{0ex}}\mathrm{for}\phantom{\rule{0.277778em}{0ex}}r\gg {r}_{\mathrm{b}}.\hfill \end{array}$$(55b)
with r = r_{b} some break radius. An equivalent condition is that the logarithmic density slope γ(r) behaves as
$$\begin{array}{cc}& \gamma (r)\approx \gamma \phantom{\rule{2em}{0ex}}\mathrm{for}\phantom{\rule{0.277778em}{0ex}}r\ll {r}_{\mathrm{b}},\hfill \end{array}$$(56a)
$$\begin{array}{cc}& \gamma (r)\approx \beta \phantom{\rule{2em}{0ex}}\mathrm{for}\phantom{\rule{0.277778em}{0ex}}r\gg {r}_{\mathrm{b}}.\hfill \end{array}$$(56b)
Furthermore, it is desirable that the logarithmic density slope changes smoothly and monotonically between the asymptotic values γ and β. Almost all of the models in the first part of the list in Table 1 satisfy these criteria. A general and flexible model that was proposed with exactly these criteria is the Zhao or double powerlaw model, presented by Zhao (1996). This model is used extensively to model dark matter haloes (e.g., Hague & Wilkinson 2013, 2014, 2015; Di Cintio et al. 2014; Allaert et al. 2017; Dekel et al. 2017; Freundlich et al. 2020a,b; Hayashi et al. 2020).
The family of Zhao models is, however, not the only possible family of models with the characteristic behaviour (56a) and (56b). We can generate various new families of models with this behaviour using the concept of sigmoid functions. Sigmoid functions, generally denoted as 𝒮(x), are monotonically increasing functions that map the entire real domain onto a finite range, which is usually taken to be the unit interval [0, 1]. Moreover, sigmoid functions have a single inflection point, usually taken at x = 0, such that 𝒮(x) is convex for x < 0 and concave for x > 0. Sigmoid functions play an important role in the theory of population dynamics in a wide variety of scientific disciplines (e.g., Richards 1959; Tsoularis 2002; Banks 2013; Fornalski et al. 2020). Sigmoid function are also commonly used in artificial intelligence as activation functions in neural networks (Hayou et al. 2019; Hurbans 2020). Commonly used sigmoid functions include the logistic function, the arctangent function, and the Gompertz function; a number of possible options are listed in Table 2.
Some of the most commonly used sigmoid functions.
Now consider any sigmoid function 𝒮(x) and set
$$\begin{array}{c}\hfill \gamma (r)=\gamma +(\beta \gamma )\phantom{\rule{0.166667em}{0ex}}\mathcal{S}(\alpha ln\left(\frac{r}{{r}_{\mathrm{b}}}\right))\xb7\end{array}$$(57)
Interpreting this expression as the logarithmic density slope of a spherical model, we can find the density profile as
$$\begin{array}{c}\hfill \rho (r)={\rho}_{\mathrm{c}}{\left(\frac{r}{{r}_{\mathrm{b}}}\right)}^{\gamma}exp[\frac{\beta \gamma}{\alpha}\phantom{\rule{0.166667em}{0ex}}{\displaystyle {\int}_{\infty}^{\alpha ln(r/{r}_{\mathrm{b}})}}\mathcal{S}(x)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}x],\end{array}$$(58)
with ρ_{c} an arbitrary constant. Due to the properties of the sigmoid function, we immediately know that the model with this density profile behaves exactly as expressions ((55a) and (55b)). As we can apply the strategy above for any sigmoid function, we can easily generate various new classes of spherical models with this required asymptotic behaviour. As long as the integral in Eq. (58) can be evaluated analytically, this results in an analytical density profile.
The obvious first option is to consider the logistic function, one of the most popular sigmoid functions,
$$\begin{array}{c}\hfill \mathcal{S}(x)=\frac{1}{1+{\mathrm{e}}^{x}}\xb7\end{array}$$(59)
This logistic function was originally introduced to describe the evolution of the Belgian population (Verhulst 1845), and is sometimes referred to in the literature as the sigmoid function. Combining Eqs. (58) and (59) leads to the following expressions for the logarithmic density slope,
$$\begin{array}{c}\hfill \gamma (r)=\frac{\gamma +\beta \phantom{\rule{0.166667em}{0ex}}{(r/{r}_{\mathrm{b}})}^{\alpha}}{1+{(r/{r}_{\mathrm{b}})}^{\alpha}},\end{array}$$(60)
and the density profile,
$$\begin{array}{c}\hfill \rho (r)={\rho}_{\mathrm{c}}{\left(\frac{r}{{r}_{\mathrm{b}}}\right)}^{\gamma}{[1+{\left(\frac{r}{{r}_{\mathrm{b}}}\right)}^{\alpha}]}^{\frac{\beta \gamma}{\alpha}}\xb7\end{array}$$(61)
This is nothing but the general expression of the density profile of the Zhao model.
5.2. Algebraic sigmoid density models
As an alternative to the logistic function, consider the algebraic sigmoid function,
$$\begin{array}{c}\hfill \mathcal{S}(x)=\frac{1}{2}(1+\frac{x}{\sqrt{1+{x}^{2}}})\xb7\end{array}$$(62)
This choice leads to a new family of models with logarithmic density slope
$$\begin{array}{c}\hfill \gamma (r)=\frac{\beta +\gamma}{2}+\frac{\beta \gamma}{2}\frac{\alpha ln(r/{r}_{\mathrm{b}})}{\sqrt{1+{\alpha}^{2}{ln}^{2}(r/{r}_{\mathrm{b}})}},\end{array}$$(63)
and density profile
$$\begin{array}{c}\hfill \rho (r)={\rho}_{\mathrm{c}}{\left(\frac{r}{{r}_{\mathrm{b}}}\right)}^{\frac{\beta +\gamma}{2}}exp[\frac{\beta \gamma}{2\alpha}\sqrt{1+{\alpha}^{2}{ln}^{2}\left(\frac{r}{{r}_{\mathrm{b}}}\right)}]\xb7\end{array}$$(64)
We have added this family of models to the SpheCow code as the SigmoidDensityModel class. The only member functions we had to implement were the density and its first and second derivatives. All other photometric and dynamical properties of this family of models can be evaluated without any further ado.
In Fig. 4 we compare the dynamical properties of a subset of the algebraic sigmoid models defined by the density profile (64) and the Zhao models. The different panels represent a wide variety of profiles, all of which are automatically calculated by SpheCow. The thick lines in this figure represent the models from the new family of algebraic sigmoid models. For all models, we have fixed M_{tot} = r_{b} = 1, α = 1, and β = 4, and we have considered different values of the inner slope γ. The thin lines correspond to Zhao models with exactly the same parameters. Actually, the subfamily of Zhao models with (α, β) = (1, 4) is the wellknown family of γmodels (Dehnen 1993; Tremaine et al. 1994).
Fig. 4. Compilation of photometric and dynamical properties for two families of sigmoid models. The thick lines correspond to the new family of algebraic sigmoid models defined by the density profile (64). All models have α = 1 and β = 4, and the different colours correspond to different values of the inner density slope γ, as indicated in the top left panel. The thin lines correspond to Zhao models with exactly the same parameters. 
It is clear that corresponding models from the two families have the same asymptotic behaviour in all quantities, as expected as they have the same asymptotic density profile by construction. The properties of the models of both families display a significant variety at small radii, depending on the parameter γ that characterises the inner density slope. For γ = 0 the models have a finite central density, surface density, potential, and isotropic velocity dispersion. For 0 < γ < 1 both families of models show a shallow density cusp, but still a finite central surface density and finite potential well. The isotropic dispersion profile now tends to zero at small radii. Models with 1 < γ < 2 show a similar behaviour, except for their surface density profile which diverges in the centre. Models with γ > 2 have a strong density and surface density cusp, an infinitely deep potential well, and diverging circular velocity and isotropic dispersion profiles.
While the asymptotic behaviour of the corresponding Zhao and algebraic sigmoid models is the same, there are some minor differences in the details. For a fixed set of parameters, the algebraic sigmoid models are characterised by a steeper transition between the inner and outer profiles, as shown in the top left and top middle panels. This difference propagates to all other properties as well. Algebraic sigmoid models with small values of γ have a deeper potential well than the corresponding γmodels, and the opposite is true for large values of γ. Looking at the isotropic distribution function and differential energy distribution, the transition between the low and high binding energy parts is much sharper for the algebraic sigmoid models. As a result, the Zhao models have a larger number of stars with low binding energies, whereas the algebraic sigmoid models have more stars around the knee of the differential energy distribution. The specific choice of the sigmoid function does matter for the details of the dynamical structure.
Focusing on the panels on the third row of Fig. 4 we see that all algebraic sigmoid models shown have an isotropic distribution function that is a positive and monotonically increasing function of binding energy. This implies that these models are selfconsistent and physical, and stable against radial and nonradial perturbations (Antonov 1962; Doremus et al. 1971; Binney & Tremaine 2008). We do note, however, that this conclusion cannot be generalised for all members of the family of algebraic sigmoid models, in a similar way as for the family of Zhao models (Baes & Camps 2021). If the parameter α that determines the sharpness of the transition between the inner and outer profiles grows larger, the distribution function will first develop a kink around ℰ = Ψ(r_{b}). When α increases even more, the distribution function will become negative, making the models with an isotropic orbital structure unphysical. In the limit α → ∞, the models reduce to the broken powerlaw (BPL) models discussed by Du et al. (2020) and Baes & Camps (2021). These models are characterised by the simple density profile
$$\begin{array}{c}\hfill \rho (r)=\{\begin{array}{cc}{\rho}_{\mathrm{c}}{\left({\displaystyle \frac{r}{{r}_{\mathrm{b}}}}\right)}^{\gamma}\hfill & \phantom{\rule{2em}{0ex}}\mathrm{if}\phantom{\rule{0.277778em}{0ex}}r\le {r}_{\mathrm{b}},\hfill \\ {\rho}_{\mathrm{c}}{\left({\displaystyle \frac{r}{{r}_{\mathrm{b}}}}\right)}^{\beta}\hfill & \phantom{\rule{2em}{0ex}}\mathrm{if}\phantom{\rule{0.277778em}{0ex}}r\ge {r}_{\mathrm{b}}.\hfill \end{array}\end{array}$$(65)
This density profile is indeed what we obtain if we take the limit α → ∞ in expression (64). The BPL models can also be seen as sigmoid models with the Heaviside step function
$$\begin{array}{c}\hfill \mathcal{S}(x)=\mathrm{\Theta}(x)\equiv \{\begin{array}{cc}0\hfill & \phantom{\rule{2em}{0ex}}\mathrm{if}\phantom{\rule{0.277778em}{0ex}}x<0,\hfill \\ {\textstyle \frac{1}{2}}\hfill & \phantom{\rule{2em}{0ex}}\mathrm{if}\phantom{\rule{0.277778em}{0ex}}x=0,\hfill \\ 1\hfill & \phantom{\rule{2em}{0ex}}\mathrm{if}\phantom{\rule{0.277778em}{0ex}}x>0,\hfill \end{array}\end{array}$$(66)
as their defining (degenerate) sigmoid function.
Finally, it is interesting to compare the panels on the last two rows of Fig. 4. These rows show similar quantities, but the third row corresponds to an isotropic orbital structure, while the bottom row shows the same properties for an OsipkovMerritt orbital structure with r_{a} = 0.6. At large ℰ or Q, the isotropic and OsipkovMerritt distribution functions for any given set of parameters show a similar behaviour. This is not so surprising, as large binding energies correspond to small radii, and the OsipkovMerritt models are isotropic in the central regions. The behaviour at small ℰ or Q, corresponding to large radii, is very different, with a different slope for both the distribution function and the differential energy distribution. The most interesting difference, however, relates to the behaviour at intermediate binding energies. The anisotropy generates a kink in the distribution function and the differential energy distribution, especially for models with small values of γ. For the algebraic sigmoid model with γ = 0, this kink is so strong that the distribution function and the differential energy distribution become negative: this model cannot be supported by an OsipkovMerritt orbital structure with r_{a} = 0.6. We note that the corresponding γmodel, that is the one with γ = 0 and r_{a} = 0.6, is also affected by the anisotropy, but the distribution function remains positive over the entire domain. This is in agreement with the results of Carollo et al. (1995), who found that the γ = 0 model can be supported by an OsipkovMerritt orbital structure as long as r_{a} > 0.44.
5.3. Surface density sigmoid models
One of the useful characteristics of the SpheCow code is that it is essentially equally simple to generate models by means of a density profile or a surface density profile. Actually, for every model based on a certain density profile, we can immediately generate a counterpart with a surface brightness profile with a similar functional form, and vice versa. One wellknown example of such a couple of twin models consists of the Einasto and Sérsic models. We note that the families of Einasto and Sérsic models have no connection to each other apart from a functional similarity between the density profile of the former and the surface density profile of the latter. In particular, Einasto models do not have a Sérsic surface density profile, and vice versa (Dhar & Williams 2010; RetanaMontenegro et al. 2012).
In the same sense, it is also straightforward to generate new families of models in which the logarithmic slope of the surface density profile has the shape of a sigmoid function. For any sigmoid function 𝒮(x), we set
$$\begin{array}{c}\hfill {\gamma}_{\mathrm{p}}(R)=\gamma +(\beta \gamma )\phantom{\rule{0.166667em}{0ex}}\mathcal{S}(\alpha ln\left(\frac{R}{{R}_{\mathrm{b}}}\right)),\end{array}$$(67)
resulting in a surface density profile
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)={\mathrm{\Sigma}}_{\mathrm{c}}{\left(\frac{R}{{R}_{\mathrm{b}}}\right)}^{\gamma}exp[\frac{\beta \gamma}{\alpha}\phantom{\rule{0.166667em}{0ex}}{\displaystyle {\int}_{\infty}^{\alpha ln(R/{R}_{\mathrm{b}})}}\mathcal{S}(x)\phantom{\rule{0.166667em}{0ex}}\mathrm{d}x],\end{array}$$(68)
with a powerlaw behaviour at both small and large projected radii. If we take the logistic function as the standard sigmoid function, this results in the surface density profile,
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)={\mathrm{\Sigma}}_{\mathrm{c}}{\left(\frac{R}{{R}_{\mathrm{b}}}\right)}^{\gamma}{[1+{\left(\frac{R}{{R}_{\mathrm{b}}}\right)}^{\alpha}]}^{\frac{\beta \gamma}{\alpha}}\xb7\end{array}$$(69)
This surface density profile defines the family of Nuker models, frequently used to model the nuclear regions of galaxies (e.g., Lauer et al. 1995, 2005, 2007; Byun et al. 1996; Quillen et al. 2000; Rest et al. 2001; Laine et al. 2003; de Ruiter et al. 2005; Durret et al. 2019). Similar to the Einasto–Sérsic couple of models, the Zhao and Nuker models have no connection to each other except the similarity between the density profile (61) of the former and the surface density profile (69) of the latter (see also Zhao 1997).
Any other sigmoid function is possible as well, and will lead to a different family of models with slightly different photometric and dynamical properties. If we use the algebraic sigmoid function (62), we find
$$\begin{array}{c}\hfill \mathrm{\Sigma}(R)={\mathrm{\Sigma}}_{\mathrm{c}}{\left(\frac{R}{{R}_{\mathrm{b}}}\right)}^{\frac{\beta +\gamma}{2}}exp[\frac{\beta \gamma}{2\alpha}\sqrt{1+{\alpha}^{2}{ln}^{2}\left(\frac{R}{{R}_{\mathrm{b}}}\right)}]\xb7\end{array}$$(70)
We have implemented the family of models defined by this surface density profile as the SigmoidSurfaceDensityModel class in the SpheCow code. This required just a few minor adaptations from the implementation of the SigmoidDensityModel class: the main adaptation is the required implementation of the third derivative of the surface density profile.
We do note provide an exhaustive overview or description of the dynamical properties of this new class of spherical models. It is not surprising that this general family of models shares many properties with the family of Nuker models, which has the same asymptotic behaviour. Just as in the previous subsection, there are minor differences in the surface density profile between corresponding models from both families, which propagate to all other properties. For a more detailed discussion of the Nuker models, we refer to Baes (2020), where we used a combination of analytical tools and a preliminary version of SpheCow to investigate the dynamical structure.
6. Discussion and summary
The goal of this work was to develop and describe a new software tool that can be used to set up a spherical dynamical model with either an arbitrary analytical density profile or an arbitrary analytical surface density profile as starting point. The ambition was that this code should be capable of automatically calculating the basic intrinsic and onsky properties for any such model, as well as dynamical properties assuming either an isotropic of an OsipkovMerritt type anisotropic orbital structure. With such a code, it should be easy to replace the standard but not necessarily realistic analytical models for galaxies or dark matter haloes that are often used as starting points for theoretical or numerical investigations by more optimal alternatives.
The result of this work is SpheCow, a lightweight and flexible software code that has exactly the characteristics as described above. We have gathered all the relevant equations, and through some integral order rearrangements, derived some new expressions that make these calculations more simple. We have described our numerical integration strategy, which is based on a straightforward but very efficient GaussLegendre scheme. We have extensively validated SpheCow using a combination of comparisons to analytical calculations, and the calculation of inverse formulae. The code is publicly available as a set of C++ routines and as a Python module.
SpheCow contains readily usable implementations for many standard models, including the Plummer, Hernquist, NFW, Einasto, Sérsic, and Nuker models. The main strength of the code is, however, that it is designed to be easily extendable, in the sense that new models, defined by either an analytical density profile or an analytical surface density profile, can be added in a straightforward way. We demonstrate this by adding two new families of models: one with its logarithmic density slope and the other with its logarithmic surface density slope described by an algebraic sigmoid function. We do not investigate the properties of these models in full detail, but we show how straightforward it is to implement new models and how easy it is to subsequently explore their dynamical structure.
Apart from adding new models, the SpheCow code can be expanded in several other ways. One limitation of the current implementation is that only two orbital structures, isotropic and OsipkovMerritt, are available. Other options are possible and probably desirable. In particular, neither the isotropic nor the OsipkovMerritt case provides an accurate representation of the orbital structure of dark matter haloes as obtained from simulations (Cole & Lacey 1996; Colín et al. 2000; Mamon & Łokas 2005; Hansen & Moore 2006). Several other representations for the anisotropy profile have been proposed in the literature, which provide a more suitable fit to the results of Nbody simulations (e.g., Carlberg et al. 1997; Diemand et al. 2004; Mamon & Łokas 2005; Tiret et al. 2007; Mamon & Boué 2010). Unfortunately, in the general case, the calculation of the distribution function for such general anisotropy profiles is cumbersome and illconditioned (Dejonghe 1986). There are, however, a number of special cases for which the inversion can be performed in a similar way as for the isotropic and OsipkovMerritt models. The most obvious case are models with a constant anisotropy (Dejonghe 1986; An & Evans 2006b), and in particular the special cases of models populated only with radial orbits (Richstone & Tremaine 1984), or models with a constant radial anisotropy $\beta ={\textstyle \frac{1}{2}}$ (Evans & An 2006). Other, more complex orbital structures for which the inversion can be performed (numerically) include the models by Cuddeford (1991) and Cuddeford & Louis (1995). We plan an implementation in SpheCow of dynamical models with some of these orbital structures as future work, and invite third parties to contribute to this effort.
This is not the only possible way in which SpheCow can easily be expanded. All models implemented at this stage are selfconsistent selfgravitating models, that is, the density and gravitational potential are linked by Poisson’s equation. It is also possible to drop this restriction and to include models consisting of two or more components. Such models can be useful, for example, to study the effect of a central supermassive black hole and/or a dark matter halo on the stellar dynamical structure of a galaxy (e.g., Tremaine et al. 1994; Ciotti 1996; Ciotti et al. 1996, 2019; Baes & Dejonghe 2004; Baes et al. 2005; Ciotti & Ziaee Lorzad 2018).
We hope that this paper will inspire colleagues to use SpheCow, both to investigate the properties of existing models in detail and to explore models that have so far received less attention than they deserve.
Acknowledgments
M.B. and B.V. acknowledge financial support from the Belgian Science Policy Office (BELSPO) through the PRODEX project “SPICASKIRT: A farinfrared photometry and polarimetry simulation toolbox in preparation of the SPICA mission” (C4000128500). The authors thank the anonymous referee for a prompt and constructive referee report.
References
 Agnello, A., Evans, N. W., & Romanowsky, A. J. 2014, MNRAS, 442, 3284 [NASA ADS] [CrossRef] [Google Scholar]
 Alcock, C., Allsman, R. A., Axelrod, T. S., et al. 1995, ApJ, 449, 28 [CrossRef] [Google Scholar]
 Allaert, F., Gentile, G., & Baes, M. 2017, A&A, 605, A55 [CrossRef] [EDP Sciences] [Google Scholar]
 An, J. H., & Evans, N. W. 2006a, AJ, 131, 782 [NASA ADS] [CrossRef] [Google Scholar]
 An, J. H., & Evans, N. W. 2006b, ApJ, 642, 752 [NASA ADS] [CrossRef] [Google Scholar]
 Antonov, V. A. 1962, Solution of the Problem of Stability of Stellar System (Leningrad: Vestnik Leningradskogo Universiteta) [Google Scholar]
 Baes, M. 2020, A&A, 634, A109 [CrossRef] [EDP Sciences] [Google Scholar]
 Baes, M., & Camps, P. 2021, MNRAS, 503, 2955 [CrossRef] [Google Scholar]
 Baes, M., & Ciotti, L. 2019a, A&A, 630, A113 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Baes, M., & Ciotti, L. 2019b, A&A, 626, A110 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Baes, M., & Dejonghe, H. 2002, A&A, 393, 485 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Baes, M., & Dejonghe, H. 2004, MNRAS, 351, 18 [NASA ADS] [CrossRef] [Google Scholar]
 Baes, M., & Gentile, G. 2011, A&A, 525, A136 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Baes, M., & Van Hese, E. 2007, A&A, 471, 419 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Baes, M., & Van Hese, E. 2011, A&A, 534, A69 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Baes, M., Dejonghe, H., & Buyle, P. 2005, A&A, 432, 411 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Banks, R. 2013, Growth and Diffusion Phenomena: Mathematical Frameworks and Applications, Texts in Applied Mathematics (Berlin, Heidelberg: Springer) [Google Scholar]
 Binney, J. 1982, MNRAS, 200, 951 [NASA ADS] [CrossRef] [Google Scholar]
 Binney, J., & Mamon, G. A. 1982, MNRAS, 200, 361 [NASA ADS] [CrossRef] [Google Scholar]
 Binney, J., & Tremaine, S. 2008, Galactic Dynamics, 2nd edn. (Princeton: Princeton University Press) [Google Scholar]
 Bovy, J. 2015, ApJS, 216, 29 [Google Scholar]
 Burkert, A. 1995, ApJ, 447, L25 [NASA ADS] [CrossRef] [Google Scholar]
 Butsky, I., Macciò, A. V., Dutton, A. A., et al. 2016, MNRAS, 462, 663 [NASA ADS] [CrossRef] [Google Scholar]
 Byun, Y. I., Grillmair, C. J., Faber, S. M., et al. 1996, AJ, 111, 1889 [NASA ADS] [CrossRef] [Google Scholar]
 Cardone, V. F., Piedipalumbo, E., & Tortora, C. 2005, MNRAS, 358, 1325 [NASA ADS] [CrossRef] [Google Scholar]
 Carlberg, R. G., Yee, H. K. C., Ellingson, E., et al. 1997, ApJ, 485, L13 [NASA ADS] [CrossRef] [Google Scholar]
 Carollo, C. M., de Zeeuw, P. T., & van der Marel, R. P. 1995, MNRAS, 276, 1131 [NASA ADS] [CrossRef] [Google Scholar]
 Ciotti, L. 1991, A&A, 249, 99 [NASA ADS] [Google Scholar]
 Ciotti, L. 1996, ApJ, 471, 68 [NASA ADS] [CrossRef] [Google Scholar]
 Ciotti, L., & Ziaee Lorzad, A. 2018, MNRAS, 473, 5476 [NASA ADS] [CrossRef] [Google Scholar]
 Ciotti, L., Lanzoni, B., & Renzini, A. 1996, MNRAS, 282, 1 [Google Scholar]
 Ciotti, L., Mancino, A., & Pellegrini, S. 2019, MNRAS, 490, 2656 [NASA ADS] [CrossRef] [Google Scholar]
 Cole, S., & Lacey, C. 1996, MNRAS, 281, 716 [CrossRef] [Google Scholar]
 Colín, P., Klypin, A. A., & Kravtsov, A. V. 2000, ApJ, 539, 561 [NASA ADS] [CrossRef] [Google Scholar]
 Cuddeford, P. 1991, MNRAS, 253, 414 [NASA ADS] [Google Scholar]
 Cuddeford, P., & Louis, P. 1995, MNRAS, 275, 1017 [NASA ADS] [CrossRef] [Google Scholar]
 de Ruiter, H. R., Parma, P., Capetti, A., et al. 2005, A&A, 439, 487 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 de Vaucouleurs, G. 1948, Ann. Astrophys., 11, 247 [Google Scholar]
 de Zeeuw, T. 1985, MNRAS, 216, 273 [NASA ADS] [CrossRef] [Google Scholar]
 Dehnen, W. 1993, MNRAS, 265, 250 [NASA ADS] [CrossRef] [Google Scholar]
 Dejonghe, H. 1986, Phys. Rep., 133, 217 [NASA ADS] [CrossRef] [Google Scholar]
 Dejonghe, H. 1987, MNRAS, 224, 13 [NASA ADS] [CrossRef] [Google Scholar]
 Dekel, A., Ishai, G., Dutton, A. A., & Maccio, A. V. 2017, MNRAS, 468, 1005 [NASA ADS] [CrossRef] [Google Scholar]
 Dhar, B. K., & Williams, L. L. R. 2010, MNRAS, 405, 340 [NASA ADS] [Google Scholar]
 Di Cintio, A., Brook, C. B., Dutton, A. A., et al. 2014, MNRAS, 441, 2986 [Google Scholar]
 Diemand, J., Moore, B., & Stadel, J. 2004, MNRAS, 352, 535 [NASA ADS] [CrossRef] [Google Scholar]
 Doremus, J.P., Feix, M. R., & Baumann, G. 1971, Phys. Rev. Lett., 26, 725 [NASA ADS] [CrossRef] [Google Scholar]
 Du, W., Zhao, G.B., Fan, Z., et al. 2020, ApJ, 892, 62 [CrossRef] [Google Scholar]
 Durret, F., Tarricq, Y., Márquez, I., Ashkar, H., & Adami, C. 2019, A&A, 622, A78 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Eddington, A. S. 1916, MNRAS, 76, 572 [NASA ADS] [CrossRef] [Google Scholar]
 Einasto, J. 1965, Trudy Astrofizicheskogo Instituta AlmaAta, 5, 87 [NASA ADS] [Google Scholar]
 Evans, N. W., & An, J. 2005, MNRAS, 360, 492 [NASA ADS] [CrossRef] [Google Scholar]
 Evans, N. W., & An, J. H. 2006, Phys. Rev. D, 73, 023524 [NASA ADS] [CrossRef] [Google Scholar]
 Evans, N. W., & Williams, A. A. 2014, MNRAS, 443, 791 [CrossRef] [Google Scholar]
 Evans, N. W., An, J., Bowden, A., & Williams, A. A. 2015, MNRAS, 450, 846 [CrossRef] [Google Scholar]
 Evans, N. W., O’Hare, C. A. J., & McCabe, C. 2019, Phys. Rev. D, 99, 023012 [CrossRef] [Google Scholar]
 Fielder, C. E., Mao, Y.Y., Zentner, A. R., et al. 2020, MNRAS, 499, 2426 [CrossRef] [Google Scholar]
 Fornalski, K. W., Reszczyńska, J., Dobrzyński, L., Wysocki, P., & Janiak, M. K. 2020, Acta Phys. Pol. A, 138, 854 [CrossRef] [Google Scholar]
 Freundlich, J., Dekel, A., Jiang, F., et al. 2020a, MNRAS, 491, 4523 [CrossRef] [Google Scholar]
 Freundlich, J., Jiang, F., Dekel, A., et al. 2020b, MNRAS, 499, 2912 [CrossRef] [Google Scholar]
 Graham, A. W., & Driver, S. P. 2005, PASA, 22, 118 [NASA ADS] [CrossRef] [Google Scholar]
 Hague, P. R., & Wilkinson, M. I. 2013, MNRAS, 433, 2314 [NASA ADS] [CrossRef] [Google Scholar]
 Hague, P. R., & Wilkinson, M. I. 2014, MNRAS, 443, 3712 [NASA ADS] [CrossRef] [Google Scholar]
 Hague, P. R., & Wilkinson, M. I. 2015, ApJ, 800, 15 [NASA ADS] [CrossRef] [Google Scholar]
 Hansen, S. H., & Moore, B. 2006, New Astron., 11, 333 [NASA ADS] [CrossRef] [Google Scholar]
 Hayashi, K., Chiba, M., & Ishiyama, T. 2020, ApJ, 904, 45 [CrossRef] [Google Scholar]
 Hayou, S., Doucet, A., & Rousseau, J. 2019, in Proceedings of the 36th International Conference on Machine Learning, eds. K. Chaudhuri, & R. Salakhutdinov, Proc. Mach. Learn. Res. (PMLR), 97, 2672 [Google Scholar]
 Hénon, M. 1959, Ann. Astrophys., 22, 126 [Google Scholar]
 Hénon, M. 1960, Ann. Astrophys., 23, 474 [NASA ADS] [Google Scholar]
 Hernquist, L. 1990, ApJ, 356, 359 [Google Scholar]
 Hurbans, R. 2020, Grokking Artificial Intelligence Algorithms (Shelter Island: Manning Publications) [Google Scholar]
 Jaffe, W. 1983, MNRAS, 202, 995 [NASA ADS] [Google Scholar]
 King, I. R. 1966, AJ, 71, 64 [Google Scholar]
 Laine, S., van der Marel, R. P., Lauer, T. R., et al. 2003, AJ, 125, 478 [Google Scholar]
 Lauer, T. R., Ajhar, E. A., Byun, Y. I., et al. 1995, AJ, 110, 2622 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Lauer, T. R., Faber, S. M., Gebhardt, K., et al. 2005, AJ, 129, 2138 [NASA ADS] [CrossRef] [Google Scholar]
 Lauer, T. R., Gebhardt, K., Faber, S. M., et al. 2007, ApJ, 664, 226 [Google Scholar]
 Lemze, D., Wagner, R., Rephaeli, Y., et al. 2012, ApJ, 752, 141 [NASA ADS] [CrossRef] [Google Scholar]
 Łokas, E. L., & Mamon, G. A. 2001, MNRAS, 321, 155 [NASA ADS] [CrossRef] [Google Scholar]
 Ludlow, A. D., Navarro, J. F., White, S. D. M., et al. 2011, MNRAS, 415, 3895 [NASA ADS] [CrossRef] [Google Scholar]
 Mamon, G. A., & Boué, G. 2010, MNRAS, 401, 2433 [NASA ADS] [CrossRef] [Google Scholar]
 Mamon, G. A., & Łokas, E. L. 2005, MNRAS, 363, 705 [Google Scholar]
 Mamon, G. A., Biviano, A., & Murante, G. 2010, A&A, 520, A30 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 May, A., & Binney, J. 1986, MNRAS, 221, 13P [CrossRef] [Google Scholar]
 Mazure, A., & Capelato, H. V. 2002, A&A, 383, 384 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Merritt, D. 1985a, AJ, 90, 1027 [NASA ADS] [CrossRef] [Google Scholar]
 Merritt, D. 1985b, MNRAS, 214, 25P [NASA ADS] [CrossRef] [Google Scholar]
 Michie, R. W. 1963, MNRAS, 125, 127 [NASA ADS] [CrossRef] [Google Scholar]
 Michie, R. W., & Bodenheimer, P. H. 1963, MNRAS, 126, 269 [NASA ADS] [CrossRef] [Google Scholar]
 Navarro, J. F., Frenk, C. S., & White, S. D. M. 1997, ApJ, 490, 493 [NASA ADS] [CrossRef] [Google Scholar]
 Neureiter, B., Thomas, J., Saglia, R., et al. 2021, MNRAS, 500, 1437 [Google Scholar]
 Osipkov, L. P. 1979, Pisma v Astronomicheskii Zhurnal, 5, 77 [Google Scholar]
 Peñarrubia, J., Pontzen, A., Walker, M. G., & Koposov, S. E. 2012, ApJ, 759, L42 [NASA ADS] [CrossRef] [Google Scholar]
 Plummer, H. C. 1911, MNRAS, 71, 460 [CrossRef] [Google Scholar]
 Prugniel, P., & Simien, F. 1997, A&A, 321, 111 [NASA ADS] [Google Scholar]
 Quillen, A. C., Bower, G. A., & Stritzinger, M. 2000, ApJS, 128, 85 [NASA ADS] [CrossRef] [Google Scholar]
 Rest, A., van den Bosch, F. C., Jaffe, W., et al. 2001, AJ, 121, 2431 [NASA ADS] [CrossRef] [Google Scholar]
 RetanaMontenegro, E., van Hese, E., Gentile, G., Baes, M., & FrutosAlfaro, F. 2012, A&A, 540, A70 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Richards, F. J. 1959, J. Exp. Bot., 10, 290 [CrossRef] [Google Scholar]
 Richstone, D. O., & Tremaine, S. 1984, ApJ, 286, 27 [NASA ADS] [CrossRef] [Google Scholar]
 Salucci, P., & Burkert, A. 2000, ApJ, 537, L9 [NASA ADS] [CrossRef] [Google Scholar]
 Sérsic, J. L. 1968, Atlas de Galaxias Australes (Cordoba, Argentina: Observatorio Astronomico) [Google Scholar]
 Taylor, J. E., & Navarro, J. F. 2001, ApJ, 563, 483 [NASA ADS] [CrossRef] [Google Scholar]
 Tiret, O., Combes, F., Angus, G. W., Famaey, B., & Zhao, H. S. 2007, A&A, 476, L1 [NASA ADS] [CrossRef] [EDP Sciences] [Google Scholar]
 Tremaine, S., Richstone, D. O., Byun, Y.I., et al. 1994, AJ, 107, 634 [NASA ADS] [CrossRef] [Google Scholar]
 Tsoularis, A. 2002, Math. Biosci., 179, 21 [CrossRef] [MathSciNet] [PubMed] [Google Scholar]
 Vasiliev, E. 2019, MNRAS, 482, 1525 [NASA ADS] [CrossRef] [Google Scholar]
 Vasiliev, E., & Valluri, M. 2020, ApJ, 889, 39 [CrossRef] [Google Scholar]
 Veltmann, U. I. K. 1979, AZh, 56, 976 [Google Scholar]
 Verhulst, P.F. 1845, Nouveaux Mémoires de l’Académie Royale des Sciences et BellesLettres de Bruxelles, 18, 1 [Google Scholar]
 Wojtak, R., Gottlöber, S., & Klypin, A. 2013, MNRAS, 434, 1576 [NASA ADS] [CrossRef] [Google Scholar]
 Zhao, H. 1996, MNRAS, 278, 488 [Google Scholar]
 Zhao, H. 1997, MNRAS, 287, 525 [NASA ADS] [CrossRef] [Google Scholar]
All Tables
All Figures
Fig. 1. Absolute value of the relative error of the density, surface density, potential, velocity dispersion, projected dispersion, and distribution function of the Plummer model (c represents the scale radius of the Plummer model). See text in Sect. 4.1 for the meaning of the different curves in each panel. 

In the text 
Fig. 2. Average relative error on the calculation of the surface density, potential, and distribution function for the Plummer model as a function of the number of integration points in the GaussLegendre integration scheme. 

In the text 
Fig. 3. Absolute value of the relative error of the density of the Vaucouleurs model, as calculated by SpheCow. The cyan line corresponds to the calculation using the standard deprojection Eq. (36), the purple line to the integration of the isotropic distribution function over velocity space (48), and the orange line to the integration of the OsipkovMerritt distribution function over velocity space (49). 

In the text 
Fig. 4. Compilation of photometric and dynamical properties for two families of sigmoid models. The thick lines correspond to the new family of algebraic sigmoid models defined by the density profile (64). All models have α = 1 and β = 4, and the different colours correspond to different values of the inner density slope γ, as indicated in the top left panel. The thin lines correspond to Zhao models with exactly the same parameters. 

In the text 
Current usage metrics show cumulative count of Article Views (fulltext article views including HTML views, PDF and ePub downloads, according to the available data) and Abstracts Views on Vision4Press platform.
Data correspond to usage on the plateform after 2015. The current usage metrics is available 4896 hours after online publication and is updated daily on week days.
Initial download of the metrics may take a while.