Inpainting Galaxy Counts onto N-Body Simulations over Multiple Cosmologies and Astrophysics

Antoine Bourdin, Ronan Legin, Matthew Ho, Alexandre Adam, Yashar Hezaveh, Laurence Perreault-Levasseur · DOI

Abstract

Cosmological hydrodynamical simulations, while the current state-of-the art methodology for generating theoretical predictions for the large scale structures of the Universe, are among the most expensive simulation tools, requiring upwards of 100 million CPU hours per simulation. N-body simulations, which exclusively model dark matter and its purely gravitational interactions, represent a less resource-intensive alternative, however, they do not model galaxies, and as such cannot directly be compared to observations. In this study, we use conditional score-based models to learn a mapping from N-body to hydrodynamical simulations, specifically from dark matter density fields to the observable distribution of galaxies. We demonstrate that our model is capable of generating galaxy fields statistically consistent with hydrodynamical simulations at a fraction of the computational cost, and demonstrate our emulator is significantly more precise than traditional emulators over the scales 0.36 $h\ \text{Mpc}^{-1} \leq k \leq 3.88\ h\ \text{Mpc}^{-1}$.

Introduction

In modern cosmology, researchers face a significant trade-off between computational efficiency and physical detail. Hydrodynamical simulations represent the high-fidelity standard, modeling complex baryonic physics such as gas dynamics, star formation, and black hole feedback. However, these simulations are prohibitively expensive, often requiring over 100 million CPU hours for a single high-resolution run. Conversely, N-body simulations focus solely on dark matter and gravity. While they are significantly faster—scaling at $O(n \log n)$ compared to $O(n^2)$—they lack the baryonic components necessary for direct comparison with astronomical observations.

To bridge this gap, traditional methods employ Halo Occupancy Distribution (HOD) models, which use simplified mathematical prescriptions to populate dark matter halos with galaxies. However, HOD models often fail to account for local environmental effects and struggle to generalize across varying cosmological parameters. This work introduces a generative AI approach using conditional score-based diffusion models to "inpaint" realistic galaxy distributions onto N-body simulations, achieving high statistical accuracy with minimal computational overhead.

Methodology

The core of this approach is a conditional score-based diffusion model. Similar to modern image generation techniques, the model learns to reverse a stochastic process that gradually adds noise to the data.

Model Architecture and Training

The model utilizes a 3D U-Net architecture, which is essential for capturing both local galaxy-scale details and large-scale cosmic web structures. To handle the discrete nature of galaxy counts, the authors applied a log-transformation to the counts, enabling the continuous diffusion model to accurately represent voxels containing high galaxy densities. Furthermore, Fourier features (sinusoidal functions) were injected into the input to help the network learn high-frequency details and sharp density gradients between neighboring voxels.

Dataset: CAMELS-Astrid

The model was trained on the CAMELS-Astrid simulation suite, consisting of 1,000 pairs of N-body and hydrodynamical simulations. This dataset is uniquely diverse, with each pair featuring different cosmological parameters (e.g., matter density $\Omega_m$) and astrophysical parameters (e.g., galactic wind strength). The data was partitioned into 900 simulations for training and 100 for testing, with each volume gridded onto a $32^3$ voxel space representing $(25\ \text{Mpc}/h)^3$.

Key Results and Insights

The diffusion model demonstrates a massive speedup, generating 100 galaxy realizations for a given dark matter field in approximately 20 minutes on 20 GPUs—a task that would take millions of CPU hours using traditional hydrodynamical methods.

Comparison of N-body dark matter density (top left), Hydro Sim ground truth (bottom left), and the generated galaxy counts from HOD and Diffusion models (right). The diffusion model captures the stochasticity and spatial structure more accurately than the HOD baseline.

Statistical Fidelity and Generalization

The model's predictions for the galaxy power spectrum and spatial cross-correlation significantly outperformed the HOD baseline. Notably, the model exhibits implicit marginalization: it was not explicitly provided with cosmological parameters during training but learned to infer them from the dark matter distribution. This allows it to generalize to "Universes" with parameters outside its training set. Additionally, as a probabilistic model, it captures the inherent stochasticity of galaxy formation by generating multiple plausible realizations for a single dark matter input.

Limitations and Future Work

While the results are promising, the study identifies areas for improvement. The current model was trained on a relatively small dataset (900 simulations), and performance could likely be enhanced through data augmentation or pre-training on larger volumes.

TARP coverage test results. The plot shows that while the Diffusion model is more accurate than HOD, it exhibits a slight calibration bias at lower credibility values.

As shown in the TARP (Test of Accuracy with Random Points) coverage test, there is a slight bias in the model's uncertainty calibration. Future efforts will focus on refining this calibration and scaling the model to "outpaint" much larger volumes, aligning with the requirements of upcoming massive sky surveys like Euclid and the Vera C. Rubin Observatory.

Summary updated

BibTeX
@inproceedings{bourdin2024inpainting,
  author = {Antoine Bourdin and Ronan Legin and Matthew Ho and Alexandre Adam and Yashar Hezaveh and Laurence Perreault-Levasseur},
  title = {{Inpainting Galaxy Counts onto N-Body Simulations over Multiple Cosmologies and Astrophysics}},
  booktitle = {AI4Science @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=jFZvD2dgUM},
}
Figure