Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for stream flow rate threshold, #3382.
- Loading branch information
1 parent
cbb3297
commit 0569334
Showing
8 changed files
with
160 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// name: InStreamFlowThreshold | ||
// keywords: stream instream connector outside | ||
// cflags: --flowThreshold=2 | ||
// status: correct | ||
// | ||
// Checks that the --flowThreshold flag works. | ||
// | ||
|
||
connector S | ||
Real r; | ||
flow Real f; | ||
stream Real s; | ||
end S; | ||
|
||
model A | ||
S s1; | ||
S s2; | ||
S s3; | ||
Real instream_s1; | ||
Real instream_s2; | ||
Real instream_s3; | ||
equation | ||
connect(s1, s2); | ||
connect(s2, s3); | ||
instream_s1 = inStream(s1.s); | ||
instream_s2 = inStream(s2.s); | ||
end A; | ||
|
||
model InStreamFlowThreshold | ||
A a; | ||
Real instream_a_s1; | ||
Real instream_a_s2; | ||
equation | ||
instream_a_s1 = inStream(a.s1.s); | ||
instream_a_s2 = inStream(a.s2.s); | ||
end InStreamFlowThreshold; | ||
|
||
// Result: | ||
// class InStreamFlowThreshold | ||
// Real a.s1.r; | ||
// Real a.s1.f; | ||
// Real a.s1.s; | ||
// Real a.s2.r; | ||
// Real a.s2.f; | ||
// Real a.s2.s; | ||
// Real a.s3.r; | ||
// Real a.s3.f; | ||
// Real a.s3.s; | ||
// Real a.instream_s1; | ||
// Real a.instream_s2; | ||
// Real a.instream_s3; | ||
// Real instream_a_s1; | ||
// Real instream_a_s2; | ||
// equation | ||
// a.instream_s1 = a.s1.s; | ||
// a.instream_s2 = a.s2.s; | ||
// instream_a_s1 = a.s1.s; | ||
// instream_a_s2 = a.s2.s; | ||
// a.s1.f = 0.0; | ||
// a.s2.f = 0.0; | ||
// a.s3.f = 0.0; | ||
// (-a.s1.f) + (-a.s3.f) + (-a.s2.f) = 0.0; | ||
// a.s1.r = a.s2.r; | ||
// a.s1.r = a.s3.r; | ||
// a.s2.s = (max(a.s1.f, 2.0) * a.s1.s + max(a.s3.f, 2.0) * a.s3.s) / (max(a.s1.f, 2.0) + max(a.s3.f, 2.0)) " equation generated by stream handling"; | ||
// a.s3.s = (max(a.s1.f, 2.0) * a.s1.s + max(a.s2.f, 2.0) * a.s2.s) / (max(a.s1.f, 2.0) + max(a.s2.f, 2.0)) " equation generated by stream handling"; | ||
// a.s1.s = (max(a.s3.f, 2.0) * a.s3.s + max(a.s2.f, 2.0) * a.s2.s) / (max(a.s3.f, 2.0) + max(a.s2.f, 2.0)) " equation generated by stream handling"; | ||
// end InStreamFlowThreshold; | ||
// 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,68 @@ | ||
// name: InStreamNominalThreshold | ||
// keywords: stream instream connector outside | ||
// status: correct | ||
// | ||
// Checks that the nominal value of a flow is used for the flow rate threshold. | ||
// | ||
|
||
connector S | ||
Real r; | ||
flow Real f; | ||
stream Real s; | ||
end S; | ||
|
||
model A | ||
S s1(f(nominal = 1e-3)); | ||
S s2(f(nominal = 2000)); | ||
S s3; | ||
Real instream_s1; | ||
Real instream_s2; | ||
Real instream_s3; | ||
equation | ||
connect(s1, s2); | ||
connect(s2, s3); | ||
instream_s1 = inStream(s1.s); | ||
instream_s2 = inStream(s2.s); | ||
end A; | ||
|
||
model InStreamNominalThreshold | ||
A a; | ||
Real instream_a_s1; | ||
Real instream_a_s2; | ||
equation | ||
instream_a_s1 = inStream(a.s1.s); | ||
instream_a_s2 = inStream(a.s2.s); | ||
end InStreamNominalThreshold; | ||
|
||
// Result: | ||
// class InStreamNominalThreshold | ||
// Real a.s1.r; | ||
// Real a.s1.f(nominal = 0.001); | ||
// Real a.s1.s; | ||
// Real a.s2.r; | ||
// Real a.s2.f(nominal = 2000.0); | ||
// Real a.s2.s; | ||
// Real a.s3.r; | ||
// Real a.s3.f; | ||
// Real a.s3.s; | ||
// Real a.instream_s1; | ||
// Real a.instream_s2; | ||
// Real a.instream_s3; | ||
// Real instream_a_s1; | ||
// Real instream_a_s2; | ||
// equation | ||
// a.instream_s1 = a.s1.s; | ||
// a.instream_s2 = a.s2.s; | ||
// instream_a_s1 = a.s1.s; | ||
// instream_a_s2 = a.s2.s; | ||
// a.s1.f = 0.0; | ||
// a.s2.f = 0.0; | ||
// a.s3.f = 0.0; | ||
// (-a.s1.f) + (-a.s3.f) + (-a.s2.f) = 0.0; | ||
// a.s1.r = a.s2.r; | ||
// a.s1.r = a.s3.r; | ||
// a.s2.s = (max(a.s1.f, 1e-10) * a.s1.s + max(a.s3.f, 1e-07) * a.s3.s) / (max(a.s1.f, 1e-10) + max(a.s3.f, 1e-07)) " equation generated by stream handling"; | ||
// a.s3.s = (max(a.s1.f, 1e-10) * a.s1.s + max(a.s2.f, 0.0002) * a.s2.s) / (max(a.s1.f, 1e-10) + max(a.s2.f, 0.0002)) " equation generated by stream handling"; | ||
// a.s1.s = (max(a.s3.f, 1e-07) * a.s3.s + max(a.s2.f, 0.0002) * a.s2.s) / (max(a.s3.f, 1e-07) + max(a.s2.f, 0.0002)) " equation generated by stream handling"; | ||
// end InStreamNominalThreshold; | ||
// 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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// name: DrumBoiler | ||
// cflags: --flowThreshold=1e-15 | ||
// status: correct | ||
|
||
loadModel(Modelica,{"3.2"}); | ||
|
1 change: 1 addition & 0 deletions
1
openmodelica/cruntime/optimization/benchmark/runExReduceDrumBoiler.mos
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
1 change: 1 addition & 0 deletions
1
openmodelica/cruntime/optimization/benchmark/runReduceDrumBoiler.mos
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// name: ReduceDrumBoiler | ||
// cflags: --flowThreshold=1e-15 | ||
// status: correct | ||
|
||
loadModel(Modelica,{"3.2"}); | ||
|
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