Skip to content

Commit 7257817

Browse files
Willi BraunOpenModelica-Hudson
authored andcommitted
add a further test for inverse algorithm solving
Belonging to [master]: - OpenModelica/OMCompiler#2336 - OpenModelica/OpenModelica-testsuite#913
1 parent eb6a2d7 commit 7257817

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// name: InverseAlgorithm4
2+
// keywords: inverse algorithm
3+
// status: correct
4+
5+
loadString("
6+
model InverseAlgorithm4
7+
Real x;
8+
Real w;
9+
Integer y,z;
10+
equation
11+
der(x) = y;
12+
when sample(0,0.1) then
13+
w = x+sin(time);
14+
y = integer(sin(x)*w+10);
15+
z = integer(y);
16+
end when;
17+
initial algorithm
18+
y := integer(sin(2*w)+10);
19+
z := integer(y);
20+
end InverseAlgorithm4;
21+
"); getErrorString();
22+
23+
simulate(InverseAlgorithm4, simflags="-lv=LOG_SOTI"); getErrorString();
24+
25+
// Result:
26+
// true
27+
// ""
28+
// record SimulationResult
29+
// resultFile = "InverseAlgorithm4_res.mat",
30+
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'InverseAlgorithm4', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv=LOG_SOTI'",
31+
// messages = "LOG_SOTI | info | ### SOLUTION OF THE INITIALIZATION ###
32+
// | | | | | states variables
33+
// | | | | | | [1] Real x(start=0, nominal=1) = 0 (pre: 0)
34+
// | | | | | derivatives variables
35+
// | | | | | | [2] Real der(x) = 10 (pre: 0)
36+
// | | | | | other real variables
37+
// | | | | | | [3] Real w(start=0, nominal=1) = 0 (pre: 0)
38+
// | | | | | integer variables
39+
// | | | | | | [1] Integer y(start=0) = 10 (pre: 10)
40+
// | | | | | | [2] Integer z(start=0) = 0 (pre: 0)
41+
// | | | | | boolean variables
42+
// | | | | | | [1] Boolean $whenCondition1(start=true) = false (pre: true)
43+
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
44+
// LOG_SUCCESS | info | The simulation finished successfully.
45+
// "
46+
// end SimulationResult;
47+
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization").
48+
// "
49+
// endResult

simulation/modelica/algorithms_functions/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Interpolation.mos \
2828
InverseAlgorithm1.mos \
2929
InverseAlgorithm2.mos \
3030
InverseAlgorithm3.mos \
31+
InverseAlgorithm4.mos \
3132
LocalVariableInit.mos \
3233
ModelicaTest.Fluid.Dissipation.Verifications.HeatTransfer.Channel.kc_evenGapLaminar.mos \
3334
SimplePeriodicSampler.mos \

0 commit comments

Comments
 (0)