Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/OpenModelica/OpenModelica…
- Loading branch information
Showing
27 changed files
with
474 additions
and
184 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,38 @@ | ||
// name: solveTest | ||
// keywords: external F77 LAPACK | ||
// status: correct | ||
// teardown_command: rm -f *SolveTest* | ||
|
||
setCommandLineOptions("+simCodeTarget=Cpp"); | ||
|
||
loadModel(Modelica); | ||
loadString(" | ||
model SolveTest | ||
Real[:, :] A = [0, 1; 2, 3]; | ||
Real[:] b = {4, 5}; | ||
input Real u = 0; // prevent presolving during translation | ||
output Real[2] x; | ||
equation | ||
x = Modelica.Math.Matrices.solve(A, (u + 1) * b); | ||
end SolveTest; | ||
"); | ||
getErrorString(); | ||
|
||
simulate(SolveTest); | ||
val(x[1], 1); | ||
val(x[2], 1); | ||
getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// true | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "SolveTest_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'SolveTest', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// -3.5 | ||
// 4.0 | ||
// "" |
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
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,76 @@ | ||
// 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, numberOfIntervals=1); | ||
val(x, 1); | ||
val(a, 1); | ||
val(y, 1); | ||
getErrorString(); | ||
|
||
system("./test_ChangeParam_me_FMU -override a=-2,i=-10,b=false,s=\"bar\" -r test_ChangeParam.mat"); | ||
readSimulationResult("test_ChangeParam.mat", {x,a,y}, 6); | ||
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 = 1, 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.389089930122227 | ||
// 2.0 | ||
// 6.389089930122227 | ||
// "" | ||
// [<interactive>:14:7-14:43:writable] | ||
// stdout | info | Simulation call terminate() at time 1.000000 | ||
// | | | | Message : Simulation done by bar | ||
// 0 | ||
// {{1.0,1.0,1.0,0.1353363211567342,0.1353363211567342,0.1353363211567342},{-2.0,-2.0,-2.0,-2.0,-2.0,-2.0},{-11.0,-11.0,-11.0,-10.13533632115674,-10.13533632115674,-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
Oops, something went wrong.