What
With particle simulations we can simulate the behaviour of particles in an environment. Such simulations can be used across many fields of science and engineering. The following demonstrates how a basic particle simulations can be used for disease spread simulations.
Technically it’s C-Code, compiled to WebAssembly, that draws onto a pixel buffer that is displayed in an HTML canvas. This is more about demonstrating very basic particle simulation than about an accurate disease model.
Note: For this to work your browser needs to support WebAssembly. The simulation works on the mobile phones I’ve tested, but it’s built for desktop, so it may be difficult to hit the buttons.
When
I’ve been using such simulations in the past for location estimations of objects. There are many applications of particle simulations such as locaiton estimation for robots, congestion simulation, water flow simulation, etc.
As an intermediate to test the framework I’m building we can run a simulation of disease spread.
Why
Particle Simulations can also be used for position estimation. For this the particles are thought of as positional estimates with a probability weighting assigned to each of them. Over time, with a model of the robots motion and sensory input from distance sensors, we can adjust the probability weighting assigned to each particle to improve our “guess” of where the robot is.
For a disease spread model we can use the probability weighting of each particle as the probability that it carries an infectious disease. A simulated coughing person infects the particles around him with every time he coughs and the motion model corresponds to the wind/air movements in the room. Other people in the room get infected when they come in contact to a high enough quantity of infected particles.
Background
With the current pandemic came a number of measures to contain the disease. We currently have masks, minimal distances, vaccinations, but also requirements for ventilation in public buildings such as schools. The health ministry has set a certain amount of time - x minutes - in which a not infected person can be in close proximity to an infected person before being categorized as a “contact person” that is then mandated to enter quarantine.
The question arises how this x amount of minutes was derived.
Two options that come to mind are:
- from questionnaires when an infection of a person was traced back to another person that was previously infected and, from memory, the approximate time they were close was specified.
- or by running particle simulations
How
As with the Smartphone Apps for infection tracing where Bluetooth beacons are considered to propagate similarly to infectious particles in the air, the particle simulations are also just a highly inaccurate estimation - yet they are something.
The inaccuracies in particles simulations for disease spread stem from the high number of required parameters.
- if outdoors, the exact wind direction. If indoors the exact floor plan and the air movements in the building. Opened/closed doors/windows, ventilation systems, people moving around, contact duration, activities, etc
- the location and number of people that are spreading the disease
- the location of people that could be infected
- and many more
For a very basic simulation and to only demo particle simulations I’ve come up with three basic variables:
- spreadFactor - assuming the contagious person is continuously coughing and infects particles around him with a probability of 100%, how many particles does he infect.
- reductionFactor - how does the travel distance of infectious particles reduce their likely-hood of being able to affect a person. The reasoning is that in a normal environment some particles be absorbed by the environment or aren’t even infectious to begin with.
- contagionFactor - how many contagious particles does a person have to come in contact with to get infected, i.e. how infectious is this disease
I’ll be simulating only a single contagious person at a specific position, with a specific floor plan and a number of people at fixed locations around the floor plan.
For the simulation we need equations on how the particles behave. For this I’m using the following basic equations:
spreadFactor
The spreadFactor controls how much infectious particles are emitted by the infected person. For this, in each iteration, we want to increase the probability that a particle carries the infectious disease. For this I’m using the normalized distance times the spread factor times an arbitrary 10 to increase the impact.
reductionFactor
The reductionFactor controls how much infectious particles loose their “infectiousness”. So in each iteration we reduce the probability of all factors by a a factor. The factor controls how harsh the environment is to the infected particles. It is reduced by 1000 to reduce it’s effect and give the simulation a somewhat realistic feel.
contagionFactor
How fast a not infected person becomes infected upon contact with infected particles is controlled by the contagionFactor. Here I’m computing the distance between a particle and the a person. If it is below 1.3, then the particle is considered close enough to have an impact. In that case the particles probability to be infected times the contagionFactor is added to the probability of infection. Afterwards I’m dividing by five to give use a controllable range of 0 and 1 for the factor.
Limitations
Of course this is a very limited simulation with arbitrary factors. In a more scientific approach one would justify each of the factors by empirical experimentation. One would likely simulate hundreds of common floor plans, use more factors and derive those factors from empirical studies. But this here is just basic experimentation to demonstrate the basics of particle simulation.
Progress
The particle simulation framework I’ve written for my robot localization experiments was adapted for this basic disease spread simulation. I’m using my C-Code UI-Library to draw the floor plan and user interface. The code was then dropped in WebAssembly to get the interactive demo application that you can see above.
We can play with the three factors and see how it effects the simulation.