Repository navigation
Assign the real and imaginary parts of k separately in ComplexBlocks.Routing.Extractor - #4850
Open
hubertus65 wants to merge 1 commit into
Open
hubertus65 wants to merge 1 commit into
hubertus65 wants to merge 1 commit into
Conversation
…Routing.Extractor
Extractor sets its internal Complex selection vector k in a when-equation:
k[i] = if index == i then Complex(1,0) else Complex(0,0);
OpenModelica 1.27.1 cannot generate code for a record assignment in a
when-equation ("No runtime support for this record assignment"), whatever
its right-hand side, so models using Extractor do not build. Assign the
two Real fields instead:
k[i].re = if index == i then 1 else 0;
k[i].im = 0;
With this change OpenModelica simulates a test with Extractor (with and
without allowOutOfRange) and matches the results of OCT (Modelon Impact)
for the original code, except at the event instant itself. OCT compiles
and simulates the changed block with the same results.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UmNZkRw6HV9CeBvNk36AzT
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.ComplexBlocks.Routing.Extractorsets its protected Complex selection vectorkin a when-equation:OpenModelica 1.27.1 cannot generate code for a record assignment inside a when-equation, so no model that uses
Extractorbuilds:The error is not specific to the if-expression.
k[i] = Complex(if index == i then 1 else 0, 0)fails the same way. This PR assigns the two Real fields instead, which OpenModelica supports:Verification
Test:
Extractorwithnin=3, driven by anIntegerStepindex from 1 to 3 (and out of range withallowOutOfRange=true) at t = 0.5.The OCT "after" result was produced with a copy of the changed block, since Impact ships its own MSL. The test model is part of the ModelicaTest coverage work on branch
coverage-improvement.🤖 Generated with Claude Code
https://claude.ai/code/session_01UmNZkRw6HV9CeBvNk36AzT