Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added testcase for fmi parameters changes
- Loading branch information
Willi Braun
committed
Aug 3, 2015
1 parent
4db7025
commit 722fdf9
Showing
4 changed files
with
170 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
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,84 @@ | ||
// name: testChangeParam | ||
// keywords: FMI 2.0 export | ||
// status: correct | ||
// teardown_command: rm -rf binaries sources modelDescription.xml modelDescription.tmp.xml test_ChangeParam* output.log | ||
// | ||
|
||
|
||
loadString(" | ||
model test_ChangeParam | ||
parameter Real a = 2.0; | ||
parameter Integer i = 1; | ||
parameter Boolean b = true; | ||
parameter String s = \"foo\"; | ||
Real x(start=1); | ||
input Real u; | ||
output Real y; | ||
equation | ||
der(x) = x*a+u; | ||
y = if b then der(x)-x-i else der(x)+x+i; | ||
when time>1 then | ||
terminate(\"Simulation done by \" + s); | ||
end when; | ||
annotation(experiment(StopTime=2)); | ||
end test_ChangeParam; | ||
"); | ||
getErrorString(); | ||
loadModel(Modelica); | ||
|
||
|
||
translateModelFMU(test_ChangeParam, version="2.0"); | ||
getErrorString(); | ||
importFMU("test_ChangeParam.fmu"); | ||
|
||
loadFile("test_ChangeParam_me_FMU.mo"); | ||
getErrorString(); | ||
|
||
simulate(test_ChangeParam_me_FMU); | ||
val(x, 1); | ||
val(a, 1); | ||
val(y, 1); | ||
getErrorString(); | ||
|
||
system("./test_ChangeParam_me_FMU -override a=-2,i=-10,b=false,s=\"bar\""); | ||
echo(false); | ||
readSimulationResult("test_ChangeParam_me_FMU_res.mat", {x,a,y}); | ||
echo(true); | ||
val(x, 1); | ||
val(a, 1); | ||
val(y, 1); | ||
getErrorString(); | ||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "SimCode: The model test_ChangeParam has been translated to FMU" | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// "test_ChangeParam_me_FMU.mo" | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "test_ChangeParam_me_FMU_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'test_ChangeParam_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "[<interactive>:14:7-14:43:writable] | ||
// stdout | info | Simulation call terminate() at time 1.000000 | ||
// | | | | Message : Simulation done by foo | ||
// " | ||
// end SimulationResult; | ||
// 7.389089930122212 | ||
// 2.0 | ||
// 6.389089930122212 | ||
// "" | ||
// [<interactive>:14:7-14:43:writable] | ||
// stdout | info | Simulation call terminate() at time 1.000000 | ||
// | | | | Message : Simulation done by bar | ||
// 0 | ||
// true | ||
// 0.135336321156737 | ||
// 2.0 | ||
// -10.13533632115674 | ||
// "" | ||
// 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
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,84 @@ | ||
// name: testChangeParam | ||
// keywords: FMI 2.0 export | ||
// status: correct | ||
// teardown_command: rm -rf binaries sources modelDescription.xml modelDescription.tmp.xml test_ChangeParam* output.log | ||
// | ||
|
||
|
||
loadString(" | ||
model test_ChangeParam | ||
parameter Real a = 2.0; | ||
parameter Integer i = 1; | ||
parameter Boolean b = true; | ||
parameter String s = \"foo\"; | ||
Real x(start=1); | ||
input Real u; | ||
output Real y; | ||
equation | ||
der(x) = x*a+u; | ||
y = if b then der(x)-x-i else der(x)+x+i; | ||
when time>1 then | ||
terminate(\"Simulation done by \" + s); | ||
end when; | ||
annotation(experiment(StopTime=2)); | ||
end test_ChangeParam; | ||
"); | ||
getErrorString(); | ||
loadModel(Modelica); | ||
|
||
|
||
translateModelFMU(test_ChangeParam, version="2.0"); | ||
getErrorString(); | ||
importFMU("test_ChangeParam.fmu"); | ||
|
||
loadFile("test_ChangeParam_me_FMU.mo"); | ||
getErrorString(); | ||
|
||
simulate(test_ChangeParam_me_FMU); | ||
val(x, 1); | ||
val(a, 1); | ||
val(y, 1); | ||
getErrorString(); | ||
|
||
system("./test_ChangeParam_me_FMU -override a=-2,i=-10,b=false,s=\"bar\""); | ||
echo(false); | ||
readSimulationResult("test_ChangeParam_me_FMU_res.mat", {x,a,y}); | ||
echo(true); | ||
val(x, 1); | ||
val(a, 1); | ||
val(y, 1); | ||
getErrorString(); | ||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "SimCode: The model test_ChangeParam has been translated to FMU" | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// "test_ChangeParam_me_FMU.mo" | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "test_ChangeParam_me_FMU_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'test_ChangeParam_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "[<interactive>:14:7-14:43:writable] | ||
// stdout | info | Simulation call terminate() at time 1.000000 | ||
// | | | | Message : Simulation done by foo | ||
// " | ||
// end SimulationResult; | ||
// 7.389089930122212 | ||
// 2.0 | ||
// 6.389089930122212 | ||
// "" | ||
// [<interactive>:14:7-14:43:writable] | ||
// stdout | info | Simulation call terminate() at time 1.000000 | ||
// | | | | Message : Simulation done by bar | ||
// 0 | ||
// true | ||
// 0.135336321156737 | ||
// 2.0 | ||
// -10.13533632115674 | ||
// "" | ||
// endResult |