Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialization of a simple composite model
Belonging to [master]: - OpenModelica/OpenModelica-testsuite#1101
- Loading branch information
1 parent
6c01304
commit c15ea99
Showing
2 changed files
with
69 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ TEST = ../rtest -v | |
|
||
TESTFILES = \ | ||
initialization.mos \ | ||
initialization2.mos \ | ||
|
||
FAILINGTESTFILES = \ | ||
|
||
|
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 @@ | ||
// keywords: fmu export import | ||
// status: correct | ||
// teardown_command: rm -rf initialization2.fmu initialization2.log initialization2.lua input.csv temp-initialization2/ | ||
|
||
loadString(" | ||
model initialization2 | ||
input Real u; | ||
output Real y = u; | ||
Real x(fixed=false); | ||
initial equation | ||
x - u = 0.0; | ||
equation | ||
der(x) = -x; | ||
end initialization2;"); getErrorString(); | ||
|
||
buildModelFMU(initialization2, version="2.0", fmuType="me", platforms={"static"}); getErrorString(); | ||
|
||
writeFile("input.csv", "time,y | ||
0.0,2.3 | ||
1.0,2.3 | ||
"); getErrorString(); | ||
|
||
writeFile("initialization2.lua", " | ||
oms3_setCommandLineOption(\"--suppressPath=true\") | ||
oms3_setTempDirectory(\"./temp-initialization2/\") | ||
|
||
oms3_newModel(\"test\") | ||
oms3_addSystem(\"test.root\", oms_system_sc) | ||
oms3_addSubModel(\"test.root.A\", \"input.csv\") | ||
oms3_addSubModel(\"test.root.B\", \"initialization2.fmu\") | ||
oms3_addConnection(\"test.root.A.y\", \"test.root.B.u\") | ||
oms3_setResultFile(\"test\", \"\") | ||
|
||
oms3_instantiate(\"test\") | ||
oms3_initialize(\"test\") | ||
print(\"info: Initialization\") | ||
print(\"info: A.y: \" .. oms3_getReal(\"test.root.A.y\")) | ||
print(\"info: B.x: \" .. oms3_getReal(\"test.root.B.x\")) | ||
print(\"info: B.y: \" .. oms3_getReal(\"test.root.B.y\")) | ||
print(\"info: B.u: \" .. oms3_getReal(\"test.root.B.u\")) | ||
|
||
oms3_terminate(\"test\") | ||
oms3_delete(\"test\") | ||
"); getErrorString(); | ||
|
||
system(getInstallationDirectoryPath() + "/bin/OMSimulator initialization2.lua"); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// "initialization2.fmu" | ||
// "" | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// info: No result file will be created | ||
// info: maximum step size for 'test.root': 0.100000 | ||
// info: Initialization | ||
// info: A.y: 2.3 | ||
// info: B.x: 2.3 | ||
// info: B.y: 2.3 | ||
// info: B.u: 2.3 | ||
// info: Final Statistics for 'test.root': | ||
// NumSteps = 0 NumRhsEvals = 0 NumLinSolvSetups = 0 | ||
// NumNonlinSolvIters = 0 NumNonlinSolvConvFails = 0 NumErrTestFails = 0 | ||
// 0 | ||
// endResult |