# Are there some (simple) mathematical models which can simulate the cellular/web structure of the universe?

To visualize the structure of a solar system we have some simple mathematical model:
Planets orbiting around a Star in circular motion.
If we want to be more precise the circle becomes a ellipse, the center of motion shifted slightly to the planet and so on.

Q: Is there also a (simple) mathematical model to visualize the cellular/web structure of the universe?
It doesn't need to be very precise. It could be as simple as the model for solar system using circular motion. 2D is fine too.

Here some picture what I'm looking for:
(It doesn't need to be that precise, just look similar too this) (picture from wikipedia, could not find how they made it)

In best case the mathematical model uses a 2D/3D field (array) of initialization values for generation.

Edit: It won't need to represent every step from big bang to now. The current state is sufficient.

• There's some info at en.wikipedia.org/wiki/… & en.wikipedia.org/wiki/Bolshoi_Cosmological_Simulation They don't give any details about the algorithms, but they mention an algorithm inspired by slime moulds. Commented Oct 13, 2023 at 3:52
• This looks promising: Monte Carlo Physarum Machine: Characteristics of Pattern Formation in Continuous Stochastic Transport Networks "MCPM is a probabilistic generalization of Jones's 2010 agent-based model for simulating the growth of Physarum polycephalum slime mold. We compare MCPM to Jones's work on theoretical grounds, and describe a task-specific variant designed for reconstructing the large-scale distribution of gas and dark matter in the Universe known as the Cosmic web." Commented Oct 13, 2023 at 6:51
• Blender : Is there any way to create this material? (black cold lava rock) "This kind of rock is called Scoria (as opposed to pumice, which is usually lighter in color)." Commented Oct 13, 2023 at 19:03
• Can you say what you mean by a 'simple' mathematical model which could simulate anything about the structure of the universe? Commented Oct 16, 2023 at 20:43
• @RobbieGoodwin can't give an exact definition of 'simple' but here some nice to have properties: 1) It should not have a simulation of all particles in it 2) and with this is also locally computable, the more local the better (but always generates the same global picture) 3) Given a 2D/3D field (array) of uniform distributed random values (my use case) the best case would be if the model can tell the state of a certain pixel/point just by reading it's related random value (most likely won't work out, so we also allow some neighborhood evaluation) .. Commented Oct 27, 2023 at 8:10

I suppose it depends on your definition of "simple", but I would say "No".

### Kepler simulations

A solar system is simple because you have one dominating mass with orbiting masses that can, at least to first order, be modeled as mass-less. If you neglect the planets' masses, you can in fact calculate analytically their positions at any time, using Kepler's law. However, as soon as you have three or more masses, you need to calculate positions numerically.

### N-body simulations

The simplest model of the structure formation of the Universe are N-body codes which calculate the gravitational forces between a large number of particles that each represent a certain amount of dark matter (say, $$10^4\,M_\odot$$ for high-resolution simulations, or $$10^8\,M_\odot$$ for low-resolution simulations, where $$1M_\odot$$ is the mass of the Sun). At each point in time you can then advance each particle in space according to the sum of the gravitational forces from all other particles. The reason this is moderately simple is that dark matter is collisionless, so you only have gravity to worry about.

Modern-day N-body simulations have billions or even trillions of particles. With, say, $$N=10^{12}$$ this means that, for each time step, you in principle need to calculate $$10^{24}$$ forces. However, various numerical tricks exist that result in the number of calculations scaling not with $$N^2$$, but with $$N\log N$$, reducing the computational cost tremendously. For instance, for $$N=10^{12}$$ you now "only" need $$\sim10^{13}$$ calculations.

One such method (Barnes-Hut) is to only calculate forces between nearby particles individually, while treating more distant particles collectively. Another method (particle-mesh; PM) discretizes space into cubic cells and solves forces in Fourier space where equations are simpler. The Bolshoi simulation that PM 2Ring mentions uses a variety of this method, except that the grid adapts to the density such that a cell in a high-density region is split into eight cells, recursively, and at each time step, the grid adapts to the new density field.

I wrote such a (non-adaptive) PM code once, as a master student; it took me a week, and I knew much of the physics in advance. So that's why I don't think I'd say it's downright "simple", but doable, yes. Here's the result (I'm sorry for the bad resolution; I had to reduce the file):

### Hydro-simulations

With N-body simulations you can simulate the cosmic web rather accurately on large scales, including galactic haloes. But the galaxies themselves are made of gas which requires hydrodynamics, complicating the simulations quite a lot. Several approaches exist to this: Arguably the easiest to understand is analogous to the N-body code, but in addition to dark matter particles, you now also have star particles (which are also collisionless), and gas particles. The latter are what complicates the calculations, because gas is not collisionless but has pressure, viscosity, etc. (and even magnetic fields, if you're really crazy). To make the fluid more continuous, the particles are "smoothed" in space, which is why this method is called smoothed particles hydrodynamics.

Another approach discretized space in cells, calculating the diffusion of gas across boundaries. Usually the cells are refined in dense regions to achieve higher resolution without spending computer power on refining less dense regions, similar to the Bolshoi simulation, but with gas. This method is called adaptive mesh refinement.

The different techniques each have the pros and cons. The "moving mesh" method combines the SPH and AMR techniques: Space is divided into irregular polygons that move around like particles, all the time change shape and size, while gas diffuses through boundaries. The Illustris simulation is an example of such a simulation.

With hydrodynamics, you can catch all the intricacies of heating, cooling, stellar population evolution, feedback from star formation and active galactic nuclei, metal enrichment, dust formation, galactic morphology, etc.

But such simulations are most definitely not "simple", requiring years of effort to develop from large teams of (astro-)physicists and computer scientists.

• @dtn Yes, exactly. A box of some finite size, but with periodic boundaries so that a particle exiting one face enters the opposite face. A very small cosmological volume is perhaps 100 million lightyears on one side, while a very large one is a few billion lightyears across. For a given number of particles (limited by your computer power), the advantage of a small box is the high resolution, while the advantage of the large box is the high number of galaxies, i.e. better statistics. The initial arrangement is not completely random, however, but follows a power spectrum obtained from the CMB.
– pela
Commented Oct 13, 2023 at 11:59
• @J.Doe Yes, the largest simulations are definitely not simple. In addition to taking a long time to develop, they take extremely long time to run, easily millions of hours, although distributed on thousands of computers. The simple one I show that I made myself only takes 10 minutes to run though.
– pela
Commented Oct 14, 2023 at 21:42
• @dtn I'm still not entirely sure I understand, but: The large-scale structure modeled is full of galaxies, so select any point in the box, and zoom out, you will eventually include a galaxy. Depending on your resolution, this galaxy may be more or less realistic: Lo-res sims will mostly just give you a collection of particles that may however still be realistic in terms of mass distribution (i.e. the number of large collection vs. small collections). High-res sims give you beautiful galaxies with realistic stellar populations, metallicity gradients, molecular clouds, spiral arms, and what not.
– pela
Commented Oct 15, 2023 at 10:34
• These links might be helpful: here, here, here, here, here, and here.
– pela
Commented Oct 15, 2023 at 15:14
• @pela, I'm referring to the apparent large-scale structure in the starting positions. RANDU was infamous for producing such a structure when used to generate three-dimensional coordinates.
– Mark
Commented Oct 17, 2023 at 3:33

In order to make a cosmic web pattern one can run a physics-based simulation approximating the flow of mass, as in Pela's answer. However, it is also possible to make "phenomenological models" that imitate the pattern without the underlying physics.

One common approach in physics is to look at the Fourier transform of phenomena, and if it has a simple functional form generate a new random pattern of that form and apply the inverse transform. This for example works well in replicating the texture of ocean waves under many conditions. However, for the cosmic web this approach does not work great. The reason is that the two-point correlation function (which dominates the power spectrum of the Fourier transform) is fairly insensitive to the web-like structure. The interesting patterns are due to phase correlations in the cosmic matter distribution, that are harder to turn into something that can be sampled and inverse-transformed.

Another approach is generative adversarial networks. Train a neural network to distinguish pictures of the cosmic web from other pictures, and another one to generate pictures that fools the first. This, once trained, can efficiently make even 3D webs.

One can also use aggregation processes to move randomly distributed points together, mimicking gravitation without doing a proper N-body simulation. One amusing approach is inspired by Physarum slime molds.

However, if only general visual similarity is required one can also use Voronoi noise, where random points are used to generate a density function that can then be perturbed by Perlin noise and sampled to quickly generate a fake cosmic web.

– pela
Commented Oct 13, 2023 at 15:29
• Thank you for the answer mentioning multiple interesting methods! It's funny how interdisciplinary this is, from slime-mold growth over hydrodynamics to Fourier transformation. My current favorite due to is simplicity is the Voronoi noise solution. However a little more accurate to the real structure would be nice to have. Maybe I could use it as initialization for other methods. The slime mold solution looks very good but might be a little to compute intensive for target use case Commented Oct 13, 2023 at 19:31
• (I will have a closer look on the mentioned methods. Unless there is no better fitting answer I will mark this as answer in next days. I hope pela is ok with this. Sadly there can only be one winner. His post was very informative too but the question was about a simple method. Should have define it better, sorry for that. Thank you for all answers and commends. ) Commented Oct 13, 2023 at 19:33
• tested around with Voronoi noise. It can look pretty good. However some local structure is missing for some variation in lightening and object sizes. Just adding some noise is not sufficient enough. Are there any simple ideas to make it look more realistic? Most mentioned methods are about the mass distribution and not the lightening. Happy to hear about some easy way doing this. However I don't think any exists. I will mark this as answer (at least for now). Thank you all for helping out. Learned many new fancy things to try around with. Commented Oct 15, 2023 at 1:30

Here's a relatively simple way to make fake cosmic web patterns. Unfortunately, it takes a lot of points to make diagrams that resemble the one from Wikipedia, and with relatively small numbers of points we only have hints of the filamentary structure.

As mentioned by Pela and Anders, it takes a lot of computation to simulate gravity on huge numbers of points. My program doesn't attempt to do that. ;) It just produces a randomly distributed set of points that are vaguely similar to the cosmic web.

My method is based on random "blue noise" created by Poisson Disc sampling, which generates points that are evenly distributed, without the clumping and large voids that generally result when plain (white noise) random numbers are used to place points. Poisson Disc sampling is often used in CGI for a variety of tasks, eg placing trees, blades of grass, hair, animal fur, etc. Blue noise is also used in dithering / anti-aliasing. Incidentally, the cones in our retinas follow a blue noise distribution.

Here's a typical example.

I noticed that when you project 3D blue noise down to the plane it retains a lot of its openness, but some clustering & filament formation occurs, resulting in the kind of image we want for a cosmic web pattern.

So if we generate 4D blue noise and project it down to 3D space, we should get something resembling the cosmic web...

Those 3 diagrams were generated using this Sage / Python script. The script allows you to zoom in and rotate the 3D views. The num_points parameter is an upper bound on the actual number of points generated. It's used to calculate the Poisson disc radius: the minimum radial distance permitted between points. The candidates parameter determines how many random points are generated at each placement step. A higher candidate number leads to slightly higher density and a more accurate blue noise distribution, but takes longer to generate. Useful values range from around 15 to 35.

In the actual cosmic web, clusters and filaments occur in regions of higher mass density. So we can enhance the diagram by modifying the size and color of points based on the density in their neighbourhood. A simple way to estimate that density is to count the neighbours within a certain distance of each point. I found that using half the Poisson disc radius gives good results.

Here's the script. It can use any standard matplotlib color map, but it's designed to use color maps that run from dark to light. The scripts run on the SageMath server, but the interactive 3D rendering happens in your browser, via three.js. If you try to create diagrams with too many points and you don't have enough RAM, your browser may complain or crash.

The scripts are written in plain Python, using Numpy, SciPy, and matplotlib. They only use Sage functions for the actual plotting. SciPy uses a fairly old Poisson Disc algorithm. There are modern algorithms which are faster, and which give a more accurate blue noise spectrum, eg the sample elimination method of Cem Yuksel.

• Very nice! I wonder if you could get an even more filamentary structure by using "violet noise"?
– pela
Commented Oct 16, 2023 at 14:50
• Thanks, @pela! I don't know a cheap way to make 4D violet noise (and I'd like to avoid doing Fourier transforms on large 4d arrays), but I'm happy to test it if you know an algorithm I can use. FWIW, I also tried projecting 5D blue noise. I guess it looks slightly better, but it takes longer to generate. (I guess that's mostly because there are lots of neighbouring cells in a 5D grid). Commented Oct 16, 2023 at 17:32
• Unfortunately no, this is far from my expertise. I would not have guessed that it would be more difficult than blue noise. I had thought that one could simply tilt the input spectrum to be even steeper than the blue noise, but I suppose not…
– pela
Commented Oct 16, 2023 at 19:46
• @J.Doe SciPy uses the Bridson algorithm to do Poisson Disc sampling, which (kind of) generates the points one by one. On each loop iteration it generates a bunch of candidates, and tests if any of them are valid. An alternative is Robert Ulichney's Void & Cluster algorithm, but that's more suited for making continuous fields. OTOH, because it uses FFT it creates tileable patterns. By layering tiles of different sizes you can make infinite regions that aren't obviously tiled. Commented Oct 27, 2023 at 17:02
• @J.Doe blog.demofox.org/2019/06/25/… has some info on both types of blue noise. And I have a Python demo of both algorithms here: gist.github.com/PM2Ring/04375fca6727eb2df125491c390b147c Commented Oct 27, 2023 at 17:03