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
  • Index
  • » Users
  • » arvin_ttl
  • » Profile

Posts

Posts

Hello,

Is there in OMC command, to return the hierarchical tree structure of a Modelica package? I see commands like "getPackages", "getClassNames" and "getUsedClassNames" which return packages and classes of one level of the structure tree. But what i mean is something which returns the whole tree structure.

Thanks,
Arvin

Hello,

The following two models are mathematically similar. However when i look at the generated code of the created FMUs, i see that for test1, in which der(x1) and der(x2) appear in the same order in both if and else statements, there is no linear system detected (i.e. test1_03lsy.c is empty) while for test2, it considers the if/else statement as one system of equation. I concluded that, when the order of equations in if/else statements are not in the same order OpenModelica's Symbolic engine is not smart enough to map equations with the if/else statement.

please clarify me with this subject.

Thanks,
Arvin

Code:



model test1
  Integer flg;
  Real u, y;
  Real x1, x2;
initial equation
x1=1;
x2=1;
equation
u = 1;
flg = if time<1 then 0 else 1;
if flg == 0 then
  der(x1)=-x1+x2^2;
  der(x2)= -2*x2;
else
  der(x1)=-x1+x2^2;
  der(x2)= -2*x2+u;
end if;
  y= x1;
end test1;

Code:



model test2
  Integer flg;
  Real u, y;
  Real x1, x2;
initial equation
x1=1;
x2=1;
equation
u = 1;
flg = if time<1 then 0 else 1;
if flg == 0 then
  der(x1)=-x1+x2^2;
  der(x2)= -2*x2;
else
  der(x2)= -2*x2+u;
  der(x1)=-x1+x2^2;
end if;
  y= x1;
end test2;

[Tested on OM1.11 - 32bit]

Please look at the following attached model.

parameter-test---Hardcoded.mo

When i run the simulation of this model for 10 seconds in OM environment, and try to change "parameter a" after compilation (give new value in Plotting/Variable Browser), i could see that changing the value affects the output of the model, y.

However when i export the model as an FMU ver 1.0, model exchange, and C code generation, And import it back to the OM environment, i see that after running, changing the value of parameter a does not affect the dynamics of the output y. It seems that either the parameter is not correctly set for the FMU or the value of the parameter is hardcoded to the default given value in the OM code.

In contrast, I have another model (shown in the link below) which uses the same parameter declarations, however when the FMU is created and simulated in OM environment, one could see that changing parameter a, directly affects the corresponding output, i.e. ya.

parameter-test---not-hardcoded.mo

How is it possible to have such a different behavior for setting parameters of the FMUs?

Thanks,
Arvin

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

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.

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

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?

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

I am reading FMI 1.0 model exchange documentation.

I read that when and state event happens between two integration time steps[ti-1, ti], the event indicators change sign. and then fmiEventUpdate should be called.

I do not know by calling fmiEventUpdate:

1- does FMU calculate exact time of the event internally and iteratively? why it needs this time?
2- i guess it calculates this exact time, say, t_event, and then integrate internally in the time period: [ti-1,t_event]. then it changes the equations to the new set of equations and integrate within the period: [t_event,ti]. is it right?

Thanks,
Arvin

Hello,

Since yesterday i am trying to download OM from https://www.openmodelica.org/download/download-windows both for windows and linux bu it seems that the download server is down. could you please check that.

Thanks,
Arvin

Hello,

Is there any article or report that compares FMU performance generated by different modelica tools (openmodelica, dymola, maplesim, ...)?

I am using hundreds of fmu's genereted by openmodelica (FMI 1.0 Model exchange) for real-time simulation of large scale power grids but i see that the performance of the fmu's is not good enough when the number of the fmu's increases.

Also is there any difference between FMI 1.0 and FMI 2.0 in terms of performance?

Thanks,
Arvin

OM: revision-539229e

for the simple following model, i get a wrong answer. why?

Code:


model a
  Real x1;
  Real x2;
equation
  x1 + x2 = 0;
  x1 - x2 = 1;
end a;

results:

x1=0.5;
x2=0;

but it should return FMIdiscard in case of divergency, based on the FMI standard manual.

Hello,

is there any way in OM to have control over sorting equations so that you can tell OM that which equations should be solved first?

i checked the fmi documentation and there is a status, fmiDiscard, which should be returned by the FMU in case when the interative algorithms are not converged. is this status also returned by FMU created by OM?

What if the iterative method to solve algebraic loops does not converge? is there any way in the FMI to check that?

So you mean that the created FMU is dependent on OM?

When an algebraic loop appears in the sorted generated code of the FMU, how the FMU solves the equations? Is there any internal iterative solver like newton-raphson inside the FMU or it makes calls to the OM solvers' library?

Hello,

i have a simple model as follows:

Code:


model test
  parameter Real b=0;
  Real y;
equation
  if b == 0 then
    y = 1000;
  else
    y = b;
  end if;
end test;

before simulation, first i instantiate the mode and i see that in the flattened model, only the equation regarding to b==0 is considered. i assume that the code generator also considers only this equation because after compilation and running the simulation, changing the value of b in plot window, does not affect the results.

I tried to remove the default value of b and i saw that this time the complete if statements appears in the flattened code after instantiation and therefore compiled after pushing simulation button.

I think the code generator should compile the if statements completely, no matter if the parameter in the if statement has a default value of not, because when you have a model which its dynamics changes regarding to the value of the parameters, and you want to generate an FMU from that, the FMU should also consists all equations for different values of the parameter.

Thanks,
Arvin

Hello,

I have a simple model as follows:

Code:


model parameter_test
  parameter Real p1=1;
  parameter Real p2=p1;
  Real u1, u2;
equation
  u1 = p1;
  u2 = p2;
end parameter_test;

when i export it to FMU and import it back to OM, changing parameter p1 in the FMU block, does not affect any of p2, u1 and u2 after simulation;

i modified my code to the following then:

Code:


model parameter_test_2
  parameter input Real p1;
  parameter Real p2=p1;
  Real u1, u2;
equation
  u1 = p1;
  u2 = p2;
end parameter_test_2;

now changing p1 in FMU affects u1, but still the dependent parameter, p2 is not changing.

how can i modify this code, so that in the FMU, changing p1 affects p2 and u2 consequently?

Thanks,
Arvin

Thanks for your answer Gregory

So you mean that first equations in the parameter declaration are evaluated and then initial equations are solved?

,Arvin

Hello,

I have a library in Modelica and i have written it in a non-structured way (saved just as one file in the computer.) I would like to convert my library to a Structured Hierarchical directory. Is there any way to do this automatically in OpenModelica?

Thanks,
Arvin

Hello,

i just wrote a simple program as follows:

Code:


model tmp
  parameter Real x(fixed = false);
  parameter Real y = 1 / x;
initial equation
  x = 2;
equation
end tmp;

when i run this program i get the following error:
division by zero at time 0, (a=1) / (b=0), where divisor b expression is: x

i slightly modified the above code as follows:

Code:


model tmp
  parameter Real x(fixed = false);
  parameter Real y(fixed=false);
initial equation
  x = 2;
  y = 1 / x;
equation
end tmp;

and the error did not appear anymore.

could you please explain me, why this happens?

Thanks,
Arvin

  • Index
  • » Users
  • » arvin_ttl
  • » Profile
You are here: