Simulation Speed of Nonlinear Solver in Modelica

怎甘沉沦 提交于 2020-04-14 19:05:42

问题


Why does Modelica's nonlinear solver oneSolveNonlinearEquation take more time to solve a nonlinear equation than traditional fixed point iterative (FPI) scheme? The equation

y= arctan(1-x/1+x)-x 

solved by the oneSolveNonlinearEquation solver (which basically uses Brent's Method) solves the above equation in 6 iterations whereas traditional iterative approach takes 111 iterations. However, the CPU time taken by the iterative scheme is lesser than that taken by the oneSolveNonlinearEquation solver (see image).

Why is this? Could be due to computational efficiency of the iterative scheme i.e., to say lesser event generation in the iterative scheme?

CPU Time of nonlinear equation solved by Brent's method (oneSolveNonlinearEquation solver) and typical fixed point iterative (FPI) scheme


回答1:


The different root finding methods have different properties. Convergence speed is just one, and it can be counted in number of iterations, or in CPU time. Both will greatly depend on start values, curvature and monotonicity of the function, bounds, cost to evaluate the function, availability of analytic derivatives etc.. Other interesting properties could be guarantee of convergence, or whether derivatives are required.
The Wikipedia article on root finding algorithms gives a good overview of the advantages and disadvantages of the different methods:

  • https://en.wikipedia.org/wiki/Root-finding_algorithm

If one method works much better than others for your special case, you should just implement and use it! Be careful when benchmarking, it is very easy to find examples where each method can shine. For this reason, you should test each algorithm on a variety of functions, maybe 10 different ones, and each one with different intervals. Bisection will perform worse for the same function but larger start interval. Brent is a good and proven method, that is why it is used in the MSL. You could even think about sending a Pull Request to the MSL and add alternatives.



来源:https://stackoverflow.com/questions/60260770/simulation-speed-of-nonlinear-solver-in-modelica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!