Skip to content

Commit

Permalink
- fix derivativ of min/max, ToDo implement derivative of min/max for …
Browse files Browse the repository at this point in the history
…more than two arguments

- bugfix dynamic state selection, state changes during runtime works now well
- improve calculation of jacobian
- improve analysation of jacobian
- move BackendDAEUtil.jacobianTypeStr to BackendDump
- improve calculation of liniear system rhs
- move Modelica.Mechanics.MultiBody.Examples.Elementary.PendulumWithSpringDamper.mos and Modelica.Mechanics.MultiBody.Examples.Elementary.ThreeSprings.mos to working tests

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12621 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Aug 21, 2012
1 parent d64f975 commit 15f3ef7
Show file tree
Hide file tree
Showing 11 changed files with 358 additions and 241 deletions.
14 changes: 8 additions & 6 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4555,11 +4555,12 @@ algorithm
list<DAE.ComponentRef> names;
BackendDAE.BinTree movedVars;
BackendDAE.Matching matching;
case (BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns,matching=matching),shared,eqn_lst,var_lst,jac,inMovedVars)
DAE.FunctionTree funcs;
case (BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns,matching=matching),shared as BackendDAE.SHARED(functionTree=funcs),eqn_lst,var_lst,jac,inMovedVars)
equation
eqns1 = BackendDAEUtil.listEquation(eqn_lst);
v = BackendDAEUtil.listVar1(var_lst);
((_,beqs,sources)) = BackendEquation.traverseBackendDAEEqns(eqns1,BackendEquation.equationToExp,(v,{},{}));
((_,beqs,sources,_)) = BackendEquation.traverseBackendDAEEqns(eqns1,BackendEquation.equationToExp,(v,{},{},SOME(funcs)));
beqs = listReverse(beqs);
rhsVals = ValuesUtil.valueReals(List.map(beqs,Ceval.cevalSimple));
jacVals = evaluateConstantJacobian(listLength(var_lst),jac);
Expand Down Expand Up @@ -4873,7 +4874,7 @@ algorithm
transEqArr = equationToResidualFormArr(eq_subSyst_Arr,1,l);
BackendDAE.SHARED(knownVars,externalObjects,aliasVars,_,removedEqs,constraints,classAttrs,cache,env,functionTree,eventInfo,extObjClasses,backenDAEType,symjacs) = sub_shared2;
eqns_subSyst = BackendDAE.EQUATION_ARRAY(sizeArr,NOE,arrSize,transEqArr);
jac_subSyst = BackendDAEUtil.calculateJacobian(vars_subSyst, eqns_subSyst, m_subSyst2, mT_subSyst2,false);
jac_subSyst = BackendDAEUtil.calculateJacobian(vars_subSyst, eqns_subSyst, m_subSyst2, false,sub_shared);
SOME(jac_subSyst1) = jac_subSyst;
row = listGet(jac_subSyst1,1);
(_,_,eq) = row;
Expand Down Expand Up @@ -4916,7 +4917,7 @@ algorithm
linearDAE = BackendDAE.DAE({eqSystem},shared);
eqnsNewton = List.intRange(l);
varsNewton = List.intRange(l);
jacNewton = BackendDAEUtil.calculateJacobian(variables,eqArray,m_new,mT_new,false);
jacNewton = BackendDAEUtil.calculateJacobian(variables,eqArray,m_new,false,sub_shared);
jacTypeNewton = BackendDAEUtil.analyzeJacobian(variables,eqArray,jacNewton);
comps_Newton = BackendDAE.EQUATIONSYSTEM(eqnsNewton,varsNewton,jacNewton,jacTypeNewton);
matching = BackendDAE.MATCHING(match1,match1,{comps_Newton});
Expand Down Expand Up @@ -11459,6 +11460,7 @@ algorithm
Option<list<tuple<Integer, Integer, BackendDAE.Equation>>> jac;
list<BackendDAE.Var> varlst;
list<DAE.Exp> explst;
DAE.FunctionTree funcs;
case ({},_,_,_) then inTpl;
case (BackendDAE.SINGLEEQUATION(eqn=e)::rest,_,_,_)
equation
Expand All @@ -11474,12 +11476,12 @@ algorithm
tpl = BackendDAEUtil.traverseBackendDAEExpsEqns(BackendDAEUtil.listEquation(eqnlst),countOperationsExp,tpl);
then
countOperationstraverseComps(rest,isyst,ishared,tpl);
case ((comp as BackendDAE.EQUATIONSYSTEM(jac=jac,jacType=BackendDAE.JAC_TIME_VARYING()))::rest,_,_,_)
case ((comp as BackendDAE.EQUATIONSYSTEM(jac=jac,jacType=BackendDAE.JAC_TIME_VARYING()))::rest,_,BackendDAE.SHARED(functionTree=funcs),_)
equation
(eqnlst,varlst,_) = BackendDAETransform.getEquationAndSolvedVar(comp, BackendEquation.daeEqns(isyst), BackendVariable.daeVars(isyst));
tpl = addJacSpecificOperations(listLength(eqnlst),inTpl);
tpl = countOperationsJac(jac,tpl);
((_,explst,_)) = BackendEquation.traverseBackendDAEEqns(BackendDAEUtil.listEquation(eqnlst),BackendEquation.equationToExp,(BackendDAEUtil.listVar1(varlst),{},{}));
((_,explst,_,_)) = BackendEquation.traverseBackendDAEEqns(BackendDAEUtil.listEquation(eqnlst),BackendEquation.equationToExp,(BackendDAEUtil.listVar1(varlst),{},{},SOME(funcs)));
((_,tpl)) = Expression.traverseExpList(explst,countOperationsExp,tpl);
then
countOperationstraverseComps(rest,isyst,ishared,tpl);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAETransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ algorithm
shared = BackendDAE.SHARED(evars,evars,av,eeqns,eeqns,constrs,clsAttrs,cache,env,funcs,BackendDAE.EVENT_INFO({},{}),{},BackendDAE.ALGEQSYSTEM(),{});
(m,mt) = BackendDAEUtil.incidenceMatrix(syst, shared, BackendDAE.ABSOLUTE());
// calculate jacobian. If constant, linear system of equations. Otherwise nonlinear
jac = BackendDAEUtil.calculateJacobian(vars_1, eqns_1, m, mt,true);
jac = BackendDAEUtil.calculateJacobian(vars_1, eqns_1, m, true,shared);
// Jacobian of a Linear System is always linear
jac_tp = BackendDAEUtil.analyzeJacobian(vars_1,eqns_1,jac);
then
Expand Down

0 comments on commit 15f3ef7

Please sign in to comment.