Skip to content

Commit

Permalink
Add test for inversion of pow
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaeuber authored and OpenModelica-Hudson committed Oct 12, 2017
1 parent d1ab6ca commit 20b20c0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions simulation/modelica/nonlinear_system/Makefile
Expand Up @@ -48,6 +48,7 @@ problem12.mos \
TestInputIteration.mos \
TestFalseIterationNLS.mos \
ScalingTest1.mos \
inverseTest.mos \

# test that currently fail. Move up when fixed.
# Run make testfailing
Expand Down
50 changes: 50 additions & 0 deletions simulation/modelica/nonlinear_system/inverseTest.mos
@@ -0,0 +1,50 @@
// name: inverseTest
// keywords: nonlinear system solver inverse
// status: correct
// cflags:
//
// ticket:4253

loadString("
function x_to_y
input Real x;
output Real y;
// annotation(Inline = false, inverse(x = y_to_x(y)));
algorithm
y := x ^ 2;
y := sign(x) * y;
end x_to_y;

function y_to_x
input Real y;
output Real x;
algorithm
x := sqrt(abs(y));
x := sign(y) * x;
end y_to_x;

model inverseTest
parameter Real y = -5;
Real x;
equation
y = x_to_y(x);
end inverseTest;
"); getErrorString();

simulate(inverseTest, stopTime=0.0, simflags="-output x"); getErrorString();


// Result:
// true
// ""
// record SimulationResult
// resultFile = "inverseTest_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'inverseTest', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-output x'",
// messages = "stdout | info | The initialization finished successfully without homotopy method.
// time=0,x=-2.2360679774997898051
// stdout | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: There are iteration variables with default zero start attribute. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization").
// "
// endResult

0 comments on commit 20b20c0

Please sign in to comment.