Author’s note: This article is part of Apiary’s “Deep Dives” series, where we explore how the grandest scientific tools intersect with the humble world of bees and the emerging field of self‑governing AI. The aim is to give you a clear, data‑rich picture of why virtual universes matter – and what they can teach us about stewardship on Earth.
Introduction: Why Simulating the Cosmos Matters
When we look up on a clear night, the Milky Way stretches across the sky like a faint river of stars. Those points of light are only the tip of an intricate cosmic iceberg that extends billions of light‑years, containing galaxy clusters, filaments, and voids that together form the large‑scale structure of the universe. Understanding how such structures emerged from the hot, dense state of the Big Bang is not a luxury for astronomers; it is a cornerstone of modern physics.
Cosmological simulations translate the equations of general relativity, quantum mechanics, and thermodynamics into billions of virtual particles that evolve under gravity and other forces. By reproducing the observed distribution of galaxies, the cosmic microwave background (CMB), and the statistics of dark matter halos, these simulations become laboratories where we can test theories that are otherwise inaccessible. They let us ask “what if?” about the early universe, explore the consequences of different dark matter candidates, and predict the fate of the galaxies we see today.
Beyond pure science, the methods and insights from cosmological modeling echo in other complex systems—most notably in the organization of bee colonies and the governance of autonomous AI agents. Hierarchical structures, feedback loops, and emergent behavior are common threads that tie together a galaxy’s evolution, a hive’s productivity, and the ethical deployment of self‑learning software. In the sections that follow, we will travel from the first fractions of a second after the Big Bang to the present‑day sky, unpacking the physics, the numerics, and the real‑world relevance of cosmological simulations.
1. The Cosmic Canvas: From the Big Bang to Large‑Scale Structure
The universe’s story begins 13.8 billion years ago with a rapid expansion called inflation. In the first 380 000 years, the plasma of photons, electrons, and baryons cooled enough for neutral hydrogen to form, releasing the CMB—a nearly uniform glow at 2.73 K that we still detect today. Tiny temperature fluctuations in the CMB, measured by the Planck satellite to a precision of 1 µK, encode the seeds of all later structure.
These primordial perturbations are best described by a nearly scale‑invariant power spectrum, $P(k) \propto k^{n_s}$ with $n_s \approx 0.965$. In a universe dominated by cold dark matter (CDM), the overdense regions grow linearly with the scale factor $a(t)$ until they become non‑linear, collapsing into bound halos. The resulting web of filaments, sheets, and voids—often called the “cosmic web”—was first visualized in N‑body simulations in the 1980s (e.g., the Cold Dark Matter simulation by Davis et al., 1985).
Modern simulations now start from a box that can be as large as 1 Gpc (gigaparsec) on a side, containing a volume of $10^9$ Mpc$^3$. Within this volume, the distribution of dark matter particles follows the initial Gaussian random field derived from the CMB. As the simulation evolves, gravity pulls matter together, forming a hierarchy of structures: small halos merge into larger ones, and the largest halos host galaxy clusters with masses up to $10^{15}\,M_\odot$ (the mass of the Coma Cluster).
The significance of the large‑scale structure is twofold. First, it provides a statistical test for cosmological parameters: the correlation function of galaxies, the abundance of massive clusters, and the lensing shear pattern all depend sensitively on $\Omega_m$, $\sigma_8$, and the dark energy equation of state $w$. Second, the environment set by the cosmic web influences galaxy formation—dense nodes nurture massive ellipticals, while underdense voids host low‑mass, late‑type spirals.
2. Building the Simulation: Physics, Numerics, and Supercomputers
Creating a faithful model of the universe demands a marriage of physics, mathematics, and raw computing power. The core of any cosmological simulation is an N‑body solver that computes the gravitational interaction among $N$ particles. Direct pairwise calculation scales as $O(N^2)$ and becomes infeasible beyond $N \sim 10^6$. To reach the billions of particles required for modern runs, scientists use hierarchical algorithms such as the Barnes‑Hut tree method (scales as $O(N \log N)$) or the Particle‑Mesh (PM) approach, which solves Poisson’s equation on a grid via Fast Fourier Transforms (FFTs).
A typical state‑of‑the‑art run—like the IllustrisTNG suite—employs $2 \times 1820^3 \approx 12$ billion particles in a $(75\,\text{Mpc})^3$ box, achieving a dark matter particle mass of $7.5 \times 10^6\,M_\odot$ and a baryonic (gas) cell mass of $1.4 \times 10^6\,M_\odot$. The gravitational softening length, which prevents artificial two‑body scattering, is set to $\sim 0.7$ kpc (physical) for dark matter and $\sim 0.35$ kpc for stars.
Hydrodynamics is added using either Smoothed Particle Hydrodynamics (SPH) or Adaptive Mesh Refinement (AMR). SPH treats gas as particles with a smoothing kernel, while AMR refines a grid where density or temperature gradients exceed a threshold. The AREPO moving‑mesh code, used by IllustrisTNG, blends the best of both worlds: it follows gas parcels like SPH particles but solves the Euler equations on an ever‑changing Voronoi tessellation, preserving Galilean invariance and reducing numerical diffusion.
Time integration is performed with a leapfrog or Runge‑Kutta scheme, often employing adaptive time steps. The Courant–Friedrichs–Lewy (CFL) condition ensures that fluid signals do not cross more than one cell per step, while the gravitational time step is limited by the local dynamical time $\tau_{\rm dyn} \sim \sqrt{r^3 / G M}$.
Running such a simulation requires petaflop‑scale supercomputers. For example, the IllustrisTNG TNG100 run consumed roughly 30 million CPU‑hours on the Stampede2 cluster, equivalent to running 3,400 cores continuously for a year. The data output—often 1–2 PB (petabytes) of particle snapshots, halo catalogs, and derived fields—must be stored, indexed, and made accessible through high‑performance data portals.
3. Dark Matter and Dark Energy: The Invisible Scaffold
The visible universe is only the luminous frosting on a massive, invisible cake. Dark matter, comprising about 27 % of the cosmic energy budget, dominates the gravitational potential that guides structure formation. In the CDM paradigm, dark matter is assumed to be cold (i.e., non‑relativistic at early times) and collisionless, interacting only through gravity.
Simulations test the CDM hypothesis by varying the particle mass and interaction cross‑section. Warm dark matter (WDM) models, with particle masses of a few keV, suppress small‑scale power, leading to fewer dwarf‑galaxy‑size halos. The ELVIS suite of simulations demonstrated that a WDM particle of 2 keV would reduce the number of subhalos around a Milky Way‑mass halo by roughly 30 % compared with CDM, a difference that can be probed by counting satellite galaxies in the Local Group.
Dark energy, responsible for the accelerated expansion discovered in 1998, enters simulations as a background component characterized by the equation of state $w = p/\rho$. The simplest model, a cosmological constant $\Lambda$, has $w = -1$. Simulations that adopt $w = -0.9$ or evolve $w(z)$ with a Chevallier‑Polarski‑Linder (CPL) parametrization produce noticeably different growth rates for large‑scale structure. The DEUSS (Dark Energy Universe Simulation Series) project showed that a 5 % change in $w$ alters the cluster mass function at $z=0$ by roughly 10 %, a shift detectable by upcoming surveys such as Euclid and the Vera C. Rubin Observatory (formerly LSST).
Both dark matter and dark energy are therefore not merely background terms; they actively shape the timing, abundance, and internal dynamics of galaxies. By comparing simulated halo mass functions, velocity dispersions, and lensing maps with observations, researchers constrain the nature of these invisible components.
4. Baryonic Physics: Gas, Stars, and Feedback
While dark matter provides the skeleton, baryons (ordinary matter) flesh out galaxies with gas, stars, and black holes. Modeling baryonic processes is the most challenging aspect of cosmological simulations because it involves a wide range of scales—from sub‑parsec star formation to megaparsec‑scale outflows.
Gas cooling and heating. Gas in dark matter halos can radiatively cool via atomic transitions (e.g., hydrogen Lyman‑α, metal lines) and molecular cooling (e.g., CO). The cooling rate $\Lambda(T, Z)$ depends on temperature $T$ and metallicity $Z$, with metal‑line cooling becoming dominant for $T \gtrsim 10^5$ K. Simulations implement cooling tables derived from photoionization codes like CLOUDY. In addition, a uniform ultraviolet background (e.g., the Haardt‑Madau 2012 model) photo‑heats low‑density gas, suppressing star formation in low‑mass halos—an effect known as “reionization feedback”.
Star formation. Because individual stars cannot be resolved, simulations adopt a sub‑grid prescription: gas above a density threshold (e.g., $n_{\rm H} > 0.13\,\text{cm}^{-3}$) and below a temperature floor (e.g., $T < 10^4$ K) is converted into stellar particles at a rate $\dot{\rho}\star = \epsilon{\rm SF}\,\rho_{\rm gas}/t_{\rm ff}$, where $t_{\rm ff}$ is the local free‑fall time and $\epsilon_{\rm SF}$ is the star‑formation efficiency (typically $0.01$–$0.02$).
Feedback. Without feedback, simulated galaxies become overly massive and compact, a problem known as the “overcooling catastrophe”. Stellar feedback injects energy, momentum, and metals back into the interstellar medium (ISM) via supernovae (SNe), stellar winds, and radiation pressure. For instance, each Type II SN releases $10^{51}$ erg of energy; in the EAGLE simulation, this energy is distributed thermally to neighboring gas particles with a stochastic heating temperature of $10^{7.5}$ K, ensuring that the heated gas can escape the dense ISM before radiating away.
Black hole feedback is equally crucial for massive galaxies. Supermassive black holes (SMBHs) accrete gas at rates estimated by the Bondi‑Hoyle formula, $\dot{M}{\rm BH} = \alpha\,4\pi G^2 M{\rm BH}^2 \rho / (c_s^2 + v^2)^{3/2}$, where $\rho$ is the local gas density, $c_s$ the sound speed, $v$ the relative velocity, and $\alpha$ a boost factor. The IllustrisTNG model distinguishes a “quasar mode” (high accretion, isotropic thermal injection) from a “kinetic mode” (low accretion, collimated jets) that can quench star formation in massive halos, reproducing observed red‑sequence galaxies.
Metal enrichment. Metals produced by SNe and asymptotic giant branch (AGB) stars are tracked as passive scalars, influencing cooling rates and providing observable signatures (e.g., O VI absorption). The metallicity distribution in the circumgalactic medium (CGM) of simulated $L^\star$ galaxies matches the column density profiles measured by the COS‑HALO survey, validating the feedback implementation.
These baryonic processes generate a complex, self‑regulating system where star formation fuels feedback, which in turn suppresses further star formation—a cosmic analogue of the feedback loops that keep a bee colony’s brood production in balance.
5. From Halos to Galaxies: The Hierarchical Assembly
The ΛCDM framework predicts that structure forms hierarchically: small dark matter halos collapse first, later merging to create larger systems. This “bottom‑up” scenario is evident in the merger trees extracted from simulations.
A typical Milky Way‑mass halo ($M_{200} \approx 1.2 \times 10^{12}\,M_\odot$) at $z=0$ has experienced roughly 30–40 significant mergers (mass ratio > 1:10) since $z=3$. The most massive of these, often called the “major merger”, can dramatically reshape the host galaxy. In the Auriga high‑resolution zoom‑in simulations, a $1:1$ merger at $z \approx 1.5$ transformed a disk‑dominated galaxy into a spheroidal system, suppressing subsequent thin‑disk formation for several gigayears.
Conversely, smooth accretion of diffuse gas—often called “cold flows”—can feed star formation without a disruptive merger. In low‑mass halos ($M_{200} < 10^{11}\,M_\odot$), gas streams along filaments at temperatures $T \sim 10^4$ K, penetrating deep into the halo and fueling a steady star‑formation rate (SFR) of $1$–$5\,M_\odot\,\text{yr}^{-1}$. This process is captured in the FIRE (Feedback In Realistic Environments) simulations, where the interplay of cold inflows and outflows sets the galaxy’s gas reservoir.
The stellar mass–halo mass (SMHM) relation, $M_\star/M_{\rm halo} \approx 0.02$ at the peak around $M_{\rm halo} \sim 10^{12}\,M_\odot$, emerges naturally from the balance of accretion and feedback. Below the peak, stellar efficiency drops sharply due to reionization and SN feedback; above the peak, AGN feedback curtails further star formation. This relation is a key benchmark: the EAGLE simulation matches the observed SMHM within 0.2 dex across five orders of magnitude in halo mass, confirming that the implemented physics can reproduce the observed galaxy population.
6. The Role of Galaxy Mergers and Interactions
Galaxy mergers are not merely a footnote; they are engines of morphological transformation, starburst activity, and SMBH growth. The frequency of mergers can be quantified by the merger rate per galaxy, $\mathcal{R}(M_\star, z) \approx 0.03\,(1+z)^{2.5}$ Gyr$^{-1}$ for galaxies with $M_\star > 10^{10}\,M_\odot$, as derived from the Illustris simulation.
Major mergers (mass ratios $> 1:3$) often trigger short‑lived but intense starbursts, raising the SFR by factors of $5$–$10$ for $\sim 100$ Myr. The classic example is the Antennae galaxies (NGC 4038/4039), whose tidal tails and overlapping nuclei are reproduced in idealized merger simulations that include detailed gas dynamics and feedback.
Minor mergers (mass ratios $1:10$–$1:4$) contribute to the steady buildup of stellar halos and thick disks. In the IllustrisTNG simulation, the stellar halo of a Milky Way analog contains $\sim 30$ % of its mass from accreted satellites, with most of the contribution arising from minor mergers between $z=2$ and $z=0.5$.
Interaction‑driven quenching is another pathway. When a massive satellite plunges through a larger host’s hot halo, ram‑pressure stripping can remove the satellite’s cold gas, halting star formation. This process explains the high fraction of quenched dwarf galaxies in the Local Group’s dense environment.
The dynamical friction timescale, $t_{\rm DF} \approx 1.17 \, \frac{r_{\rm circ}^2 V_c}{G M_{\rm sat} \ln \Lambda}$, defines how quickly a satellite spirals into the central galaxy, where $r_{\rm circ}$ is the circular orbit radius, $V_c$ the circular velocity, $M_{\rm sat}$ the satellite mass, and $\ln \Lambda$ the Coulomb logarithm. Simulations confirm that satellites with $M_{\rm sat} / M_{\rm host} > 0.1$ merge within a few gigayears, while lighter companions survive for longer periods, feeding the host’s stellar halo over extended timescales.
These merger-driven processes echo the way bee colonies integrate new foragers or absorb “drift” individuals from neighboring hives, adjusting the colony’s genetic and task composition. Both systems rely on stochastic encounters that can either reinforce the status quo or trigger a re‑organization.
7. Connecting Simulations to Observations: Surveys and Synthetic Skies
A simulation is only as valuable as its ability to predict observable quantities. The modern era of large‑scale surveys—SDSS, DESI, Euclid, Rubin—provides a wealth of data against which models are calibrated.
Mock catalogs are generated by projecting simulated galaxies onto a light cone that mimics the survey’s geometry, redshift distribution, and selection functions. For example, the Millennium simulation’s light‑cone catalogs were used to forecast the clustering signal expected in the BOSS galaxy redshift survey, allowing a direct comparison of the two‑point correlation function $ξ(r)$ and confirming the ΛCDM prediction to within 5 % on scales $1$–$50\,h^{-1}\,\text{Mpc}$.
Spectral energy distributions (SEDs) are assigned to simulated galaxies using stellar population synthesis models (e.g., FSPS). By adding dust attenuation based on the simulated gas and metal distribution, researchers produce realistic broadband colors that can be compared with the observed color–magnitude diagram (the “red sequence” and “blue cloud”). The EAGLE simulation reproduces the observed $g-r$ color bimodality for galaxies with $M_\star > 10^{10}\,M_\odot$ at $z=0$, indicating that its feedback implementation captures the quenching processes correctly.
Weak gravitational lensing provides a mass‑based probe that bypasses uncertainties in stellar mass estimates. Simulated lensing maps are constructed by integrating the projected mass density $\kappa$ along the line of sight, then comparing the shear power spectrum $C_\ell^{\gamma\gamma}$ with measurements from the KiDS and DES surveys. The Horizon‑AGN simulation matches the observed shear amplitude to within 10 % across $ℓ = 100$–$2000$, providing confidence that its treatment of baryonic physics does not overly suppress small‑scale power.
Cross‑linking to other Apiary topics: The methodology of creating synthetic skies parallels the generation of virtual habitats for bee colonies, where environmental parameters (flower density, pesticide exposure) are varied systematically to forecast colony health. Similarly, the statistical pipelines used to compare simulation output to real data echo the validation loops employed when training self‑governing AI Agents that must operate under real‑world constraints.
8. Lessons for Earth: Parallels with Bee Ecology and AI Governance
At first glance, the evolution of galaxies and the daily labor of honeybees seem worlds apart. Yet both systems are governed by a set of simple, local rules that give rise to complex, emergent structures.
Hierarchical organization. In a galaxy cluster, dark matter halos host individual galaxies, which in turn contain star clusters and planetary systems. In a hive, the colony is the top‑level entity, composed of sub‑units such as brood cells, forager groups, and the queen’s reproductive apparatus. In both cases, the health of the whole depends on the flow of resources across scales: gas inflows feed star formation just as nectar flows feed brood development.
Feedback regulation. Stellar feedback (supernovae, radiation pressure) injects energy that can expel gas, regulating star formation. Similarly, bees use “social immunity”—behaviors like grooming and hygienic removal of diseased brood—to limit pathogen spread, a feedback that prevents colony collapse. Both systems illustrate how too little feedback leads to runaway growth (over‑cooling galaxies, overpopulation in a hive) while too much feedback can starve the system of essential material.
Self‑governing agents. Modern AI research is exploring agents that negotiate, allocate resources, and adapt their policies without central oversight. The algorithms that evolve such agents draw on reinforcement learning, where local reward signals shape global behavior. Cosmological simulations can be viewed as a grand, deterministic analogue: each particle follows the same physical laws, yet the collective outcome is a richly structured universe. Understanding how local rules scale up helps inform the design of robust, decentralized AI governance frameworks—especially when the goal is to preserve biodiversity and ecosystem services, as emphasized by Apiary’s bee‑conservation mission.
Data‑driven calibration. Just as simulations are tuned against galaxy surveys, bee‑population models are calibrated with field observations (e.g., hive weight, forager counts). The cross‑disciplinary lesson is the importance of “closing the loop”: iterate between model, observation, and prediction to reduce uncertainty.
In short, the same scientific mindset that drives cosmological simulations—building a physical model, testing it against data, refining the feedback prescriptions—can be harnessed to protect pollinators and to steer AI systems toward ethical, resilient outcomes.
Why It Matters
Cosmological simulations are not abstract exercises in computational artistry; they are the most powerful microscopes we have for the universe’s deepest history. By reproducing the observed distribution of galaxies, the temperature fluctuations of the CMB, and the subtle bending of light by dark matter, they anchor our cosmological model in reality. The same rigor—clear physical principles, quantitative validation, and iterative improvement—can be applied to the stewardship of Earth’s ecosystems and the governance of emerging AI.
When we understand how a galaxy’s fate is shaped by the interplay of gravity, gas dynamics, and feedback, we gain insight into the universal language of complex systems. That language tells us how to balance growth and restraint in a bee colony, how to design AI agents that self‑regulate, and how to make policy choices that honor both scientific truth and ecological integrity. The cosmos, in its grandeur, offers a mirror for the challenges we face on the ground. By learning from the stars, we become better guardians of the planet.
For further reading, explore our related pages:
- Big Bang – The origin story of the universe.
- Dark Matter – The invisible matter that scaffolds galaxies.
- Dark Energy – The driver of cosmic acceleration.
- Hydrodynamics – How gas behaves under gravity and pressure.
- Feedback – Energy cycles that shape galaxies and ecosystems.
- Galaxy Mergers – The cosmic dance that reshapes structures.
- Observational Surveys – The telescopic campaigns that test simulations.
- Bee Conservation – How hierarchical modeling informs pollinator protection.
- AI Agents – Lessons from physics for autonomous system design.