Skip to content

Commit 964a432

Browse files
Willi BraunOpenModelica-Hudson
authored andcommitted
added tests for irksco solver
1 parent 873d569 commit 964a432

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed

simulation/modelica/solver/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ problem1-dasslsteps.mos \
77
problem1-impeuler.mos \
88
problem1-trapezoid.mos \
99
problem1-imprk.mos \
10+
problem1-irksco.mos \
1011
problem1-ida.mos \
1112
problem1-symSolverImp.mos \
1213
problem1-symSolverExp.mos \
@@ -16,6 +17,7 @@ problem2-dasslsteps.mos \
1617
problem2-impeuler.mos \
1718
problem2-trapezoid.mos \
1819
problem2-imprk.mos \
20+
problem2-irksco.mos \
1921
problem2-ida.mos \
2022
problem2-idaLinearSolver.mos \
2123
problem2-imprkLS.mos \
@@ -32,6 +34,7 @@ problem4-symSolverImp.mos \
3234
problem4-symSolverExp.mos \
3335
problem5-symSolverImp.mos \
3436
problem5-symSolverExp.mos \
37+
problem6-irksco.mos \
3538
problem6-symSolverImp.mos \
3639
problem6-symSolverExp.mos \
3740
testDAEp1.mos \
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// name: problem1-irksco
2+
// status: correct
3+
// teardown_command: rm -f testSolver.problem1* output.log
4+
5+
loadFile("testSolverPackage.mo"); getErrorString();
6+
simulate(testSolver.problem1, stopTime=2e-6, method="irksco"); getErrorString();
7+
8+
res := OpenModelica.Scripting.compareSimulationResults("testSolver.problem1_res.mat",
9+
getEnvironmentVar("REFERENCEFILES")+"/solver/testSolver.problem1.mat",
10+
"testSolver.problem1_diff.csv",0.01,0.0001,
11+
{
12+
"u[1]",
13+
"u[5]",
14+
"u[15]",
15+
"u[20]",
16+
"u[25]",
17+
"u[30]",
18+
"u[35]",
19+
"u[40]",
20+
"u[45]",
21+
"u[50]",
22+
"u[55]",
23+
"u[60]",
24+
"u[65]",
25+
"u[70]",
26+
"u[75]",
27+
"u[80]",
28+
"u[85]",
29+
"u[90]",
30+
"u[95]",
31+
"u[100]",
32+
"u[105]",
33+
"u[115]",
34+
"u[120]",
35+
"u[125]",
36+
"u[130]",
37+
"u[135]",
38+
"u[140]",
39+
"u[145]",
40+
"u[150]"
41+
});
42+
getErrorString();
43+
44+
45+
// Result:
46+
// true
47+
// ""
48+
// record SimulationResult
49+
// resultFile = "testSolver.problem1_res.mat",
50+
// simulationOptions = "startTime = 0.0, stopTime = 2e-06, numberOfIntervals = 500, tolerance = 1e-06, method = 'irksco', fileNamePrefix = 'testSolver.problem1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
51+
// messages = ""
52+
// end SimulationResult;
53+
// "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").
54+
// "
55+
// {"Files Equal!"}
56+
// ""
57+
// endResult
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// name: problem2-irksco
2+
// status: correct
3+
// teardown_command: rm -f testSolver.problem2* output.log
4+
5+
stopTime := 321.8122;
6+
loadFile("testSolverPackage.mo"); getErrorString();
7+
simulate(testSolver.problem2, stopTime=stopTime, numberOfIntervals=12000, method="irksco"); getErrorString();
8+
9+
res := OpenModelica.Scripting.compareSimulationResults("testSolver.problem2_res.mat",
10+
getEnvironmentVar("REFERENCEFILES")+"/solver/testSolver.problem2.mat",
11+
"testSolver.problem2_diff.csv",0.1,0.1,
12+
{
13+
"y[1]",
14+
"y[2]",
15+
"y[3]",
16+
"y[4]",
17+
"y[5]",
18+
"y[6]",
19+
"y[7]",
20+
"y[8]",
21+
"der(y[1])",
22+
"der(y[2])",
23+
"der(y[3])",
24+
"der(y[4])",
25+
"der(y[5])",
26+
"der(y[6])",
27+
"der(y[7])",
28+
"der(y[8])"
29+
});
30+
getErrorString();
31+
32+
val(y[1], stopTime);
33+
val(y[2], stopTime);
34+
val(y[3], stopTime);
35+
val(y[4], stopTime);
36+
val(y[5], stopTime);
37+
val(y[6], stopTime);
38+
val(y[7], stopTime);
39+
val(y[8], stopTime);
40+
41+
// Result:
42+
// 321.8122
43+
// true
44+
// ""
45+
// record SimulationResult
46+
// resultFile = "testSolver.problem2_res.mat",
47+
// simulationOptions = "startTime = 0.0, stopTime = 321.8122, numberOfIntervals = 12000, tolerance = 1e-06, method = 'irksco', fileNamePrefix = 'testSolver.problem2', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
48+
// messages = ""
49+
// end SimulationResult;
50+
// "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").
51+
// "
52+
// {"Files Equal!"}
53+
// ""
54+
// 0.0007377800165165728
55+
// 0.0001443770473138093
56+
// 5.900481571640651e-05
57+
// 0.001176893518986693
58+
// 0.002404322870577208
59+
// 0.006281181632403043
60+
// 0.002873587226516164
61+
// 0.002826412773485283
62+
// endResult
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// name: problem6-irksco
2+
// status: correct
3+
// teardown_command: rm -f testSolver.problem6* output.log
4+
5+
loadFile("./testSolverPackage.mo");
6+
getErrorString();
7+
8+
resfile := "testSolver.problem6_res.mat";
9+
simulate(testSolver.problem6, stopTime=3.0, method="irksco"); getErrorString();
10+
11+
echo(false);
12+
s:=readSimulationResultSize(resfile);
13+
res:=readSimulationResult(resfile,{flying},s);
14+
res2:=readSimulationResult(resfile,{n_bounce},s);
15+
res3:=readSimulationResult(resfile,{h},s);
16+
echo(true);
17+
res[1,1];
18+
res[1,s];
19+
res2[1,s];
20+
if res3[1,s] > -1e-2 then 1 else 0;
21+
22+
23+
24+
// Result:
25+
// true
26+
// ""
27+
// "testSolver.problem6_res.mat"
28+
// record SimulationResult
29+
// resultFile = "testSolver.problem6_res.mat",
30+
// simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'irksco', fileNamePrefix = 'testSolver.problem6', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
31+
// messages = ""
32+
// end SimulationResult;
33+
// "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").
34+
// "
35+
// true
36+
// 1.0
37+
// 0.0
38+
// 15.0
39+
// 1
40+
// endResult

0 commit comments

Comments
 (0)