Skip to content

Commit 6700bd2

Browse files
ptaeuberOpenModelica-Hudson
authored andcommitted
Add test for conflicting aliases and expected output
Belonging to [master]: - OpenModelica/OMCompiler#1985 - OpenModelica/OpenModelica-testsuite#770
1 parent 748835d commit 6700bd2

File tree

4 files changed

+80
-15
lines changed

4 files changed

+80
-15
lines changed

simulation/libraries/3rdParty/ThermoSysPro/ThermoSysPro.Examples.SimpleExamples.TestThreeWayValve.mos

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ getEnvironmentVar("REFERENCEFILES")+"/ThermoSysPro/ThermoSysPro.Examples.SimpleE
2828
// record SimulationResult
2929
// resultFile = "ThermoSysPro.Examples.SimpleExamples.TestThreeWayValve_res.mat",
3030
// simulationOptions = "startTime = 0.0, stopTime = 1000.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'ThermoSysPro.Examples.SimpleExamples.TestThreeWayValve', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
31-
// messages = "stdout | warning | While solving non-linear system an assertion failed during initialization.
32-
// | | | | | The non-linear solver tries to solve the problem that could take some time.
33-
// | | | | | It could help to provide better start-values for the iteration variables.
34-
// | | | | | For more information simulate with -lv LOG_NLS
35-
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
31+
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
3632
// LOG_SUCCESS | info | The simulation finished successfully.
3733
// "
3834
// end SimulationResult;

simulation/modelica/initialization/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ OverdeterminedInitialization.Fluid.TwoVolumesFullInitial.mos \
7777
OverdeterminedInitialization.Fluid.TwoVolumesFullSteadyStatePressureAndTemperature.mos \
7878
redundantInitialEquations.mos \
7979
conflictingStartValues.mos \
80+
conflictingStartValues2.mos \
8081

8182
# test that currently fail. Move up when fixed.
8283
# Run make failingtest

simulation/modelica/initialization/conflictingStartValues.mos

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ simulate(conflictingStartValues, stopTime=0.0, simflags="-output=x,a"); getError
4040
// LOG_SUCCESS | info | The simulation finished successfully.
4141
// "
4242
// end SimulationResult;
43-
// "Warning: Alias set with conflicting start values having the same priority
44-
// * Candidate: c(start = 10.0)
45-
// * Candidate: b(start = p = 100.0)
46-
// => Select value from c(start = 10.0) for variable: a
43+
// "Warning: Alias set with conflicting start values
44+
// * Candidate: c(start = 10.0, confidence number = 6)
45+
// * Candidate: b(start = p = 100.0, confidence number = 1)
46+
// => Select value from b(start = p = 100.0) for variable: a
4747
// Warning: Alias set with conflicting nominal values
48-
// * Candidate: b(nominal = 1000.0)
49-
// * Candidate: a(nominal = 100.0)
48+
// * Candidate: b(nominal = 1000.0, confidence number = 6)
49+
// * Candidate: a(nominal = 100.0, confidence number = 6)
5050
// => Select value from a(nominal = 100.0) for variable: a
51-
// Warning: Alias set with conflicting start values having the same priority
52-
// * Candidate: z(start = 4.0)
53-
// * Candidate: y(start = 3.0)
54-
// => Select value from z(start = 4.0) for variable: x
51+
// Warning: Alias set with conflicting start values
52+
// * Candidate: z(start = 4.0, confidence number = 6)
53+
// * Candidate: y(start = 3.0, confidence number = 6)
54+
// => Select value from y(start = 3.0) for variable: x
5555
// "
5656
// endResult
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// name: conflictingStartValues2
2+
// keywords: initialization conflict
3+
// status: correct
4+
//
5+
// ticket:4329,4603
6+
7+
loadString("
8+
model start
9+
parameter Real s = 1;
10+
equation
11+
end start;
12+
13+
model squared
14+
Real x (start=Start.s);
15+
Real y (start=10);
16+
Real z (start=100);
17+
start Start;
18+
equation
19+
x*y = 9;
20+
x = y;
21+
x = z;
22+
end squared;
23+
24+
model squared2
25+
squared S (y(start=p2));
26+
Real z;
27+
parameter Real p2=3;
28+
equation
29+
S.x + S.y = S.z + z;
30+
end squared2;
31+
32+
function f
33+
input Real x;
34+
output Real y;
35+
algorithm
36+
y := 3*x;
37+
end f;
38+
39+
model conflictingStartValues2
40+
squared2 S2 (S.z(start=f(p+p)));
41+
parameter Real p=-0.5;
42+
equation
43+
end conflictingStartValues2;
44+
");getErrorString();
45+
46+
setCommandLineOptions("-d=aliasConflicts"); getErrorString();
47+
simulate(conflictingStartValues2, stopTime=0.0, simflags="-output S2.S.x,S2.S.y,S2.S.z"); getErrorString();
48+
49+
// Result:
50+
// true
51+
// ""
52+
// true
53+
// ""
54+
// record SimulationResult
55+
// resultFile = "conflictingStartValues2_res.mat",
56+
// simulationOptions = "startTime = 0.0, stopTime = 0.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'conflictingStartValues2', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-output S2.S.x,S2.S.y,S2.S.z'",
57+
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
58+
// time=0,S2.S.x=-3,S2.S.y=-3,S2.S.z=-3
59+
// LOG_SUCCESS | info | The simulation finished successfully.
60+
// "
61+
// end SimulationResult;
62+
// "Warning: Alias set with conflicting start values
63+
// * Candidate: S2.S.x(start = S2.S.Start.s = 1.0, confidence number = 3)
64+
// * Candidate: S2.S.z(start = f(2.0 * p) = f(-1.0), confidence number = 1)
65+
// * Candidate: S2.S.y(start = S2.p2 = 3.0, confidence number = 2)
66+
// => Select value from S2.S.z(start = f(2.0 * p) = f(-1.0)) for variable: S2.S.x
67+
// "
68+
// endResult

0 commit comments

Comments
 (0)