Skip to content

Commit

Permalink
- base-clock partitioning (incomplete yet)
Browse files Browse the repository at this point in the history
  - propagation of new attribute EQSYSTEM.partitionKind
  - new incidence matrix type: BASECLOCK


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21474 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Jul 11, 2014
1 parent 3467c6d commit 2dbb273
Show file tree
Hide file tree
Showing 25 changed files with 615 additions and 409 deletions.
16 changes: 13 additions & 3 deletions Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -76,9 +76,18 @@ uniontype EqSystem "An independent system of equations (and their corresponding
Option<IncidenceMatrixT> mT;
Matching matching;
StateSets stateSets "the statesets of the system";
BaseClockPartitionKind partitionKind;
end EQSYSTEM;
end EqSystem;

public
uniontype BaseClockPartitionKind
record UNKNOWN_PARTITION end UNKNOWN_PARTITION;
record CLOCKED_PARTITION end CLOCKED_PARTITION;
record CONTINUOUS_TIME_PARTITION end CONTINUOUS_TIME_PARTITION;
record UNSPECIFIED_PARTITION "treated as CONTINUOUS_TIME_PARTITION" end UNSPECIFIED_PARTITION;
end BaseClockPartitionKind;

public
uniontype Shared "Data shared for all equation-systems"
record SHARED
Expand Down Expand Up @@ -556,10 +565,11 @@ end Solvability;

public
uniontype IndexType
record ABSOLUTE "produce incidence matrix with absolute indexes" end ABSOLUTE;
record NORMAL "produce incidence matrix with positive/negative indexes" end NORMAL;
record ABSOLUTE "produce incidence matrix with absolute indexes" end ABSOLUTE;
record NORMAL "produce incidence matrix with positive/negative indexes" end NORMAL;
record SOLVABLE "procude incidence matrix with only solvable entries, for example {a,b,c}[d] then d is skipped" end SOLVABLE;
record SPARSE "produce incidence matrix as normal, but add for Inputs also a value" end SPARSE;
record BASECLOCK "produce incidence matrix for base-clock partitioning" end BASECLOCK;
record SPARSE "produce incidence matrix as normal, but add for Inputs also a value" end SPARSE;
end IndexType;

//
Expand Down
3 changes: 1 addition & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -61,7 +61,6 @@ protected import Expression;
protected import ExpressionDump;
protected import Flags;
protected import Global;
protected import GlobalScript;
protected import HashTableExpToExp;
protected import HashTableExpToIndex;
protected import HashTable;
Expand Down Expand Up @@ -132,7 +131,7 @@ algorithm
eqnarr,
NONE(),
NONE(),
BackendDAE.NO_MATCHING(), {})::{},
BackendDAE.NO_MATCHING(), {}, BackendDAE.UNKNOWN_PARTITION())::{},
BackendDAE.SHARED(knvars,
extVars,
aliasVars,
Expand Down
546 changes: 311 additions & 235 deletions Compiler/BackEnd/BackendDAEOptimize.mo

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions Compiler/BackEnd/BackendDAETransform.mo
Expand Up @@ -96,7 +96,9 @@ algorithm
BackendDAE.Variables vars;
array<Integer> markarray;
BackendDAE.StateSets stateSets;
case (BackendDAE.EQSYSTEM(vars,eqs,SOME(_),SOME(mt),BackendDAE.MATCHING(ass1=ass1,ass2=ass2),stateSets=stateSets),_,_,_)
BackendDAE.BaseClockPartitionKind partitionKind;

case (BackendDAE.EQSYSTEM(vars,eqs,SOME(_),SOME(mt),BackendDAE.MATCHING(ass1=ass1,ass2=ass2),stateSets=stateSets,partitionKind=partitionKind),_,_,_)
equation
comps = tarjanAlgorithm(mt,ass2);
markarray = arrayCreate(BackendDAEUtil.equationArraySize(eqs),-1);
Expand All @@ -105,7 +107,7 @@ algorithm
//noscalass2 = eqnAssignmentNonScalar(1,arrayLength(mapEqnIncRow),mapEqnIncRow,ass2,{});
then
// Frenkel TUD: Do not hand over the scalar incidence Matrix because following modules does not check if scalar or not
(BackendDAE.EQSYSTEM(vars,eqs,NONE(),NONE(),BackendDAE.MATCHING(ass1,ass2,comps1),stateSets),comps1);
(BackendDAE.EQSYSTEM(vars,eqs,NONE(),NONE(),BackendDAE.MATCHING(ass1,ass2,comps1),stateSets,partitionKind),comps1);
else
equation
Error.addInternalError("./Compiler/BackEnd/BackendDAETransform.mo: function strongComponentsScalar failed
Expand Down Expand Up @@ -296,12 +298,14 @@ algorithm
BackendDAE.EquationArray eqs;
BackendDAE.Variables vars;
BackendDAE.StateSets stateSets;
case (BackendDAE.EQSYSTEM(vars,eqs,SOME(m),SOME(mt),BackendDAE.MATCHING(ass1=ass1,ass2=ass2),stateSets=stateSets),_)
BackendDAE.BaseClockPartitionKind partitionKind;

case (BackendDAE.EQSYSTEM(vars,eqs,SOME(m),SOME(mt),BackendDAE.MATCHING(ass1=ass1,ass2=ass2),stateSets=stateSets,partitionKind=partitionKind),_)
equation
comps = tarjanAlgorithm(mt,ass2);
comps1 = analyseStrongComponents(comps,syst,shared,ass1,ass2,{});
then
(BackendDAE.EQSYSTEM(vars,eqs,SOME(m),SOME(mt),BackendDAE.MATCHING(ass1,ass2,comps1),stateSets),comps1);
(BackendDAE.EQSYSTEM(vars,eqs,SOME(m),SOME(mt),BackendDAE.MATCHING(ass1,ass2,comps1),stateSets,partitionKind),comps1);
else
equation
Error.addInternalError("./Compiler/BackEnd/BackendDAETransform.mo: function strongComponents failed
Expand Down Expand Up @@ -360,6 +364,7 @@ algorithm
list<BackendDAE.Equation> eqn_lst;
BackendDAE.EquationArray eqns;
BackendDAE.StrongComponent compX;

case (comp,BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns),_,ass1,ass2)
equation
(eqn_lst,var_varindx_lst) = List.map3_2(comp, getEquationAndSolvedVar_Internal, eqns, vars, ass2);
Expand Down Expand Up @@ -465,7 +470,7 @@ algorithm
var_lst_1 = List.map(var_lst, transformXToXd);
vars_1 = BackendVariable.listVar1(var_lst_1);
eqns_1 = BackendEquation.listEquation(eqn_lst1);
syst = BackendDAE.EQSYSTEM(vars_1,eqns_1,NONE(),NONE(),BackendDAE.NO_MATCHING(),{});
syst = BackendDAE.EQSYSTEM(vars_1,eqns_1,NONE(),NONE(),BackendDAE.NO_MATCHING(),{},BackendDAE.UNKNOWN_PARTITION());
(m,mt) = BackendDAEUtil.incidenceMatrix(syst,BackendDAE.ABSOLUTE(),NONE());
// calculate jacobian. If constant, linear system of equations. Otherwise nonlinear
(jac,shared) = BackendDAEUtil.calculateJacobian(vars_1, eqns_1, m, true, shared);
Expand Down

0 comments on commit 2dbb273

Please sign in to comment.