A publishing partnership

The following article is Open access

Field-level Neural Network Emulator for Cosmological N-body Simulations

, , , , , and

Published 2023 July 25 © 2023. The Author(s). Published by the American Astronomical Society.
, , Citation Drew Jamieson et al 2023 ApJ 952 145 DOI 10.3847/1538-4357/acdb6c

Download Article PDF
DownloadArticle ePub

You need an eReader or compatible software to experience the benefits of the ePub3 file format.

0004-637X/952/2/145

Abstract

We build a field-level emulator for cosmic structure formation that is accurate in the nonlinear regime. Our emulator consists of two convolutional neural networks trained to output the nonlinear displacements and velocities of N-body simulation particles based on their linear inputs. Cosmology dependence is encoded in the form of style parameters at each layer of the neural network, enabling the emulator to effectively interpolate the outcomes of structure formation between different flat Lambda cold dark matter cosmologies over a wide range of background matter densities. The neural network architecture makes the model differentiable by construction, providing a powerful tool for fast field-level inference. We test the accuracy of our method by considering several summary statistics, including the density power spectrum with and without redshift space distortions, the displacement power spectrum, the momentum power spectrum, the density bispectrum, halo abundances, and halo profiles with and without redshift space distortions. We compare these statistics from our emulator with the full N-body results, the COmoving Lagrangian Acceleration (COLA) method, and a fiducial neural network with no cosmological dependence. We find that our emulator gives accurate results down to scales of k ∼ 1 Mpc−1h, representing a considerable improvement over both COLA and the fiducial neural network. We also demonstrate that our emulator generalizes well to initial conditions containing primordial non-Gaussianity without the need for any additional style parameters or retraining.

Export citation and abstract BibTeX RIS

Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.

1. Introduction

We can learn more from the rapidly improving cosmological observations than we extract from traditional summary statistics (Laureijs et al. 2011; Doré et al. 2014; Spergel et al.2015; DESI Collaboration et al. 2016; Abbott et al. 2018, 2022; Ivezić et al. 2019). However, utilizing this invaluable data set to its full potential and extracting the maximum amount of physical information from its contents will involve data analysis without an analytically tractable likelihood. This requires highly efficient and accurate methods of data simulation. Recent advances in machine learning offer a potential path forward toward rapid and accurate methods of simulating the evolution of large-scale cosmic structure.

Standard practice in cosmology has been to employ summary statistics with analytically tractable likelihoods, such as power spectra and bispectra, in order to connect theory with observation (Percival et al. 2001; Tegmark et al. 2004; Beutler et al. 2011; Blake et al. 2012; Alam et al. 2017; Abbott et al. 2018; D'Amico et al. 2020; Ivanov et al. 2020; Alam et al. 2021; Abbott et al. 2022; Philcox & Ivanov 2022). These statistics are also measured in configuration space, where they correspond to the two-point, three-point, and higher N-point correlation functions (Slepian et al. 2017; Philcox et al. 2021). In this approach, a cutoff is straightforwardly imposed on small scales so as to only analyze those modes in the linear and quasi-linear regimes, where accurate predictions can be made without reliance on numerical simulations. Another approach is to build summary statistics emulators based on simulations so that some information is extracted from nonlinear scales (Chapman et al. 2022; Zennaro et al. 2023; Kobayashi et al. 2022; Neveux et al. 2022; Yuan et al. 2022; Zhai et al. 2023). However, the data compression involved in such analyses inevitably discards some information from observational surveys (Charnock et al. 2018; Samushia et al. 2021; Dai & Seljak 2022). More information may be extracted by considering higher N-point statistics beyond the power spectrum and bispectrum, but this requires computing a prohibitive number of mock data sets in order to determine the covariance matrices of these statistics.

Novel summary statistics may prove to be near optimal at utilizing information in the data, including scattering wavelet transformations (Cheng et al. 2020; Valogiannis & Dvorkin2022a; Eickenberg et al. 2022; Valogiannis & Dvorkin 2022b) and k-nearest-neighbor distributions (Wang et al. 2022). Another approach is likelihood-free inference at the field level, which exploits all of the information in the data. By extracting the maximum amount of information, field-level analysis will achieve the tightest constraints on the values of cosmological parameters. Techniques along these lines include deep-learning models (Ribli et al. 2019; Villaescusa-Navarro et al. 2021a, 2021b; Villanueva-Domingo & Villaescusa-Navarro 2023), forward modeling approaches (Jasche & Wandelt 2013; Wang et al. 2014; Ata et al. 2015; Jasche & Lavaux 2015; Seljak et al. 2017; Schmidt et al. 2019; Cabass & Schmidt 2020), and other methods of simulation-based inference (Alsing et al. 2019; Cranmer et al. 2020). Because these methods cannot be formulated in terms of analytically tractable likelihoods, they require fast, accurate, and ideally autodifferentiable methods of simulating the data.

The most accurate theoretical predictions for structure formation at the field level come from expensive simulations. Even under the approximation where baryonic pressure and galaxy formation are neglected, so that all matter is treated as cold dark matter (CDM), state-of-the-art N-body simulations take a significant amount of time and computational resources, making them impractical for field-level inference. These simulations evolve a large number of particles under the influence of Newtonian gravity in an expanding universe. Such algorithms transform a nearly uniform distribution of particles into the intricate structures of the cosmic web, a network of extremely dense dark matter halos and vast, nearly empty voids. This is a highly nonlinear process that is difficult to model accurately by other means.

Lagrangian perturbation theory (LPT; Scoccimarro & Sheth 2002; Monaco et al. 2002; Kitaura & Hess 2013; Avila et al. 2015; Chuang et al. 2015; Stein et al. 2019), log-normal generation Agrawal et al. (2017), particle mesh algorithms (White et al. 2014; Feng et al. 2016; Modi et al. 2021), COmoving Lagrangian Acceleration (COLA; Tassev et al. 2013; Howlett et al. 2015), and neural network mock generation (Berger & Stein 2019; Ramanah et al. 2019) all approximate nonlinear evolution with methods that are fast but either fail on small scales or do not accurately reproduce all of the key summary statistics. Another strategy is to develop a secondary algorithm responsible for correcting the small-scale errors of fast approximation schemes (Kaushal et al. 2022). This requires running multiple codes in succession, reducing gains in computational time and efficiency. Another approach that reduces the computational resources required for cosmological inference is the rescaling method, which converts the results from one simulation with a given set of cosmological parameters to the corresponding results for a different set of cosmological parameters (Angulo & White 2010; Contreras et al. 2020). The rescaled results are specific to the set of initial conditions from the original simulation; the amplitudes of the density modes are rescaled, while the phases are held fixed. Thus, the rescaling technique cannot be used to sample over both initial conditions and cosmological parameters simultaneously without running many N-body simulations.

In this work, we train a convolutional neural network (CNN) emulator capable of accurately reproducing the outcomes of N-body simulations for a wide range of cosmological parameter values. Unlike the previous methods mentioned above, our CNN-based approach is both accurate in the deeply nonlinear regime and capable of computing the N-body evolution for arbitrary initial conditions. The nonlinear dynamics of structure formation involve couplings between all modes of the density field. Perturbative approaches typically approximate these couplings to second or third order. Our model learns the full, nonperturbative couplings and their dependency on Ωm.

Since our model is constructed from CNNs, it is fully differentiable, addressing the need to efficiently sample over both initial conditions and cosmological parameters simultaneously. This will greatly accelerate parameter inference from upcoming survey data. Our emulator is a significant advancement over the previous work in He et al. (2019), where the authors trained a CNN to reproduce the FastPM displacements of 323 particles. We also build on the previous work of Alves de Oliveira et al. (2020), where the authors trained a CNN to reproduce the N-body displacement field for a fixed cosmology. In this work, we build the first field-level phase-space emulator to predict the full N-body evolution of both the displacements and velocities of 5123 particles 11 for a wide range of cosmological parameter values.

The emulator computes the N-body evolution on a flat, Lambda CDM (ΛCDM) cosmological background, so the only relevant cosmological parameter is Ωm. Other ΛCDM parameters only affect the initial conditions (the model input), not the gravitational clustering, so they do not need to be included in the CNN design. One advantage of our method is that the CNN can generalize to extensions of ΛCDM when the additional cosmological parameters only affect the early universe, or the initial conditions of the N-body simulation. As we will show, this includes primordial non-Gaussianity (PNG), which enters through the statistics of the linear field.

Our emulator can also easily be extended to include other cosmological parameters that do affect late-time, nonlinear clustering, such as the sum of neutrino masses, global spatial curvature, and parameters of dynamical dark energy models. In these cases, an extended model can be retrained with additional N-body simulations that include the relevant physics. Currently, our emulator makes predictions at redshift zero, but it is trivial to generalize this by including redshift as an extra parameter and training on simulation snapshots at earlier times.

2. Setup

We train two CNN models to emulate the evolution of a system of N-body particles interacting under the influence of Newtonian gravity on an expanding cosmological background, which is specified by the matter fraction Ωm. One CNN takes the linear, also known as the Zel'dovich approximation (ZA), displacement field at redshift z = 0 and the value of Ωm as inputs and outputs the nonlinear displacement field at redshift z = 0. The other CNN takes the ZA velocity field at redshift z = 0 and the value of Ωm as input and outputs the nonlinear velocity field at redshift z = 0. Initially, the N-body particles are distributed on a uniform grid with positions q , and their final positions at redshift zero are

Equation (1)

where Ψ( q ) is the final displacement for the particle initially at grid site q . The final velocities of each particle are

Equation (2)

where the dots denote time derivatives. Since all of the particles have the same mass, Mp , the velocities are really mass-weighted and represent the momentum field:

Equation (3)

Our CNN model effectively nonlinearizes the linear inputs, directly approximating the outcome of an N-body simulation by learning the mode couplings of the dark matter field.

We train our CNN emulator with 2000 simulations from the Quijote Latin hypercube N-body suite (Villaescusa-Navarro et al. 2020). Each has a unique set of five cosmological parameters: Ωm, Ωb, σ8, ns, and h. The values of these cosmological parameters are randomly sampled in a five-dimensional Latin hypercube. Additionally, each simulation has a unique random seed for its initial condition, so all of the initial conditions are different in every simulation. The simulations were run using the N-body code Gadget-3 (Springel 2005) with 5123 particles in a 1 Gpc h−1 box. Our CNNs are trained on the redshift zero simulation snapshots.

We split the 2000 Latin hypercube samples into a training set of 1757 cosmologies, a validation set of 122 cosmologies, and a testing data set of 121 cosmologies. The loss on the training data set is used to determine back-propagation gradients through the neutral network and update the model parameters during each training epoch. The loss on the validation set is monitored as a diagnostic for overfitting during training. After training the emulator, the testing simulations are used to determine how the model performs on data independent from the training and validation sets.

In addition to the usual convolution parameters of a CNN, our emulator contains extra parameters at each layer that encode the Ωm dependence of clustering across multiple scales. The value of Ωm is fed to each layer of the CNN and transformed into an array with the same dimension as the layer's input. 12 The convolution kernels are multiplied by this array prior to performing the convolution. We described this in greater detail in Appendix A. Following StyleGAN2 (Karras et al. 2019), we refer to Ωm as a style parameter, and we refer to the emulator as the styled neural network (SNN) model. We compare this model against two competitors. The first has the same neural network architecture, except it does not include the style parameter, so it has no cosmology dependence. We refer to this model as the fiducial neural network (FNN) model, since it was trained on a set of N-body simulations in the Quijote simulation suite with only the fiducial values of the five cosmological parameters. This comparison allows us to evaluate the gains in accuracy achieved by including the style parameter, which gives the SNN its cosmology dependence.

The second competitor we consider is COLA (Tassev et al. 2013), implemented with L-PICOLA (Howlett et al. 2015). The COLA method is a fast approximation for solving the N-body equations of motion using tens rather than thousands of integration time steps. Although the COLA method is fast, it produces inaccurate results on small scales. Comparing with COLA gives us a basis for assessing the gains in accuracy from implementing a CNN to predict the outcomes of simulations rather than using approximate N-body solvers. Below, we present results from the predictions of our SNN emulator and compare the results with the full N-body simulations, the FNN, and COLA.

3. Results

While the main goal of building a field-level emulator is to do full field-level inference, it is useful to assess the model's accuracy by evaluating summary statistics. The emulator can also be used for fast mock generation to study the covariance of summary statistics, for which we need to validate its accuracy. In this section, we compare the power spectra (two-point statistics) of the matter density, N-body displacement, and momentum field modes from the full N-body simulations with our emulator and its competitors. We then compare the bispectrum (three-point statistics) of the matter field modes. In addition to these N-point statistics, we demonstrate that our emulator reproduces the abundances of dark matter halos and their profiles better than its competitors. We then determine the effects of redshift space distortions (RSDs) on some of these observables and how they compare with the full N-body results.

3.1. Density Power Spectra

For each simulation in the testing data set, we estimate the Eulerian density field using a cloud-in-cell (CIC) particle mesh assignment on a grid with 10243 voxels. At the voxel centered on position x , we sum the CIC particle weights to obtain the effective number of particles n( x ) and then determine the overdensity ${\delta }_{{\rm{m}}}({\boldsymbol{x}})=n({\boldsymbol{x}})/\bar{n}-1$ with respect to the mean number of particles per cell $\bar{n}$. We Fourier transform the density fields using FFTW3 (Frigo & Johnson 2005) and deconvolve the CIC window function, yielding the density modes δm( k ). We then compute the density power spectrum Pmm(k), given by

Equation (4)

Here, ${\delta }_{{\rm{D}}}^{(3)}({\boldsymbol{k}})$ denotes the 3D Dirac delta function, which enforces the homogeneity of the density statistics, while the fact that the power spectrum depends only on the magnitude k ≡ ∣ k ∣ is required by isotropy. In practice, we compute the power spectrum as the mean squared mode amplitude in bins the width of the Nyquist wavenumber of the Fourier mesh.

Let δm,pred be the predicted density field constructed from either the emulator, COLA, or the fiducial model, and let δm,true be the density field constructed from the N-body simulations. We characterize the errors in the model predictions using the cross-correlation coefficient:

Equation (5)

The stochasticity is defined as 1 − r(k)2, which quantifies the excess fraction of correlation in the prediction that cannot be accounted for in the target simulation data. We also characterize the errors using the fractional difference between the predicted and true transfer functions:

Equation (6)

The results for these density power spectrum errors are shown in the top two rows of Figure 1. The color of each curve indicates the value of σ8 from the corresponding simulation. We use σ8 rather than the style parameter Ωm to label the curves because the small-scale errors are determined by the abundances of high-density structures; σ8 parameterizes the amplitude of small-scale power, so a higher σ8 generally indicates a greater abundance of collapsed objects (i.e., dark matter halos).

Figure 1.

Figure 1. Power spectrum errors for the SNN (left), COLA (middle), and the FNN (right). Each pair of rows shows the stochasticities and transfer function errors for the Eulerian density field (top), Lagrangian displacement field (middle), and Eulerian momentum field (bottom) power spectra. The color of each curve corresponds to its value of σ8 according to the color bar at the top.

Standard image High-resolution image

The SNN is considerably more accurate than COLA at scales out to k ∼ 1 Mpc−1 h. The emulator achieves percent-level accuracy in the transfer functions for all cosmologies. The emulator also achieves percent-level stochasticities for all cosmologies except those with extremely high σ8. As we will continue to see in the results presented later, it is the virialized motion inside of collapsed regions that limits the emulator's accuracy, and this explains the elevated errors in the matter power spectrum for high σ8 simulations. Due to the fast orbits and fairly chaotic behavior of particles inside a virialized halo, if we output the simulation snapshots at slightly earlier or later times, the particle positions and velocities can change significantly. Since the CNNs map the ZA inputs to nonlinear fields at the particle level, it is very difficult for the CNNs to learn general rules about the fates of these particles. For COLA, the accuracy is limited by the combination of LPT and large time steps. Even with these limitations, in the worst cases, the emulator achieves stochasticities of less than 2% at k = 1 Mpc−1 h, which is comparable with COLA's accuracy. We also see that the FNN errors have a much stronger cosmology dependence, so the SNN is using its style parameter to effectively interpolate between different cosmological models and make more accurate predictions.

The emulator performs worst on cosmologies with a combination of high σ8 and low Ωm. The large-scale power in these cosmologies has an extremely high amplitude. This results in a large divergence in the linear displacement field on large scales, so particles generally flow out further from their initial positions. In these extreme cosmologies, the nonlinear displacements are more nonlocal, sourced by a wider region of the density field. This poses a different limitation on the SNN, besides small-scale resolution, since it has a limited field of view for the environment surrounding each particle. In principle, this limitation can be alleviated by adding more convolutional layers, widening the model's field of view. However, in practice, this would increase the evaluation time and require more memory for the large number of additional parameters. We initially implemented the neural network with only three layers, and in this case, the sensitivity of the stochasticities to low values of Ωm was even more dramatic, and the worst cases were worse than COLA. Increasing to four layers improved these worst cases without too severe a cost in memory and computational time.

3.2. Displacement Power Spectra

From Equation (1), the N-body displacement field is defined with respect to the initial Lagrangian grid, so these can be Fourier transformed directly. The displacement power spectrum, PΨ Ψ (k), is then given by

Equation (7)

where Ψ( k ) are the Fourier modes of the displacement field, and the dot indicates taking the Cartesian inner product between the displacement mode vectors. The displacement stochasticity and transfer function errors are defined analogously to those of the density field in Equations (5) and (6). These errors are plotted in the middle two rows of Figure 1.

Again, we find that the SNN achieves smaller errors than COLA and has fewer cosmology-dependent errors than the FNN. Similar to the density power spectrum results, the worst cases for the emulator are the high σ8 cosmology with low Ωm. The SNN displacement stochasticities are less than 3% at k = 1 Mpc−1 h, and the transfer function errors are negligible (<0.1%) down to this scale.

Note that the small bump in the FNN errors at k ∼ 0.04 Mpc−1 h−1 corresponds to the baryonic acoustic oscillations (BAOs) in the power spectrum. The shape of these oscillations depends on the ratio Ωbm. Since the FNN only encountered one example of this ratio, it is unable preserve the shape of the BAOs in cosmologies with parameters that are far from the fiducial values of its training data. A similar bump in the FNN errors can also be seen in the results for the density power spectrum.

3.3. Momentum Power Spectra

The previous two power spectra depended on the displacement field alone. To compare the accuracy of the velocity part of our model, we construct the momentum power spectrum. We estimate the momentum field, p ( x ), by distributing the particles to a 10243 mesh using the CIC assignment scheme. Note that this is an Eulerian momentum field, not the Lagrangian momentum field in Equation (3), which was defined with respect to the initial particle grid. We Fourier transform the momentum field and deconvolve the CIC window function to obtain the momentum modes p ( k ). We then compute the momentum power spectrum P p p (k),

Equation (8)

using the same method that was used for the density power spectrum. The errors are plotted in the bottom two rows of Figure 1.

The SNN momentum transfer functions are much more accurate on small scales than those from COLA and show much less cosmology dependence than the FNN transfer function errors. The same is true for the stochasticities for all but the most extreme high-σ8 low-Ωm cosmology, where the stochasticities are slightly larger, although comparable with COLA. The emulator has stochasticities of less than 2% at k = 1 Mpc−1 h for most cosmologies. The three worst cases have stochasticities of 4%–5% at this scale. The SNN transfer functions at k = 1 Mpc−1 h are biased slightly too high by a few percent but remain considerably more accurate than COLA.

In general, the SNN momentum power spectrum errors are worse than those from the density or displacement power spectra. This is due to the fact that constructing the momentum field relies on the particle displacements, which are taken from the output of the displacement SNN. Thus, the errors from the displacement field propagate to the momentum field.

3.4. Density Bispectra

In addition to the two-point statistics, we also considered the three-point statistics of the Eulerian matter density field. The matter bispectrum B(k1, k2, k3) is defined as

Equation (9)

Since the Dirac delta function requires the three wavevectors to form a closed triangle, the bispectrum can also be expressed as a function of the magnitude of two wavevectors and the angle between them, B(k1, k2, θ). We use both notations interchangeably. It is also convenient to define the reduced bispectrum,

Equation (10)

where Pi = Pmm(ki ) is the density power spectrum evaluated at ki . We use the Pylians3 13 library to compute the bispectrum.

We characterize the bispectrum errors by taking the fractional difference with respect to the N-body bispectrum. These are shown in Figure 2 for two different configurations. The two rows of plots show the bispectra in the equilateral configuration as a function of the magnitude of the three wavevectors. The bottom two rows show the bispectra fixing k1 = 0.1 and k2 = 1 Mpc−1 h as a function of the angle between them. The top row of each set of plots shows the reduced bispectrum errors, while the bottom row shows the error in the bispectrum. The color of each bispectrum curve corresponds to its value of Ωm.

Figure 2.

Figure 2. Bispectrum errors for equilateral configurations (top two rows) and configurations obtained from varying the angle between two wavevectors with fixed magnitudes (bottom two rows). The bottom rows in each pair show the errors in the bispectrum, while the top rows show the errors in the reduced bispectrum. The color of each curve corresponds to its value of Ωm according to the color bar at the top.

Standard image High-resolution image

Unlike the power spectrum errors, the SNN bispectrum errors do not exhibit a strong dependence on Ωm or σ8. The SNN bispectrum errors are significantly better than those from COLA or the FNN. This demonstrates that the model is inferring general physical principles about nonlinear gravitational clustering and its cosmology dependence, enabling it to accurately model structure formation on small scales. The SNN errors are less than 5% at k = 0.5 Mpc−1 h and do not increase significantly until after k = 1 Mpc−1 h. The errors in both the bispectra and reduced bispectra are comparable for the SNN because its power spectrum errors are small on these scales.

3.5. Halos

The matter density field is not directly measured in large-scale structure surveys. Instead, biased tracers of the underlying density field, such as galaxies, are used to infer the statistics and initial conditions of the density field. Under gravitational clustering, the dark matter forms high-density, virialized structures called halos, which are the environments in which galaxies form and reside.

We identify halos in the N-body, CNN, and COLA outputs using the halo-finder code Rockstar (Behroozi et al. 2013). Rockstar identifies halos using a friend-of-friends algorithm and then determines the halo properties by spherical overdensity calculations out to each halo's virial radius. Particles that are not bound to a halo's center of mass are omitted, so the six-dimensional phase space of the N-body particle data is utilized by this algorithm. Rockstar provides us with an excellent framework for further assessing the combined full phase-space predictions of our emulator.

One important observable related to dark matter halos is their density profiles. These density profiles are the result of extremely nonlinear processes of gravitational collapse, mergers, and accretion. To construct halo density profiles from our data, we select a sample of 500 halos with an average mass of 5 × 1014 M h−1. These were taken from a single simulation in the testing data set with cosmological parameters closest to the fiducial ΛCDM cosmology. The simulation has Ωm = 0.3223 and σ8 = 0.8311, while the fiducial cosmology has Ωm = 0.3175 and σ8 = 0.834. We construct the density field from the positions of the N-body particles using a CIC mesh assignment on a grid of 0.5 Mpc h−1 in cell length. We average the densities of each halo in the z-direction over a 3 Mpc h−1 slice centered on each halo's center of mass. The results are shown in the top two rows of the left panel of Figure 3.

Figure 3.

Figure 3. Left: stacked profiles of 500 halos in real space (top two rows) and redshift space (bottom two rows) with mean mass of 5 × 1014 M h−1. The top and bottom rows show the residuals with respect to the N-body simulation. The middle two rows show the profiles. Right: halo mass function errors (top) and errors in the multipole moments of the redshift space matter power spectrum (bottom two rows). The color of each curve corresponds to its value of Ωm according to the color bar at the top.

Standard image High-resolution image

The SNN achieves much more accurate halo interiors than COLA and also shows improvements over COLA in the environments surrounding halos. The SNN even shows small improvements over the FNN, even though these halos form in a cosmology close to the FNN's training data. This demonstrates that even small changes in Ωm can result in a loss of accuracy for the FNN in the deeply nonlinear regime.

Another important observable related to halos is their number density as a function of mass, nh (M), which is known as the halo mass function. We construct the halo mass function for each testing cosmology and compute its error as the fractional difference with respect to the N-body results. These errors are shown in the top row in the right panel of Figure 3.

The SNN shows a dramatic improvement over COLA, and again we find a reduced cosmology dependence in the errors compared with the FNN. The abundances of low-mass halos (M < 5 × 1013 M h−1) from the SNN are biased high by about 10%–20% but scattered around the N-body mass functions at higher mass. To be fair to COLA, its purpose is not to accurately recover the small-scale details of halos, and its systematically low halo abundances are well known. Abundance matching methods have been developed to identify dense structures in COLA output that correspond to halos from the full N-body evolution (Izard et al. 2016).

3.6. Redshift Space Distortions

In large-scale structure surveys, the distance to a galaxy is inferred through its observed redshift. This redshift is not due to cosmic expansion alone but gets an additional Doppler contribution from the galaxy's peculiar velocity. Even with the correct cosmological model, the observed positions of galaxies are radially displaced compared to their true positions. The shapes of galaxies are also distorted along the line of sight. These effects are known as RSDs. Matter inside of halos tends to have large, virialized velocities, which results in a smearing of the halo density along the line of sight, known as the "Fingers of God" phenomenon. On larger scales, where matter falls toward the local minimum of the gravitational potential, spherical profiles are squashed along the line of sight. It is crucial to accurately describe the late-time, nonlinear density field in redshift space in order to compare with realistic survey data.

We use the Pylians3 library to apply RSD to the N-body particle data and then construct the density profiles for halos in redshift space. The stacked redshift space profiles of the same 500 halos as in the previous subsection are shown in the bottom two rows of the left panel of Figure 3, along with their residuals with respect to the N-body simulations. All of the models exhibit the larger-scale flattening effect due to coherent infall, which appears as the two bulges on either side of the halo. However, only the SNN accurately reproduces the scale of the Fingers of God smearing along the y-axis compared with the N-body simulations.

As a final test of our model's accuracy in the nonlinear regime, we consider the multipole moments of the matter power spectrum in redshift space. Since RSDs contribute only radial distortions, they select the radial direction as special and induce anisotropy in the power spectrum. This anisotropy can be characterized by expanding the redshift space power in multipole moments:

Equation (11)

Here, ${{ \mathcal L }}_{{\ell }}$ are the Legendre polynomials, and θ is the angle between the wavevector k and the radial line-of-sight direction. We used the Pylians library to determine the monopole ( = 0) and quadrupole ( = 2) moments of the redshift space density power spectrum. The fractional errors with respect to the N-body results are shown in the bottom two rows of the right panel of Figure 3.

The SNN reproduces the monopole and quadrupole power spectra more accurately than COLA on small scales. Once again, we see that the SNN errors have less cosmology dependence than the FNN errors, indicating that the full phase-space evolution is modeled better across a wide range of Ωm values due to its inclusion as a style parameter. Note that since RSDs tend to move small-scale power to larger scales, the errors are larger at the 1 Mpc−1 h scale compared with the power spectrum errors in real space.

3.7. Primordial Non-Gaussianity

Searching for observational evidence of PNG is one of the highest-priority objectives of contemporary large-scale structure surveys. If detected, PNG would provide crucial evidence for inflation and possibly rule out a wide range of early universe models (Creminelli & Zaldarriaga 2004; Meerburg et al. 2019). The simulations that our emulator was trained on have purely Gaussian initial conditions. Non-Gaussianity can be added to the initial conditions by first drawing the modes of a random Gaussian scalar potential Φg( k ) and then constructing the non-Gaussian potential (Scoccimarro et al. 2012):

Equation (12)

Here, fNL sets the amplitude of the primordial bispectrum, and K( k 1, k 2) is an integration kernel specifying the shape of the primordial bispectrum. There are several typical choices for this kernel, usually referred to as bispectrum templates (Komatsu et al. 2003; Babich et al. 2004; Senatore et al. 2010). These include the local (LC), orthogonal (OR), and equilateral (EQ) templates. Since PNG enters only through the initial conditions of a simulation, our model should immediately generalize to these cosmologies without the need for additional parameters or training.

To test this, we use the new QUIJOTE-PNG (Coulton et al. 2023) N-body simulations. These augment the previous QUIJOTE data set with simulations that include the PNG templates mentioned above in their initial conditions. We use a set of seven simulations, one with Gaussian (G) initial conditions and two from each of the bispectrum template types listed earlier, setting fNL = ±100. All other cosmological parameters are the same as in the fiducial cosmology, and the simulation configurations are identical to those of the training data. We compute the ZA displacements and velocities at redshift zero for all of these simulations and predict the nonlinear configurations using our emulator. We then compare these with the full N-body simulations. The results are shown in Figure 4.

Figure 4.

Figure 4. Left: standard deviation in the SNN errors of the displacement (top) and velocity (bottom) fields for Gaussian and PNG simulations, including LC, OR, and EQ primordial bispectrum templates. The ± signs indicate the sign of fNL, which has a magnitude ∣fNL∣ = 100 for all PNG simulations. Right: SNN component error probability density functions for displacements (top) and velocities (bottom) from Gaussian and PNG simulations. No labels or legend are shown because the distributions are indistinguishable.

Standard image High-resolution image

The top left panel shows the standard deviation of the displacement errors for the Gaussian and non-Gaussian simulations. There is no significant or systematic increase in error in the simulations with PNG; some even have smaller errors than the Gaussian case. The bottom left panel shows the standard deviation of the velocity errors, again without any systematic increase from the presence of PNG in the initial conditions. The right panels show the probability density functions for the errors in the displacement (top) and velocity (bottom) components for all seven simulations. We do not include a legend to label the different template types, since their error distributions are indistinguishable. This indicates that the emulator generalizes to these PNG simulations as expected.

Figure 5.

Figure 5. Neural network architecture for our model, which maps the linear ZA displacements and velocities to their nonlinear values after N-body evolution. The bottom right shows a single particle's Lagrangian cell. Its trajectory is the red dashed line. The blue (purple) vector shows the initial ZA displacement (velocity). Its final nonlinear displacement and velocity are the black vectors. The neural networks are trained to predict the red vectors, which are the difference between the final nonlinear vectors and the linear ZA vectors. Each convolutional operation is modulated and then demodulated by a set of parameters that transform the matter density parameter Ωm prior to operating on the particle data.

Standard image High-resolution image

These results are unsurprising, since the model has been exposed to an enormous diversity of density environments during training. The presence of PNG alters the statistics of these configurations, but the physics of nonlinear gravitational clustering in these environments remains the same. It is this underlying physics of late-time structure formation that the emulator infers from its training data. Further tests are still required to determine how well the emulator preserves the observational features of PNG in various summary statistics, including the power spectrum and bispectrum, as well as at the field level. We leave this to future work.

4. Conclusion

We have trained and tested a full phase-space emulator for N-body simulations based on two styled neural networks (SNNs). The emulator achieves percent-level accuracy on deeply nonlinear scales of k ∼ 1 Mpc−1 h−1. We have demonstrated this for the density, Lagrangian displacement, and momentum power spectra. The emulator also achieves accuracy on the order of a few percent for the density bispectrum. The SNN model reproduces the abundances of dark matter halos with an accuracy on the order of 10%. We have also demonstrated that the emulator accurately predicts the full phase-space N-body evolution, reproducing the features of RSDs in halo profiles and the matter density power spectrum.

The accuracy of our emulator represents a significant improvement over other fast simulation techniques, such as the COLA method. Comparisons against a neural network model without the style parameter, thus lacking cosmology dependence, demonstrate that the emulator has learned to interpolate between cosmologies within the range of its training data. The emulator was trained on simulations with flat, ΛCDM cosmological backgrounds. Due to the design choice of predicting residuals between the full nonlinear displacements and velocities and their linear approximations, the emulator generalizes well to extensions to ΛCDM that only affect the early universe and thus enter only through the linear fields. We have demonstrated this for the case of primordial non-Gaussianity.

For other extensions to ΛCDM that do affect late-time clustering, as well as for redshift dependence, our emulator can be easily augmented without the need for significant changes to the underlying code. Additional style parameters can be defined, and then the model can be retrained on simulation data that include the new physics. This may only require a small amount of new training data and retraining time if transfer-learning techniques are employed to retain the current capabilities of the emulator.

The accuracy, speed, and differentiability of our emulator make it an ideal tool for field-level forward modeling approaches to cosmological inference. Additionally, the emulator can efficiently generate large numbers of mocks for studying the covariance matrices of various observables. For a full field-level analysis pipeline of large-scale structure surveys, our model would need to be extended to included redshift dependence for light-cone realizations, higher resolution, or upsampling methods (Li et al. 2021) to capture the full range of galaxy-hosting halos that surveys are sensitive to and the baryonic effects of galaxy formation and feedback. In light of the success of the current emulator, these extensions represent promising avenues of research for simulation-based inference in large-scale structure. Our emulator demonstrates the power of machine-learning techniques to accelerate onerous computational tasks; this will help to achieve robust and optimal constraints, which could lead to the discovery of new physics from large-scale structure observations.

The Flatiron Institute is supported by the Simons Foundation.

Data Availability

Our trained model parameters are available at github.com/dsjamieson/map2map_emu or Li et al. (2023). We train and test the neural networks with map2map (github.com/eelregit/map2map), a neural network framework for field-to-field emulators based on PyTorch (Paszke et al. 2019). It implements the aforementioned mechanisms to fully preserve translational symmetry, including the boundary conditions, and do rotational data augmentation for problems of arbitrary dimensions. It can also optimize the data loading IO at training time so that the GPUs are not starved of data due to their high performance.

Appendix: Methods

A.1.  N-body Simulation and LPT

Current cosmological N-body simulations model structure formation in the universe by evolving a large number (106– 1012) of massive dark matter particles that interact with each other only via gravity. Since our universe begins with an almost uniform and Gaussian initial condition, the simulations start with particles only slightly perturbed from a uniform configuration, here a grid. For each particle, this initial small displacement Ψ from its grid location q can be computed accurately with the LPT. The particle position is then x = q + Ψ( q ). The leading-order LPT (ZA) predicts linear particle motion ΨZA( q , z) = D(z)/D(z0)ΨZA( q , z0), where the growth function D is a function of redshift z. As a result, the ZA velocity is linearly related to the displacement v ZA( q , z) = aH(z)f(z)ΨZA, where a = 1/(1 + z) is the expansion scale factor, $H={\rm{d}}\,\mathrm{log}\,a/{\rm{d}}\,t$ is the Hubble expansion rate, and $f={\rm{d}}\,\mathrm{log}\,D/{\rm{d}}\,\mathrm{log}\,a$ is known as the growth rate.

Structures collapse under gravity and cluster hierarchically in the universe. On small scales, particle motion becomes nonperturbative, invalidating ZA and higher-order LPT. This process becomes so nonlinear that it can only be accurately modeled by expensive N-body simulations via time integration of thousands of time steps. On the other hand, on large scales, the universe remains relatively uniform, and perturbation theories still apply. This motivates us to build a model to emulate the small-scale structure formation in the N-body simulations while retaining the ZA predictions on large scales. The CNNs integrate well into this framework, since they excel at local textures but lack a global view beyond their finite receptive fields. Therefore, our goal is to train CNN models to nonlinearize the linear ZA inputs to make predictions comparable in accuracy to N-body simulations.

For benchmarks, we compare the neural network predictions to alternative fast simulation models. Fast approximate simulations (Tassev et al. 2013; Feng et al. 2016) save computation time by only integrating tens of time steps and thus are less accurate than the full N-body simulations. Here, we compare the neural network model to the popular method COLA (Tassev et al. 2013), as implemented in L-PICOLA (Howlett et al. 2015). COLA solves the particle motions relative to the second-order LPT trajectory. We run L-PICOLA with the same settings as the full N-body simulations but for only 10 time steps.

A.2. Physical Considerations

As explained above, we want the neural network to keep the ZA predictions (ΨZA and v ZA at the target redshift) on large scales, where perturbation theories are valid and accurate. This accounts for the nonlocal gravitational interactions beyond the local views of CNNs. The CNN models can then take the linear inputs and form the appropriate small-scale textures. This is most easily implemented by a global residual operation, in which the CNN predicts the difference between the N-body and ZA motions.

The design with global residual connection has other advantages too. One is that the Galilean symmetry is approximately preserved by effective data augmentations. This is because even though the ZA and N-body particle motions may be affected by large-scale shifts in displacements or velocities, e.g., by adding a global constant vector, their difference is not. The other advantage is that the large-scale dependence on cosmological parameters is automatically accounted for by the ZA inputs, so the neural network emulators only need to model the small-scale cosmology modulation, as explained below. Therefore, we train two separate networks for displacement and velocity, respectively, whose inputs are linearly related.

By construction, CNNs should preserve the translational symmetry if they are fully convolutional. However, this is broken in most cases by the nonperiodic paddings commonly adopted in computer vision tasks. Our models fully preserve the translational symmetry using the periodic boundary condition of the N-body simulation volume. In addition, they approximately preserve the rotational symmetry of the cubic geometry by data augmentations that rotate and reflect the input and output fields as in He et al. (2019).

A.3. Network and Training

Before applying CNN models to our problem, we need to prepare the data in an image-like format, which is straightforward thanks to the uniform initial condition of the universe. Both the ZA inputs and N-body target are functions of the Lagrangian or initial positions, q , which form a uniform grid. Therefore, the displacements form a 3D image, with three channels being the Cartesian components of the particle displacements. Likewise, we format the velocity fields in a similar way.

For both displacement and velocity, we adopt a simple U-Net/V-Net-type architecture (Ronneberger et al. 2015; Milletari et al. 2016) similar to that in Alves de Oliveira et al. (2020). A diagram depicting the network architecture is shown in Figure 5. It works on four levels of resolution connected in a V shape first by three downsampling layers and then by three upsampling layers by stride-2 23 convolutions and stride-1/2 23 transposed convolutions, respectively. Blocks of two 33 convolutions connect the input, resampling, and output layers. Similar to V-Net, a residual connection (ResNet; He et al. 2016), here a 13 convolution instead of identity, is added over each block. We use a batch normalization layer after every convolution except the first one and the last two and a leaky ReLU activation (with negative slope 0.01) after each batch normalization, as well as the first and second-to-last convolution layers. As in the original ResNet architecture, the second or last activation in each residual block applies after the addition. And as in U-Net, the inputs to each of the downsampling layers are concatenated to the outputs of the upsampling layers of the same resolution at the top three resolution levels. All layers have 64 channels, except the input and the output (3) and those after concatenations (128). Finally, an important difference from the original U-Net architecture is that we add the input displacement or velocity fields directly to the output. Therefore, the network is effectively learning the corrections from linear to nonlinear motions, as we have mentioned above.

With the Lagrangian description, the simplest loss functions for training one can formulate aim to minimize the residuals in the displacements. Alves de Oliveira et al. (2020) and Li et al. (2021) showed that combining that with a loss of Eulerian quantities can greatly improve the performance of the trained model in the Eulerian space. For the displacement model, we can compute the particle positions and thus their (Eulerian) density distribution, described by the overdensity $\delta ({\boldsymbol{x}})\equiv n({\boldsymbol{x}})/\bar{n}-1$, where n( x ) is the particle number in voxel x , and $\bar{n}$ is its mean value. Specifically, we use the CIC, or trilinear scheme, to assign particles to the voxels. The total loss for our displacement network is $\mathrm{log}{L}_{\delta }+\lambda \mathrm{log}{L}_{{\boldsymbol{\Psi }}}$, with Lδ and LΨ being the mean squared error (MSE) losses on n( x ) and Ψ( q ), respectively. Combining the two losses with a logarithm allows us to ignore their absolute magnitudes and trade between the relative changes. The parameter λ is a weight on this trade-off, and we find that setting λ = 3 for the displacement network achieves faster training. For the velocity network, we use a loss of $\mathrm{log}{L}_{{\boldsymbol{v}}({\bf{q}})}+\mathrm{log}{L}_{{\boldsymbol{v}}({\boldsymbol{x}})}+\mathrm{log}{L}_{{{\boldsymbol{v}}}^{2}({\boldsymbol{x}})}$. The first term is the MSE loss of the particle velocities (in Lagrangian space, thus the q argument). The second and last terms are defined by

Equation (A1)

where m is the particle mass, ⨂ forms tensor products of the particle velocity, and Δ takes the residual from predicted to N-body results. For n = 1, this is simply the loss on the momentum fields, and for n = 2, the loss minimizes the residual of the mass-weighted velocity dispersions. We find the n = 2 loss crucial for correctly predicting the RSD, especially the Fingers of God effect, as shown in Figure 3.

The most important feature of our models is the ability to incorporate the dependence on cosmological parameters. The late-time structure evolution is sensitive to the expansion history of the universe, i.e., the expansion rate H0 = 100 h km s−1 Mpc−1 and the matter density parameter Ωm. The former has been accounted for by using proper units that include h; thus, we only need to include Ωm as an input to our networks. We achieve this following StyleGAN2 (Karras et al. 2019), in which style parameters are incorporated by weight modulations and demodulations on the convolution kernels. In the modulation phase, the style parameters (here Ωm) are first affine transformed to the same dimension as the number of input convolution channels and then multiplied by the kernel of each channel. In the demodulation phase, the convolution kernels are renormalized by their fan-ins, so that propagating data do not explode or vanish. We refer readers to Equations (1)–(3) in Karras et al. (2019) for more details.

Limited by the size of the GPU memory, an entire simulation field (5123) cannot be fed to the network at once and has to be cropped into smaller chunks of size 1283. To preserve the translational equivariance, we keep no paddings in the convolutions, resulting in smaller network outputs than their inputs, and we compensate for this by periodically padding 48 voxels per side to the input fields. We train with a batch size of 16 distributed on 16 Nvidia V100 GPUs and use the Adam optimizer (Kingma & Ba 2014) with learning rate 0.0004 and hyperparameters β1 = 0.9 and β2 = 0.999. We reduce the learning to 10% when the loss does not improve for three epochs. We trained both models until the loss converged, which took 80 epochs for the displacement model and 60 epochs for the velocity model. The training ran for 2 × 104 GPU hr, roughly equally for each model.

Finally, it is worth mentioning that the total data size amounts to 12 TB. This poses technical challenges because training the networks requires repeatedly loading the whole data set to the GPU nodes. If the data sampling and loading are not carefully designed, the GPUs can easily outrun the cluster IO and be starved for data. We solve this and implement efficient training in map2map.

Footnotes

  • 11  

    The CNNs are trained on simulations with 5123 particles in a 1 Gpc h−1 box. This fixes the resolution that the CNNs can accurately model, but a different number of particles can be used by scaling the box size to keep the resolution fixed.

  • 12  

    Note that Ωm is the only cosmological parameter that the N-body evolution depends on because the simulation is carried out in units of Mpc h−1 and M h−1, which absorb the dependence on the Hubble parameter. The other cosmological parameters determine the shape of the linear power spectrum and the linear growth factor, so they only enter into the ZA field that is the input for our model.

  • 13  
Please wait… references are loading.
10.3847/1538-4357/acdb6c