Skip to content

Commit

Permalink
Added new tests for inverse solving of algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed Jun 26, 2015
1 parent 8f1c202 commit 28812c9
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
2 changes: 1 addition & 1 deletion openmodelica/modelicaML/twotankmodel.mos
Expand Up @@ -7,7 +7,7 @@
// ModelicaML: 1.3.6 Examples from 29.Nov 2010
//
loadFile("./TwoTanksSystemExample/package.mo"); getErrorString();
simulate(TwoTanksSystemExample.Simulations.TankSystemSimulation, method="rungekutta", stopTime=400, numberOfIntervals=4000, simflags="-iim=numeric -iom=newuoa"); getErrorString();
simulate(TwoTanksSystemExample.Simulations.TankSystemSimulation, method="rungekutta", stopTime=400, numberOfIntervals=4000); getErrorString();

val(dm.tank1.h,11);
val(dm.tank1.h,49);
Expand Down
38 changes: 38 additions & 0 deletions simulation/modelica/algorithms_functions/InverseAlgorithm1.mos
@@ -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 simulation/modelica/algorithms_functions/InverseAlgorithm2.mos
@@ -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
2 changes: 2 additions & 0 deletions simulation/modelica/algorithms_functions/Makefile
Expand Up @@ -22,6 +22,8 @@ FunctionIndirectRecursion.mos \
FunctionIndirectRecursion2.mos \
FunctionInReinit.mos \
Interpolation.mos \
InverseAlgorithm1.mos \
InverseAlgorithm2.mos \
LocalVariableInit.mos \
ModelicaTest.Fluid.Dissipation.Verifications.HeatTransfer.Channel.kc_evenGapLaminar.mos \
SimplePeriodicSampler.mos \
Expand Down

0 comments on commit 28812c9

Please sign in to comment.