Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of if/for containing connections (#11694)
- Mark if-conditions/for-ranges as structural if they are parameter expressions and the if/for contains connections. Fixes #11606
- Loading branch information
Showing
8 changed files
with
139 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// name: ForConnect2 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
model ForConnect2 | ||
C c1[3], c2[3]; | ||
parameter Integer n(start = 3); | ||
equation | ||
for i in 1:n loop | ||
connect(c1[i], c2[i]); | ||
end for; | ||
end ForConnect2; | ||
|
||
// Result: | ||
// class ForConnect2 | ||
// Real c1[1].e; | ||
// Real c1[1].f; | ||
// Real c1[2].e; | ||
// Real c1[2].f; | ||
// Real c1[3].e; | ||
// Real c1[3].f; | ||
// Real c2[1].e; | ||
// Real c2[1].f; | ||
// Real c2[2].e; | ||
// Real c2[2].f; | ||
// Real c2[3].e; | ||
// Real c2[3].f; | ||
// final parameter Integer n(start = 3); | ||
// equation | ||
// c1[1].e = c2[1].e; | ||
// (-c1[1].f) - c2[1].f = 0.0; | ||
// c1[2].e = c2[2].e; | ||
// (-c1[2].f) - c2[2].f = 0.0; | ||
// c1[3].e = c2[3].e; | ||
// (-c1[3].f) - c2[3].f = 0.0; | ||
// c1[1].f = 0.0; | ||
// c1[2].f = 0.0; | ||
// c1[3].f = 0.0; | ||
// c2[1].f = 0.0; | ||
// c2[2].f = 0.0; | ||
// c2[3].f = 0.0; | ||
// end ForConnect2; | ||
// endResult |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// name: IfConnect4 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
// | ||
|
||
connector C | ||
Real e; | ||
flow Real f; | ||
end C; | ||
|
||
model IfConnect4 | ||
parameter Boolean b(start = true); | ||
C c1, c2; | ||
equation | ||
if b then | ||
connect(c1, c2); | ||
end if; | ||
end IfConnect4; | ||
|
||
// Result: | ||
// class IfConnect4 | ||
// final parameter Boolean b(start = true); | ||
// Real c1.e; | ||
// Real c1.f; | ||
// Real c2.e; | ||
// Real c2.f; | ||
// equation | ||
// c1.e = c2.e; | ||
// (-c1.f) - c2.f = 0.0; | ||
// c1.f = 0.0; | ||
// c2.f = 0.0; | ||
// end IfConnect4; | ||
// endResult |
This file contains 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