Skip to content

Commit

Permalink
added test for ticket-5206
Browse files Browse the repository at this point in the history
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed Nov 7, 2018
1 parent 87420c2 commit 01e433a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions simulation/modelica/equations/Makefile
Expand Up @@ -23,6 +23,7 @@ IfEquation6.mos \
IfEquationUnbalanced.mos \
ModelBalance1.mos ModelBalance2.mos ModelBalance3.mos ModelBalance4.mos \
ticket-2337.mos \
ticket-5206.mos \
WatchDog1AlgorithmWhen.mos WatchDog2EquationWhen.mos \
WhenEquation.mos WhenEquation1.mos \
WhenNoRetCall.mos \
Expand Down
56 changes: 56 additions & 0 deletions simulation/modelica/equations/ticket-5206.mos
@@ -0,0 +1,56 @@
// name: ticket-5206
// keywords: if equations, non-linear, residual equations
// status: correct


loadString("
model Test5206
Real x(start=1);
Real y(start=8);
Real usat(start=1);
Real u(start=2);
parameter Real y0(fixed = false, start = 8);
parameter Real T = 1;
parameter Real k = 10;
parameter Real uMin = 0;
parameter Real uMax = 1;
parameter Real y_ref = 8;
initial equation
der(x) = 0;
if u > usat then
u = usat + 1;
else
y = y_ref;
end if;
equation
T * der(x) = usat - x;
y = k * x;
usat = homotopy(actual = smooth(0, if u > uMax then uMax else if u < uMin then uMin else u), simplified = u);
u = y0 - y;
end Test5206;
");
getErrorString();

simulate(Test5206);
getErrorString();

val(x,0.0);
val(x,1.0);

// Result:
// true
// ""
//
// The selection of a new tearing variable failed.
// record SimulationResult
// resultFile = "Test5206_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Test5206', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: Function Tearing.selectTearingVar failed at least once. Use -d=tearingdump or -d=tearingdumpV for more information.
// "
// 1.0
// 1.0
// endResult

0 comments on commit 01e433a

Please sign in to comment.