A particle-based simulation of an SIS (Susceptible-Infected-Susceptible) epidemic model where particles move according to an Ornstein-Uhlenbeck process in a 2D periodic domain.
Practical activity for the Physics of Biological Systems minicourse at ICTP-SAIFR
This simulation combines:
- Spatial dynamics: Particles perform Ornstein-Uhlenbeck (OU) motion, oscillating around equilibrium positions with periodic boundary conditions
- Epidemic dynamics: Distance-dependent infection spreading following an SIS model with spatial interactions
Particles move via an Ornstein-Uhlenbeck process:
- Each particle has an equilibrium position
x₀ - Position evolves as:
dx = -α(x - x₀)dt + σdW - Periodic boundary conditions (Pac-Man style wrapping)
- States: Susceptible (S, blue) or Infected (I, red)
- Recovery: Infected → Susceptible with rate
β - Infection: Probability from neighbor at distance
r:p(r) = exp(-λr) dt - Total infection probability:
P(infection) = 1 - ∏(1 - pⱼ)over all infected neighbors
.
├── include/
│ ├── config.h # System parameters and constants
│ ├── system.h # System structure and function declarations
│ └── random.h # Random number generation utilities
├── src/
│ ├── system.c # Core simulation functions
│ └── random.c # Random number generators
├── move.c # OpenGL visualization main
├── main.c # Simple command-line main
├── run_move.sh # Compilation script (with OpenGL)
└── run_main.sh # Compilation script (no OpenGL)
./run_move.sh [PHI] [RC] [N] [ALPHA] [SIGMA] [DT] [BETA] [LAMBDA]./run_main.sh [PHI] [RC] [N] [ALPHA] [SIGMA] [DT] [BETA] [LAMBDA]PHI: Particle density (default: 0.9)RC: Cutoff radius for interactions (default: 2.5)N: Number of particles (default: 1000)ALPHA: OU relaxation rate (default: 5.0)SIGMA: OU noise strength (default: 0.5)DT: Time step (default: 0.01)BETA: Recovery rate I→S (default: 0.5)LAMBDA: Infection spatial decay (default: 1.0)
# Use all defaults
./run_move.sh
# Custom parameters
./run_move.sh 0.7 2.5 2500 5.0 0.5 0.01 0.8 1.5./moveControls:
ESC: Exitp: Pause/resumeg: Toggle cell grid+/-: Zoom in/outr: Reset zoomf/F: Increase/decrease FPSArrow keys: Pan view
./main > output.txt
./main | grep -v "^#" > data.txtOutput format:
step time S I
0 0.0000 999 1
100 1.0000 985 15
200 2.0000 970 30
...
- Uses cell lists for efficient neighbor searches
- Cell size = cutoff radius
RC - Each particle searches only in neighboring cells (3×3 grid)
Three versions available in system.c:
propagation_v00: Independent transitions (no spatial interaction)propagation_v01: Count-based infection (linear in neighbor count)propagation_v02: Distance-dependent infection (exponential decay)
- Minimum image convention for distance calculation
- Position wrapping using modulo arithmetic
- Ensures particles near boundaries interact correctly
System Management:
makeSystem(): Initialize simulationdestroySystem(): Free memoryiteration(): Update particle positionspropagation_v02(): Update epidemic states
Spatial Partitioning:
getCellIndex(): Assign particles to cellsgetNeighborList(): Build neighbor cell listsminImage(): Compute minimum distance (PBC)
- Standard libraries:
stdio.h,stdlib.h,math.h,time.h - OpenGL (visualization only):
GL/gl.h,GL/glu.h,GL/glut.h
- Matheus L. F. Ribeiro (UFMG)
- Marcelo H. Schwade (IB-USP)
- Vinicius M. Muccillo (IFT-UNESP)
- William G. C. Oropesa (ICTP-SAIFR)
