I’m trying to create a manipulatable SIR model with variable infection rate in Mathematica. To (very roughly) imitate the effect of government policies, I want the infection rate to be a certain constant if dI/dt is less than a certain value and another constant if dI/dt is above a certain value. This is what I have currently:
g1(t_) =
If(
i(t) < 0.2, b0, b1
)
p1(t_) = 1;
(Beta)1(t_) = g1(t)*p1(t);
simpleSirModel1 = {
{
s'(t) == -(Beta)1(t)*s(t)*i(t),
i'(t) == (Beta)1(t)* s(t) *i(t) - (Gamma)*i(t),
r'(t) == (Gamma)*i(t)
},
s(0) == 1, i(0) == 0.001, r(0) == 0}
simpleSirSolution1 =
ParametricNDSolveValue(
simpleSirModel1, {s, i, r}, {t, 0, 300}, {(Gamma), b0, b1},
Method -> {"DiscontinuityProcessing" -> False})
Manipulate(
Plot(Evaluate@Through(simpleSirSolution1((Gamma), b0, b1)(t)), {t,
0, 100}, PlotLegends -> {"S", "I", "R"}, TicksStyle -> Medium,
AxesLabel -> {Style("Days After 3/2", Black, FontSize -> 10),
Style("Fraction of Population", Black, FontSize -> 10)},
PlotStyle -> {{Darker(Green), Thickness(0.005)}, {Red,
Thickness(0.005)}, {Magenta, Thickness(0.005)}},
ImageSize -> Large, PlotRange -> {{0, 100}, {0, 1}}),
{{b0, 0.2}, 0, 0.5},
{{b1, 0.1}, 0, 0.5},
{{(Gamma), 0.07}, 0, 0.5}
)
When I execute the manipulate, I receive an error message:
ParametricNDSolveValue::mxst: Maximum number of 97466 steps reached at the point t == 46.10884123355165`.
Is there a way to increase the maximum number of steps that ParametricNDSolveValue can handle? Is this the best way to approach my problem? I’m not sure how to otherwise approach it, since the function (Beta)1(t)
changes value depending on the system it’s in.