Skip to content

Commit

Permalink
Added tests for stream flow rate threshold, #3382.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Jul 16, 2015
1 parent cbb3297 commit 0569334
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 18 deletions.
69 changes: 69 additions & 0 deletions flattening/modelica/streams/InStreamFlowThreshold.mo
@@ -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
68 changes: 68 additions & 0 deletions flattening/modelica/streams/InStreamNominalThreshold.mo
@@ -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
2 changes: 2 additions & 0 deletions flattening/modelica/streams/Makefile
Expand Up @@ -3,8 +3,10 @@ TEST=../../../rtest -v
TESTFILES=\
ActualStream.mo \
ActualStreamMinMax.mo \
InStreamFlowThreshold.mo \
InStreamInsideOutside.mo \
InStreamInvalidArgument.mo \
InStreamNominalThreshold.mo \
InStreamPipeline.mo \
InStreamTwoInside.mo \
InStreamTwoOutside.mo \
Expand Down
6 changes: 3 additions & 3 deletions flattening/modelica/streams/StreamConcept_NoMedium_Total.mo
Expand Up @@ -2271,7 +2271,7 @@ end SiemensPower_Components_Valves_Tests_valve_fixeddensity_test;
// valve_fixeddensity1.m_flow = valve_fixeddensity1.port_a.m_flow;
// valve_fixeddensity1.port_a.m_flow + valve_fixeddensity1.port_b.m_flow = 0.0;
// valve_fixeddensity1.port_a.h_outflow = watersink_ph_StreamConcept.port.h_outflow;
// valve_fixeddensity1.port_b.h_outflow = (max(-InStreamEnthalpy.port.m_flow, 1e-15) * InStreamEnthalpy.port.h_outflow + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-15) * watersink_ph_StreamConcept1.port.h_outflow) / (max(-InStreamEnthalpy.port.m_flow, 1e-15) + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-15));
// valve_fixeddensity1.port_b.h_outflow = (max(-InStreamEnthalpy.port.m_flow, 1e-07) * InStreamEnthalpy.port.h_outflow + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-07) * watersink_ph_StreamConcept1.port.h_outflow) / (max(-InStreamEnthalpy.port.m_flow, 1e-07) + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-07));
// if noEvent(valve_fixeddensity1.m_flow > valve_fixeddensity1.m_flow_small) then
// valve_fixeddensity1.fromleft = 1.0;
// elseif noEvent(valve_fixeddensity1.m_flow < (-valve_fixeddensity1.m_flow_small)) then
Expand All @@ -2280,7 +2280,7 @@ end SiemensPower_Components_Valves_Tests_valve_fixeddensity_test;
// valve_fixeddensity1.fromleft = 0.5 * (1.0 + -0.5 * valve_fixeddensity1.m_flow * (-3.0 + (valve_fixeddensity1.m_flow / valve_fixeddensity1.m_flow_small) ^ 2.0) / valve_fixeddensity1.m_flow_small);
// end if;
// valve_fixeddensity1.p = valve_fixeddensity1.fromleft * valve_fixeddensity1.port_a.p + (1.0 - valve_fixeddensity1.fromleft) * valve_fixeddensity1.port_b.p;
// valve_fixeddensity1.h = valve_fixeddensity1.fromleft * (max(-InStreamEnthalpy.port.m_flow, 1e-15) * InStreamEnthalpy.port.h_outflow + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-15) * watersink_ph_StreamConcept1.port.h_outflow) / (max(-InStreamEnthalpy.port.m_flow, 1e-15) + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-15)) + (1.0 - valve_fixeddensity1.fromleft) * watersink_ph_StreamConcept.port.h_outflow;
// valve_fixeddensity1.h = valve_fixeddensity1.fromleft * (max(-InStreamEnthalpy.port.m_flow, 1e-07) * InStreamEnthalpy.port.h_outflow + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-07) * watersink_ph_StreamConcept1.port.h_outflow) / (max(-InStreamEnthalpy.port.m_flow, 1e-07) + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-07)) + (1.0 - valve_fixeddensity1.fromleft) * watersink_ph_StreamConcept.port.h_outflow;
// valve_fixeddensity1.dp = valve_fixeddensity1.port_a.p - valve_fixeddensity1.port_b.p;
// watersink_ph_StreamConcept.port.p = watersink_ph_StreamConcept.p_in;
// watersink_ph_StreamConcept.port.h_outflow = watersink_ph_StreamConcept.h0;
Expand All @@ -2291,7 +2291,7 @@ end SiemensPower_Components_Valves_Tests_valve_fixeddensity_test;
// watersink_ph_StreamConcept1.port.h_outflow = watersink_ph_StreamConcept1.h0;
// InStreamEnthalpy.port.m_flow = 0.0;
// InStreamEnthalpy.port.h_outflow = 0.0;
// InStreamEnthalpy.h_out = (max(-valve_fixeddensity1.port_a.m_flow, 1e-15) * valve_fixeddensity1.port_a.h_outflow + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-15) * watersink_ph_StreamConcept1.port.h_outflow) / (max(-valve_fixeddensity1.port_a.m_flow, 1e-15) + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-15));
// InStreamEnthalpy.h_out = (max(-valve_fixeddensity1.port_a.m_flow, 1e-07) * valve_fixeddensity1.port_a.h_outflow + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-07) * watersink_ph_StreamConcept1.port.h_outflow) / (max(-valve_fixeddensity1.port_a.m_flow, 1e-07) + max(-watersink_ph_StreamConcept1.port.m_flow, 1e-07));
// valve_fixeddensity1.port_a.m_flow + InStreamEnthalpy.port.m_flow + watersink_ph_StreamConcept1.port.m_flow = 0.0;
// valve_fixeddensity1.port_b.m_flow + watersink_ph_StreamConcept.port.m_flow = 0.0;
// valve_fixeddensity1.port_b.p = watersink_ph_StreamConcept.port.p;
Expand Down
@@ -1,4 +1,5 @@
// name: DrumBoiler
// cflags: --flowThreshold=1e-15
// status: correct

loadModel(Modelica,{"3.2"});
Expand Down
@@ -1,4 +1,5 @@
// name: ExtendsReduceDrumBoiler
// cflags: --flowThreshold=1e-15
// status: correct

loadModel(Modelica,{"3.2"});
Expand Down
@@ -1,4 +1,5 @@
// name: ReduceDrumBoiler
// cflags: --flowThreshold=1e-15
// status: correct

loadModel(Modelica,{"3.2"});
Expand Down
Expand Up @@ -45,40 +45,40 @@ runScript(modelTesting);getErrorString();
// Result file: Modelica.Fluid.Examples.TraceSubstances.RoomCO2WithControls_res.mat
// Messages: assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductOut.mCs[1,1] >= 0.0
// assert | warning | Variable ductOut.mCs[1,1] out of [min, max] interval: ductOut.mCs[1,1] >= 0.0 has value: -1.49935e-17
// assert | warning | Variable ductOut.mCs[1,1] out of [min, max] interval: ductOut.mCs[1,1] >= 0.0 has value: -1.42247e-17
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductOut.mCs[2,1] >= 0.0
// assert | warning | Variable ductOut.mCs[2,1] out of [min, max] interval: ductOut.mCs[2,1] >= 0.0 has value: -6.45958e-26
// assert | warning | Variable ductOut.mCs[2,1] out of [min, max] interval: ductOut.mCs[2,1] >= 0.0 has value: -5.25393e-26
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductOut.mCs_scaled[1,1] >= 0.0
// assert | warning | Variable ductOut.mCs_scaled[1,1] out of [min, max] interval: ductOut.mCs_scaled[1,1] >= 0.0 has value: -9.87062e-15
// assert | warning | Variable ductOut.mCs_scaled[1,1] out of [min, max] interval: ductOut.mCs_scaled[1,1] >= 0.0 has value: -9.36454e-15
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductOut.mCs_scaled[2,1] >= 0.0
// assert | warning | Variable ductOut.mCs_scaled[2,1] out of [min, max] interval: ductOut.mCs_scaled[2,1] >= 0.0 has value: -4.25252e-23
// assert | warning | Variable ductOut.mCs_scaled[2,1] out of [min, max] interval: ductOut.mCs_scaled[2,1] >= 0.0 has value: -3.45881e-23
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductOut.Cs[1,1] >= 0.0
// assert | warning | Variable ductOut.Cs[1,1] out of [min, max] interval: ductOut.Cs[1,1] >= 0.0 has value: -2.83566e-16
// assert | warning | Variable ductOut.Cs[1,1] out of [min, max] interval: ductOut.Cs[1,1] >= 0.0 has value: -2.69027e-16
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductOut.Cs[2,1] >= 0.0
// assert | warning | Variable ductOut.Cs[2,1] out of [min, max] interval: ductOut.Cs[2,1] >= 0.0 has value: -1.22168e-24
// assert | warning | Variable ductOut.Cs[2,1] out of [min, max] interval: ductOut.Cs[2,1] >= 0.0 has value: -9.93656e-25
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductIn.mCs[2,1] >= 0.0
// assert | warning | Variable ductIn.mCs[2,1] out of [min, max] interval: ductIn.mCs[2,1] >= 0.0 has value: -1.83586e-17
// assert | warning | Variable ductIn.mCs[2,1] out of [min, max] interval: ductIn.mCs[2,1] >= 0.0 has value: -1.00662e-18
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductIn.mCs_scaled[2,1] >= 0.0
// assert | warning | Variable ductIn.mCs_scaled[2,1] out of [min, max] interval: ductIn.mCs_scaled[2,1] >= 0.0 has value: -1.2086e-14
// assert | warning | Variable ductIn.mCs_scaled[2,1] out of [min, max] interval: ductIn.mCs_scaled[2,1] >= 0.0 has value: -6.62685e-16
// assert | warning | The following assertion has been violated at time 172.800000
// | | | | ductIn.Cs[2,1] >= 0.0
// assert | warning | Variable ductIn.Cs[2,1] out of [min, max] interval: ductIn.Cs[2,1] >= 0.0 has value: -3.47209e-16
// assert | warning | The following assertion has been violated at time 518.400000
// assert | warning | Variable ductIn.Cs[2,1] out of [min, max] interval: ductIn.Cs[2,1] >= 0.0 has value: -1.90378e-17
// assert | warning | The following assertion has been violated at time 345.600000
// | | | | ductIn.mCs[1,1] >= 0.0
// assert | warning | Variable ductIn.mCs[1,1] out of [min, max] interval: ductIn.mCs[1,1] >= 0.0 has value: -1.4313e-16
// assert | warning | The following assertion has been violated at time 518.400000
// assert | warning | Variable ductIn.mCs[1,1] out of [min, max] interval: ductIn.mCs[1,1] >= 0.0 has value: -8.01515e-18
// assert | warning | The following assertion has been violated at time 345.600000
// | | | | ductIn.mCs_scaled[1,1] >= 0.0
// assert | warning | Variable ductIn.mCs_scaled[1,1] out of [min, max] interval: ductIn.mCs_scaled[1,1] >= 0.0 has value: -9.42263e-14
// assert | warning | The following assertion has been violated at time 518.400000
// assert | warning | Variable ductIn.mCs_scaled[1,1] out of [min, max] interval: ductIn.mCs_scaled[1,1] >= 0.0 has value: -5.2766e-15
// assert | warning | The following assertion has been violated at time 345.600000
// | | | | ductIn.Cs[1,1] >= 0.0
// assert | warning | Variable ductIn.Cs[1,1] out of [min, max] interval: ductIn.Cs[1,1] >= 0.0 has value: -2.70696e-15
// assert | warning | Variable ductIn.Cs[1,1] out of [min, max] interval: ductIn.Cs[1,1] >= 0.0 has value: -1.51588e-16
//
// Files Equal!
// "true
Expand Down

0 comments on commit 0569334

Please sign in to comment.