Remove algebraic loop without delay
5 次查看(过去 30 天)
显示 更早的评论
I have an algebraic loop in my Simulink scheme. Actually, it only generates a warning and the system runs perfectly fine anyway, because the solver is able to solve such a loop somehow.
The problem is that this causes a huge increment of the computational time for the simulation, that I cannot afford. Hence, I must remove the algebraic loop.
But the usual way of adding a delay in the scheme is not a solution, since it (correctly removes the loop, but) adds some dynamics to the system that does not make it work as it should.
How can I solve this problem?
1 个评论
Paul
2023-9-19
Hi Ale_798,
The first question to be answered is whether or not an algebraic loop is expected for the actual system you're trying to model. Sometimes, an algebraic loop is expected. But most of the time (in my own experience) an algebraic loop results from an improper or approximate represenation of the underlying system. Does the existence of the algebraic loop make sense for the system you're trying to model?
回答(1 个)
John D'Errico
2023-9-18
编辑:John D'Errico
2023-9-18
I don't know for sure how Simulink resolves the issue internally, but the answer seems straightforward. Consider the equation
x = 2*x + 3
You want to solve for x. Now the trivial solution is to perform algebra, since this is effectively an algebraic problem. And that equation is a trivial one to solve. But suppose it were slightly more complex?
x = tan(x) + 3
this is now a problem that has no algebraic solution. We can use a numerical solver to resolve it of course. BUT THAT ADDS TIME. How could it not?
The thing is, Simulink is not smart enough to resolve when a trivial algebraic operation could solve the problem. How could it? Simulink does not do symbolic algebra. And so, Simulink MUST resort always to a numerical solver. Yes, some of the time it will converge rapidly. But there is no assurance. And no matter what, it will be far less efficient than a simple, direct computation.
The trick of adding a delay sort of works, almost, because often it might be the case where x is slowly varying. Now it may cost us little to change the problem to something like
x(i+1) = f(x(i))
No algebraic loop anymore. But potentially different fundamental behavior.
I'd suggest the answer is to remove the implicit loop you have created. In the first case, you would have something as simple as:
x = -3
In the second case, as I said, there is no solution to that problem. At least, none besides the use of a solver, a root finder.
Sometimes difficult problems take time to solve. Then the solution often reduces to getting a faster computer.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Configure Simulation Conditions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!