I have a contrived Modelica model in which a have a state machine variable manipulated by multiple when
statements:
model WhenExample
type State = enumeration(first, second, third);
State state;
initial equation
state = State.first;
equation
when sample(0, 1) then
state = State.second;
end when;
when sample(0, 3) then
state = State.third;
end when;
end WhenExample;
When compiling under OpenModelica OMC, I get the following error:
[1] 16:46:39 Symbolic Error
Too many equations, over-determined system. The model has 2 equation(s) and 1 variable(s).
This kinda makes sense as I do have two equations for my single state
variable. However, those equations only apply at discrete points in time, right?
Do I need to make sure all "manipulations" of a particular variable happen only in a single when
statement?
elsewhen
has to be used (or an algorithm section as shown below). – sjoelund.se