Skip to main content
Version: 🚧 Alpha 🚧

7. Differential equations

This final step adds an equation-based infection process inside buildings and compares it with the agent-based counts. The equations describe changes in susceptible (S) and infected (I) occupants over time (t), with beta controlling the infection rate.

Incremental model 7: final step introducing a mathematical model for disease spread in buildings.

Set equation parameters​

The global beta value controls transmission in the equations, and h sets the integration step used by the solver.

global {
float beta <- 0.01;
float h <- 0.1;
}

Define the SI equations​

For each building, T is the number of occupants, S is the susceptible count and I is the infected count. The two differential equations transfer population from susceptible to infected while keeping the total constant.

species building {
float I;
float S;
float T;
float t;
float I_to1;

equation SI {
diff(S, t) = (-beta * S * I / T);
diff(I, t) = (beta * S * I / T);
}
}

Apply the equations to occupants​

When a building has occupants, the reflex sets T, S and I, solves the equations with the fourth-order Runge–Kutta method, and carries fractional infections forward in I_to1. Whole infections are assigned to susceptible occupants.

species building {
reflex epidemic when: nb_total > 0 {
T <- float(nb_total);
S <- float(nb_total - nb_infected);
I <- T - S;
float I0 <- I;
if (I > 0 and S > 0) {
solve SI method: #rk4 step_size: h;
I_to1 <- I_to1 + (I - I0);
int I_int <- min([int(S), int(I_to1)]);
I_to1 <- I_to1 - I_int;
ask (I_int among (people_in_building where (!each.is_infected))) {
is_infected <- true;
}
}
}
}

The complete Incremental Model 7 source combines this process with the GIS, movement, multi-level populations, 3D display and comparison chart.