Spectacular Videos: Synthetic Universes, with Star Collision Graph

Entitled “Spectacular Videos: Synthetic Universes, with Star Collision Graph”, the full version in PDF format is accessible in the “Free Books and Articles” section, here. Also discussed in details with Python code in my book “Synthetic Data”, available here.

This project started as an attempt to generate simulations for the three-body problem in astronomy: studying the orbits of three celestial bodies subject to their gravitational interactions. There are many illustrations available online, and after some research, I was intrigued by Philip Mocz’s version of the N-body problem: the generalization involving an arbitrary number of celestial bodies. These bodies are referred to as stars in this article. Philip is a computational physicist at Lawrence Livermore National Laboratory, with a Ph.D. in astrophysics from Harvard University.

My simulations are based on his code, which I have significantly upgraded. The end result is the three-galaxy problem: small star clusters, each with hundreds of stars, coalescing due to gravitational forces of the individual stars. It simulates the merging of galaxies. In addition, I added a birth process, with new stars constantly generated. I also allow for star collisions, resulting in fewer but bigger stars over time. Finally, my simulations allow for stars with negative masses, as well as unusual gravitation laws, different from the classic inverse square law.

Massive red star with negative mass at the center, unusual gravity law

These bizarre universes lead to spectacular data animations (MP4 videos), but perhaps most importantly, it may help explain what could cause our universe to expand, including the different stages of compression and expansion over time. Depending on the initial configuration, very different outcomes are possible. Negative masses, with cluster centroids based on the absolute value of the mass while gravitational forces are based on the signed mass, could lead to a different model of the universe. Many well-known phenomena, such as rogue stars escaping their cluster at great velocity, black holes and twin stars formation, star filaments, and star clusters becoming less energetic over time (decreasing expansion, smaller velocities) are striking features visible in my videos. Star collisions lead to an interesting graph problem.


The N-body problem consists of predicting the evolution of celestial bodies bound by gravity. Here I go one step further: up to 1000 stars and star clusters are simulated using various initial conditions, to produce videos that show how these synthetic universes evolve. It tells a lot about the past and future of our current universe, corroborating the theory that it is expanding, albeit more and more slowly. In addition, stars with negative masses and gravity laws other than the standard inverse square, when allowed, lead to the most bizarre systems and spectacular videos. Star collisions are studied in details and lead to interesting graph theory applications. I provide the Python code for these simulations, including the production of animated data visualizations (videos) and graph representations.

A more traditional universe, starting with 3 star clusters (collided stars in orange)

Table of Contents

  1. Introduction
  2. Model parameters and simulation results
    . . . Explanation of color codes
    . . . Detailed description of top parameters
    . . . Interesting parameter sets
  3. Analysis of star collisions and collision graph
    . . . Weighted directed graph: visualization with NetworkX
    . . . Interesting findings: how the universe got started
  4. Animated data visualizations
  5. Python code and computational issues
    . . . Simulating the real and synthetic universes
    . . . Visualizing collision graphs
Collision graph for the biggest star eater in the simulation

Download the Article

The technical article, entitled Spectacular Videos: Synthetic Universes, with Star Collision Graph, is accessible in the “Free Books and Articles” section, here. It contains links to my GitHub files, to easily copy and paste the code. The text highlighted in orange in this PDF document are keywords that will be incorporated in the index, when I aggregate all my related articles into books about machine learning, visualization and Python, similar to these ones. The text highlighted in blue corresponds to external clickable links, mostly references. And red is used for internal links, pointing to a section, bibliography entry, equation, and so on.

To not miss future articles, sign-up to our newsletter, here.

About the Author

Vincent Granville is a pioneering data scientist and machine learning expert, co-founder of Data Science Central (acquired by  TechTarget in 2020), founder of MLTechniques.com, former VC-funded executive, author and patent owner. Vincent’s past corporate experience includes Visa, Wells Fargo, eBay, NBC, Microsoft, and CNET. Vincent is also a former post-doc at Cambridge University, and the National Institute of Statistical Sciences (NISS).  

Vincent published in Journal of Number TheoryJournal of the Royal Statistical Society (Series B), and IEEE Transactions on Pattern Analysis and Machine Intelligence. He is also the author of multiple books, including “Intuitive Machine Learning and Explainable AI”, available here. He lives  in Washington state, and enjoys doing research on spatial stochastic processes, chaotic dynamical systems, experimental math and probabilistic number theory.

%d bloggers like this: