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

equations do not switch based on param value in if statement

equations do not switch based on param value in if statement

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

Edited by: arvin_ttl - Feb-06-15 20:11:46
There are 0 guests and 0 other users also viewing this topic
You are here: