A field-level emulator for modeling baryonic effects across hydrodynamic simulations
Abstract
We develop a new and simple method to model baryonic effects at the field level relevant for weak lensing analyses. We analyze thousands of state-of-the-art hydrodynamic simulations from the CAMELS project, each with different cosmology and strength of feedback, and we find that the cross-correlation coefficient between full hydrodynamic and N-body simulations is very close to 1 down to . This suggests that modeling baryonic effects at the field level down to these scales only requires N-body simulations plus a correction to the mode’s amplitude given by: . In this paper, we build an emulator for this quantity, using Gaussian processes, that is flexible enough to reproduce results from thousands of hydrodynamic simulations that have different cosmologies, astrophysics, subgrid physics, volumes, resolutions, and at different redshifts. Our emulator is accurate at the percent level and exhibits a range of validation superior to previous studies. This method and our emulator enable field-level simulation-based inference analyses and accounting for baryonic effects in weak lensing analyses.
keywords:
baryons – large-scale structure – field-level inference – emulator – Gaussian processes1 Introduction
Weak gravitational lensing is a powerful tool for measuring the clustering of matter in our universe, and thus obtaining information about matter content and initial conditions of our universe (Kilbinger, 2015) through various summary statistics. However, deriving precise cosmological constraints from weak lensing observations necessitates highly accurate theoretical models that account for baryonic physics, which redistributes matter on small scales via processes such as Active Galactic Nuclei (AGN) feedback. These processes remain poorly understood and inadequately constrained by current observations, leading to challenges in formulating a predictive theory.
While causality ensures that baryonic effects are negligible on large scales (Lewis & Challinor, 2011), baryonic effects gain significance on smaller scales, affecting structure formation through hydrodynamic processes. These processes, including AGN and stellar feedback, can heat gas and inject large amounts of energy into galaxies and the surrounding halo. Specifically, AGN feedback can eject gas to very large distances, which can further modify the dark matter distribution through gravitational interactions.
Studies have shown that probing the small scales contains a wealth of information, leading to stronger parameter constraints (Lu & Haiman, 2021), while ignoring small scale information leads to significant deterioration of these constraints (Köhlinger et al., 2016, 2017; Hikage et al., 2019). This small-scale information is heavily influenced by baryonic effects, and the large uncertainty associated with these effects makes them one of the primary sources of systematic error in weak lensing analyses. Hence, accurate modeling of baryonic effects is crucial when probing the information-rich small scales for an unbiased cosmological analysis.
At present, numerical simulations remain the sole comprehensive method for precise simulation of baryonic effects and the deeply non-linear evolution of cosmic structures. Hydrodynamic simulations provide a detailed and accurate representation of the behavior of baryonic matter by modeling complex physical processes such as gas dynamics, star formation, and feedback mechanisms (Teyssier, 2002; Di Matteo et al., 2005; Jenkins et al., 1998). However, these simulations are not ab initio parameter free, but instead must parametrize the lack of physics understanding via free parameters that can be varied. Furthermore, hydrodynamic simulations require substantial computational resources as compared to dark matter only N-body simulations.
The development of emulators has emerged as a powerful technique to overcome this computational challenge, enabling rapid and accurate predictions of physical properties without the need for running costly simulations. These emulators interpolate simulation results and have been shown to be remarkably accurate. Various emulators have been developed for cosmology, catering to various observables, encompassing the matter power spectrum (Heitmann et al., 2014; Euclid Collaboration et al., 2019; Winther et al., 2019; Angulo et al., 2021; Knabenhans et al., 2021), mass function (McClintock et al., 2019; Bocquet et al., 2020), and the galaxy correlation function and Lyman- Forest (Zhai et al., 2019; Bird et al., 2019).
While most previous work has focused on modeling the baryonic effects on the matter power spectrum (Huang et al., 2019; Mead et al., 2021a; Aricò et al., 2021a; Schneider et al., 2019, 2020; Giri & Schneider, 2023), there is an increasing need for developing fast baryon models at the field level for analysis beyond two-point statistics. For example, simulation-based inference methods (Cranmer et al., 2020) show great promise in extracting rich non-Gaussian information either through high-order statistics (e.g., Hahn et al., 2023), or directly from the fields (e.g., Dai & Seljak, 2021, 2022; Villaescusa-Navarro et al., 2021a, b). These approaches rely on fast and accurate cosmological predictions from numerical simulations. Previous field-level baryon models, such as Baryon Correction Model (Schneider & Teyssier, 2015) and Enthalpy Gradient Descent (Dai et al., 2018), move the dark matter particles from N-body simulations to mimic the baryonic effects. While they have been shown to accurately predict the power spectrum from hydrodynamical simulations (Schneider et al., 2019), they can be computationally expensive when the particle resolution is high.
By analyzing a diverse range of baryonic feedback hydrodynamics simulations across multiple redshifts, we will show that adding baryons to N-body simulations can be achieved using a field-level transfer function to augment N-body fields with a Fourier mode amplitude, k, dependent transfer function correction. We develop a transfer function emulator using Gaussian process for modeling the baryonic effects in terms of , where is the total matter power spectrum, and is the dark matter power spectrum.
In this paper, we develop the emulator and show that it is accurate at a percent level over our whole parameter space, which covers scales h/Mpc and redshifts . We validate the performance of our emulator against thousands of hydrodynamical simulations and their respective gravity-only counterparts. In particular, we make use of CAMELS-Astrid (Ni et al., 2023), CAMELS-IllustrisTNG, CAMELS-SIMBA(Villaescusa-Navarro et al., 2021c, 2023), BAHAMAS (McCarthy et al., 2017, 2018), Horizon AGN (Dubois et al., 2014), Owls (Schaye et al., 2010; van Daalen et al., 2011), and Eagle (Schaye et al., 2015; Crain et al., 2015; McAlpine et al., 2016; Hellwing et al., 2016) simulations. We also compare against commonly utilized emulators like BACCO (Aricò et al., 2021a), HMcode (Mead et al., 2021a, b), and BCemu (Giri & Schneider, 2023) on all simulations. Finally, we show the improvement of the field-level baryon model against hydrodynamic fields at varying redshifts. This emulator is fast as it only requires a single FFT and its inverse, which enables large-volume N-body simulations for generating realistic weak lensing mock data for cosmological analysis at the field level.
This paper is organized as follows: in section 2, we describe the suite of simulations that are used for training and testing our emulator. In section 3 we explain how our emulator can be used to emulate baryonic effects at the field level. In section 4 we describe the methods and construction of the Gaussian process emulator. In section 5 we test the emulator’s robustness on multiple hydrodynamic test simulations, compare it with currently available emulators, and show field-level improvements using our emulator. We summarize and conclude in section 6.
2 Simulations
In this section, we describe the simulations that we employ throughout this paper. Our main suites of simulations are part of the Cosmology and Astrophysics with MachinE Learning Simulations (CAMELS) (Villaescusa-Navarro et al., 2021c, 2023; Ni et al., 2023). CAMELS is a suite of 10,421 cosmological simulations each with a comoving volume of evolved from to with dark matter particles and gas particles in the initial conditions. These contain 5,097 N-body simulations and 5,324 hydrodynamic simulations. Notably, each hydrodynamic simulation in CAMELS pairs with an N-body counterpart, sharing identical cosmological parameters and initial random seeds.
Simulations in CAMELS are categorized into various suites (Astrid, IllustrisTNG, and SIMBA) and sets based on the employed code for running the simulations and the arrangement of cosmological and astrophysical parameters (), as well as the initial random seeds. The Astrid suite comprises 1,092 hydrodynamic simulations executed using the MP-Gadget simulation code (Feng et al., 2018), employing analogous subgrid physics as the original Astrid simulations (Ni et al., 2022; Bird et al., 2022). Additionally, the IllustrisTNG suite (based on Vogelsberger et al., 2013; Torrey et al., 2014) and the SIMBA suite (based on Davé et al., 2016), with 1,092 hydrodynamic simulations each, are executed using the AREPO code (Springel, 2010; Weinberger et al., 2020) and the GIZMO code (Hopkins, 2015), respectively.
Each simulation is characterized by its cosmology (given by and ) and its astrophysical feedback (given by ). In particular, throughout CAMELS’ suites, the astrophysical parameters represent the value of subgrid physics parameters that influence stellar and Active Galactic Nuclei (AGN) feedback mechanisms.
We made use of the Latin Hypercube, LH, set within each suite of CAMELS, which contains 1,000 simulations whose cosmological and astrophysical parameters are arranged in a latin-hypercube within a very broad range111We note that in the case of Astrid, the parameter varies between 0.25 and 4.
(1) | |||||
(2) | |||||
(3) | |||||
(4) |
and every simulation has a different value of the initial random seed. Within each LH set, CAMELS provides 1,000 simulations for each redshift that span a wide range of cosmologies and baryonic feedbacks, perfect for our purposes of capturing the underlying physics.
Importantly, each suite has been run with a different code and therefore the subgrid physics model is completely different. So, notably, while the range of variation of the above parameters remains consistent across all CAMELS suites, the precise definitions and overall impact of these astrophysical parameters vary significantly across suites. These simulations are designed to train and set machine learning algorithms given the way their cosmological, astrophysical, and initial random seed parameters are set. We utilize this set for each suite throughout this paper to train and test our methodology on simulations with significantly different cosmologies and astrophysics.
Figure 1 shows the baryonic effect in the matter power spectrum, , across different redshift values in all CAMELS suites utilized in this study. From the figure, it is clear that baryonic feedback can have very diverse and strong effects on the matter power spectrum, especially on small scales. SIMBA, with its aggressive AGN feedback, produces the most prominent suppression of the matter power on large scales. On the other hand, IllustrisTNG exhibits a more moderate impact on the matter power spectrum as a consequence of having milder AGN feedback, and Astrid spans the widest range of baryonic feedback, encompassing effects seen in both SIMBA and IllustrisTNG.












To cover the broadest range of baryonic feedback, based on Figure 1, we used simulations from the Astrid suite at to train our emulator. For selecting the training simulations, we performed a random sampling of 800 simulations (out of the 1000 available) from the Astrid suite within CAMELS at .
Post-training, we test the emulator using the remaining 200 simulations from Astrid at alongside all other available hydrodynamic simulation suites in CAMELS. Figure 2 illustrates the matter power spectrum ratio in the Astrid test data. Additionally, the IllustrisTNG suite and the SIMBA suite are part of the test dataset.

Previous studies (Heitmann et al., 2014; Smith et al., 2014; Rasera et al., 2014; Heitmann et al., 2013) have shown that both high physical resolution and large box sizes are required to guarantee convergence of the power spectrum. Schneider & Teyssier (2015) showed that deviations of the power spectrum ratio using small boxes, like in CAMELS, are at the level. However, these could also be due to cosmic variance which affects the small CAMELS-like box volumes. To study the effects of cosmic variance on the matter power spectrum ratio, we show the ratios for simulations with the same cosmology and astrophysics from CAMELS-Astrid’s CV set in figure 3. From this, we can see that the matter power spectrum ratio is affected by cosmic variance up to on small scales, suggesting that the deviations for small boxes are due to cosmic variance.

In addition to the diverse array of simulations in CAMELS, we extended the validation of our emulator by testing it against simulations outside the CAMELS database. These external simulations, including BAHAMAS (McCarthy et al., 2017, 2018), Horizon AGN (Dubois et al., 2014), Owls (Schaye et al., 2010; van Daalen et al., 2011), and Eagle (Schaye et al., 2015; Crain et al., 2015; McAlpine et al., 2016; Hellwing et al., 2016), serve as crucial benchmarks to assess the robustness and generalizability of the emulator’s predictions beyond CAMELS. These simulations encompass various diverse physical processes including AGN feedback, supernovae feedback, mass loss from Asymptotic Giant Branch stars, radiative cooling, stellar winds, and stellar initial mass function, among others. Additionally, these simulations differ from those in CAMELS in volume, resolution, and subgrid physics code (van Daalen et al., 2020), enabling us to test the robustness of our emulator to these effects. The solid lines in the left panel of Figure 6 illustrate the matter power spectrum ratio derived from these external simulations, allowing us to assess how the emulator performs across varied simulations beyond the scope of the CAMELS.
3 Baryonic effects at the field-level
In this section, we present our methodology to model baryonic effects at the field level for the total matter density field. We start by computing the cross-correlation coefficient between the matter field in full hydrodynamic simulations and their N-body counterparts. The cross-correlation coefficient, , is defined as:
(5) |
Here, , , and represent the cross-power spectrum, the N-body power spectrum, and the power spectrum of the hydrodynamic fields respectively. This coefficient’s range spans from to , where values closer to signify a strong positive linear relationship, indicates a strong negative linear relationship and implies no linear relationship between the datasets.
Figure 4 shows the cross-correlation coefficients derived from all CAMELS suites at different redshift values pertinent to this study. These coefficients serve as indicators of the correlation strength between N-body and hydrodynamic fields within the simulations.
We can see that the calculated cross-correlation coefficients are very close to 1, down to h/Mpc, for all the simulations, with most deviations being within . On the other hand, we see in Figure 1 that baryonic effects can cause deviations of up to on the matter power spectrum, with the effects getting more dominant at smaller scales. This suggests that the baryonic effects predominantly impact the amplitude of the Fourier modes (given by the power spectrum) rather than their phases (given by cross-correlation coefficients).
Since the amplitude and phase of the Fourier modes completely describe the fields, with baryonic effects mainly changing the amplitudes, aligning the power spectra of N-body fields with their hydrodynamic counterparts would also effectively align them at the field level, facilitating a cost-effective field-level analysis using just N-body simulations.
We can achieve this power spectra alignment by applying a transfer function to the N-body fields (Bond & Szalay, 1983; Seljak & Zaldarriaga, 1996). Transfer functions operate by performing specific modifications to the field data. In Fourier space, each mode of a field is represented by its amplitude, typically denoted by , and its phase. Transfer functions act on to alter their amplitudes according to certain criteria (Peacock, 1999; Dodelson, 2003).
The field-level transformation using a transfer function, , is mathematically defined as:
(6) |
Here, symbolizes the original field in Fourier space, and represents the transformed field in Fourier space after the element-wise application of the transfer function to the original field . This transformation enables the adjustment of simulated fields to match desired characteristics or observational data, enhancing the accuracy or realism of the simulation results.
In our context of incorporating baryonic effects in N-body simulations, we apply a transfer function to the simulated field to adjust its power spectrum. Defining baryonic suppression as:
(7) |
Our field transformation on N-body fields is then:
(8) |
This could increase or suppress the power of certain scales and correct discrepancies arising from missing baryonic physics effects in N-body simulations, aligning the power spectra of N-body fields with the full hydrodynamic fields.












4 Gaussian Process Emulator
To fulfill the promise of field-level modeling of baryonic effects, we need to characterize for our transfer function. In this section, we describe the main numerical methods we use to create our emulator of using Gaussian Processes.
Gaussian Processes (GPs) (Rasmussen et al., 2004) are a versatile tool within machine learning and statistics, renowned for their efficacy in regression, interpolation, and uncertainty quantification. They provide a flexible framework for modeling functions along with their associated uncertainties (e.g. Bird et al., 2019; Rogers et al., 2019; Rogers & Peiris, 2021; Pedersen et al., 2021). Moreover, a Gaussian process emulator is computationally efficient, enabling its use within standard inference methodologies such as Markov Chain Monte Carlo (MCMC) for evaluations.
For the length scales we want to model, the CAMELS simulations have 39 linearly-spaced bins spanning the range h/Mpc. Hence, to model baryonic effects at small scales down to , our emulator delineates these 39 linearly-spaced bins. We treat the baryonic effects in each bin as an individual Gaussian process, enabling independent training for each bin, with every simulation serving as a training point for these bins.
At a specific point in the parameter space, a Gaussian process models the target function — in our case — as an assembly of random variables that form a joint Gaussian distribution. This model is defined via , where signifies the parameter values at the training simulations, and represents a covariance kernel.
The choice of the kernel function plays a pivotal role in characterizing the correlation or similarity between data points and . This function serves as a prior, encapsulating the expected behavior of the underlying function — baryonic effects in our case — to be modeled. For our emulator, we adopt a Matérn 5/2 kernel, a generalized form of the radial basis function (RBF), defined by:
(9) |
Here, represents the L2 distance between two data points, denotes the variance parameter, and signifies the length scale of each input dimension, influencing the smoothness and range of correlations between data points. Our choice of this covariance kernel is motivated by the need for flexibility, achieved through the squared exponential kernel, the efficacy of linear interpolation, and allowing for noise in the training data.
At a test point , the joint distribution of the test data and training data can be expressed as:
(10) |
Here, serves as a hyperparameter signifying Gaussian noise within the training data.
Consequently, our Gaussian process involves a total of 8 hyperparameters: 6 correlation lengths, , and . The hyperparameters are optimized by maximizing the marginal log-likelihood of the training data (Rasmussen et al., 2004).
The posterior predictive distribution over test data is obtained through:
(11) | |||
(12) | |||
(13) |
The mean and variance derived from the posterior predictive distribution, using the training information at , serve as estimators for the value and interpolation uncertainty associated with .
We implement our emulator using tinygp (Foreman-Mackey et al., 2022), a Python library for GP Regression (GPR) built on top of the JAX library for numerical computing (Bradbury et al., 2018).
The GP model offers a broad prior across function space, enabling the modeling of the diverse baryonic effects we see in figure 1 without imposing strong prior constraints on its parameter dependencies. Since it is stochastic, this model provides predictions for the baryonic suppression beyond the training points, accompanied by associated uncertainties that can be integrated into our statistical model. This emulation methodology provides a robust approach for modeling and predicting the baryonic effects in simulations, enabling efficient and accurate interpolation, and quantification of uncertainties.
5 Results
In this section, we use the trained Gaussian Process emulator to generate predictions for as a function of four astrophysical parameters - within their respective ranges. We emphasize that our emulator was trained on Astrid simulations at , and therefore, the meaning of these astrophysical parameters is, in principle, associated with the Astrid subgrid physics model. However, to make our emulator generic and robust, from now on, we will consider these four astrophysical parameters as nuisance parameters that one needs to tune to reproduce the result of one particular hydrodynamic simulation.
We employ the differential evolution global optimizer from the SciPy library (Virtanen et al., 2020) to obtain the best-fit value of these nuisance parameters. This optimization technique is adept at exploring the parameter space to seek optimal solutions, especially in scenarios with complex, multi-dimensional parameter spaces. The differential evolution (Storn, 1996; Storn & Price, 1997; Price et al., 2005) method operates stochastically, offering a non-gradient approach to locating the minimum and can search through large volumes in parameter space.
We now show the accuracy of our emulator for simulations within and outside CAMELS, showing its precision to changes in simulation cosmology, feedback, subgrid physics, resolution, volume, and redshift. On top of that, we compare the accuracy of our emulator against other emulators in the literature. Finally, we demonstrate the emulator’s efficacy in creating field-level improvements when applied to the N-body fields of simulations within CAMELS, validating its potential for advancing field-level weak-lensing analyses using cosmological simulations.
5.1 Emulator accuracy
We start by quantifying the accuracy of our emulator across hydrodynamic simulations.
-
•
CAMELS simulations. Figure 5 shows the error achieved by our emulator for simulations of three different suites of CAMELS (IllustrisTNG, Astrid, and SIMBA) at four different redshifts. The solid lines represent the average percent error across simulations, while the shaded regions denote the 90th percentile range. These results correspond to all the baryonic effects illustrated in figure 1. Firstly, we can see that the emulator achieves a high accuracy down to h/Mpc with deviations remaining typically less than 5%. We emphasize that our emulator is robust to changes in redshifts and baryonic effects across CAMELS.
The performance of the emulator is similar across redshifts for the Astrid and IllustrisTNG simulations at all scales, with higher accuracy at large scales and somewhat lower precision at smaller scales. However, at and , the prediction error for SIMBA can be as high on large scales. This is likely due to the aggressive AGN feedback in SIMBA, which produces the most prominent suppression of the matter power on large scales (Gebhardt et al., 2023) as seen even in the comparison plots in Figure 1. Nonetheless, the prediction error is still within and is comparable to the other two suites at .
-
•
Non-CAMELS simulations. While the above test shows the robustness of our emulator to changes in cosmology, astrophysics, and subgrid physics, we note that all CAMELS simulations share the same volume and resolution. In order to quantify how well our emulator behaves to changes in volume, resolution, and other subgrid physics models, we quantify how well it is able to reproduce the results of the BAHAMAS, Horizon AGN, Owls, and Eagle simulations. We show the results in Figure 6.
The left panel shows the correction to the matter power spectrum in these simulations; solid lines represent the simulation results, while the corresponding dashed line depicts our emulator’s predictions. The emulator closely mirrors the inherent behavior of baryonic effects across these varied simulations. In the right panel, the prediction errors for each simulation are displayed. Consistently, the emulator maintains accuracy at the percent level up to h/Mpc, adeptly capturing the intricacies of baryonic effects across diverse scenarios. All the above tests clearly illustrate the versatility and robustness of our emulator, which is capable of reproducing the ratio for thousands of simulations with different cosmologies, astrophysics, subgrid physics, volumes, resolutions, and redshifts.














5.2 Comparison against other emulators
In recent years, different groups have created emulators to model baryonic effects for 2-point statistics. Given the findings of this work, we can also use those emulators to create field-level baryonic effects corrections. In this subsection, we conduct comparative evaluations against widely used emulators such as BACCO, HMcode, and BCemu, both within and beyond the CAMELS simulations. Through the following comparisons, we show that, overall, our emulator offers greater flexibility and robustness in modeling baryonic effects compared to the other emulators.
-
•
BACCO: BACCO is a neural network-based emulator that accounts for baryonic effects in the non-linear matter power spectrum (Aricò et al., 2021b). BACCO encompasses a parameter set comprising 8 cosmological parameters, consisting of the standard 5 CDM parameters combined with massive neutrinos and dynamical dark energy. Additionally, it includes 7 free baryonic parameters derived from physical principles, describing factors such as the gas fraction retained in halos, the intensity of AGN feedback, the characteristic galaxy mass, and the relationship between gas fractions and halo mass. In addition to the 7 free parameter model, BACCO also has 3 and 1 parameter models. When not included in the model, the baryonic parameters are fixed at their fiducial values. BACCO achieves an overall precision of 1-5% across its models and its targeted scales ( h/Mpc) and redshifts (), encompassing various cosmological hydrodynamic simulations. However, BACCO’s capacity to confidently predict the baryon-corrected power spectrum is limited to a maximum wavenumber of k = 4.7 h/Mpc, notably smaller than our emulator’s range. Furthermore, its range of validity is narrower than GPemu: and . As a result, only 39 out of the 200 Astrid test simulations are within BACCO’s specified cosmology range.
The left panel of Figure 7 shows the comparison between BACCO’s predictions (including the 7, 3, and 1 parameter models) and our emulator’s predictions on these limited 39 simulations. The solid lines represent the average percent error, while the shaded regions depict the 90th percentile of errors. The dash-dotted and dotted lines illustrate the 90th percentile outputs for BACCO’s 3 and 1 parameter emulators, respectively. The comparison results for the SIMBA and IllustrisTNG suites are similar. In Figure 8 we compare GPemu against BACCO for the non-CAMELS simulations.
Overall, we find that GPemu exhibits an accuracy similar to that of BACCO, but its range of validity, both in terms of scales and parameter-space, is wider.
-
•
HMcode: The HMcode (Mead et al., 2021a, b) is a simple halo model designed to simulate the influence of baryonic feedback on the power spectrum. It incorporates a six-parameter physical framework that includes gas expulsion by AGN feedback and encapsulates star formation. The feedback model was fitted to simulation data, taken from the library of van Daalen et al. (2020).
In our evaluation, similar to the comparison conducted against BACCO, we conducted a side-by-side analysis of HMcode’s predictions alongside our emulator’s outcomes using Astrid test data. The results of this comparison are illustrated in the middle panel of Figure 7, with solid lines representing the average percent error and shaded regions depicting the 90th percentile of the errors. We can see that our emulator demonstrates comparable performance to HMcode on larger scales while exhibiting higher accuracy on smaller scales where baryonic effects are stronger. A similar conclusion can be reached by comparing HMCode against GPemu for non-CAMELS simulations as shown in Figure 8.
-
•
BCemu: The BCemu emulator (Giri & Schneider, 2023) focuses on modeling the baryonic suppression of the matter power spectrum. It is based on a slightly modified version of the baryonification model (Schneider et al., 2019) and features seven physically-meaningful free-parameters related to gas profiles and stellar abundances within halos. BCemu demonstrated its capability to replicate the power spectra of hydrodynamical simulations with sub-percent precision. Moreover, it established a correlation between the baryonic suppression of the power spectrum and the gas and stellar fractions within halos. However, similar to BACCO, BCemu is constrained by its limited acceptance range for cosmological parameters (), encompassing only 148 out of the 200 Astrid test simulations.
The right panel of Figure 7 compares BCemu’s predictions with those of our emulator within this subset, with solid lines representing the average percent error and shaded regions depicting the 90th percentile of the errors. From Figure 8 we can see that GPemu performs similarly to BCemu when used on non-CAMELS simulations. While both emulators display comparable performance at all scales, our GP emulator shows greater flexibility and generality in its predictions of baryonic effects across a wider range of hydrodynamic simulations.











5.3 Field-level emulation
From Figure 4 we found that baryonic effects do not significantly affect the phases of Fourier modes down to . Thus, baryonic effects at the field level can be accounted for by correcting the amplitude of Fourier modes from N-body simulations. Now that we have an emulator for the ratio, , we can investigate how well our model performs at the field level. The resulting field-level transformations exhibit effective improvements, evident across multiple simulation suites at different redshifts.
In more detail, the procedure we employ to model baryonic effects at the field level is as follows. First, we take a given hydrodynamic simulation and its N-body counterpart. We then compute the power spectrum of each of them to compute the baryonic suppression: . Next, we fit the four free parameters of GPemu to get the best match to . Then, from the N-body simulation, we compute the matter density field and its Fourier transform: . Finally, we obtain the baryon-corrected field by Fourier transforming back , where
(14) |
with being the transfer function predicted by our emulator GPemu.
Figure 9 illustrates the baryonic correction of our method on IllustrisTNG when applied to N-body simulations across various redshifts. The first row displays a 2D projection of the whole 3D matter field with dimensions from a hydrodynamic simulation at four different redshifts. The second row shows the difference between the image from the hydrodynamic simulation and its N-body counterpart. The third row shows instead the difference between the hydrodynamic simulation and our field-level correction model. As expected, our field-level correction is more accurate than the N-body simulation, and the residual fluctuations (shown in red and blue) are due to small-scale modes where the cross-correlation coefficient deviates from 1.
















6 Conclusions
Field-level approaches have the potential to extract all the available information from cosmological surveys. Modeling and marginalizing over baryonic effects at the field-level becomes a key ingredient in these efforts. In this work we have developed a new method to model baryonic effects for the total matter density field, the relevant quantity for weak lensing analyses.
The key finding in this work is that by computing the cross-correlation between the total matter density field in hydrodynamic and N-body simulations from thousands of simulations of the CAMELS project (see Figure 4) we conclude that baryonic effects weakly affect the phases of Fourier modes of the total matter density field down to scales as small as . This finding implies that baryonic effects will predominantly modify Fourier mode amplitudes. Thus, we can baryonify the total matter field of an N-body simulation by rescaling its Fourier mode amplitudes.
In this work we have built an emulator using Gaussian processes for the total to dark matter power spectrum ratio that takes as input 2 cosmological parameters ( and ) and 4 astrophysical parameters (, , , ). We have trained our emulator using 800 state-of-the-art hydrodynamic simulations from the Astrid suite of CAMELS. We then show that our emulator is able to reproduce the baryonic effects of thousands of hydrodynamic simulations that have different cosmologies, astrophysics, subgrid physics, resolutions, volumes, and redshifts within a few percent precision.
We have compared our emulator against others in the literature, such as BACCO, HMCode, and BCemu. We find that our emulator shares a similar level of accuracy with those, but it has a wider range of validity given that it has been trained on CAMELS, where variations in cosmology and astrophysics are very large. We also showed explicitly how using our method reduces the residuals when working at the field level by comparing the results of hydrodynamic simulations against baryonified N-body simulations. A limitation of using CAMELS is that the box size is very small, and baryonic effects may not be fully captured due to the absence of larger halos in these simulation boxes. This will need to be investigated in more detail using a suite of simulations varying box size.
Our emulator enables robust, cost-effective field-level weak lensing modeling and facilitates precise power spectra analyses at the two-point level. The versatility and accuracy of our GP baryonification emulator underscore its potential as a powerful tool in cosmological simulations, offering opportunities for enhanced analyses and deeper insights into baryonic effects in large-scale structures. However, whether this emulator suffices at the field level depends on the specifics of the observational program. For example, for weak lensing, this will require making weak lensing maps using ray-tracing techniques. The overall detectability of the effects that go beyond our field level emulator in the the weak lensing depends on the density of background galaxies and the observed area of the sky. This analysis goes beyond the purpose of this paper, and will be presented elsewhere.
Acknowledgements
We thank Raul Angulo and Aurel Schneider for their comments on the usage of the BACCO and BCemu emulators. DS thanks James Sullivan for helpful discussions on Gaussian processes. The work of FVN is supported by the Simons Foundation. The CAMELS project is supported by the Simons Foundation and the NSF grant AST 2108078.
References
- Angulo et al. (2021) Angulo R. E., Zennaro M., Contreras S., Aricò G., Pellejero-Ibañez M., Stücker J., 2021, Monthly Notices of the Royal Astronomical Society, 507, 5869–5881
- Aricò et al. (2021a) Aricò G., Angulo R. E., Contreras S., Ondaro-Mallea L., Pellejero-Ibañez M., Zennaro M., 2021a, MNRAS, 506, 4070
- Aricò et al. (2021b) Aricò G., Angulo R. E., Contreras S., Ondaro-Mallea L., Pellejero-Ibañez M., Zennaro M., 2021b, MNRAS, 506, 4070
- Bird et al. (2019) Bird S., Rogers K. K., Peiris H. V., Verde L., Font-Ribera A., Pontzen A., 2019, Journal of Cosmology and Astroparticle Physics, 2019, 050–050
- Bird et al. (2022) Bird S., Ni Y., Di Matteo T., Croft R., Feng Y., Chen N., 2022, MNRAS, 512, 3703
- Bocquet et al. (2020) Bocquet S., Heitmann K., Habib S., Lawrence E., Uram T., Frontiere N., Pope A., Finkel H., 2020, ApJ, 901, 5
- Bond & Szalay (1983) Bond J. R., Szalay A. S., 1983, ApJ, 274, 443
- Bradbury et al. (2018) Bradbury J., et al., 2018
- Crain et al. (2015) Crain R. A., et al., 2015, MNRAS, 450, 1937
- Cranmer et al. (2020) Cranmer K., Brehmer J., Louppe G., 2020, Proceedings of the National Academy of Sciences, 117, 30055
- Dai & Seljak (2021) Dai B., Seljak U., 2021, Proceedings of the National Academy of Science, 118, 2020324118
- Dai & Seljak (2022) Dai B., Seljak U., 2022, Monthly Notices of the Royal Astronomical Society, 516, 2363
- Dai et al. (2018) Dai B., Feng Y., Seljak U., 2018, Journal of Cosmology and Astroparticle Physics, 2018, 009
- Davé et al. (2016) Davé R., Thompson R., Hopkins P. F., 2016, MNRAS, 462, 3265
- Di Matteo et al. (2005) Di Matteo T., Springel V., Hernquist L., 2005, Nature, 433, 604–607
- Dodelson (2003) Dodelson S., 2003, Modern Cosmology. Academic Press, Amsterdam
- Dubois et al. (2014) Dubois Y., et al., 2014, MNRAS, 444, 1453
- Euclid Collaboration et al. (2019) Euclid Collaboration et al., 2019, MNRAS, 484, 5509
- Feng et al. (2018) Feng Y., Bird S., Anderson L., Font-Ribera A., Pedersen C., 2018, MP-Gadget/MP-Gadget: A tag for getting a DOI, doi:10.5281/zenodo.1451799, https://doi.org/10.5281/zenodo.1451799
- Foreman-Mackey et al. (2022) Foreman-Mackey D., Yadav S., theorashid Fowlie A., Tronsgaard R., Schmerler S., Killestein T., 2022, dfm/tinygp: v0.2.3, doi:10.5281/zenodo.7269074, https://doi.org/10.5281/zenodo.7269074
- Gebhardt et al. (2023) Gebhardt M., et al., 2023, Cosmological baryon spread and impact on matter clustering in CAMELS (arXiv:2307.11832)
- Giri & Schneider (2023) Giri S. K., Schneider A., 2023, BCemu: Model baryonic effects in cosmological simulations, Astrophysics Source Code Library, record ascl:2308.010 (ascl:2308.010)
- Hahn et al. (2023) Hahn C., et al., 2023, arXiv e-prints, p. arXiv:2310.15246
- Heitmann et al. (2013) Heitmann K., Lawrence E., Kwan J., Habib S., Higdon D., 2013, The Astrophysical Journal, 780, 111
- Heitmann et al. (2014) Heitmann K., Lawrence E., Kwan J., Habib S., Higdon D., 2014, ApJ, 780, 111
- Hellwing et al. (2016) Hellwing W. A., Schaller M., Frenk C. S., Theuns T., Schaye J., Bower R. G., Crain R. A., 2016, Monthly Notices of the Royal Astronomical Society: Letters, 461, L11–L15
- Hikage et al. (2019) Hikage C., et al., 2019, PASJ, 71, 43
- Hopkins (2015) Hopkins P. F., 2015, Monthly Notices of the Royal Astronomical Society, 450, 53–110
- Huang et al. (2019) Huang H.-J., Eifler T., Mandelbaum R., Dodelson S., 2019, Monthly Notices of the Royal Astronomical Society, 488, 1652
- Jenkins et al. (1998) Jenkins A., et al., 1998, The Astrophysical Journal, 499, 20–40
- Kilbinger (2015) Kilbinger M., 2015, Reports on Progress in Physics, 78, 086901
- Knabenhans et al. (2021) Knabenhans M., et al., 2021, Monthly Notices of the Royal Astronomical Society, 505, 2840–2869
- Köhlinger et al. (2016) Köhlinger F., Viola M., Valkenburg W., Joachimi B., Hoekstra H., Kuijken K., 2016, Monthly Notices of the Royal Astronomical Society, 456, 1508
- Köhlinger et al. (2017) Köhlinger F., et al., 2017, Monthly Notices of the Royal Astronomical Society, 471, 4412
- Lewis & Challinor (2011) Lewis A., Challinor A., 2011, CAMB: Code for Anisotropies in the Microwave Background, Astrophysics Source Code Library, record ascl:1102.026 (ascl:1102.026)
- Lu & Haiman (2021) Lu T., Haiman Z., 2021, Monthly Notices of the Royal Astronomical Society, 506, 3406–3417
- McAlpine et al. (2016) McAlpine S., et al., 2016, Astronomy and Computing, 15, 72
- McCarthy et al. (2017) McCarthy I. G., Schaye J., Bird S., Le Brun A. M. C., 2017, MNRAS, 465, 2936
- McCarthy et al. (2018) McCarthy I. G., Bird S., Schaye J., Harnois-Deraps J., Font A. S., van Waerbeke L., 2018, MNRAS, 476, 2999
- McClintock et al. (2019) McClintock T., et al., 2019, ApJ, 872, 53
- Mead et al. (2021a) Mead A. J., Brieden S., Tröster T., Heymans C., 2021a, MNRAS, 502, 1401
- Mead et al. (2021b) Mead A. J., Brieden S., Tröster T., Heymans C., 2021b, MNRAS, 502, 1401
- Ni et al. (2022) Ni Y., et al., 2022, MNRAS, 513, 670
- Ni et al. (2023) Ni Y., et al., 2023, arXiv e-prints, p. arXiv:2304.02096
- Peacock (1999) Peacock J. A., 1999, Cosmological Physics
- Pedersen et al. (2021) Pedersen C., Font-Ribera A., Rogers K. K., McDonald P., Peiris H. V., Pontzen A., Slosar A., 2021, Journal of Cosmology and Astroparticle Physics, 2021, 033
- Price et al. (2005) Price K., Storn R., Lampinen J., 2005, Differential Evolution-A Practical Approach to Global Optimization. Vol. 141, doi:10.1007/3-540-31306-0,
- Rasera et al. (2014) Rasera Y., Corasaniti P.-S., Alimi J.-M., Bouillot V., Reverdy V., Balmès I., 2014, Monthly Notices of the Royal Astronomical Society, 440, 1420
- Rasmussen et al. (2004) Rasmussen C., Bousquet O., Luxburg U., Rätsch G., 2004, Advanced Lectures on Machine Learning: ML Summer Schools 2003, Canberra, Australia, February 2 - 14, 2003, Tübingen, Germany, August 4 - 16, 2003, Revised Lectures, 63-71 (2004), 3176
- Rogers & Peiris (2021) Rogers K. K., Peiris H. V., 2021, Physical Review D, 103
- Rogers et al. (2019) Rogers K. K., Peiris H. V., Pontzen A., Bird S., Verde L., Font-Ribera A., 2019, Journal of Cosmology and Astroparticle Physics, 2019, 031–031
- Schaye et al. (2010) Schaye J., et al., 2010, MNRAS, 402, 1536
- Schaye et al. (2015) Schaye J., et al., 2015, MNRAS, 446, 521
- Schneider & Teyssier (2015) Schneider A., Teyssier R., 2015, Journal of Cosmology and Astroparticle Physics, 2015, 049–049
- Schneider et al. (2019) Schneider A., Teyssier R., Stadel J., Chisari N. E., Brun A. M. L., Amara A., Refregier A., 2019, Journal of Cosmology and Astroparticle Physics, 2019, 020–020
- Schneider et al. (2020) Schneider A., et al., 2020, Journal of Cosmology and Astroparticle Physics, 2020, 020–020
- Seljak & Zaldarriaga (1996) Seljak U., Zaldarriaga M., 1996, ApJ, 469, 437
- Smith et al. (2014) Smith R. E., Reed D. S., Potter D., Marian L., Crocce M., Moore B., 2014, Monthly Notices of the Royal Astronomical Society, 440, 249
- Springel (2010) Springel V., 2010, Monthly Notices of the Royal Astronomical Society, 401, 791–851
- Storn (1996) Storn R., 1996. pp 519 – 523, doi:10.1109/NAFIPS.1996.534789
- Storn & Price (1997) Storn R., Price K., 1997, Journal of Global Optimization, 11, 341
- Teyssier (2002) Teyssier R., 2002, A&A, 385, 337
- Torrey et al. (2014) Torrey P., Vogelsberger M., Genel S., Sijacki D., Springel V., Hernquist L., 2014, Monthly Notices of the Royal Astronomical Society, 438, 1985–2004
- Villaescusa-Navarro et al. (2021a) Villaescusa-Navarro F., et al., 2021a, arXiv preprint arXiv:2109.09747
- Villaescusa-Navarro et al. (2021b) Villaescusa-Navarro F., et al., 2021b, arXiv e-prints, p. arXiv:2109.10360
- Villaescusa-Navarro et al. (2021c) Villaescusa-Navarro F., et al., 2021c, ApJ, 915, 71
- Villaescusa-Navarro et al. (2023) Villaescusa-Navarro F., et al., 2023, The Astrophysical Journal Supplement Series, 265, 54
- Virtanen et al. (2020) Virtanen P., et al., 2020, Nature Methods, 17, 261–272
- Vogelsberger et al. (2013) Vogelsberger M., Genel S., Sijacki D., Torrey P., Springel V., Hernquist L., 2013, MNRAS, 436, 3031
- Weinberger et al. (2020) Weinberger R., Springel V., Pakmor R., 2020, ApJS, 248, 32
- Winther et al. (2019) Winther H. A., Casas S., Baldi M., Koyama K., Li B., Lombriser L., Zhao G.-B., 2019, Physical Review D, 100
- Zhai et al. (2019) Zhai Z., et al., 2019, ApJ, 874, 95
- van Daalen et al. (2011) van Daalen M. P., Schaye J., Booth C. M., Dalla Vecchia C., 2011, MNRAS, 415, 3649
- van Daalen et al. (2020) van Daalen M. P., McCarthy I. G., Schaye J., 2020, MNRAS, 491, 2424