CoVIS-19

↝      Year

2022

↝      Description

For my Bachelor's thesis, I built a simulation and visualization of SARS-CoV-2 spreading across Germany, driven by real data: the official infection numbers of the Robert Koch Institute and real movement data from our co-author NET CHECK. Every particle is a simulated person, deciding each day where to travel to and whether to get infected. And all of that runs inside Houdini, a visual effects software which turned out to be a pretty great tool for science - especially since you can debug your simulation by simply looking at it.

Read the whole thesis here →

↝      Tools used

Houdini     
Python     
Python Pandas     
Redshift
Every particle a personStylized render of the simulated population

 

January 20th to February 10th, 2022One day per second, every 80th person in Germany simulated

 

Connecting the dots

During the pandemic, we saw so many numbers: incidence rates, case counts, colorful maps of counties. Those are great for analyzing, but they're also quite abstract. I wanted to build something more intuitive - a simulation of individual people, where you can actually see infections popping up and people traveling across the country.

So every particle in this video is a person. It shows January 20th to February 10th, 2022, with every 80th person in Germany being simulated, which makes for about a million particles. Each day takes one second: people traveling to another county glide across the map, and infected people grow and light up in red, so you can watch outbreaks flare up in different regions.

 

A day in the life of a particle

Under the hood, every particle only needs a handful of attributes: the county it's in, the county it's traveling to next, whether it's infected and if so, for how long. For every simulated day, each particle then makes its own decisions.

First up: infection. The chance of a particle getting infected is the share of infected people in its current county on that day, taken from the RKI's data. I smoothed that data with a 7-day rolling average, so that delays in reporting and quiet weekends don't mess things up. If a particle does get infected, the dice are rolled again to decide for how long - anywhere from one to nine days, based on an estimate by the UK Health Security Agency.

Next up: traveling. From NET CHECK's data, we know how many people traveled from each county to every other county on each day. We can turn these numbers into probabilities, and every particle draws a random number to decide where it ends up. Say 50% of the travelers from a county go to county A and 20% go to county B: draw anything below 0.5 and you're off to A, anything between 0.5 and 0.7 and you're going to B. Pretty simple on its own, but with a million particles making their own little decisions, the simulation stays surprisingly close to the real data.

 

Still frame of January 27th

 

Closeup of Bavaria and SaxonyTravelers between distant counties cut straight across the map - even across the border

 

Seeing is debugging

Now why would you use Houdini for this? It's a visual effects software after all, the kind you'd use for explosions and floods rather than for epidemiology. But under the hood, Houdini is a node-based programming environment: every step is a node, and the data flows down through the network, where you can look at it at any point - both as a spreadsheet and in the 3D viewport.

For a project like this, that's incredibly helpful. If something went wrong, I could literally see it, like particles ending up in the wrong county or a region with way too many infections. The infection and travel calculations live in their own Python nodes, so I could work on each of them separately. And since everything works with relative instead of absolute numbers, changing how many people the simulation represents is just one slider at the very top.

It's not all sunshine though: if you get stuck in an infinite loop inside a Python node, the only way out is restarting the whole of Houdini.

 

Setting up the mapCounties and the starting population
Every simulated dayInfections, travels and coloring

 

A minute a day

Of course, a million little decision-makers come at a price. My first version took 10 minutes for every simulated day - for just 80,000 people. Most of that time went into looking up the right data for every single particle, so I split the infection data into one file per day, and the travel data into one file per day and county. On top of that, a cache keeps recently used data in memory, so the thousands of particles in the same county don't each read the same file again. Add a custom way of scattering the travelers in their new county, which is 95% faster than Houdini's own, and I got it down to about a minute per day, for ten times as many people!

 

Crystal ball

Since every particle makes its own choices, the model can even keep going after the data runs out. To predict the next days, it saves the decisions the particles made - separately for each day of the week, since Mondays look quite different from Sundays - and uses them as the input for the following days. Just like most simple forecasts, it stays close to reality for a few days before drifting off, but watching it happen on the map is a lot more intuitive than looking at a line on a chart.

 

Funnily enough, the original plan looked quite different: the first idea was a contact-based simulation using detailed location data, where infections would spread between people who actually came close to each other. When access to that data was denied at short notice, I switched to travel between counties - which in the end made for a model that's easy to feed with new data, adapt to other countries or scale up to a higher resolution.

     Go Back