Skip to main content
1 of 4
Chris K
  • 20.4k
  • 3
  • 39
  • 75

To make it easy, I'll use my EcoEvo package.

First time, you'll need to install it:

PacletInstall["EcoEvo", "Site" -> "http://raw.githubusercontent.com/cklausme/EcoEvo/master"]

Then, load the package to get started:

<<EcoEvo`

Both models are a little bit funny, in that total population size is conserved. Thus, model (i) is effectively one-dimensional and model (ii) is effectively two-dimensional.

Model (i): SI

SetModel[{
  Pop[pop] -> {
    Component[s] -> {Equation :> -β s i/n + γ i},
    Component[i] -> {Equation :> β s i/n - γ i}
  },
  Parameters :> {β > 0, γ > 0, n > 0}
}]

Let's go straight to the phase planes using PlotEcoPhasePlane, manually adding the total population constraint as a straight line. The subcritical case (disease-free equilibrium eq[[1]] is stable):

β = 0.95; γ = 1; n = 1;
Show[
 PlotEcoPhasePlane[{s, 0, 1.1}, {i, 0, 1.1}],
 Plot[n - s, {s, 0, n}]
]

enter image description here

and the supercritical case (endemic equilibrium eq[[2]] is stable):

β = 4; γ = 1; n = 1;
Show[
 PlotEcoPhasePlane[{s, 0, 1}, {i, 0, 1}],
 Plot[n - s, {s, 0, n}]
]

enter image description here

Again, because of the total-population constraint, this is effectively a one-dimensional system with either two or one feasible (non-negative) equilibria.

Model (ii): SIR

Here we can get rid of the degeneracy by defining r := n - s - i, then work in the SI phase-plane.

r := n - s - i;
SetModel[{
  Pop[pop] -> {
    Component[s] -> {Equation :> -β s i/n + ξ r},
    Component[i] -> {Equation :> β s i/n - γ i}
  },
  Parameters :> {β > 0, γ > 0, ξ > 0}
}]

To verify your analytical results:

eq = SolveEcoEq[]

enter image description here

EcoEigenvalues[eq[[1]]]

enter image description here

EcoEigenvalues[eq[[2]]]

enter image description here

The eigenvalues of the non-trivial equilibrium are ugly, but we can check stability using Routh-Hurwitz criteria in EcoStableQ:

Simplify[EcoStableQ[eq[[2]]]]

enter image description here

On to the phase planes, to which I will include the equilibria (probably should automate this...).

Subcritical case:

β = 0.95; γ = 1; ξ = 1; n = 1;
eq = SolveEcoEq[];
Show[
 PlotEcoPhasePlane[{s, 0, 1.1}, {i, 0, 1.1}],
 RuleListPlot[eq, PlotMarkers -> EcoStableQ[eq]]
]

enter image description here

Supercritical case (stable focus, complex eigenvalues):

β = 4; γ = 1; ξ = 1; n = 1;
eq = SolveEcoEq[];
N[EcoEigenvalues[eq[[-1]]]]
Show[
 PlotEcoPhasePlane[{s, 0, 1.1}, {i, 0, 1.1}],
 RuleListPlot[eq, PlotMarkers -> EcoStableQ[eq]]
]
(* {-1.25 + 1.19896 I, -1.25 - 1.19896 I} *)

enter image description here

Supercritical case (stable node, real eigenvalues):

β = 4; γ = 1; ξ = 10; n = 1;
eq = SolveEcoEq[];
N[EcoEigenvalues[eq[[-1]]]]
Show[
 PlotEcoPhasePlane[{s, 0, 1.1}, {i, 0, 1.1}],
 RuleListPlot[eq, PlotMarkers -> EcoStableQ[eq]]
]
(* {-9.60337, -3.1239} *)

enter image description here

Chris K
  • 20.4k
  • 3
  • 39
  • 75