Virus Simulator

With the home confinement imposed by the epidemic of the COVID-19 virus, I have been doing many projects that I had on hold for long. But also started new ones…

I saw a nice explanation of the impact of containment on the spread of the virus through the population and the potential impact on the health services and the level of mortality etc…

I thought that I could make some sort of display frame and build a simulator.

 

 

It is an electronics build but the actual coding of the simulator has been more of a challenge. In particular, creating a model that is simple enough so that the display is fluid and give an impression of true virus spreading etc…

This is interesting: try

The current system creates a random population of people (pixels) scattered across the 4 panels of 64 by 64 leds. The system picks randomly a level of containment (or none), and a level of agitation of the people moving across the display. These are blue pixels.

The computer creates an initial load of viruses across the population randomly. Between 5 and 10.

If the people with the virus get in contact with a pixel that is not sick, then there is contagion and the new person can infect others.

There is a lifetime for the disease and a mortality rate. If a person survives the virus, they are then immune but only for a certain amount of time. This creates waves of disease spreading across the screen.

At the top of the display, there is a graph that shows the number of people sick in the population. This clearly shows the curve of the evolution of the disease. Sometimes the peak is very sharp and sometimes the peak is only a small bump.

The system tracks the time it takes for all the sick people to either die or recover. Once there are no sick people anymore, the system re-starts a new simulation with new parameters picked randomly within boundaries.

The system also tracks the parameters that result in the longest disease time, the shortest disease time, the hight death ratio and the lowest death ratio.

In general, it takes between 1 to 6 minutes to run a single simulation. This one is about 3 minutes.

So far I have been able to observe that the longest disease is when there is a high level of containment. It also reduces the level of mortality but not as much as I expected. I tend to spread the disease over a longer time period.

As per the above, the shortest simulation was 31 seconds with a starting population of 1600, an initial virus load of 12 viruses, as disease life of 45 cycles and an immunity life of 70 cycles, with no containment at all. This resulted in a 54% death rate.

Clearly this is not a scientific experiment but just a toy display. I am very please with the simulation effect which gives a good sense of a disease spreading through a population.

It is made with a Raspberry Pi running a version of Linux. It is programmed in Python.

 

This entry was posted in Home Life. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *