我正在尝试使用 Python 对方程组进行数值求解 in this paper ,方程式。 30 和 31,简化形式如下:
其中 G(k)
和 D(k)
是一些已知函数,独立于 Y
。当然,所有数量也是 t
的函数。作者评论说,由于各种函数表现出的依赖性,数值解是必要的。
我通常会按照 here 的指示实现此类耦合方程的解。或 here ,例如,但现在额外的 k 依赖性让我有点困惑。
有什么建议吗?非常感谢。
最佳答案
IDESolver
是由 Josh Karpel 创建的通用数值积分微分方程求解器.其最新版本允许用户解决多维、耦合的 IDE。从提供的示例中,IDE 像
有了解析解(sin x, cos x),可以用下面一段代码求解:
import numpy as np
import matplotlib.pyplot as plt
from idesolver import IDESolver
solver = IDESolver(
x=np.linspace(0, 7, 100),
y_0=[0, 1],
c=lambda x, y: [0.5 * (y[1] + 1), -0.5 * y[0]],
d=lambda x: -0.5,
f=lambda y: y,
lower_bound=lambda x: 0,
upper_bound=lambda x: x,
)
solver.solve()
fig = plt.figure(dpi = 600)
ax = fig.add_subplot(111)
exact = [np.sin(solver.x), np.cos(solver.x)]
ax.plot(solver.x, solver.y[1], label = 'IDESolver Solution', linestyle = '-', linewidth = 3)
ax.plot(solver.x, exact[1], label = 'Analytic Solution', linestyle = ':', linewidth = 3)
ax.legend(loc = 'best')
ax.grid(True)
ax.set_title(f'Solution for Global Error Tolerance = {solver.global_error_tolerance}')
ax.set_xlabel(r'$x$')
ax.set_ylabel(r'$y(x)$')
plt.show()
关于python - 用Python求解积分微分耦合方程组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68839342/