Repository navigation
Avoid Complex sum reduction in QuasiStatic.Polyphase.Basic.MutualInductor - #4846
Open
hubertus65 wants to merge 1 commit into
Open
hubertus65 wants to merge 1 commit into
hubertus65 wants to merge 1 commit into
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>
This was referenced Oct 31, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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