Search code examples
modelicaopenmodelica

What is the purpose of the StateSet variables seen in OpenModelica's result variable browser


When I simulate the model below, I get additional variables labelled $STATESET1, which are obviously auto-generated.

What is the purpose of these variables from the perspective of the user? Generally I am only interested in the solution, not in the specific strategies a specific solver achieved it with, right? So isn't this more like something that should be output only if one turns on model debugging of some kind rather than being something the average OpenModelica user can take advantage of? What if there is more than one "state set" (say $STATESET1 and $STATESET2): how am I supposed to know how these variables relate to my model, given their generic names? More specifically, what is $STATESET1.x[:]? Nothing in the original or flattened model gives a hint on this...

model StateSetTest
  import SI = Modelica.SIunits;
  Real[3] q(start = zeros(3), each fixed = true);
  Real q4(start = 1);
  Real[3] w(start = zeros(3), each fixed = true);
  SI.Torque[3] TResult;
equation
  q * q + q4 * q4 = 1;
  w = 2.0 * (q4 * der(q) - der(q4) * q - cross(der(q), q));
  der(w) = TResult;
  TResult = zeros(3);
end StateSetTest;

enter image description here


Solution

  • They are used for dynamic state selection, i.e. changing the state during the simulation. And yes, they are not really needed for the user. I guess we could filter them out from OMEdit. I'll open a ticket about this.