小编Osc*_*und的帖子

如何提高Python中odeint的速度?

我正在使用scipy包中的Python和odeint来解决大量(~10e6)耦合的ODE.方程组可以表示为一些矩阵乘法的总和,我使用numpy和blas支持.我的问题是这需要很长时间.当我分析代码时,我发现大多数时候进入odeint做其他事情而不是评估rhs.这是来自探查器的五个最耗时的调用:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
5       1547.915  309.583 1588.170  317.634 {scipy.integrate._odepack.odeint}
60597   11.535    0.000   23.751    0.000   terms3D.py:5(two_body_evolution)
121194  11.242    0.000   11.242    0.000   {numpy.core._dotblas.dot}
60597   10.145    0.000   15.460    0.000   generator.py:13(Gs2)
121203   3.615    0.000   3.615     0.000   {method 'repeat' of 'numpy.ndarray' objects}
Run Code Online (Sandbox Code Playgroud)

rhs基本上由two_body_evolution和Gs2组成.这个配置文件适用于~7000耦合的ODE,这对于~4000是相同的:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
5        259.427  51.885   273.316  54.663 {scipy.integrate._odepack.odeint}
30832    3.809    0.000    7.864    0.000  terms3D.py:5(two_body_evolution)
61664    3.650    0.000    3.650    0.000  {numpy.core._dotblas.dot}
30832    3.464    0.000    5.637    0.000  generator.py:13(Gs2)
61673    1.280    0.000    1.280    0.000  {method 'repeat' of …
Run Code Online (Sandbox Code Playgroud)

python performance scipy

5
推荐指数
2
解决办法
2421
查看次数

标签 统计

performance ×1

python ×1

scipy ×1