Remove algebraic loop without delay
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Paul
il 19 Set 2023
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?
Risposte (1)
John D'Errico
il 18 Set 2023
Modificato: John D'Errico
il 18 Set 2023
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.
Vedere anche
Categorie
Scopri di più su Configure Simulation Conditions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!