Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
niklwors committed Jul 28, 2015
2 parents fbd19fb + e392b23 commit c93a404
Show file tree
Hide file tree
Showing 123 changed files with 4,228 additions and 3,509 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@
*.so
*_info.json
*.fail_log
/failed.*
difftool/lex.yy.c
openmodelica/bootstrapping/CodegenC.*
openmodelica/bootstrapping/CodegenUtil.tpl
Expand Down
2 changes: 1 addition & 1 deletion flattening/modelica/mosfiles/UnusedVariable.mos
Expand Up @@ -17,6 +17,6 @@ translateModel(M);getErrorString();
// true
// false
// "[<interactive>:4:3-4:9:writable] Error: Variable y is not referenced in any equation (possibly after symbolic manipulations).
// Error: Internal error pre-optimization module clockPartitioning failed.
// Error: pre-optimization module clockPartitioning failed.
// "
// endResult
25 changes: 18 additions & 7 deletions flattening/modelica/statemachines/ConferenceTut1.mo
Expand Up @@ -34,13 +34,24 @@ end ConferenceTut1;
// Result:
// class ConferenceTut1
// Integer i(start = 0);
// output Integer state1.i = i;
// output Integer state2.i = i;
// stateMachine state1
// state state1
// output Integer state1.i;
// equation
// state1.i = 2 + previous(i);
// end state1;
//
// state state2
// output Integer state2.i;
// equation
// state2.i = -1 + previous(i);
// end state2;
// equation
// initialState(state1);
// transition(state1, state2, i > 10, false, true, false, 1);
// transition(state2, state1, i < 1, false, true, false, 1);
// end state1;
// equation
// state1.i = 2 + previous(state1.i);
// state2.i = -1 + previous(state2.i);
// initialState(state1);
// transition(state1, state2, i > 10, false, true, false, 1);
// transition(state2, state1, i < 1, false, true, false, 1);
// i = if activeState(state1) then state1.i else if activeState(state2) then state2.i else previous(i);
// end ConferenceTut1;
// endResult
Expand Up @@ -84,32 +84,73 @@ end HierarchicalAndParallelStateMachine;
// Result:
// class HierarchicalAndParallelStateMachine "Example from the MLS 3.3, Section 17.3.7"
// Integer v(start = 0);
// Integer state1.count(start = 0);
// output Integer state1.v = v;
// output Integer state1.stateA.v = state1.v;
// output Integer state1.stateB.v = state1.v;
// output Integer state1.stateC.count = state1.count;
// Integer state1.stateX.i(start = 0);
// Integer state1.stateX.w;
// Integer state1.stateY.j(start = 0);
// output Integer state2.v = v;
// stateMachine state1
// state state1
// Integer state1.count(start = 0);
// output Integer state1.v;
// stateMachine state1.stateX
// state state1.stateX
// Integer state1.stateX.i(start = 0);
// Integer state1.stateX.w;
// equation
// state1.stateX.i = 1 + previous(state1.stateX.i);
// state1.stateX.w = state1.v;
// end state1.stateX;
//
// state state1.stateY
// Integer state1.stateY.j(start = 0);
// equation
// state1.stateY.j = 1 + previous(state1.stateY.j);
// end state1.stateY;
// equation
// transition(state1.stateX, state1.stateY, state1.stateX.i > 20, false, true, false, 1);
// initialState(state1.stateX);
// end state1.stateX;
//
// stateMachine state1.stateA
// state state1.stateA
// output Integer state1.stateA.v;
// equation
// state1.stateA.v = 2 + previous(v);
// end state1.stateA;
//
// state state1.stateB
// output Integer state1.stateB.v;
// equation
// state1.stateB.v = -1 + previous(v);
// end state1.stateB;
//
// state state1.stateC
// output Integer state1.stateC.count;
// equation
// state1.stateC.count = 1 + previous(state1.count);
// end state1.stateC;
//
// state state1.stateD
// end state1.stateD;
// equation
// initialState(state1.stateA);
// transition(state1.stateA, state1.stateB, state1.v >= 6, false, true, false, 1);
// transition(state1.stateB, state1.stateC, state1.v == 0, false, true, false, 1);
// transition(state1.stateC, state1.stateA, true, false, true, false, 2);
// transition(state1.stateC, state1.stateD, state1.count >= 2, false, true, false, 1);
// end state1.stateA;
// equation
// state1.v = if activeState(state1.stateA) then state1.stateA.v else if activeState(state1.stateB) then state1.stateB.v else previous(v);
// state1.count = if activeState(state1.stateC) then state1.stateC.count else previous(state1.count);
// end state1;
//
// state state2
// output Integer state2.v;
// equation
// state2.v = 5 + previous(v);
// end state2;
// equation
// initialState(state1);
// transition(state1, state2, activeState(state1.stateD) and activeState(state1.stateY), false, true, false, 1);
// transition(state2, state1, v >= 20, false, true, false, 1);
// end state1;
// equation
// state1.stateA.v = 2 + previous(state1.stateA.v);
// state1.stateB.v = -1 + previous(state1.stateB.v);
// state1.stateC.count = 1 + previous(state1.stateC.count);
// state1.stateX.i = 1 + previous(state1.stateX.i);
// state1.stateX.w = state1.v;
// state1.stateY.j = 1 + previous(state1.stateY.j);
// transition(state1.stateX, state1.stateY, state1.stateX.i > 20, false, true, false, 1);
// initialState(state1.stateX);
// initialState(state1.stateA);
// transition(state1.stateA, state1.stateB, state1.v >= 6, false, true, false, 1);
// transition(state1.stateB, state1.stateC, state1.v == 0, false, true, false, 1);
// transition(state1.stateC, state1.stateA, true, false, true, false, 2);
// transition(state1.stateC, state1.stateD, state1.count >= 2, false, true, false, 1);
// state2.v = 5 + previous(state2.v);
// initialState(state1);
// transition(state1, state2, activeState(state1.stateD) and activeState(state1.stateY), false, true, false, 1);
// transition(state2, state1, v >= 20, false, true, false, 1);
// v = if activeState(state1) then state1.v else if activeState(state2) then state2.v else previous(v);
// end HierarchicalAndParallelStateMachine;
// endResult
// endResult
6 changes: 1 addition & 5 deletions flattening/modelica/statemachines/InitialState2Test.mo
@@ -1,6 +1,6 @@
// name: InitialState2Test
// keywords: state machines features
// status: correct
// status: wrong

model InitialState2Test
block AState
Expand All @@ -11,8 +11,4 @@ equation
end InitialState2Test;

// Result:
// class InitialState2Test
// equation
// initialState(aState);
// end InitialState2Test;
// endResult
7 changes: 1 addition & 6 deletions flattening/modelica/statemachines/InitialStateTest.mo
@@ -1,6 +1,6 @@
// name: InitialStateTest
// keywords: state machines features
// status: correct
// status: wrong

model InitialStateTest
block AState
Expand All @@ -12,9 +12,4 @@ equation
end InitialStateTest;

// Result:
// class InitialStateTest
// output Real aState.dummy;
// equation
// initialState(aState);
// end InitialStateTest;
// endResult
8 changes: 4 additions & 4 deletions flattening/modelica/statemachines/Makefile
Expand Up @@ -3,16 +3,16 @@ TEST = ../../../rtest -v
TESTFILES = \
TicksInStateTest.mo \
TimeInStateTest.mo \
InitialStateTest.mo \
HierarchicalAndParallelStateMachine.mo \
ActiveStateTest.mo \
TransitionTest.mo \
InitialState2Test.mo \
ConferenceTut1.mo \

# test that currently fail. Move up when fixed.
# Run make failingtest
FAILINGTESTFILES = \
HierarchicalAndParallelStateMachine.mo \
InitialStateTest.mo \
InitialState2Test.mo \
TransitionTest.mo \

# Dependency files that are not .mo .mos or Makefile
# Add them here or they will be cleaned.
Expand Down
10 changes: 1 addition & 9 deletions flattening/modelica/statemachines/TransitionTest.mo
@@ -1,6 +1,6 @@
// name: TransitionTest
// keywords: state machines features
// status: correct
// status: wrong

model TransitionTest
block AState
Expand All @@ -15,12 +15,4 @@ equation
end TransitionTest;

// Result:
// class TransitionTest
// output Real aState1.dummy;
// output Real aState2.dummy;
// equation
// transition(aState1, aState2, true, true, true, false, 1);
// transition(aState1, aState2, true, false, true, false, 1);
// transition(aState1, aState2, false, false, false, true, 10);
// end TransitionTest;
// endResult
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

0 comments on commit c93a404

Please sign in to comment.