I have a piece of modelica code in a long when-elsewhen statement that uses reinit() for a continuous time variable and with if-elseif embedded in an equation section. In some cases, if a specific condition occurs, then I'm using the kind of code below to do nothing and have the same variables assignments as with other sections of the when and if sections:
variable = pre(variable) ;
It seems that Dymola rewrites my equations in the form (I try to reproduce in a very synthetic form the code I'm using):
condition1 = pre(variable1);
...
conditionN = .... ;
when {condition1, ..., consitionN} then
variable1 = if NothingToDoCondition then pre(variable) else value;
variable2 = if NothingToDoCondition then pre(variable) else anotherValue;
....
variableM =... //as above
if condition then
reinit(x,y) ;
else
//no equation
end if ;
elsewhen ....
// repeat as above
end when;
The Dymola check complains that:
This elsewhen in equations is not supported, it can be worked around by rewriting as algorithm, however be careful since the right-hand-side is dependent on left-hand-side variables and that is handled differently in algorithms
First, I don't know how to convert my piece of code into an algorithm section since I'm using reinit(), which cannot be used in the algorithm section. Is there an alternative to the reinit() that I can use in an algorithm section?
Second, how to interpret the message from the Dymola check ? What's the implications for using a when statement in an algorithm or equation ?