- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Final parameters and if expressions
Page Start Prev 1 Next End
Final parameters and if expressions
Final parameters and if expressions
Dec-02-11 13:17:14
Hello,
I have a simple model (see below) which conditionally assigns a value to a parameter. If this parameter is final the its value is always 0.
Furthermore if the right hand side is a final parameter value, the result also is 0, wheter or not the left hand side is a final parameter.
Code:
type CondEnum = enumeration(a, b);
model Test
final parameter CondEnum cond = CondEnum.b;
parameter Real val = 1.0;
final parameter Real final_value = 1.0;
parameter Real value1 = if cond == CondEnum.a then val else -val;
final parameter Real value2 = if cond == CondEnum.a then val else -val;
parameter Real value3 = if cond == CondEnum.a then final_value else -final_value;
Real result1;
Real result2;
Real result3;
equation
result1 = value1; // ok (==-val)
result2 = value2; // error (==0)
result3 = value3; // error (==0)
end Test;
Model checking and simulation proceeds without errors.
Best regards,
Michael
Re: Final parameters and if expressions
Dec-02-11 15:14:26
The SimCode contains the following:
Code:
simple equation: result1 = value1
simple equation: result2 = if CondEnum.b == CondEnum.a then 1.0 else -1.0
simple equation: result3 = if CondEnum.b == CondEnum.a then 1.0 else -1.0
But the equations are actually not put in the generated code. I'll open up a bug for it (http://openmodelica.org:8080/cb/issue/1 … tion=true)
- sjoelund.se
- 1700 Posts
Page Start Prev 1 Next End
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Final parameters and if expressions
There are 0 guests and 0 other users also viewing this topic