Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new tests for inverse solving of algorithms
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
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
38 changes: 38 additions & 0 deletions
38
simulation/modelica/algorithms_functions/InverseAlgorithm1.mos
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: InverseAlgorithm1 | ||
// keywords: inverse algorithm | ||
// status: correct | ||
|
||
loadString(" | ||
model InverseAlgorithm1 | ||
Real x; | ||
Real y, z; | ||
initial equation | ||
y = 0.2; | ||
equation | ||
der(x) = y; | ||
algorithm | ||
y := sin(x); | ||
z := y; | ||
end InverseAlgorithm1; | ||
"); getErrorString(); | ||
|
||
simulate(InverseAlgorithm1, simflags="-lv=LOG_SOTI"); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "InverseAlgorithm1_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'InverseAlgorithm1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv=LOG_SOTI'", | ||
// messages = "LOG_SOTI | info | ### SOLUTION OF THE INITIALIZATION ### | ||
// | | | | | states variables | ||
// | | | | | | [1] Real x(start=0, nominal=1) = 0.201358 (pre: 0) | ||
// | | | | | derivatives variables | ||
// | | | | | | [2] Real der(x) = 0.2 (pre: 0) | ||
// | | | | | other real variables | ||
// | | | | | | [3] Real y(start=0, nominal=1) = 0.2 (pre: 0) | ||
// | | | | | | [4] Real z(start=0, nominal=1) = 0.2 (pre: 0) | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// endResult |
48 changes: 48 additions & 0 deletions
48
simulation/modelica/algorithms_functions/InverseAlgorithm2.mos
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,48 @@ | ||
// name: InverseAlgorithm2 | ||
// keywords: inverse algorithm #3081 | ||
// status: correct | ||
|
||
loadString(" | ||
model InverseAlgorithm2 | ||
Real x, y, z; | ||
Real der_x, der_y, der_z; | ||
equation | ||
der_x = der(x) + 1; | ||
der_y = der(y) + 2; | ||
der_z = der(z) + 3; | ||
initial equation | ||
der(x) = 0; | ||
der(y) = 0.5; | ||
der(z) = 0; | ||
algorithm | ||
der_x := x; | ||
der_y := der_x + y; | ||
der_z := der_y + z; | ||
end InverseAlgorithm2; | ||
"); getErrorString(); | ||
|
||
simulate(InverseAlgorithm2, simflags="-lv=LOG_SOTI"); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "InverseAlgorithm2_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'InverseAlgorithm2', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv=LOG_SOTI'", | ||
// messages = "LOG_SOTI | info | ### SOLUTION OF THE INITIALIZATION ### | ||
// | | | | | states variables | ||
// | | | | | | [1] Real x(start=0, nominal=1) = 1 (pre: 0) | ||
// | | | | | | [2] Real y(start=0, nominal=1) = 1.5 (pre: 0) | ||
// | | | | | | [3] Real z(start=0, nominal=1) = 0.5 (pre: 0) | ||
// | | | | | derivatives variables | ||
// | | | | | | [4] Real der(x) = 0 (pre: 0) | ||
// | | | | | | [5] Real der(y) = 0.5 (pre: 0) | ||
// | | | | | | [6] Real der(z) = 0 (pre: 0) | ||
// | | | | | other real variables | ||
// | | | | | | [7] Real der_x(start=0, nominal=1) = 1 (pre: 0) | ||
// | | | | | | [8] Real der_y(start=0, nominal=1) = 2.5 (pre: 0) | ||
// | | | | | | [9] Real der_z(start=0, nominal=1) = 3 (pre: 0) | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// 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