admin管理员组文章数量:1287230
I am trying to solve a nonlinear system of differential equations in Wolfram Mathematica using NDSolve and visualize the solution with Manipulate. However, I encounter the following error when running the code. Interestingly, the plot still appears in the output, but the warning message also shows up. Is this normal, or is there something wrong with my Mathematica code? I suspect the issue arises because my system of equations is quite complex and nonlinear, with fractions whose denominators contain variables. Is that the main cause of this error?
This is the code that I made:
Module[{plt1, plt2, plt3, sol, S0 = SS0, Ih0 = IhIh0, Y0 = YY0}, sol =
sol =
NDSolve[{S'[t] ==
3.5*S[t]*(1 - (S[t] + Ih[t])/50) - 1*S[t]*Ih[t] - (
0.34*(S[t])^2*Y[t])/(S[t] + 0.1*Ih[t]),
Ih'[t] ==
1*S[t]*Ih[t] - (2.2*(Ih[t])^2*Y[t])/(S[t] + 0.1*Ih[t]) -
0.02*Ih[t],
Y'[t] == (0.9*0.34*(S[t])^2*Y[t])/(S[t] + 0.1*Ih[t]) - (
0.02*2.2*(Ih[t])^2*Y[t])/(S[t] + 0.1*Ih[t]) - 0.022*Y[t],
S[t /; t <= 0] == S0, Ih[t /; t <= 0] == Ih0,
Y[t /; t <= 0] == Y0}, {S[t], Ih[t], Y[t]}, {t, 0, 500}];
plt1 =
ParametricPlot[{t, S[t]} /. sol, {t, 0, 500}, PlotRange -> All,
AspectRatio -> 1, PlotStyle -> {Red, Thick}, Axes -> {t, S}];
plt2 =
ParametricPlot[{t, Ih[t]} /. sol, {t, 0, 500}, PlotRange -> All,
AspectRatio -> 1, PlotStyle -> {Green, Thick}, Axes -> {t, Ih}];
plt3 =
ParametricPlot[{t, Y[t]} /. sol, {t, 0, 500}, PlotRange -> All,
AspectRatio -> 1, PlotStyle -> {Blue, Thick}, Axes -> {t, Y}];
Show[plt1, plt2, plt3, ImageSize -> {300, 300}]],
Style["Persamaan differensial :", Bold],
Style["S'= rS(1-\!\(\*FractionBox[\(S + I\), \
\(K\)]\))-\[Lambda]SI-\!\(\*FractionBox[\(\*SuperscriptBox[\(pS\), \
\(2\)] Y\), \(S + \[Alpha]I\)]\)", Bold],
Style["I'=\!\(\*FormBox[\(\[Lambda]SI - \
\*FractionBox[\(\*SuperscriptBox[\(cI\), \(2\)] Y\), \(S + \
\[Alpha]I\)] - \[Gamma]I\),
TraditionalForm]\) ", Bold],
Style["Y'=\!\(\*FormBox[\(\*FractionBox[\(\*SuperscriptBox[\(\[Delta]\
pS\), \(2\)] Y\), \(S + \[Alpha]I\)] - \
\*FractionBox[\(\*SuperscriptBox[\(\[Eta]cI\), \(2\)] Y\), \(S + \
\[Alpha]I\)] - dY\),
TraditionalForm]\)", Bold],
Delimiter,
Style["parameters", Bold, 10],
Delimiter,
Style["initial conditions", Bold, 10],
{{SS0, 4, "S0"}, 0, 10, .01, ImageSize -> Small,
Appearance -> "Labeled"},
{{IhIh0, 1, "Ih0"}, 0, 10, .01, ImageSize -> Small,
Appearance -> "Labeled"},
{{YY0, 6, "Y0"}, 0, 10, .01, ImageSize -> Small,
Appearance -> "Labeled"},
ControlPlacement -> Left, SynchronousUpdating -> False]```
I got the plot and error message in the output. Is it normal or or is there something wrong with my Mathematica code? How can I resolve this error and still obtain a reliable solution? Are there specific methods or options in NDSolve designed to handle stiff systems? Should I focus on adjusting and finding the right values for S0, Ih0, and Y0 to prevent the error? I have attached the plot generated from Manipulate that illustrates the problem. I would greatly appreciate any explanations and suggestions to solve this issue. Thank you very much!
本文标签:
版权声明:本文标题:modeling - How fix error in Mathematica "NDSolve::ndsz: At t == ... step size is effectively zero; singularity or stiff 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1741305977a2371370.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论