用于行星模拟的'修复'性能 [英] 'Repa' performance for planetary simulation
问题描述
我用欧拉辛方法
编写了太阳系外行星的模拟, a>,并通过使用 repa
和b)使用 yarr
来执行此操作。 yarr
似乎比 repa
执行速度快x30。
鉴于此,我甚至没有尝试使用并行性。我的 repa
代码中是否有任何明显的性能问题?该存储库位于 github 。如果这有帮助,我可以生成一个 repa
-only版本的缩减版,但不会得到与 yarr
或者,我如何调试 repa 中的性能问题?
大多数欧拉数值积分方法都会遇到累积舍入误差,最终会导致模拟爆炸。您可能需要研究先进的数值积分方法,例如四阶Runge-Kutta或预测校正器。
另一个n体问题模拟变得粘滞的地方是两个物体变得非常接近,比如一颗月球的轨道非常偏离它的行星。如果使用固定的时间增量进行模拟,那么在角速度变化较大时的误差可能会导致零除误差或导致模拟爆炸的非常小的值分裂。使用依赖于角速度的变量delta-t可能是有益的。
这些建议是基于运行许多这样的模拟作为本科物理课程I于1973年进行了测试,同时测试各种数值积分方法。自数字计算开始以来,Runge-Kutta和预测校正方法就已出现,并且有许多书籍可供使用。参见William H. Press,Brian P. Flannery,Saul A. Teukolsky和William的 , 数字食谱:科学计算的艺术 T. Vetterling。 (剑桥大学出版社,1989)
I have written a simulation of the outer planets of the solar system using the Euler symplectic method and implemented this a) using repa
and b) using yarr
.
yarr
seems to perform about x30 quicker than repa
.
Given this, I didn't even try to use parallelism. Is there any obvious performance problems in my repa
code? The repository is at github. I can produce a cut-down repa
-only version if this is helpful, but then you won't get the performance comparison against yarr
.
Alternatively, how do I debug performance issues in repa
?
Most Euler numeric integration methods suffer from cumulative round-off error that will eventually cause the simulation to "blow up". You may want to investigate advanced numerical integration methods, such as 4th-order Runge-Kutta or predictor-corrector.
Another place where n-body problem simulations become sticky is when two bodies get very close, such as a moon with a very eccentric orbit about its planet. If one uses fixed time increments for the simulation, the error during large changes of angular velocity can lead to division-by-zero errors or division by very small values that result in the simulation blowing up. Use of a variable delta-t that depends on the angular velocity can be beneficial.
These suggestions are based on running many such simulations as a project for an undergraduate physics course I took in 1973, while testing various numerical integration methods. Runge-Kutta and predictor corrector methods have been around since the dawn of digital computing and a number of books are available. See, e.g., Numerical Recipes: The Art of Scientific Computing by William H. Press, Brian P. Flannery, Saul A. Teukolsky and William T. Vetterling. (Cambridge University Press, 1989)
这篇关于用于行星模拟的'修复'性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!