使用 NDSolve 和因变量求解 ODE

发布于 2024-12-28 18:41:34 字数 510 浏览 0 评论 0原文

我有初始条件:

sf = 200; 
sm = 100; 
p = 40; 
betaf = 0.15; 
betam = 0.15; 
mums = 0.02; 
mufs = 0.02; 
sigma = 0.20; 
mum = 0.02; 
muf = 0.02; 

并且 ODE:

sf' := -muf*sf + (betaf + mums + sigma)*p - HarmonicMean[sf, sm]; 
sm' := -mum*sm + (betam + mufs + sigma)*p - HarmonicMean[sf, sm}]; 
p' := p - (mufs + mums + sigma)*p + HarmonicMean[{sf, sm}];

我想要的是一个抽象解 (sf(t),sm(t),p(t)),并使用 NDSolve 稍后绘制它。 我的问题是所有变量都依赖于所有 3 个方程,所以我不知道如何编写 NDSolve 调用。

I have intialconditions:

sf = 200; 
sm = 100; 
p = 40; 
betaf = 0.15; 
betam = 0.15; 
mums = 0.02; 
mufs = 0.02; 
sigma = 0.20; 
mum = 0.02; 
muf = 0.02; 

and the ODE:

sf' := -muf*sf + (betaf + mums + sigma)*p - HarmonicMean[sf, sm]; 
sm' := -mum*sm + (betam + mufs + sigma)*p - HarmonicMean[sf, sm}]; 
p' := p - (mufs + mums + sigma)*p + HarmonicMean[{sf, sm}];

That i want is an abstract solution (sf(t),sm(t),p(t)) with NDSolve to plot it later.
My problem is that all variables are dependet in all 3 equations, so i don't know how to write the NDSolve call.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栖竹 2025-01-04 18:41:34

我无法获得解析解,但数值解是这样的。请注意,并非您列出的所有符号都是系统的变量:那些不依赖于自变量 t 的符号是参数。 (另请注意,OP 代码中存在一些拼写错误)。

variables = {sf[t], sm[t], p[t]};
parameters = {betaf -> 0.15, betam -> 0.15, mums -> 0.02, 
   mufs -> 0.02, sigma -> 0.20, mum -> 0.02, muf -> 0.02};

equations = {
   sf'[t] == -muf*sf[t] + (betaf + mums + sigma)*p[t] - 
     HarmonicMean[{sf[t], sm[t]}],
   sm'[t] == -mum*sm[t] + (betam + mufs + sigma)*p[t] - 
     HarmonicMean[{sf[t], sm[t]}],
   p'[t] == 
    p[t] - (mufs + mums + sigma)*p[t] + HarmonicMean[{sf[t], sm[t]}],
   sf[0] == 200,
   sm[0] == 100,
   p[0] == 40
   };

sol = NDSolve[equations /. parameters, variables, {t, 0, 100}];

Plot[Evaluate[variables /. sol], {t, 0, 100}]

Mathematica 图形

I could not manage to get an analytic solution, but the numerical one goes like this. Note that not all symbols you listed are variables of the system: those not being dependent of the independent variable t are parameters. (Also note that there are some typos in the OP's code).

variables = {sf[t], sm[t], p[t]};
parameters = {betaf -> 0.15, betam -> 0.15, mums -> 0.02, 
   mufs -> 0.02, sigma -> 0.20, mum -> 0.02, muf -> 0.02};

equations = {
   sf'[t] == -muf*sf[t] + (betaf + mums + sigma)*p[t] - 
     HarmonicMean[{sf[t], sm[t]}],
   sm'[t] == -mum*sm[t] + (betam + mufs + sigma)*p[t] - 
     HarmonicMean[{sf[t], sm[t]}],
   p'[t] == 
    p[t] - (mufs + mums + sigma)*p[t] + HarmonicMean[{sf[t], sm[t]}],
   sf[0] == 200,
   sm[0] == 100,
   p[0] == 40
   };

sol = NDSolve[equations /. parameters, variables, {t, 0, 100}];

Plot[Evaluate[variables /. sol], {t, 0, 100}]

Mathematica graphics

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文