Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Nonlinear algebraic loop while it is not neccesary

Nonlinear algebraic loop while it is not neccesary

Hello,

I am evaluating performance of FMUs created from OpenModelica models.

in this way I found that Nonlinear algebraic loops inside a model can reduce performance tremendously. so i am trying to find ways to break such algebraic loops in open modelica.

meanwhile I have come to a simple model which i believe it could be solved for derivatives (unknows) symbolically while Open Modelica considers it as a nonlinear system of equations and tries to solve it by iterations. i have attached the Modelica file test.mo and also the analytical state space solution that i have written myself as test.jpg.

I think modelica uses general nonlinear solution for piece-wise linear functions, like the limiter in this example while instead it can manipulate the equations symbolically for each linear case.

at the end, is there any suggestion that i could break such an algebraic loops or make it linear?

Thanks,
Arvin

https://www.openmodelica.org/images/agorapro/attachments/3955/mini_test.jpg

modelica-file-for-testcase.mo

Edited by: arvin_ttl - Nov-26-15 14:55:10

Re: Nonlinear algebraic loop while it is not neccesary

The debugger says you get one non-linear system of size 1 unknown (3 torn variables):

f2.u := smooth(0, if add.y > limiter.uMax then limiter.uMax else if add.y < limiter.uMin then limiter.uMin else add.y)
add.u2 := DIVISION(add.y - add.k1 * f1.x_scaled[1], add.k2)
y := (1.0 + -2.0 * f2.a[2]) * f2.x_scaled[1] + 2.0 * f2.u
y + (-f3.a[2]) * f3.x_scaled[1] - add.u2 (residual)

add.y is the unknown in this case. Re-ordering the equations does not work.

Re: Nonlinear algebraic loop while it is not neccesary

Yes. that is right, i have already seen this. but as i said it could be solved as linear system of equations considering limiter equation as a piece-wise linear function. Is there any trick (modeling, modelica flags, ....) to let OM choose linear option instead of nonlinear one?

Re: Nonlinear algebraic loop while it is not neccesary

No, there is no way to make the simulation switch to a different set of equations based on which branch is selected. I also do not agree that it results in a linear equation system even with the knowledge that it is piece-wise linear: you still form an algebraic loop due to being required to check if the boolean conditions changed for the limiter.

Re: Nonlinear algebraic loop while it is not neccesary

I have attached the analytical solution. the nonlinear system of equations can be decoupled to two linear system of equations.

https://www.openmodelica.org/images/agorapro/attachments/3955/mini_1448551860_test.jpg

Re: Nonlinear algebraic loop while it is not neccesary

I don't agree that the analytical solution is the same as the problem above. It seems to approximate the stop by setting a derivative to zero. Which means that the value which is supposed to be limited will be slightly larger or smaller than the limit.

Re: Nonlinear algebraic loop while it is not neccesary

sjoelund.se wrote:


I don't agree that the analytical solution is the same as the problem above. It seems to approximate the stop by setting a derivative to zero. Which means that the value which is supposed to be limited will be slightly larger or smaller than the limit.

yes, i agree with you. they are not the same.

Re: Nonlinear algebraic loop while it is not neccesary

Hello,

I found a solution to break the algebraic loop by using FixedDelay block on the feed back loop and setting --delayBreakLoop to true. I originally tested this approach in Dymola and by setting delaytime to 0.001, for integration timestep of 0.01sec using Euler solver, the results were stable and close to the reference (with no delay with algebraic loop) and and the performance is almost twice improved.

but repeating the same scenario in OpenModelica, the results are not stable. i have attached the results comparison as well as the test case.


test.mo

test1.mo

https://www.openmodelica.org/images/agorapro/attachments/3955/mini_com-OMvsDymola.jpg

Re: Nonlinear algebraic loop while it is not neccesary

If you are using a delayTime of 0.001, you need to set an integration step of 0.001 or smaller, or the results become totally wrong (stepSize needs to be smaller than the smallest delay). However, our Euler seems to be unstable until you reach a step-size of 0.00001. Use our rungekutta solver instead and you will not get instability as easily.

There are 0 guests and 0 other users also viewing this topic
You are here: