Epidemiology: The SIR model: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary  | 
				A WASSERMANN (talk | contribs) No edit summary  | 
				||
| Line 39: | Line 39: | ||
brd.createElement('text', [12,-0.7, "γ: recovery rate"]);  | brd.createElement('text', [12,-0.7, "γ: recovery rate"]);  | ||
brd.createElement('text', [12,-0.4,   | |||
        function() {return "S(t)="+brd.round(S.pos[1],3) +", I(t)="+brd.round(I.pos[1],3) +", R(t)="+brd.round(R.pos[1],3);}]);  | |||
S.hideTurtle();  | S.hideTurtle();  | ||
I.hideTurtle();  | I.hideTurtle();  | ||
| Line 45: | Line 47: | ||
function clearturtle() {  | function clearturtle() {  | ||
S.cs();  |   S.cs();  | ||
I.cs();  |   I.cs();  | ||
R.cs();  |   R.cs();  | ||
S.hideTurtle();  |   S.hideTurtle();  | ||
I.hideTurtle();  |   I.hideTurtle();  | ||
R.hideTurtle();  |   R.hideTurtle();  | ||
}  | }  | ||
function run() {  | function run() {  | ||
S.setPos(0,1.0-s.Value());  |   S.setPos(0,1.0-s.Value());  | ||
R.setPos(0,0);  |   R.setPos(0,0);  | ||
I.setPos(0,s.X());  |   I.setPos(0,s.X());  | ||
delta = 0.1; // global  |   delta = 0.1; // global  | ||
t = 0.0;  // global  |   t = 0.0;  // global  | ||
loop();  |   loop();  | ||
}  | }  | ||
function turtleMove(turtle,dx,dy) {  | function turtleMove(turtle,dx,dy) {  | ||
turtle.lookTo([1.0+turtle.pos[0],dy+turtle.pos[1]]);  |   turtle.lookTo([1.0+turtle.pos[0],dy+turtle.pos[1]]);  | ||
turtle.fd(dx*Math.sqrt(1+dy*dy));  |   turtle.fd(dx*Math.sqrt(1+dy*dy));  | ||
}  | }  | ||
function loop() {  | function loop() {  | ||
var dS = -beta.Value()*S.pos[1]*I.pos[1];  |   var dS = -beta.Value()*S.pos[1]*I.pos[1];  | ||
var dR = gamma.Value()*I.pos[1];  |   var dR = gamma.Value()*I.pos[1];  | ||
var dI = -(dS+dR);  |   var dI = -(dS+dR);  | ||
turtleMove(S,delta,dS);  |   turtleMove(S,delta,dS);  | ||
turtleMove(R,delta,dR);  |   turtleMove(R,delta,dR);  | ||
turtleMove(I,delta,dI);  |   turtleMove(I,delta,dI);  | ||
t += delta;  |   t += delta;  | ||
if (t<20.0 && I.pos[1]) {  |   if (t<20.0 && I.pos[1]) {  | ||
setTimeout(loop,10);  |     setTimeout(loop,10);  | ||
}  |   }  | ||
}  | }  | ||
</script>  | </script>  | ||
</html>  | </html>  | ||
Revision as of 17:40, 21 January 2009
Simulation of differential equations with turtle graphics using JSXGraph.
SIR model without vital dynamics
A single epidemic outbreak is usually far more rapid than the vital dynamics of a population, thus, if the aim is to study the immediate consequences of a single epidemic, one may neglect the birth-death processes. In this case the SIR system described above can be expressed by the following set of differential equations:
- [math]\displaystyle{ \frac{dS}{dt} = - \beta I S }[/math]
 
- [math]\displaystyle{ \frac{dR}{dt} = \gamma I }[/math]
 
- [math]\displaystyle{ \frac{dI}{dt} = -(dS+dR) }[/math]
 
The lines in the JSXGraph-simulation below have the following meaning:
* Blue: Rate of susceptible population * Red: Rate of infected population * Green: Rate of recovered population (which means: immune, isolated or dead)