From 4737c560c08ab18c33a3271c4e763ec681ff8e0c Mon Sep 17 00:00:00 2001 From: Willi Braun Date: Mon, 12 Dec 2016 23:21:40 +0100 Subject: [PATCH] added daeMode problem7 (records testcase) --- simulation/modelica/solver/testDAEPackage.mo | 34 ++++++++ simulation/modelica/solver/testDAEp7.mos | 81 ++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 simulation/modelica/solver/testDAEp7.mos diff --git a/simulation/modelica/solver/testDAEPackage.mo b/simulation/modelica/solver/testDAEPackage.mo index a71d9db6977..8a7990bfd47 100644 --- a/simulation/modelica/solver/testDAEPackage.mo +++ b/simulation/modelica/solver/testDAEPackage.mo @@ -58,6 +58,7 @@ package testDAE der(y) = x^2-y*w; end p5; + // problem6: simple dae with array and matrix elements model p6 Real x[2]; Real A[2,2] = [3,1;2,1]; @@ -65,4 +66,37 @@ package testDAE A*der(x)={1,2}; end p6; + // problem7: simple dae with record functions + model p7 + record R + Real a; + Real b; + end R; + function inRecordF + input R r; + output Real y; + algorithm + y := exp(-0.9*r.a)*cos(r.b); + end inRecordF; + function outRecordF + input Real x; + input Real y; + output R r; + algorithm + r.a := exp(-0.9*x)*cos(y); + r.b := sin(x*y); + end outRecordF; + + Real x(start = 0.9,fixed=true); + Real y(fixed=false); + Real v = cos(time)*der(y); + Real w = der(x)+x*y; + R r = outRecordF(x,y); + Real r1,r2; + equation + R(r1,r2) = outRecordF(2*x,3*y); + (1 + 0.5*sin(y))*der(x) + y = 2*sin(v+w); + x-der(y) = inRecordF(r)+v*w; + end p7; + end testDAE; diff --git a/simulation/modelica/solver/testDAEp7.mos b/simulation/modelica/solver/testDAEp7.mos new file mode 100644 index 00000000000..640b94d86a9 --- /dev/null +++ b/simulation/modelica/solver/testDAEp7.mos @@ -0,0 +1,81 @@ +// name: testDAE.p7 +// status: correct +// teardown_command: rm -f testDAE.p7* output.log + + +loadFile("./testDAEPackage.mo"); +getErrorString(); + +simulate(testDAE.p7); +getErrorString(); + +val(x,0.0); +val(y,0.0); + +val(x,1.0); +val(y,1.0); + +setCommandLineOptions("+daeMode=dynamic"); +simulate(testDAE.p7, simflags="-daeMode", method="ida"); +getErrorString(); + +val(x,0.0); +val(y,0.0); + +val(x,1.0); +val(y,1.0); + +setCommandLineOptions("+daeMode=all"); +simulate(testDAE.p7, simflags="-daeMode", method="ida"); +getErrorString(); + +val(x,0.0); +val(y,0.0); + +val(x,1.0); +val(y,1.0); + + + +// Result: +// true +// "" +// record SimulationResult +// resultFile = "testDAE.p7_res.mat", +// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'testDAE.p7', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", +// messages = "" +// end SimulationResult; +// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization"). +// 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"). +// " +// 0.9 +// 0.0 +// 2.391669920617771 +// 0.4103029387651521 +// true +// record SimulationResult +// resultFile = "testDAE.p7_res.mat", +// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'ida', fileNamePrefix = 'testDAE.p7', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-daeMode'", +// messages = "" +// end SimulationResult; +// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization"). +// 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"). +// " +// 0.9 +// 0.0 +// 2.391665238603284 +// 0.4103115806759719 +// true +// record SimulationResult +// resultFile = "testDAE.p7_res.mat", +// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'ida', fileNamePrefix = 'testDAE.p7', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-daeMode'", +// messages = "" +// end SimulationResult; +// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization"). +// 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"). +// " +// 0.9 +// 0.0 +// 2.391659403667771 +// 0.4103081681124501 +// endResult