Skip to content

Commit

Permalink
- Compiler/BackEnd
Browse files Browse the repository at this point in the history
  - move some functions from BackendDAEUtil.mo to BackendVariable.mo and BackendEquation.mo
  - move code for initialization to Initialization.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14239 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Dec 5, 2012
1 parent f4bde44 commit 80f54d1
Show file tree
Hide file tree
Showing 20 changed files with 1,560 additions and 1,519 deletions.
30 changes: 15 additions & 15 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -108,18 +108,18 @@ algorithm
Debug.execStat("Enter Backend",BackendDAE.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
functionTree := Env.getFunctionTree(inCache);
(DAE.DAE(elems),functionTree) := processDelayExpressions(lst,functionTree);
vars := BackendDAEUtil.emptyVars();
knvars := BackendDAEUtil.emptyVars();
extVars := BackendDAEUtil.emptyVars();
vars := BackendVariable.emptyVars();
knvars := BackendVariable.emptyVars();
extVars := BackendVariable.emptyVars();
(vars,knvars,extVars,eqns,reqns,ieqns,constrs,clsAttrs,whenclauses,extObjCls,aliaseqns) := lower2(listReverse(elems), functionTree, vars, knvars, extVars, {}, {}, {}, {}, {}, {}, {}, {});
whenclauses_1 := listReverse(whenclauses);
aliasVars := BackendDAEUtil.emptyVars();
aliasVars := BackendVariable.emptyVars();
// handle alias equations
(vars,knvars,extVars,aliasVars,eqns,reqns,ieqns,whenclauses_1) := handleAliasEquations(aliaseqns,vars,knvars,extVars,aliasVars,eqns,reqns,ieqns,whenclauses_1);
vars_1 := detectImplicitDiscrete(vars,knvars,eqns);
eqnarr := BackendDAEUtil.listEquation(eqns);
reqnarr := BackendDAEUtil.listEquation(reqns);
ieqnarr := BackendDAEUtil.listEquation(ieqns);
eqnarr := BackendEquation.listEquation(eqns);
reqnarr := BackendEquation.listEquation(reqns);
ieqnarr := BackendEquation.listEquation(ieqns);
constrarra := listArray(constrs);
clsattrsarra := listArray(clsAttrs);
einfo := BackendDAE.EVENT_INFO(whenclauses_1, {}, {}, {}, 0, 0);
Expand Down Expand Up @@ -3282,13 +3282,13 @@ algorithm
sampleLst=sampleLst,whenClauseLst=whenclauses,relationsNumber=countRelations,
numberMathEvents=countMathFunctions),eoc,btp,symjacs))),_)
equation
vars = BackendDAEUtil.listVar1(allvars);
eqs_lst = BackendDAEUtil.equationList(remeqns);
vars = BackendVariable.listVar1(allvars);
eqs_lst = BackendEquation.equationList(remeqns);
(zero_crossings,eqs_lst1,whenclauses,countRelations, countMathFunctions, relationsLst, sampleLst) = findZeroCrossings2(vars, knvars, eqs_lst, 0, whenclauses, 0, countRelations, countMathFunctions, zero_crossings, relationsLst, sampleLst);
remeqns = BackendDAEUtil.listEquation(eqs_lst1);
eqs_lst = BackendDAEUtil.equationList(inieqns);
remeqns = BackendEquation.listEquation(eqs_lst1);
eqs_lst = BackendEquation.equationList(inieqns);
(zero_crossings,eqs_lst1,_,countRelations, countMathFunctions, relationsLst, sampleLst) = findZeroCrossings2(vars, knvars, eqs_lst, 0, {}, 0, countRelations, countMathFunctions, zero_crossings, relationsLst, sampleLst);
inieqns = BackendDAEUtil.listEquation(eqs_lst1);
inieqns = BackendEquation.listEquation(eqs_lst1);
Debug.fcall(Flags.RELIDX,print, "findZeroCrossings1 sample index: " +& intString(listLength(sampleLst)) +& "\n");
einfo1 = BackendDAE.EVENT_INFO(whenclauses,zero_crossings,sampleLst,relationsLst,countRelations, countMathFunctions);
then
Expand Down Expand Up @@ -3333,13 +3333,13 @@ algorithm
relationsNumber=countRelations,numberMathEvents=countMathFunctions),
eoc,btp,symjacs),allvars))
equation
eqs_lst = BackendDAEUtil.equationList(eqns);
eqs_lst = BackendEquation.equationList(eqns);
(zero_crossings,eqs_lst1,_,countRelations, countMathFunctions, relations, sampleLst) = findZeroCrossings2(vars, knvars, eqs_lst, 0, {}, 0, countRelations, countMathFunctions, zero_crossings, relations, sampleLst);
Debug.fcall(Flags.RELIDX,print, "findZeroCrossings1 number of relations : " +& intString(countRelations) +& "\n");
Debug.fcall(Flags.RELIDX,print, "findZeroCrossings1 sample index: " +& intString(listLength(sampleLst)) +& "\n");
eqns1 = BackendDAEUtil.listEquation(eqs_lst1);
eqns1 = BackendEquation.listEquation(eqs_lst1);
einfo1 = BackendDAE.EVENT_INFO(whenclauses, zero_crossings, sampleLst, relations, countRelations, countMathFunctions);
allvars = listAppend(allvars,BackendDAEUtil.varList(vars));
allvars = listAppend(allvars,BackendVariable.varList(vars));
then
(BackendDAE.EQSYSTEM(vars,eqns1,m,mT,matching),(BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcs,einfo1,eoc,btp,symjacs),allvars));
end match;
Expand Down
260 changes: 130 additions & 130 deletions Compiler/BackEnd/BackendDAEOptimize.mo

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Compiler/BackEnd/BackendDAETransform.mo
Expand Up @@ -1118,8 +1118,8 @@ algorithm
eqn_lst = replaceDerOpInEquationList(eqn_lst);
// States are solved for der(x) not x.
var_lst_1 = List.map(var_lst, transformXToXd);
vars_1 = BackendDAEUtil.listVar1(var_lst_1);
eqns_1 = BackendDAEUtil.listEquation(eqn_lst);
vars_1 = BackendVariable.listVar1(var_lst_1);
eqns_1 = BackendEquation.listEquation(eqn_lst);
syst = BackendDAE.EQSYSTEM(vars_1,eqns_1,NONE(),NONE(),BackendDAE.NO_MATCHING());
(m,mt) = BackendDAEUtil.incidenceMatrix(syst,BackendDAE.ABSOLUTE());
// calculate jacobian. If constant, linear system of equations. Otherwise nonlinear
Expand Down Expand Up @@ -2422,13 +2422,13 @@ algorithm

case (BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs = eqns,m=SOME(m),mT=SOME(mt)),_,_)
equation
varCrefs = List.map(BackendDAEUtil.varList(vars),BackendVariable.varCref);
varCrefs = List.map(BackendVariable.varList(vars),BackendVariable.varCref);
varIndices = List.intRange(listLength(varCrefs));
prioTuples = calculateVarPriorities(varCrefs,varIndices,vars,eqns,m,mt,mapIncRowEqn,so,{});
prioTuples = List.sort(prioTuples,sortprioTuples);
varIndices = List.map(prioTuples,Util.tuple32);
vlst = List.map1r(varIndices,BackendVariable.getVarAt,vars);
states = BackendDAEUtil.listVar1(vlst);
states = BackendVariable.listVar1(vlst);
then states;

else
Expand Down

0 comments on commit 80f54d1

Please sign in to comment.