Skip to content

Commit c747575

Browse files
kabdelhakadrpo
authored andcommitted
Revert "[SimCode] update linearize"
This reverts commit e647134. See ticket #5927
1 parent ce9a30f commit c747575

26 files changed

+50
-217
lines changed

OMCompiler/Compiler/SimCode/SimCode.mo

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@ uniontype ModelInfo "Container for metadata about a Modelica model."
211211
record MODELINFO
212212
Absyn.Path name;
213213
String description;
214-
String stateInfo;
215-
String inputInfo;
216-
String outputInfo;
217214
String directory;
218215
VarInfo varInfo;
219216
SimCodeVar.SimVars vars;

OMCompiler/Compiler/SimCode/SimCodeUtil.mo

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7211,7 +7211,7 @@ public function createModelInfo
72117211
input list<SimCodeVar.SimVar> tempVars;
72127212
output SimCode.ModelInfo modelInfo;
72137213
protected
7214-
String description, directory, stateInfo = "", inputInfo = "", outputInfo = "";
7214+
String description, directory;
72157215
SimCode.VarInfo varInfo;
72167216
SimCodeVar.SimVars vars;
72177217
Integer nx, ny, ndy, np, na, next, numOutVars, numInVars, ny_int, np_int, na_int, ny_bool, np_bool, dim_1, dim_2, numOptimizeConstraints, numOptimizeFinalConstraints;
@@ -7226,13 +7226,6 @@ algorithm
72267226
directory := System.trim(fileDir, "\"");
72277227
vars := createVars(dlow, inInitDAE, tempVars);
72287228

7229-
// Somehow this flag is not always active when needed...
7230-
//if Flags.getConfigBool(Flags.GENERATE_SYMBOLIC_LINEARIZATION) then
7231-
stateInfo := createInfoString(vars.stateVars, "states");
7232-
inputInfo := createInfoString(vars.inputVars, "inputs");
7233-
outputInfo := createInfoString(vars.outputVars, "outputs");
7234-
//end if;
7235-
72367229
if debug then execStat("simCode: createVars"); end if;
72377230
BackendDAE.DAE(shared=BackendDAE.SHARED(info=BackendDAE.EXTRA_INFO(description=description))) := dlow;
72387231
nx := getNumScalars(vars.stateVars);
@@ -7261,8 +7254,8 @@ algorithm
72617254
if debug then execStat("simCode: createVarInfo"); end if;
72627255
hasLargeEqSystems := hasLargeEquationSystems(dlow, inInitDAE);
72637256
if debug then execStat("simCode: hasLargeEquationSystems"); end if;
7264-
modelInfo := SimCode.MODELINFO(class_, dlow.shared.info.description, stateInfo, inputInfo, outputInfo,
7265-
directory, varInfo, vars, functions, labels,
7257+
modelInfo := SimCode.MODELINFO(class_, dlow.shared.info.description, directory, varInfo, vars, functions,
7258+
labels,
72667259
if Flags.getConfigBool(Flags.BUILDING_FMU) then getResources(program.classes, dlow, inInitDAE) else {},
72677260
List.sort(program.classes, AbsynUtil.classNameGreater),
72687261
arrayLength(dlow.shared.partitionsInfo.basePartitions),
@@ -8218,6 +8211,7 @@ algorithm
82188211
end match;
82198212
end simVarString;
82208213

8214+
82218215
protected function printVarIndx
82228216
input Option<Integer> i;
82238217
output String s;
@@ -8240,6 +8234,7 @@ algorithm
82408234
end if;
82418235
end dumpVarLst;
82428236

8237+
82438238
public function printVarLstCrefs
82448239
input list<SimCodeVar.SimVar> inVars;
82458240
output String str;
@@ -8254,29 +8249,6 @@ algorithm
82548249
end for;
82558250
end printVarLstCrefs;
82568251

8257-
public function createInfoString
8258-
input list<SimCodeVar.SimVar> inVars;
8259-
input String name;
8260-
output String str = "";
8261-
protected
8262-
SimCodeVar.SimVar var;
8263-
list<SimCodeVar.SimVar> rest;
8264-
DAE.ComponentRef cref;
8265-
algorithm
8266-
str := name + "[" + intString(listLength(inVars))+ "] = [";
8267-
try
8268-
var :: rest := inVars;
8269-
SimCodeVar.SIMVAR(name= cref) := var;
8270-
str := str + ComponentReference.printComponentRefStr(cref);
8271-
for var in rest loop
8272-
SimCodeVar.SIMVAR(name= cref) := var;
8273-
str := str + ", " + ComponentReference.printComponentRefStr(cref);
8274-
end for;
8275-
else
8276-
end try;
8277-
str := str + "]";
8278-
end createInfoString;
8279-
82808252
protected function dumpVariablesString "dumps a list of SimCode.Variables to stdout.
82818253
author: Waurich TUD 2014-09"
82828254
input list<SimCodeFunction.Variable> vars;

OMCompiler/Compiler/Template/CodegenC.tpl

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4619,7 +4619,7 @@ template functionlinearmodel(ModelInfo modelInfo, String modelNamePrefix) "templ
46194619
Generates function in simulation file."
46204620
::=
46214621
match modelInfo
4622-
case MODELINFO(stateInfo=stateInfo, inputInfo=inputInfo, outputInfo=outputInfo, varInfo=VARINFO(__), vars=SIMVARS(__)) then
4622+
case MODELINFO(varInfo=VARINFO(__), vars=SIMVARS(__)) then
46234623
let matrixA = genMatrix("A", "n", "n", varInfo.numStateVars, varInfo.numStateVars)
46244624
let matrixB = genMatrix("B", "n", "p", varInfo.numStateVars, varInfo.numInVars)
46254625
let matrixC = genMatrix("C", "q", "n", varInfo.numOutVars, varInfo.numStateVars)
@@ -4634,12 +4634,7 @@ template functionlinearmodel(ModelInfo modelInfo, String modelNamePrefix) "templ
46344634
<<
46354635
const char *<%symbolName(modelNamePrefix,"linear_model_frame")%>()
46364636
{
4637-
return ""
4638-
"model linear_<%underscorePath(name)%> \"\n"
4639-
" <%stateInfo%>\n"
4640-
" <%inputInfo%>\n"
4641-
" <%outputInfo%>\"\n"
4642-
" parameter Integer n = <%varInfo.numStateVars%> \"number of states\";\n parameter Integer p = <%varInfo.numInVars%> \"number of inputs\";\n parameter Integer q = <%varInfo.numOutVars%> \"number of outputs\";\n"
4637+
return "model linear_<%underscorePath(name)%>\n parameter Integer n = <%varInfo.numStateVars%> \"number of states\";\n parameter Integer p = <%varInfo.numInVars%> \"number of inputs\";\n parameter Integer q = <%varInfo.numOutVars%> \"number of outputs\";\n"
46434638
"\n"
46444639
" parameter Real x0[n] = %s;\n"
46454640
" parameter Real u0[p] = %s;\n"
@@ -4660,12 +4655,7 @@ template functionlinearmodel(ModelInfo modelInfo, String modelNamePrefix) "templ
46604655
}
46614656
const char *<%symbolName(modelNamePrefix,"linear_model_datarecovery_frame")%>()
46624657
{
4663-
return ""
4664-
"model linear_<%underscorePath(name)%> \"\n"
4665-
" <%stateInfo%>\n"
4666-
" <%inputInfo%>\n"
4667-
" <%outputInfo%>\"\n"
4668-
" parameter Integer n = <%varInfo.numStateVars%> \"number of states\";\n parameter Integer p = <%varInfo.numInVars%> \"number of inputs\";\n parameter Integer q = <%varInfo.numOutVars%> \"number of outputs\";\n parameter Integer nz = <%varInfo.numAlgVars%> \"data recovery variables\";\n"
4658+
return "model linear_<%underscorePath(name)%>\n parameter Integer n = <%varInfo.numStateVars%> \"number of states\";\n parameter Integer p = <%varInfo.numInVars%> \"number of inputs\";\n parameter Integer q = <%varInfo.numOutVars%> \"number of outputs\";\n parameter Integer nz = <%varInfo.numAlgVars%> \"data recovery variables\";\n"
46694659
"\n"
46704660
" parameter Real x0[<%varInfo.numStateVars%>] = %s;\n"
46714661
" parameter Real u0[<%varInfo.numInVars%>] = %s;\n"

OMCompiler/Compiler/Template/SimCodeTV.mo

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,6 @@ package SimCode
687687
record MODELINFO
688688
Absyn.Path name;
689689
String description;
690-
String stateInfo;
691-
String inputInfo;
692-
String outputInfo;
693690
String directory;
694691
VarInfo varInfo;
695692
SimCodeVar.SimVars vars;

testsuite/openmodelica/linearization/linmodel.mos

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ readFile("linear_linearmodel.log"); // Check that output log is empty
4747
// "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").
4848
// "
4949
// true
50-
// "model linear_linearmodel \"
51-
// states[4] = [x1, x2, x3, x4]
52-
// inputs[0] = []
53-
// outputs[0] = []\"
50+
// "model linear_linearmodel
5451
// parameter Integer n = 4 \"number of states\";
5552
// parameter Integer p = 0 \"number of inputs\";
5653
// parameter Integer q = 0 \"number of outputs\";
@@ -97,10 +94,7 @@ readFile("linear_linearmodel.log"); // Check that output log is empty
9794
// "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").
9895
// "
9996
// true
100-
// "model linear_linearmodel \"
101-
// states[4] = [x1, x2, x3, x4]
102-
// inputs[0] = []
103-
// outputs[0] = []\"
97+
// "model linear_linearmodel
10498
// parameter Integer n = 4 \"number of states\";
10599
// parameter Integer p = 0 \"number of inputs\";
106100
// parameter Integer q = 0 \"number of outputs\";

testsuite/openmodelica/linearization/simLotkaVolterra.mos

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ readFile("linear_LotkaVolterra.log"); // Check that output log is empty
4747
// "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").
4848
// "
4949
// true
50-
// "model linear_LotkaVolterra \"
51-
// states[2] = [x, y]
52-
// inputs[0] = []
53-
// outputs[0] = []\"
50+
// "model linear_LotkaVolterra
5451
// parameter Integer n = 2 \"number of states\";
5552
// parameter Integer p = 0 \"number of inputs\";
5653
// parameter Integer q = 0 \"number of outputs\";
@@ -95,10 +92,7 @@ readFile("linear_LotkaVolterra.log"); // Check that output log is empty
9592
// "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").
9693
// "
9794
// true
98-
// "model linear_LotkaVolterra \"
99-
// states[2] = [x, y]
100-
// inputs[0] = []
101-
// outputs[0] = []\"
95+
// "model linear_LotkaVolterra
10296
// parameter Integer n = 2 \"number of states\";
10397
// parameter Integer p = 0 \"number of inputs\";
10498
// parameter Integer q = 0 \"number of outputs\";

testsuite/openmodelica/linearization/simNonlinear.mos

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ readFile("linear_p_nonlinsys.log"); // Check that output log is empty
4848
// "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").
4949
// "
5050
// true
51-
// "model linear_p_nonlinsys \"
52-
// states[3] = [b1.x, c1.x1, c1.x2]
53-
// inputs[1] = [u1]
54-
// outputs[2] = [y1, y2]\"
51+
// "model linear_p_nonlinsys
5552
// parameter Integer n = 3 \"number of states\";
5653
// parameter Integer p = 1 \"number of inputs\";
5754
// parameter Integer q = 2 \"number of outputs\";
@@ -100,10 +97,7 @@ readFile("linear_p_nonlinsys.log"); // Check that output log is empty
10097
// "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").
10198
// "
10299
// true
103-
// "model linear_p_nonlinsys \"
104-
// states[3] = [b1.x, c1.x1, c1.x2]
105-
// inputs[1] = [u1]
106-
// outputs[2] = [y1, y2]\"
100+
// "model linear_p_nonlinsys
107101
// parameter Integer n = 3 \"number of states\";
108102
// parameter Integer p = 1 \"number of inputs\";
109103
// parameter Integer q = 2 \"number of outputs\";

testsuite/openmodelica/linearization/simTwoTank.mos

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ readFile("linear_twoflattankmodel.log"); // Check that output log is empty
4848
// "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").
4949
// "
5050
// true
51-
// "model linear_twoflattankmodel \"
52-
// states[2] = [h1, h2]
53-
// inputs[1] = [F]
54-
// outputs[1] = [F2]\"
51+
// "model linear_twoflattankmodel
5552
// parameter Integer n = 2 \"number of states\";
5653
// parameter Integer p = 1 \"number of inputs\";
5754
// parameter Integer q = 1 \"number of outputs\";
@@ -98,10 +95,7 @@ readFile("linear_twoflattankmodel.log"); // Check that output log is empty
9895
// "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").
9996
// "
10097
// true
101-
// "model linear_twoflattankmodel \"
102-
// states[2] = [h1, h2]
103-
// inputs[1] = [F]
104-
// outputs[1] = [F2]\"
98+
// "model linear_twoflattankmodel
10599
// parameter Integer n = 2 \"number of states\";
106100
// parameter Integer p = 1 \"number of inputs\";
107101
// parameter Integer q = 1 \"number of outputs\";

testsuite/openmodelica/linearization/simVanDerPol.mos

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ readFile("linear_VanDerPol.log"); // Check that output log is empty
4242
// "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").
4343
// "
4444
// true
45-
// "model linear_VanDerPol \"
46-
// states[2] = [x, y]
47-
// inputs[0] = []
48-
// outputs[0] = []\"
45+
// "model linear_VanDerPol
4946
// parameter Integer n = 2 \"number of states\";
5047
// parameter Integer p = 0 \"number of inputs\";
5148
// parameter Integer q = 0 \"number of outputs\";
@@ -95,10 +92,7 @@ readFile("linear_VanDerPol.log"); // Check that output log is empty
9592
// "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").
9693
// "
9794
// true
98-
// "model linear_VanDerPol \"
99-
// states[2] = [x, y]
100-
// inputs[0] = []
101-
// outputs[0] = []\"
95+
// "model linear_VanDerPol
10296
// parameter Integer n = 2 \"number of states\";
10397
// parameter Integer p = 0 \"number of inputs\";
10498
// parameter Integer q = 0 \"number of outputs\";

testsuite/openmodelica/linearization/simextfunction.mos

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ readFile("linear_extfunction.log"); // Check that output log is empty
7070
// "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").
7171
// "
7272
// true
73-
// "model linear_extfunction \"
74-
// states[2] = [x, y]
75-
// inputs[0] = []
76-
// outputs[0] = []\"
73+
// "model linear_extfunction
7774
// parameter Integer n = 2 \"number of states\";
7875
// parameter Integer p = 0 \"number of inputs\";
7976
// parameter Integer q = 0 \"number of outputs\";
@@ -126,10 +123,7 @@ readFile("linear_extfunction.log"); // Check that output log is empty
126123
// "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").
127124
// "
128125
// true
129-
// "model linear_extfunction \"
130-
// states[2] = [x, y]
131-
// inputs[0] = []
132-
// outputs[0] = []\"
126+
// "model linear_extfunction
133127
// parameter Integer n = 2 \"number of states\";
134128
// parameter Integer p = 0 \"number of inputs\";
135129
// parameter Integer q = 0 \"number of outputs\";
@@ -182,10 +176,7 @@ readFile("linear_extfunction.log"); // Check that output log is empty
182176
// "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").
183177
// "
184178
// true
185-
// "model linear_extfunction \"
186-
// states[2] = [x, y]
187-
// inputs[0] = []
188-
// outputs[0] = []\"
179+
// "model linear_extfunction
189180
// parameter Integer n = 2 \"number of states\";
190181
// parameter Integer p = 0 \"number of inputs\";
191182
// parameter Integer q = 0 \"number of outputs\";
@@ -230,10 +221,7 @@ readFile("linear_extfunction.log"); // Check that output log is empty
230221
// "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").
231222
// "
232223
// true
233-
// "model linear_extfunction \"
234-
// states[2] = [x, y]
235-
// inputs[0] = []
236-
// outputs[0] = []\"
224+
// "model linear_extfunction
237225
// parameter Integer n = 2 \"number of states\";
238226
// parameter Integer p = 0 \"number of inputs\";
239227
// parameter Integer q = 0 \"number of outputs\";

0 commit comments

Comments
 (0)