Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OMSI] Added test for algebraic loops
Added models with linear and non-linear loops to test default OMSIBase solver for algebraic loops.
- Loading branch information
1 parent
4ce17f7
commit 96fa58a
Showing
5 changed files
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// name: simpleLoop | ||
// keywords: omsi omsic fmu fmi | ||
// status: correct | ||
// teardown_command: rm -rf simpleLoop.fmutmp simpleLoop.fmu simpleLoop_systemCall.log simpleLoop-tmp simpleLoop*res.mat simpleLoop_result_diff.log | ||
// | ||
// Tests simulating OMSIC OMSU/FMU with OMSimulator and check results | ||
// Simple model containing linear loop. | ||
// | ||
|
||
loadString(" | ||
model simpleLoop | ||
Real x; | ||
Real y; | ||
Real z; | ||
Real s(start=1, fixed=true); | ||
parameter Real a=1, b=-1, c = 7; | ||
equation | ||
time = a*x+b*y+c*z; | ||
2*time = 2*a*x+y-3*z; | ||
7 = 23*a-3/8*b+z; | ||
der(s) = x+y+z; | ||
end simpleLoop; | ||
"); getErrorString(); | ||
|
||
// Simulate model for reference results | ||
simulate(simpleLoop); getErrorString(); | ||
|
||
// Build omsic FMU | ||
setCommandLineOptions("--simCodeTarget=omsic"); getErrorString(); | ||
buildModelFMU(simpleLoop); getErrorString(); | ||
|
||
// Simulate with OMSimulator | ||
system(getInstallationDirectoryPath() + "/bin/OMSimulator simpleLoop.fmu --intervals=500 --tolerance=1e-6 --resultFile=\"simpleLoop_OMS_res.mat\" --suppressPath=true --tempDir=\"simpleLoop-tmp\"", "simpleLoop_systemCall.log"); getErrorString(); | ||
readFile("simpleLoop_systemCall.log"); | ||
|
||
// Compare results | ||
compareSimulationResults("simpleLoop_OMS_res.mat", | ||
"simpleLoop_res.mat", | ||
"simpleLoop_result_diff.log", | ||
vars = {"x","y","z","s","der(s)","a","b","c"} | ||
); | ||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "simpleLoop_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'simpleLoop', 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 | ||
// "" | ||
// "simpleLoop.fmu" | ||
// "" | ||
// 0 | ||
// "" | ||
// "info: maximum step size for 'model.root': 0.100000 | ||
// info: Result file: simpleLoop_OMS_res.mat (bufferSize=1) | ||
// info: Final Statistics for 'model.root': | ||
// NumSteps = 120 NumRhsEvals = 258 NumLinSolvSetups = 96 | ||
// NumNonlinSolvIters = 256 NumNonlinSolvConvFails = 0 NumErrTestFails = 49 | ||
// " | ||
// {"Files Equal!"} | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters