# Number Density of Dark Matter Halos

Is there a way to calculate the expected number density of Dark Matter Halos above a given mass, in a certain redshift range, and in a certain area?

The function you're requesting — i.e. the number density $$N$$ of DM halos above a given mass $$M_\mathrm{h}$$ — is called the cumulative halo mass function (cHMF). It is obtained by integrating the halo mass function (HMF) from a given mass to infinity. The HMF, in turn, is thus the function that describes the (differential) number density of DM halos of a given mass.

In other words, $$\boxed{N(>\!\!M_\mathrm{h}) = \int_{M_\mathrm{h}}^\infty \!\!\!dM_\mathrm{h}'\, \frac{dN}{dM_\mathrm{h}'}.}$$

# Halo mass function

So, the problem is to determine the HMF, i.e. $$dN/dM_\mathrm{h}$$. This was first calculated, analytically, by Press & Schechter (1974) assuming spherical collapse of structures from an initial, smoothed density field. It may be written as $$\frac{dN}{dM_\mathrm{h}} = \frac{\rho_{\mathrm{m,0}}}{M_\mathrm{h}} \left| \frac{d\ln\sigma}{dM_\mathrm{h}} \right| f(\sigma),$$ where $$\rho_{\mathrm{m,0}}$$ is the present-day average mass density of the Universe, $$\sigma = \sigma(M_\mathrm{h},z)$$ is the rms fluctuations of the (smoothed) density field, and $$f(\sigma)$$ is the "multiplicity function" (note that because the number density decreases so fast with halo mass, for computational purposes often the HMF is expressed as $$dN/d \ln M_\mathrm{h}$$ rather than $$dN/dM_\mathrm{h}$$).

If you want, I can give you more details about how to calculate $$\sigma(M_\mathrm{h},z)$$ and $$f(\sigma)$$. You can also find details on this in sec. 2.1 of Laursen et al. (2018), but note that there's an error in Eq. 1. If you're happy with using a "black box", you can get both the HMF and cHMF for your favorite cosmological parameters using this online HMF calculator.

Only in the Press-Schechter formalism can an analytical form of $$f(\sigma)$$ be derived, and it was subsequently found that it over(under)predicts the collapsed fraction at the low-(high-)mass end (see e.g. Governato et al. 1999); in general one must obtain it by fitting halo abundances in cosmological $$N$$-body simulations.

# Defining a halo

This is what N. Steinle describes in his answer, but actually you don't need to assume a density profile of the halos. So, how do you count halos in a simulation? There are several ways, arguably the two most popular ones being the spherical overdensity (SO) and the friends-of-friends (FoF) method.

### Spherical overdensity

In the SO method, you first calculate the center of mass (CoM) of a clump of particles in the simulation, and then you calculate the average density $$\bar{\rho}$$ of particles in successively larger spheres centered on the CoM. As you increase the radius of the sphere, $$\bar{\rho}$$ drops because you include less and less dense regions. When the density has reached a certain factor $$\Delta$$ times the average density $$\rho_\mathrm{m}(z)$$ in the Universe you stop, and the total mass of all particles inside that sphere is then the halo mass. The overdensity factor $$\Delta$$ is usually chosen to be around 200, but other choices exist, e.g. 500 which then gives slightly smaller masses (because you stop counting earlier).

A variant of this method is using ellipsoids rather than spheres, allowing for more realistic results for elongated structures.

### Friends-of-friends

In the FoF method, you start at an overdensity and count all particles that are "linked" together, meaning they are within some chosen distance (the "linking length") of each other. This method may give more realistic results for very non-spherical structures, but also tends to include particles in filaments streaming into the galaxies, which perhaps shouldn't be considered a part of a galaxy.

The figure below (from Klypin et al. 2011) shows halos from the Bolshoi simulation identified with the two methods; SO (red points) and FoF (blue points), compared to an extension of the P-S HMF (solid black line) to allow for ellipsoidal structures (Sheth & Tormen (1999, 2002). At all masses, FoF halos are seen to be more massive than SO halos.

# Redshift range and area

Re-reading your question, I think maybe you're interested not in the number density, but in the absolute number in a volume spanned by a redshift range $$dz$$ and area $$dA$$. If that is the case, then you simply multiply your $$N(>\!\!M_\mathrm{h})$$ by the cosmological volume given by $$dz$$ and $$dA$$. Let me know if you also want to know how to calculate that.

Is there a way to calculate the expected number density of Dark Matter Halos above a given mass, in a certain redshift range, and in a certain area?

There are ways of counting mass distributions of dark matter halos. I'm not sure what you mean by "expected number density," perhaps you could elaborate if my answer is not what you wanted? Do you mean the number density of the background galaxies if one is using lensing data? That is a very different question.

As with all astrophyiscs, limitations on computational power are limits on "experimental" power, since we use simulations as our laboratories, and the modeling of Dark Matter Halos is no exception.

So, a standard technique is to run N-body simulations of a dark matter universe and try to see how everything arranges itself by fitting functional forms to local regions (hence the density of a halo out to a certain mass and radius). Thus, the density you get depends on the functional form you choose! The standard profile is the NFW profile which treats the dark matter halo spherically, but this profile has many limitations that one must be careful of, for instance it is only valid approximately out to the virial radius of the galaxy. But, nowadays there are numerous available profiles (each with its own peculiarities) that try to include ellipticity of the dark matter halo. It is an area of active research to compare these profiles and improve them further, for instance see this recent paper, where the Deimer and NFW profiles are compared - the Deimer profile is capable of going beyond the virial radius because it's composed of an "inner density" that is similar to the NFW, and transitions at approximately the virial radius to an "outer" density profile.