/
simpleNonLinLoop.mos
64 lines (58 loc) · 2.4 KB
/
simpleNonLinLoop.mos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// name: simpleNonLinLoop
// keywords: omsi omsic fmu fmi
// status: correct
// teardown_command: rm -rf simpleNonLinLoop.fmutmp simpleNonLinLoop.fmu simpleNonLinLoop_systemCall.log simpleNonLinLoop-tmp simpleNonLinLoop*res.mat simpleNonLinLoop_result_diff.log
//
// Tests simulating OMSIC OMSU/FMU with OMSimulator and check results
// Simple model containing non-linear loop.
//
loadString("
model simpleNonLinLoop
Real a(start=1), b(start=1), c(start=1);
Real s(start=1, fixed=true);
equation
a + b + c=0;
2*a - 3*b + 2*c=9;
a*a + b*b + c*c=5;
der(s) = time*(a*b*c);
end simpleNonLinLoop;
"); getErrorString();
// Simulate model for reference results
simulate(simpleNonLinLoop); getErrorString();
// Build omsic FMU
setCommandLineOptions("--simCodeTarget=omsic"); getErrorString();
buildModelFMU(simpleNonLinLoop); getErrorString();
// Simulate with OMSimulator
system(getInstallationDirectoryPath() + "/bin/OMSimulator simpleNonLinLoop.fmu --intervals=500 --tolerance=1e-6 --resultFile=\"simpleNonLinLoop_OMS_res.mat\" --suppressPath=true --tempDir=\"simpleNonLinLoop-tmp\"", "simpleNonLinLoop_systemCall.log"); getErrorString();
readFile("simpleNonLinLoop_systemCall.log");
// Compare results
compareSimulationResults("simpleNonLinLoop_OMS_res.mat",
"simpleNonLinLoop_res.mat",
"simpleNonLinLoop_result_diff.log",
vars = {"der(s)","s","a","b","c"}
);
// Result:
// true
// ""
// record SimulationResult
// resultFile = "simpleNonLinLoop_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'simpleNonLinLoop', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// ""
// true
// ""
// "simpleNonLinLoop.fmu"
// ""
// 0
// ""
// "info: maximum step size for 'model.root': 0.100000
// info: Result file: simpleNonLinLoop_OMS_res.mat (bufferSize=1)
// info: Final Statistics for 'model.root':
// NumSteps = 702 NumRhsEvals = 2001 NumLinSolvSetups = 1025
// NumNonlinSolvIters = 1963 NumNonlinSolvConvFails = 0 NumErrTestFails = 541
// "
// {"Files Equal!"}
// endResult