diff --git a/simulation/modelica/nonlinear_system/Makefile b/simulation/modelica/nonlinear_system/Makefile index 2eca76ac40d..0cf3552ea19 100644 --- a/simulation/modelica/nonlinear_system/Makefile +++ b/simulation/modelica/nonlinear_system/Makefile @@ -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 diff --git a/simulation/modelica/nonlinear_system/nlsTestPackage.mo b/simulation/modelica/nonlinear_system/nlsTestPackage.mo index f3415d7a575..7f0654bd197 100644 --- a/simulation/modelica/nonlinear_system/nlsTestPackage.mo +++ b/simulation/modelica/nonlinear_system/nlsTestPackage.mo @@ -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; diff --git a/simulation/modelica/nonlinear_system/problem12.mos b/simulation/modelica/nonlinear_system/problem12.mos new file mode 100644 index 00000000000..82c1107da90 --- /dev/null +++ b/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