Even though Modelica is an acausal modeling language, we learned e.g. here that it can make a difference how you write your equations.
The code of the MutualInductor
model in the Modelica.Electrical.Polyphase.Basic
package puzzled me a bit and I am wondering if the current implementation was chosen for a specific reason.
The model uses this for loop
for j in 1:m loop
v[j] = sum(L[j, k]*der(i[k]) for k in 1:m);
end for;
to model the inductive coupling of m
phases using the inductance matrix L
.
The code above could be replaced by this much shorter and cleaner equation:
v = L * der(i);
I would expect that a Modelica translator will usually not realize that the for loop is equivalent to a matrix multiplication. Hence, my expectation is that the multiplication should be chosen, so we give the translator more information.
Does anybody know if the for loop or the matrix multiplication is beneficial for Modelica translators to solve the equation system?