Skip to content

Commit

Permalink
- BackendDAEOptimize.mo: move equal code in one function
Browse files Browse the repository at this point in the history
- BackendDAETransform.mo: update dynamic state selection (passes now testsimulation, not all with same results as old method but all simulate :) )

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9488 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jul 15, 2011
1 parent 08f233b commit d28fcba
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 63 deletions.
3 changes: 2 additions & 1 deletion Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -432,7 +432,8 @@ public
type DAEHandlerArg = tuple<StateOrder,ConstraintEquations>;

public
type ConstraintEquations = list<tuple<Integer,list<Equation>>>;
type ConstraintEquations = list<tuple<Integer,list<tuple<Equation,Boolean>>>>;


public
uniontype StateOrder
Expand Down
40 changes: 22 additions & 18 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -171,7 +171,7 @@ algorithm
end match;
end inlineArrayEqn1;

protected function doReplaceScalarArrayEqns
public function doReplaceScalarArrayEqns
"function: doReplaceScalarArrayEqns
autor: Frenkel TUD 2011-5"
input array<list<BackendDAE.Equation>> arraylisteqns;
Expand Down Expand Up @@ -215,7 +215,7 @@ algorithm
end matchcontinue;
end doReplaceScalarArrayEqns;

protected function getScalarArrayEqns"
public function getScalarArrayEqns"
Author: Frenkel TUD 2011-02"
input BackendDAE.MultiDimEquation inAEqn;
output list<BackendDAE.Equation> outEqsLst;
Expand All @@ -233,46 +233,50 @@ algorithm
equation
true = Expression.isArray(e1) or Expression.isMatrix(e1);
true = Expression.isArray(e2) or Expression.isMatrix(e2);
ea1 = Expression.flattenArrayExpToList(e1);
ea2 = Expression.flattenArrayExpToList(e2);
ealst = Util.listThreadTuple(ea1,ea2);
eqns = Util.listMap1(ealst,BackendEquation.generateEQUATION,source);
eqns = generateScalarArrayEqns(e1,e2,source);
then
eqns;
case BackendDAE.MULTIDIM_EQUATION(left=e1 as DAE.CREF(componentRef =_),right=e2,source=source)
equation
true = Expression.isArray(e2) or Expression.isMatrix(e2);
((e1_1,(_,_))) = BackendDAEUtil.extendArrExp((e1,(NONE(),false)));
ea1 = Expression.flattenArrayExpToList(e1_1);
ea2 = Expression.flattenArrayExpToList(e2);
ealst = Util.listThreadTuple(ea1,ea2);
eqns = Util.listMap1(ealst,BackendEquation.generateEQUATION,source);
eqns = generateScalarArrayEqns(e1_1,e2,source);
then
eqns;
case BackendDAE.MULTIDIM_EQUATION(left=e1,right=e2 as DAE.CREF(componentRef =_),source=source)
equation
true = Expression.isArray(e1) or Expression.isMatrix(e1);
((e2_1,(_,_))) = BackendDAEUtil.extendArrExp((e2,(NONE(),false)));
ea1 = Expression.flattenArrayExpToList(e1);
ea2 = Expression.flattenArrayExpToList(e2_1);
ealst = Util.listThreadTuple(ea1,ea2);
eqns = Util.listMap1(ealst,BackendEquation.generateEQUATION,source);
eqns = generateScalarArrayEqns(e1,e2_1,source);
then
eqns;
case BackendDAE.MULTIDIM_EQUATION(left=e1 as DAE.CREF(componentRef =_),right=e2 as DAE.CREF(componentRef =_),source=source)
equation
((e1_1,(_,_))) = BackendDAEUtil.extendArrExp((e1,(NONE(),false)));
((e2_1,(_,_))) = BackendDAEUtil.extendArrExp((e2,(NONE(),false)));
ea1 = Expression.flattenArrayExpToList(e1_1);
ea2 = Expression.flattenArrayExpToList(e2_1);
ealst = Util.listThreadTuple(ea1,ea2);
eqns = Util.listMap1(ealst,BackendEquation.generateEQUATION,source);
eqns = generateScalarArrayEqns(e1_1,e2_1,source);
then
eqns;
case aeqn then {};
end matchcontinue;
end getScalarArrayEqns;

protected function generateScalarArrayEqns"
Author: Frenkel TUD 2011-02"
input DAE.Exp e1;
input DAE.Exp e2;
input DAE.ElementSource source;
output list<BackendDAE.Equation> eqns;
protected
list<DAE.Exp> ea1,ea2;
list<tuple<DAE.Exp,DAE.Exp>> ealst;
algorithm
ea1 := Expression.flattenArrayExpToList(e1);
ea2 := Expression.flattenArrayExpToList(e2);
ealst := Util.listThreadTuple(ea1,ea2);
eqns := Util.listMap1(ealst,BackendEquation.generateEQUATION,source);
end generateScalarArrayEqns;

protected function replaceScalarArrayEqns
"Help function to e.g. inlineArrayEqn"
input tuple<BackendDAE.Equation,tuple<array<list<BackendDAE.Equation>>,Integer,list<Integer>>> tpl;
Expand Down

0 comments on commit d28fcba

Please sign in to comment.