Skip to content

Commit

Permalink
added testcase for non-linear system with a function involed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Willi Braun committed Oct 14, 2015
1 parent d9a5133 commit 998686a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions simulation/modelica/nonlinear_system/Makefile
Expand Up @@ -44,6 +44,7 @@ problem8_newton.mos \
problem9.mos \
problem10.mos \
problem11.mos \
problem12.mos \

# test that currently fail. Move up when fixed.
# Run make testfailing
Expand Down
19 changes: 19 additions & 0 deletions simulation/modelica/nonlinear_system/nlsTestPackage.mo
Expand Up @@ -149,4 +149,23 @@ package nonlinear_system

end problem11;

model problem12
function f1
input Real x;
input Real y;
input Integer n;
output Real z;
algorithm
z := 1;
for i in 1:n loop
z := z*(x+y);
end for;
end f1;
Real x,y,z;
equation
x^4 = y - 1;
y -3*x^2 + 1 = z*(1-time);
z = f1(x,y,5);
end problem12;

end nonlinear_system;
44 changes: 44 additions & 0 deletions simulation/modelica/nonlinear_system/problem12.mos
@@ -0,0 +1,44 @@
// name: problem12
// status: correct
// teardown_command: rm -f nonlinear_system.problem12* output.log

loadFile("nlsTestPackage.mo"); getErrorString();

simulate(nonlinear_system.problem12); getErrorString();

val(x,{0.0, 0.5, 1.0});
val(y,{0.0, 0.5, 1.0});
val(z,{0.0, 0.5, 1.0});

setCommandLineOptions("+d=NLSanalyticJacobian");
simulate(nonlinear_system.problem12); getErrorString();

val(x,{0.0, 0.5, 1.0});
val(y,{0.0, 0.5, 1.0});
val(z,{0.0, 0.5, 1.0});

// Result:
// true
// ""
// record SimulationResult
// resultFile = "nonlinear_system.problem12_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'nonlinear_system.problem12', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
// "
// {0.1413741945152485,0.2812491225132911,1.0}
// {1.000399466692872,1.006256979103416,2.0}
// {1.940439478068367,3.537907544719854,243.0}
// true
// record SimulationResult
// resultFile = "nonlinear_system.problem12_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'nonlinear_system.problem12', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
// "
// {0.1413741945152598,0.2812491225131152,1.0}
// {1.000399466692872,1.0062569791034,2.0}
// {1.940439478068463,3.537907544717219,243.0}
// endResult

0 comments on commit 998686a

Please sign in to comment.