Skip to content

Commit

Permalink
- Split up package BackendDAEOptimize (moved some stuff to new packag…
Browse files Browse the repository at this point in the history
…e SymbolicJacobian and other packages)

- Marked functions as protected if they should be
- Removed redundant/obsolete code
- Removed symbolic matrix G that was used to improve old initialization approach, since it is deactivated for a long time and isn't working anymore anyway


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22998 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Oct 28, 2014
1 parent c8ddc96 commit 0ac8b0b
Show file tree
Hide file tree
Showing 10 changed files with 2,594 additions and 3,067 deletions.
2,858 changes: 105 additions & 2,753 deletions Compiler/BackEnd/BackendDAEOptimize.mo

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Compiler/BackEnd/BackendDAETransform.mo
Expand Up @@ -60,6 +60,7 @@ protected import ExpressionDump;
protected import Flags;
protected import List;
protected import SCode;
protected import SymbolicJacobian;
protected import System;
protected import Util;
protected import Values;
Expand Down Expand Up @@ -493,7 +494,7 @@ algorithm
list<DAE.Exp> beqs;
case(true,SOME(jac),_,_,_,_)
equation
jacVals = BackendDAEOptimize.evaluateConstantJacobian(size,jac);
jacVals = SymbolicJacobian.evaluateConstantJacobian(size,jac);
rhsVals = List.fill(0.0,size);
(_,linInfo) = System.dgesv(jacVals,rhsVals);
false = intEq(linInfo,0);
Expand Down
15 changes: 8 additions & 7 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -97,6 +97,7 @@ protected import ResolveLoops;
protected import SCode;
protected import SimCodeUtil;
protected import System;
protected import SymbolicJacobian;
protected import SynchronousFeatures;
protected import Tearing;
protected import Types;
Expand Down Expand Up @@ -8849,24 +8850,24 @@ algorithm
(InlineArrayEquations.inlineArrayEqn, "inlineArrayEqn", false),
(BackendDAEOptimize.removeUnusedParameter, "removeUnusedParameter", false),
(BackendDAEOptimize.removeUnusedVariables, "removeUnusedVariables", false),
(BackendDAEOptimize.constantLinearSystem, "constantLinearSystem", false),
(SymbolicJacobian.constantLinearSystem, "constantLinearSystem", false),
(OnRelaxation.relaxSystem, "relaxSystem", false),
(BackendDAEOptimize.countOperations, "countOperations", false),
(BackendDump.dumpComponentsGraphStr, "dumpComponentsGraphStr", false),
(BackendDAEOptimize.generateSymbolicJacobianPast, "generateSymbolicJacobian", false),
(BackendDAEOptimize.generateSymbolicLinearizationPast, "generateSymbolicLinearization", false),
(SymbolicJacobian.generateSymbolicJacobianPast, "generateSymbolicJacobian", false),
(SymbolicJacobian.generateSymbolicLinearizationPast, "generateSymbolicLinearization", false),
(BackendDAEOptimize.removeUnusedFunctions, "removeUnusedFunctions", false),
(BackendDAEOptimize.simplifyTimeIndepFuncCalls, "simplifyTimeIndepFuncCalls", false),
(BackendDAEOptimize.inputDerivativesUsed, "inputDerivativesUsed", false),
(SymbolicJacobian.inputDerivativesUsed, "inputDerivativesUsed", false),
(BackendDAEOptimize.simplifysemiLinear, "simplifysemiLinear", false),
(BackendDAEOptimize.removeConstants, "removeConstants", false),
(Initialization.optimizeInitialSystem, "optimizeInitialSystem", false),
(BackendDAEOptimize.detectSparsePatternODE, "detectJacobianSparsePattern", false),
(SymbolicJacobian.detectSparsePatternODE, "detectJacobianSparsePattern", false),
(Tearing.tearingSystem, "tearingSystem", false),
(HpcOmEqSystems.partitionLinearTornSystem, "partlintornsystem", false),
(BackendDAEOptimize.addInitialStmtsToAlgorithms, "addInitialStmtsToAlgorithms", false),
(BackendDAEOptimize.calculateStrongComponentJacobians, "calculateStrongComponentJacobians", false),
(BackendDAEOptimize.calculateStateSetsJacobians, "calculateStateSetsJacobians", false),
(SymbolicJacobian.calculateStrongComponentJacobians, "calculateStrongComponentJacobians", false),
(SymbolicJacobian.calculateStateSetsJacobians, "calculateStateSetsJacobians", false),
(ResolveLoops.reshuffling_post, "reshufflePost", false)
};

Expand Down
36 changes: 36 additions & 0 deletions Compiler/BackEnd/Differentiate.mo
Expand Up @@ -2875,5 +2875,41 @@ algorithm
end matchcontinue;
end addElementVars2Dep;

public function differentiateVarWithRespectToX "author: lochel
TODO: REMOVE ME"
input DAE.ComponentRef inCref;
input DAE.ComponentRef inX;
input tuple<String,Boolean> inMatrixName;
output DAE.ComponentRef outCref;
algorithm
outCref := matchcontinue(inCref, inX, inMatrixName)
local
DAE.ComponentRef cref, x;
String id,str;
String matrixName;

// replace the subscripts with strings because not all elements of the arrays may be derived, this avoid trouble when generate simulation code
case(cref, x, (matrixName,true)) equation
cref = ComponentReference.joinCrefs(ComponentReference.makeCrefIdent(BackendDAE.partialDerivativeNamePrefix, ComponentReference.crefType(cref), {}),cref);
cref = ComponentReference.appendStringCref(matrixName, cref);
cref = ComponentReference.joinCrefs(cref, x);
cref = ComponentReference.replaceSubsWithString(cref);
then cref;

case(cref, x, (matrixName,false)) equation
id = ComponentReference.printComponentRefStr(cref) +& BackendDAE.partialDerivativeNamePrefix +& matrixName +& "$P" +& ComponentReference.printComponentRefStr(x);
id = Util.stringReplaceChar(id, ",", "$c");
id = Util.stringReplaceChar(id, ".", "$P");
id = Util.stringReplaceChar(id, "[", "$lB");
id = Util.stringReplaceChar(id, "]", "$rB");
then ComponentReference.makeCrefIdent(id, DAE.T_REAL_DEFAULT, {});

case(cref, _, _) equation
str = "BackendDAEOptimize.differentiateVarWithRespectToX failed: " +& ComponentReference.printComponentRefStr(cref);
Error.addMessage(Error.INTERNAL_ERROR, {str});
then fail();
end matchcontinue;
end differentiateVarWithRespectToX;

annotation(__OpenModelica_Interface="backend");
end Differentiate;

0 comments on commit 0ac8b0b

Please sign in to comment.