Skip to content

Commit

Permalink
- Fixed various balance issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Feb 10, 2014
1 parent e527317 commit 537c57e
Show file tree
Hide file tree
Showing 23 changed files with 131 additions and 83 deletions.
5 changes: 4 additions & 1 deletion ModelicaCompliance/Classes/Specialized/BlockInputOutput.mo
Expand Up @@ -4,13 +4,16 @@ model BlockInputOutput
extends Icons.TestCase;

connector C
Real e = 1.0;
Real e;
flow Real f;
end C;

block B
input C c1;
output C c2;
equation
c2.e = 1.0;
c2.f = c1.e;
end B;

B b;
Expand Down
13 changes: 5 additions & 8 deletions ModelicaCompliance/Components/Conditional/CompRemovalBalanced.mo
@@ -1,7 +1,6 @@
within ModelicaCompliance.Components.Conditional;

model CompRemovalBalanced
extends Icons.TestCase;

connector C
Real e;
Expand All @@ -10,22 +9,20 @@ model CompRemovalBalanced

model A
C c;
equation
c.e = 2.0;
end A;

A a1;
A a2 if false;
A a3;
equation
a1.c.e = 2.0;
a1.c.f = 4.0;
connect(a1.c, a2.c);
connect(a1.c, a3.c);


annotation (
__ModelicaAssociation(TestCase(shouldPass = true, section = {"4.4.5"})),
experiment(StopTime = 0.01),
Documentation(
info = "<html>Tests that a component declared with a condition that is
false is removed from the DAE. The model becomes unbalanced if a2 is not
removed along with the connection to it.</html>"));
false is removed from the DAE. The model becomes structurally singular
if a2 is not removed along with the connection to it.</html>"));
end CompRemovalBalanced;
Expand Up @@ -10,23 +10,21 @@ model CompRemovalBalancedParam

model A
C c;
equation
c.e = 2.0;
end A;

parameter Boolean b = false;
A a1;
A a2 if b;
A a3;
equation
a1.c.e = 2.0;
a1.c.f = 4.0;
connect(a1.c, a2.c);
connect(a1.c, a3.c);


annotation (
__ModelicaAssociation(TestCase(shouldPass = true, section = {"4.4.5"})),
experiment(StopTime = 0.01),
Documentation(
info = "<html>Tests that a component declared with a condition that is
a parameter with value false is removed from the DAE. The model becomes
unbalanced if a2 is not removed along with the connection to it.</html>"));
structurally singular if a2 is not removed along with the connection to it.</html>"));
end CompRemovalBalancedParam;
22 changes: 15 additions & 7 deletions ModelicaCompliance/Components/Conditional/CompRemovalUnbalanced.mo
Expand Up @@ -10,20 +10,28 @@ model CompRemovalUnbalanced

model A
C c;
equation
c.e = 2.0;
end A;

A a1;
A a2 if false;
equation
a1.c.e = 2.0;
a1.c.f = 4.0;
connect(a1.c, a2.c);
model B
C c;
equation
c.f = 1.0;
end B;

A a;
B b1 if false;
B b2;
equation
connect(a.c, b1.c);
connect(b1.c, b2.c);

annotation (
__ModelicaAssociation(TestCase(shouldPass = false, section = {"4.4.5"})),
experiment(StopTime = 0.01),
Documentation(
info = "<html>Tests that a component declared with a condition that is
false is removed from the DAE. The test should fail since the model
becomes unbalanced if a2 is removed.</html>"));
becomes structurally singular if b1 is removed.</html>"));
end CompRemovalUnbalanced;
Expand Up @@ -10,21 +10,29 @@ model CompRemovalUnbalancedParam

model A
C c;
equation
c.e = 2.0;
end A;

model B
C c;
equation
c.f = 1.0;
end B;

parameter Boolean b = false;
A a1;
A a2 if b;
equation
a1.c.e = 2.0;
a1.c.f = 4.0;
connect(a1.c, a2.c);
A a;
B b1 if b;
B b2;
equation
connect(a.c, b1.c);
connect(b1.c, b2.c);

annotation (
__ModelicaAssociation(TestCase(shouldPass = false, section = {"4.4.5"})),
experiment(StopTime = 0.01),
Documentation(
info = "<html>Tests that a component declared with a condition that is
a parameter with value false is removed from the DAE. The test should fail
since the model becomes unbalanced if a2 is removed.</html>"));
since the model becomes structurally singular if b1 is removed.</html>"));
end CompRemovalUnbalancedParam;
13 changes: 8 additions & 5 deletions ModelicaCompliance/Components/Prefixes/DiscreteValidClassType.mo
Expand Up @@ -13,20 +13,23 @@ model DiscreteValidClassType
end R;

model M
discrete C c1;
discrete C c1(f(fixed = true), d(fixed = true));
C c2;
equation
when true then
c1.d = 4.0;
c1.f = 5.0;
end when;
end M;

discrete Real x;
discrete Real x(fixed = true);
M m;
discrete R r;
discrete R r(x(fixed = true));
equation
connect(m.c1, m.c2);

when true then
x = 2.0;
m.c1.d = 4.0;
m.c1.f = 5.0;
r.x = 6.0;
end when;

Expand Down
9 changes: 6 additions & 3 deletions ModelicaCompliance/Components/Prefixes/FlowValidClassType.mo
@@ -1,7 +1,7 @@
within ModelicaCompliance.Components.Prefixes;

model FlowValidClassType
extends Icons.TestCase;
//extends Icons.TestCase;

record R
Real f;
Expand All @@ -22,8 +22,11 @@ model FlowValidClassType
end CC;

model M
CR cr(e = 1.0);
CC cc(e = 2.0);
CR cr;
CC cc;
equation
cr.e = 1.0;
cc.e = 2.0;
end M;

M m;
Expand Down
7 changes: 4 additions & 3 deletions ModelicaCompliance/Connections/Declarations/ArrayEquations.mo
Expand Up @@ -10,15 +10,16 @@ model ArrayEquations

model M
C c1, c2, c3;
equation
c1.e = {1.0, 2.0, 3.0};
c1.f = {4.0, 5.0, 6.0};
c2.f = {7.0, 8.0, 9.0};
end M;

M m;
equation
connect(m.c1, m.c2);
connect(m.c2, m.c3);
m.c1.e = {1.0, 2.0, 3.0};
m.c1.f = {4.0, 5.0, 6.0};
m.c2.f = {7.0, 8.0, 9.0};

assert(Util.compareReal(m.c1.e[1], 1.0), "m.c1.e[1] was not set correctly.");
assert(Util.compareReal(m.c1.e[2], 2.0), "m.c1.e[2] was not set correctly.");
Expand Down
12 changes: 6 additions & 6 deletions ModelicaCompliance/Connections/Declarations/ConnectArrays.mo
Expand Up @@ -10,20 +10,20 @@ model ConnectArrays

model M
C c[2];
parameter Integer n = 1;
equation
c[n].e = 1.0;
c[n].f = 2.0;
end M;

M m1, m2;
M m1(n = 1), m2(n = 2);
equation
m1.c[1].e = 1.0;
m1.c[1].f = 2.0;
m1.c[2].e = 1.0;
m1.c[2].f = 2.0;
connect(m1.c, m2.c);

assert(Util.compareReal(m2.c[1].e, 1.0), "m2.c[1].e was given an incorrect value.");
assert(Util.compareReal(m2.c[1].f, -2.0), "m2.c[1].f was given an incorrect value.");
assert(Util.compareReal(m2.c[2].e, 1.0), "m2.c[2].e was given an incorrect value.");
assert(Util.compareReal(m2.c[2].f, -2.0), "m2.c[2].f was given an incorrect value.");
assert(Util.compareReal(m2.c[2].f, 2.0), "m2.c[2].f was given an incorrect value.");
annotation (
__ModelicaAssociation(TestCase(shouldPass = true, section = {"9.1"})),
experiment(StopTime = 0.01),
Expand Down
Expand Up @@ -10,13 +10,14 @@ model ConnectParamSubscript

model M
C c[2];
equation
c[1].e = 1.0;
c[1].f = 2.0;
end M;

parameter Integer n = 2;
M m;
equation
m.c[1].e = 1.0;
m.c[2].f = 2.0;
connect(m.c[1], m.c[n]);

annotation (
Expand Down
Expand Up @@ -10,15 +10,14 @@ model ConnectWholeDim

model M
C c[2];
equation
c[1].e = c[1].f;
c[2].e = c[2].f;
end M;

parameter Integer n = 2;
M m1, m2;
equation
m1.c[1].e = 1.0;
m1.c[1].f = 2.0;
m1.c[2].e = 1.0;
m1.c[2].f = 2.0;
connect(m1.c[:], m2.c[1:2]);

annotation (
Expand Down
Expand Up @@ -43,13 +43,14 @@ model OperatorRecordEquations
model M
C c1;
C c2;
equation
c1.e = Complex(1.0, 2.0);
c1.f = Complex(3.0, 4.0);
end M;

M m;
equation
connect(m.c1, m.c2);
m.c1.e = Complex(1.0, 2.0);
m.c1.f = Complex(3.0, 4.0);

assert(Util.compareReal(m.c1.e.re, 1.0), "m.c1.e.re has incorrect value.");
assert(Util.compareReal(m.c1.e.im, 2.0), "m.c1.e.im has incorrect value.");
Expand Down
Expand Up @@ -10,15 +10,16 @@ model SimpleEquations

model M
C c1, c2, c3;
equation
c1.e = 2.0;
c1.f = 3.0;
c2.f = 4.0;
end M;

M m;
equation
connect(m.c1, m.c2);
connect(m.c2, m.c3);
m.c1.e = 2.0;
m.c1.f = 3.0;
m.c2.f = 4.0;

assert(Util.compareReal(m.c1.e, 2.0), "m.c1.e was not set correctly.");
assert(Util.compareReal(m.c2.e, 2.0), "m.c2.e was not set correctly.");
Expand Down
3 changes: 2 additions & 1 deletion ModelicaCompliance/Connections/Expandable/AugmentComplex.mo
Expand Up @@ -13,13 +13,14 @@ model AugmentComplex

model M
C c;
equation
c.e = 1.0;
end M;

EC ec;
M m;
equation
connect(m.c, ec.c);
m.c.e = 1.0;

annotation (
__ModelicaAssociation(TestCase(shouldPass = true, section = {"9.1.3"})),
Expand Down
Expand Up @@ -14,13 +14,14 @@ model FlowInConnectorInExpandable

model M
C c;
equation
c.e = 1.0;
end M;

M m;
EC ec;
equation
connect(m.c, ec.c);
m.c.e = 1.0;

annotation (
__ModelicaAssociation(TestCase(shouldPass = true, section = {"9.1.3"})),
Expand Down
Expand Up @@ -11,13 +11,14 @@ model ConnectConstants

model M
C c1, c2;
equation
c1.e = 1.0;
c1.f = 3.0;
end M;

M m;
equation
connect(m.c1, m.c2);
m.c1.e = 1.0;
m.c1.f = 3.0;

annotation (
__ModelicaAssociation(TestCase(shouldPass = true, section = {"9.3"})),
Expand Down
Expand Up @@ -11,13 +11,14 @@ model ConnectParameters

model M
C c1, c2;
equation
c1.e = 1.0;
c1.f = 3.0;
end M;

M m;
equation
connect(m.c1, m.c2);
m.c1.e = 1.0;
m.c1.f = 3.0;

annotation (
__ModelicaAssociation(TestCase(shouldPass = true, section = {"9.3"})),
Expand Down

0 comments on commit 537c57e

Please sign in to comment.