Skip to content

Commit

Permalink
[DAEmode] Fix sorting of parameter equations
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2244
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed Mar 1, 2018
1 parent 24e74bf commit 1cc3bf3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -7380,7 +7380,7 @@ algorithm
fail();
end getOptimizesDAEModeSystem;

protected function sortGlobalKnownVarsInDAE "
public function sortGlobalKnownVarsInDAE "
author: ptaeuber
This function sorts the globalKnownVars"
input output BackendDAE.BackendDAE backendDAE;
Expand Down
3 changes: 3 additions & 0 deletions Compiler/BackEnd/DAEMode.mo
Expand Up @@ -136,6 +136,9 @@ algorithm
// use preOpt instead
simDAE := BackendDAEUtil.postOptimizeDAE(simDAE, postOptModules, matchingAlgorithm, daeHandler);

// sort the globalKnownVars
simDAE := BackendDAEUtil.sortGlobalKnownVarsInDAE(simDAE);

// debug dump
if Flags.isSet(Flags.DUMP_INDX_DAE) then
BackendDump.dumpBackendDAE(simDAE, "dumpindxdae");
Expand Down
8 changes: 5 additions & 3 deletions Compiler/SimCode/SimCodeMain.mo
Expand Up @@ -1070,6 +1070,7 @@ protected
Integer nStates;
Integer numberofEqns, numStateSets, numberofLinearSys, numberofNonLinearSys,
numberofMixedSys, numberOfJacobians, numberofFixedParameters;
Boolean tmpB;

list<DAE.ComponentRef> discreteModelVars;
list<BackendDAE.TimeEvent> timeEvents;
Expand Down Expand Up @@ -1150,7 +1151,6 @@ algorithm
((uniqueEqIndex, parameterEquations)) := BackendDAEUtil.foldEqSystem(inBackendDAE, SimCodeUtil.createVarNominalAssertFromVars, (uniqueEqIndex, {}));
if debug then ExecStat.execStat("simCode: createVarNominalAssertFromVars"); end if;
(uniqueEqIndex, parameterEquations, _) := SimCodeUtil.createParameterEquations(uniqueEqIndex, parameterEquations, inBackendDAE.shared.globalKnownVars);
parameterEquations := listReverse(parameterEquations);
if debug then ExecStat.execStat("simCode: createParameterEquations"); end if;

(uniqueEqIndex, removedEquations) := BackendEquation.traverseEquationArray(BackendDAEUtil.collapseRemovedEqs(inBackendDAE), SimCodeUtil.traversedlowEqToSimEqSystem, (uniqueEqIndex, {}));
Expand All @@ -1173,9 +1173,11 @@ algorithm
emptyBDAE := BackendDAE.DAE(BackendDAEUtil.createEqSystem(
Util.getOption(inBackendDAE.shared.daeModeData.modelVars))::{},
inBackendDAE.shared);
// disable start value calculation, since it fails for some reason
Flags.enableDebug(Flags.NO_START_CALC);
// disable start value calculation, it's only helpful in case of algebraic loops
// and they are not present in DAEmode
tmpB := Flags.set(Flags.NO_START_CALC, true);
modelInfo := SimCodeUtil.createModelInfo(className, p, emptyBDAE, inInitDAE, functions, {}, numStateSets, fileDir, 0, tempVars);
Flags.set(Flags.NO_START_CALC, tmpB);

//create hash table
crefToSimVarHT := SimCodeUtil.createCrefToSimVarHT(modelInfo);
Expand Down

0 comments on commit 1cc3bf3

Please sign in to comment.