2
votes

I was playing with OpenModelica using the PowerSystem library and found something curious.

To have a full grasp of what the equation constraints from the block's classes are, I always open each block individually and instantiate it, to have the full list of variables and equations of the flattened model.

However, I noticed that when I do it, the instantiated model has additional equations that are not defined in the code concerning the block's class or any parent's class, nor exists when I use the block in another model.

For instance, when instantiating the class for a simple Resistor (AC1ph_DC), it adds the equations equating the currents to zero (the last four equations):

R[1] * i[1] = v[1];
R[2] * i[2] = v[2];
v[1] = term_p.v[1] - term_n.v[1];
v[2] = term_p.v[2] - term_n.v[2];
i[1] = term_p.i[1];
i[2] = term_p.i[2];
(...)
term_p.i[1] = 0.0;
term_p.i[2] = 0.0;
term_n.i[1] = 0.0;
term_n.i[2] = 0.0;

Is this done automatically by OpenModelica to have a solvable system when instantiating just the resistor? Is there any documentation on that available?

Also, is there any "more correct" way to visualize the flattened class code of any block?

1
The correct way is to instantiate the model to see the full equations (flattened Modelica code).Adrian Pop
Thank you for the comments. While instantiating the model might be "the" correct way, I find it less interesting because we lose track on which were the classes (blocks) related to a specific variable/equation.SuperGeo
Then you could use the static debugger in OMEdit to understand the final equation system. It provides links back to the source code.Adrian Pop

1 Answers

5
votes

In Modelica, flow variables that are not connected are set to zero. See 9.2 in Modelica Specification: https://modelica.org/documents/ModelicaSpec33Revision1.pdf