Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test for deltaSimulationResults scripting
- Loading branch information
1 parent
45431ea
commit 24cba6c
Showing
2 changed files
with
49 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
within ; | ||
model Delta | ||
Real x; | ||
parameter Real a=1; | ||
equation | ||
x = 2*time*a; | ||
annotation (uses(Modelica(version="3.2.1"))); | ||
end Delta; |
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,41 @@ | ||
// name: Delta | ||
// keywords: builtin | ||
// status: correct | ||
// | ||
|
||
loadModel(Modelica, {"3.2.1"}); getErrorString(); | ||
loadFile("Delta.mo"); getErrorString(); | ||
simulate(Delta, variableFilter = "time|x", numberOfIntervals=10, fileNamePrefix = "Delta_reference");getErrorString(); | ||
|
||
buildModel(Delta); getErrorString(); | ||
|
||
for a in {0,1,2,3} loop | ||
str_a := String(a); getErrorString(); | ||
str_cmd := "./Delta -override a=" + str_a; | ||
system(str_cmd, "output.txt"); getErrorString(); | ||
res := deltaSimulationResults("Delta_res.mat","Delta_reference_res.mat", "1norm", {"x"});getErrorString(); | ||
res1 := deltaSimulationResults("Delta_res.mat","Delta_reference_res.mat", "2norm", {"x"});getErrorString(); | ||
res2 := deltaSimulationResults("Delta_res.mat","Delta_reference_res.mat", "maxerr", {"x"});getErrorString(); | ||
|
||
print("for parameter a = "+String(a)+", the results are res1= "+String(res)+" res2= "+String(res1)+" res3="+String(res2)+"\n"); | ||
closeSimulationResultFile(); | ||
end for; | ||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "Delta_reference_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 10, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Delta_reference', options = '', outputFormat = 'mat', variableFilter = 'time|x', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "" | ||
// {"Delta","Delta_init.xml"} | ||
// "" | ||
// for parameter a = 0, the results are res1= 13 res2= 4.40454 res3=2 | ||
// for parameter a = 1, the results are res1= 0 res2= 0 res3=0 | ||
// for parameter a = 2, the results are res1= 13 res2= 4.40454 res3=2 | ||
// for parameter a = 3, the results are res1= 26 res2= 8.80909 res3=4 | ||
// | ||
// endResult |