Skip to content

Commit 23489ea

Browse files
authored
Change default solver for nonlinear algebraic systems to kinsol (#1121)
1 parent cbeadae commit 23489ea

File tree

5 files changed

+81
-4
lines changed

5 files changed

+81
-4
lines changed

src/OMSimulatorLib/Flags.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ oms::Flags::~Flags()
6464
void oms::Flags::setDefaults()
6565
{
6666
addParametersToCSV = false;
67-
algLoopSolver = oms_alg_solver_fixedpoint;
67+
algLoopSolver = oms_alg_solver_kinsol;
6868
defaultModeIsCS = false;
6969
deleteTempFiles = true;
7070
dumpAlgLoops = false;

src/OMSimulatorLib/Flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace oms
144144
const std::vector<Flag> flags = {
145145
{"", "", "FMU or SSP file", re_filename, Flags::Filename, false},
146146
{"--addParametersToCSV", "", "Export parameters to .csv file (true, [false])", re_default, Flags::AddParametersToCSV, false},
147-
{"--algLoopSolver", "", "Specifies the alg. loop solver method ([fixedpoint], kinsol) used for algebraic loops spanning over multiple components.", re_default, Flags::AlgLoopSolver, false},
147+
{"--algLoopSolver", "", "Specifies the alg. loop solver method (fixedpoint, [kinsol]) used for algebraic loops spanning over multiple components.", re_default, Flags::AlgLoopSolver, false},
148148
{"--clearAllOptions", "", "Reset all flags to default values", re_void, Flags::ClearAllOptions, false},
149149
{"--deleteTempFiles", "", "Deletes temp files as soon as they are no longer needed ([true], false)", re_bool, Flags::DeleteTempFiles, false},
150150
{"--dumpAlgLoops", "", "Dump information for alg loops (true, [false])", re_bool, Flags::DumpAlgLoops, false},

testsuite/simulation/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ DualMassOscillator.lua \
1212
Enumeration.lua \
1313
Enumeration2.lua \
1414
equationPair.py \
15+
equationPair_fixedpoint.py \
1516
exportConnectorsToResultFile.lua \
1617
exportSnapshotSSP.lua \
1718
exportSSMTemplate.lua \

testsuite/simulation/equationPair.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## status: correct
2-
## teardown_command: rm -rf equationPair-py/
2+
## teardown_command: rm -rf equationPair/
33
## linux: no
44
## mingw32: no
55
## mingw64: yes
@@ -9,7 +9,7 @@
99
import OMSimulator as oms
1010

1111
oms.setCommandLineOption("--suppressPath=true --algLoopSolver=kinsol --dumpAlgLoops=true")
12-
oms.setTempDirectory("./equationPair-py/")
12+
oms.setTempDirectory("./equationPair/")
1313

1414
model = oms.newModel("equationPair")
1515
root = model.addSystem('root', oms.Types.System.WC)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## status: correct
2+
## teardown_command: rm -rf equationPair_fixedpoint/
3+
## linux: no
4+
## mingw32: no
5+
## mingw64: yes
6+
## win: yes
7+
## mac: no
8+
9+
import OMSimulator as oms
10+
11+
oms.setCommandLineOption("--suppressPath=true --algLoopSolver=fixedpoint --dumpAlgLoops=true --maxLoopIteration=3")
12+
oms.setTempDirectory("./equationPair_fixedpoint/")
13+
14+
model = oms.newModel("equationPair")
15+
root = model.addSystem('root', oms.Types.System.WC)
16+
17+
# instantiate FMUs
18+
root.addSubModel('equation1', '../resources/equationPair.equation1.fmu')
19+
root.addSubModel('equation2', '../resources/equationPair.equation2.fmu')
20+
21+
# add connections
22+
root.addConnection('equation1.x1', 'equation2.x1')
23+
root.addConnection('equation1.x2', 'equation2.x2')
24+
25+
# simulation settings
26+
model.resultFile = ''
27+
model.stopTime = 0.0
28+
29+
model.instantiate()
30+
try:
31+
model.initialize()
32+
except:
33+
pass
34+
finally:
35+
model.terminate()
36+
model.delete()
37+
38+
## Result:
39+
## info: Alg. loop (size 2)
40+
## equationPair.root.equation1
41+
## equationPair.root.equation2
42+
## info: iteration 1
43+
## inputs:
44+
## equation2.x2: 8.4
45+
## equation1.x1: 4
46+
## outputs:
47+
## equation1.x2: 2
48+
## equation2.x1: 54.4
49+
## residuals:
50+
## res[0]: 6.4
51+
## res[1]: -50.4
52+
## info: iteration 2
53+
## inputs:
54+
## equation2.x2: 2
55+
## equation1.x1: 54.4
56+
## outputs:
57+
## equation1.x2: -1175.34
58+
## equation2.x1: 16
59+
## residuals:
60+
## res[0]: 1177.34
61+
## res[1]: 38.4
62+
## info: iteration 3
63+
## inputs:
64+
## equation2.x2: -1175.34
65+
## equation1.x1: 16
66+
## outputs:
67+
## equation1.x2: -94
68+
## equation2.x1: -7048.06
69+
## residuals:
70+
## res[0]: -1081.34
71+
## res[1]: 7064.06
72+
## error: [fixPointIteration] max. number of iterations (3) exceeded at time = 0.000000
73+
## error: [initialize] Initialization of system "equationPair.root" failed
74+
## info: 0 warnings
75+
## info: 2 errors
76+
## endResult

0 commit comments

Comments
 (0)