Skip to content

Commit

Permalink
added daeMode problem7 (records testcase)
Browse files Browse the repository at this point in the history
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed Dec 12, 2016
1 parent 6f62e74 commit 4737c56
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
34 changes: 34 additions & 0 deletions simulation/modelica/solver/testDAEPackage.mo
Expand Up @@ -58,11 +58,45 @@ 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];
equation
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;
81 changes: 81 additions & 0 deletions 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

0 comments on commit 4737c56

Please sign in to comment.