Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

added test from ticket:3266 #856

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions openmodelica/linearization/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ testDrumBoiler.mos \
testknownvar.mos \
testMathFuncs.mos \
testRecordDiff.mos \
testSortFunction.mos \
testSteamPipe.mos \
ticket3701.mos \

Expand Down
70 changes: 70 additions & 0 deletions openmodelica/linearization/testSortFunction.mos
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// name: testSortFunction
// keywords: jacobian differentiation linearization
// status: correct
// teardown_command: rm -rf SortTest* output.log
//

loadModel(Modelica);getErrorString();
loadString("
model SortTest
input Real u; // prevent evaluation by frontend
Real x(start=1);
Real[:, :] M = [3, cos(x)*x; 1 + u, 2+time];
output Real[size(M, 1), size(M, 2)] N;
equation
der(x) = M[2,1]+sin(x);
N = Modelica.Math.Matrices.sort(M);
end SortTest;
");

setCommandLineOptions("--generateSymbolicLinearization");
linearize(SortTest, stopTime=1.0);getErrorString();

loadFile("linear_SortTest.mo");
list(linear_SortTest);


// Result:
// true
// ""
// true
// true
// record SimulationResult
// resultFile = "SortTest_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'SortTest', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "stdout | info | Linearization will performed at point of time: 1.000000
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// stdout | info | Linear model is created!
// "
// 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").
// "
// true
// "model linear_SortTest
// parameter Integer n = 1;
// // states
// parameter Integer k = 1;
// // top-level inputs
// parameter Integer l = 4;
// // top-level outputs
// parameter Real x0[1] = {2.801060045691952};
// parameter Real u0[1] = {0};
// parameter Real A[1, 1] = [-0.9425769139614838];
// parameter Real B[1, 1] = [1];
// parameter Real C[4, 1] = [0; 0; 0; -1.878100615247814];
// parameter Real D[4, 1] = [1; 0; 0; 0];
// Real x[1](start = x0);
// input Real u[1](start = u0);
// output Real y[4];
// Real 'x_x' = x[1];
// Real 'u_u' = u[1];
// Real 'y_N[1,1]' = y[1];
// Real 'y_N[1,2]' = y[2];
// Real 'y_N[2,1]' = y[3];
// Real 'y_N[2,2]' = y[4];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// end linear_SortTest;"
// endResult