Skip to content

Commit 97cd6bb

Browse files
committed
- initialization
- always generate all the stuff for the numerical initialization (even if +d=solveinitialsystem is used) - add executable-flag [-iim symbolic] to solve the initialization problem symbolically (currently you also need +d=solveinitialsystem) - remove obsolete function: - ./Compiler/BackEnd/SimCodeUtil.addJacobiansToSimCode - SimulationRuntime/c - introduce new initialization option: -iim symbolic - improve dumps - remove c++ comments - remove unused vars - make some code fragments more readable - use comments - even for function descriptions! - use meaningful variable names - use spaces between arguments git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13806 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 4eae838 commit 97cd6bb

File tree

14 files changed

+358
-283
lines changed

14 files changed

+358
-283
lines changed

Compiler/BackEnd/BackendDAEOptimize.mo

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6629,7 +6629,7 @@ algorithm
66296629
list<BackendDAE.Var> vars;
66306630
BackendDAE.Equation eqn;
66316631
list<BackendDAE.Equation> eqns;
6632-
DAE.Exp e, e1, crefExp, startExp;
6632+
DAE.Exp e, e1, crefExp, startExp;
66336633
DAE.ComponentRef cref;
66346634
DAE.Type tp;
66356635

@@ -6821,17 +6821,17 @@ algorithm
68216821
parameters = List.select(knownVarList, BackendVariable.isParam);
68226822
outputs = List.select(orderedVarList, BackendVariable.isVarOnTopLevelAndOutput);
68236823

6824-
(jacobian,_,_) = createJacobian(DAE, // DAE
6825-
states, //
6826-
BackendDAEUtil.listVar1(states), //
6827-
BackendDAEUtil.listVar1(inputs), //
6828-
BackendDAEUtil.listVar1(parameters), //
6829-
BackendDAEUtil.listVar1(outputs), //
6830-
orderedVarList, //
6831-
(orderedVarCrefList, knownVarCrefList), //
6832-
"G"); // name
6824+
(jacobian, _, _) = createJacobian(DAE, // DAE
6825+
states, //
6826+
BackendDAEUtil.listVar1(states), //
6827+
BackendDAEUtil.listVar1(inputs), //
6828+
BackendDAEUtil.listVar1(parameters), //
6829+
BackendDAEUtil.listVar1(outputs), //
6830+
orderedVarList, //
6831+
(orderedVarCrefList, knownVarCrefList), //
6832+
"G"); // name
68336833
then (jacobian, DAE);
6834-
6834+
68356835
else equation
68366836
Error.addMessage(Error.INTERNAL_ERROR, {"./Compiler/BackEnd/BackendDAEOptimize.mo: function generateInitialMatrices failed"});
68376837
then fail();

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 154 additions & 142 deletions
Large diffs are not rendered by default.

Compiler/BackEnd/BackendQSS.mo

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ algorithm
10141014
list<String> externalFunctionIncludes;
10151015
list<list<SimCode.SimEqSystem>> odeEquations;
10161016
list<SimCode.SimEqSystem> allEquations,algebraicEquations,residualEquations,startValueEquations,parameterEquations,removedEquations,sampleEquations,algorithmAndEquationAsserts;
1017+
Boolean useSymbolicInitialization;
10171018
list<SimCode.SimEqSystem> initialEquations;
10181019
list<DAE.Constraint> constraints;
10191020
list<BackendDAE.ZeroCrossing> zeroCrossings,relations;
@@ -1030,15 +1031,15 @@ algorithm
10301031
list<SimCode.JacobianMatrix> jacobianMatrixes;
10311032
list<SimCode.SimEqSystem> eqs;
10321033
case (SimCode.SIMCODE(modelInfo,literals,recordDecls,externalFunctionIncludes,allEquations,odeEquations,
1033-
algebraicEquations,residualEquations,initialEquations,startValueEquations,
1034+
algebraicEquations,residualEquations,useSymbolicInitialization,initialEquations,startValueEquations,
10341035
parameterEquations,removedEquations,algorithmAndEquationAsserts,constraints,zeroCrossings,relations,
10351036
sampleConditions,sampleEquations,helpVarInfo,whenClauses,discreteModelVars,extObjInfo,makefileParams,
10361037
delayedExps,jacobianMatrixes,simulationSettingsOpt,fileNamePrefix,crefToSimVarHT),_)
10371038
equation
10381039
{eqs} = odeEquations;
10391040
eqs = List.map1(eqs,replaceZC,zc_exps);
10401041
then SimCode.SIMCODE(modelInfo, literals, recordDecls, externalFunctionIncludes,
1041-
allEquations, {eqs}, algebraicEquations, residualEquations,
1042+
allEquations, {eqs}, algebraicEquations, residualEquations, useSymbolicInitialization,
10421043
initialEquations, startValueEquations, parameterEquations,
10431044
removedEquations, algorithmAndEquationAsserts, constraints,
10441045
zeroCrossings, relations, sampleConditions, sampleEquations,

Compiler/BackEnd/BackendVariable.mo

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,25 @@ algorithm
152152
end match;
153153
end setVarFixed;
154154

155-
public function varFixed
156-
"function: varFixed
155+
public function varFixed "function varFixed
157156
author: PA
158157
Extracts the fixed attribute of a variable.
159158
The default fixed value is used if not found. Default is true for parameters
160159
(and constants) and false for variables."
161160
input BackendDAE.Var inVar;
162161
output Boolean outBoolean;
163162
algorithm
164-
outBoolean:=
165-
matchcontinue (inVar)
163+
outBoolean := matchcontinue(inVar)
166164
local
167165
Boolean fixed;
168166
BackendDAE.Var v;
169167
case (BackendDAE.VAR(values = SOME(DAE.VAR_ATTR_REAL(fixed=SOME(DAE.BCONST(fixed)))))) then fixed;
170168
case (BackendDAE.VAR(values = SOME(DAE.VAR_ATTR_INT(fixed=SOME(DAE.BCONST(fixed)))))) then fixed;
171169
case (BackendDAE.VAR(values = SOME(DAE.VAR_ATTR_BOOL(fixed=SOME(DAE.BCONST(fixed)))))) then fixed;
172170
case (BackendDAE.VAR(values = SOME(DAE.VAR_ATTR_ENUMERATION(fixed=SOME(DAE.BCONST(fixed)))))) then fixed;
173-
case (v) /* params are by default fixed */
174-
equation
175-
BackendDAE.PARAM() = varKind(v);
176-
then
177-
true;
171+
case (v) equation /* params are by default fixed */
172+
BackendDAE.PARAM() = varKind(v);
173+
then true;
178174
/* See Modelica Spec 3.2 page 88:
179175
For constants and parameters, the attribute fixed is by default true. For other variables
180176
fixed is by default false. For all variables declared as constant it is an error to have "fixed = false".
@@ -185,7 +181,7 @@ algorithm
185181
then
186182
not fixed;
187183
*/
188-
case (_) then false; /* rest defaults to false*/
184+
case (_) then false; /* rest defaults to false */
189185
end matchcontinue;
190186
end varFixed;
191187

Compiler/BackEnd/ResidualCmp.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ algorithm
187187
makefileParams = SimCode.MAKEFILE_PARAMS("","","","","","","","","",includeDirs,libs,"");
188188
delayexp = SimCode.DELAYED_EXPRESSIONS({},0);
189189
hashTable = SimCodeUtil.emptyHashTable();
190-
rescmp = SimCode.SIMCODE(modelInfo,{},recordDecls,externalFunctionIncludes,{},{},{},allEquations,allInitEquations,{},{},{},{},{},{},{},{},{},{},{},{},extObjInfo,makefileParams,delayexp,{},NONE(),filenamePrefix,hashTable);
190+
rescmp = SimCode.SIMCODE(modelInfo,{},recordDecls,externalFunctionIncludes,{},{},{},allEquations,false,allInitEquations,{},{},{},{},{},{},{},{},{},{},{},{},extObjInfo,makefileParams,delayexp,{},NONE(),filenamePrefix,hashTable);
191191
then
192192
rescmp;
193193
else

Compiler/BackEnd/SimCode.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ uniontype SimCode
8686
list<list<SimEqSystem>> odeEquations;
8787
list<SimEqSystem> algebraicEquations;
8888
list<SimEqSystem> residualEquations;
89+
Boolean useSymbolicInitialization; // true if a system to solve the initial problem symbolically is generated, otherwise false
8990
list<SimEqSystem> initialEquations;
9091
list<SimEqSystem> startValueEquations;
9192
list<SimEqSystem> parameterEquations;

0 commit comments

Comments
 (0)