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

different generated fmu code when changing the order of equation

different generated fmu code when changing the order of equation

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;

Edited by: arvin_ttl - Apr-27-18 18:15:54
There are 0 guests and 0 other users also viewing this topic
You are here: