I like the fact that you are moving from traditional SIR model for a more spatially realistic simulation of disease spread. In the standard SIR model (which you have shared), the population is assumed to be well-mixed but in real life scenarios, people only infect their neighbours, and that is exactly what a lattice-based SIR model helps capture.
How I approached simulating the system is as follows:
- I placed all the individuals on a 100×100 grid.
- Each person (cell) is either: Susceptible (S) = 0, Infected (I) = 1, Recovered (R) = 2.
- Initially, I choose 10 random cells (individuals) to infect.
- Then, at every time step, each infected cell attempts to infect its 4 neighbours (up, down, left, right) with a probability β.
- Each infected cell has a probability γ of recovering.
I have also attached the code for simulation. I hope it helps you out!
idx = randperm(L*L, nInfectedStart);
colormap([1 1 1; 1 0 0; 0.52 0.74 1]);
neighbors = [i-1 j; i+1 j; i j-1; i j+1];
for k = 1:size(neighbors,1)
if x >= 1 && x <= L && y >= 1 && y <= L
if grid(x,y) == SUSCEPTIBLE
newGrid(i,j) = RECOVERED;
colormap([1 1 1; 1 0 0; 0.52 0.74 1]);
title(['Step ' num2str(step)]);