Skip to content

Commit 26e093e

Browse files
author
Willi Braun
committed
- bug fix for linearization(modelname with underscore instaed of dot)
- bug fix added uniqueEqIndex for symbolic jacobian for *_info.xml git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16492 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 60f9580 commit 26e093e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Compiler/BackEnd/SimCodeUtil.mo

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ algorithm
15951595
SymbolicJacs = listAppend(SymbolicJacsStateSelect, SymbolicJacs);
15961596

15971597
// generate jacobian or linear model matrices
1598-
LinearMatrices = createJacobianLinearCode(symJacs, modelInfo, uniqueEqIndex);
1598+
(LinearMatrices,uniqueEqIndex) = createJacobianLinearCode(symJacs, modelInfo, uniqueEqIndex);
15991599
LinearMatrices = jacG::LinearMatrices;
16001600

16011601
(_, numberofLinearSys, numberofNonLinearSys, numberofMixedSys, LinearMatrices) = countandIndexAlgebraicLoops({}, numberofLinearSys, numberofNonLinearSys, numberofMixedSys, LinearMatrices);
@@ -4895,28 +4895,29 @@ end createSymbolicSimulationJacobian;
48954895
protected function createJacobianLinearCode
48964896
input BackendDAE.SymbolicJacobians inSymjacs;
48974897
input SimCode.ModelInfo inModelInfo;
4898-
input Integer uniqueEqIndex;
4898+
input Integer iuniqueEqIndex;
48994899
output list<SimCode.JacobianMatrix> res;
4900+
output Integer ouniqueEqIndex;
49004901
algorithm
4901-
res := matchcontinue (inSymjacs, inModelInfo, uniqueEqIndex)
4902+
(res,ouniqueEqIndex) := matchcontinue (inSymjacs, inModelInfo, iuniqueEqIndex)
49024903
local
49034904
case (_, _, _)
49044905
equation
49054906
System.realtimeTick(CevalScript.RT_CLOCK_EXECSTAT_JACOBIANS);
49064907
// b = Flags.disableDebug(Flags.EXEC_STAT);
49074908
// The jacobian code requires single systems;
49084909
// I did not rewrite it to take advantage of any parallelism in the code
4909-
(res, _) = createSymbolicJacobianssSimCode(inSymjacs, inModelInfo, uniqueEqIndex, {"A", "B", "C", "D"});
4910+
(res, ouniqueEqIndex) = createSymbolicJacobianssSimCode(inSymjacs, inModelInfo, iuniqueEqIndex, {"A", "B", "C", "D"});
49104911
// if optModule is not activated add dummy matrices
49114912
res = addLinearizationMatrixes(res);
49124913
// _ = Flags.set(Flags.EXEC_STAT, b);
49134914
Debug.execStat("generated analytical Jacobians SimCode. : ", CevalScript.RT_CLOCK_EXECSTAT_JACOBIANS);
49144915
_ = System.realtimeTock(CevalScript.RT_CLOCK_EXECSTAT_JACOBIANS);
4915-
then res;
4916+
then (res,ouniqueEqIndex);
49164917
else
49174918
equation
49184919
res = {({}, {}, "A", ({}, ({}, {})), {}, 0), ({}, {}, "B", ({}, ({}, {})), {}, 0), ({}, {}, "C", ({}, ({}, {})), {}, 0), ({}, {}, "D", ({}, ({}, {})), {}, 0)};
4919-
then res;
4920+
then (res,iuniqueEqIndex);
49204921
end matchcontinue;
49214922
end createJacobianLinearCode;
49224923

Compiler/Template/CodegenC.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ template functionlinearmodel(ModelInfo modelInfo) "template functionlinearmodel
20022002
//string def_proctedpart("\n Real x[<%varInfo.numStateVars%>](start=x0);\n Real u[<%varInfo.numInVars%>](start=u0); \n output Real y[<%varInfo.numOutVars%>]; \n");
20032003
<<
20042004
const char *linear_model_frame =
2005-
"model linear_<%dotPath(name)%>\n parameter Integer n = <%varInfo.numStateVars%>; // states \n parameter Integer k = <%varInfo.numInVars%>; // top-level inputs \n parameter Integer l = <%varInfo.numOutVars%>; // top-level outputs \n"
2005+
"model linear_<%underscorePath(name)%>\n parameter Integer n = <%varInfo.numStateVars%>; // states \n parameter Integer k = <%varInfo.numInVars%>; // top-level inputs \n parameter Integer l = <%varInfo.numOutVars%>; // top-level outputs \n"
20062006
" parameter Real x0[<%varInfo.numStateVars%>] = {%s};\n"
20072007
" parameter Real u0[<%varInfo.numInVars%>] = {%s};\n"
20082008
<%matrixA%>
@@ -2013,7 +2013,7 @@ template functionlinearmodel(ModelInfo modelInfo) "template functionlinearmodel
20132013
<%vectorU%>
20142014
<%vectorY%>
20152015
"\n <%getVarName(vars.stateVars, "x", varInfo.numStateVars )%> <% getVarName(vars.inputVars, "u", varInfo.numInVars) %> <%getVarName(vars.outputVars, "y", varInfo.numOutVars) %>\n"
2016-
"equation\n der(x) = A * x + B * u;\n y = C * x + D * u;\nend linear_<%dotPath(name)%>;\n"
2016+
"equation\n der(x) = A * x + B * u;\n y = C * x + D * u;\nend linear_<%underscorePath(name)%>;\n"
20172017
;
20182018
>>
20192019
end match

0 commit comments

Comments
 (0)