Conversation
…ctor The voltage equation v[l] = sum(j*omega*L[l, k]*i[k] for k in 1:m) sums time-varying Complex operator records. OCT (Modelon Impact) crashes on it with a StackOverflowError in record scalarization, so the component cannot be used there at all. Write the sum as scalar products of the real and imaginary parts instead: v[l] = j*omega*Complex(L[l, :]*i.re, L[l, :]*i.im); The equation is mathematically identical. In OpenModelica 1.27.1, all 644 variables of a 3-phase test circuit (unsymmetric source, L and load) agree with the original within 4.3e-13 absolute. OCT now compiles and simulates the component and matches that result. Dymola 2026x translates both versions to the same balanced system. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Without testing: This is legal Modelica. I prefer versions that are easier to read for humans. |
|
Same argument as in the last comment:The question is what we want to achieve with the Standard Library: make it work for as many tools as possible, or make it a gate by using as many features of the Modelica language as possible. FWIW: I also filed a bug report for Modelon Impact. That doesn't mean that a rewrite that works on more tools is isn't useful. I also have made similar changes that make models work in OpenModelica. And regarding speed: there is no measurable difference. |
|
Same reply as in the last comment: |
HansOlsson
left a comment
There was a problem hiding this comment.
I neither see it as necessary nor that it improves readability.
casella
left a comment
There was a problem hiding this comment.
I also agree that readability is not really improved by this PR.
|
This seems to be tool issue. |
Modelica.Electrical.QuasiStatic.Polyphase.Basic.MutualInductorcomputes its voltages with asumreduction over time-varyingComplexoperator records:OCT, the compiler of Modelon Impact, crashes on this equation with a
java.lang.StackOverflowErrorinFType.createRecordConstructor. The array-constructor formsum({...})crashes the same way. As a result the component cannot be used in Impact at all, and nothing else in the MSL uses it, so the problem went unnoticed. It was found while writing a ModelicaTest coverage test for the component.This PR writes the same sum as scalar products of the real and imaginary parts:
The equation is mathematically identical. Verification with a 3-phase test circuit: unsymmetric source, non-uniform
Lmatrix, unequal load resistors.Dymola was limited to translation by the local license size limit.
Alternatives that also compile in both OCT and OpenModelica were not chosen because they change the component's notation more. They are an explicit split into
v.re/v.imand a real-valuedsum(... for k in 1:m)per part. The form chosen keeps thej*omeganotation of the original.🤖 Generated with Claude Code