Skip to content

Commit

Permalink
- bug fix for BackenDAEutil.analyzeJacobian
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14818 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Willi Braun committed Jan 17, 2013
1 parent da969ff commit d8bf384
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6546,20 +6546,27 @@ algorithm
list<tuple<Integer, Integer, BackendDAE.Equation>> jac;
Boolean b,b1;
BackendDAE.JacobianType jactype;
String str;
case (_,_,SOME(jac))
equation
true = jacobianConstant(jac);
b = rhsConstant(vars,eqns);
jactype = Util.if_(b,BackendDAE.JAC_CONSTANT(),BackendDAE.JAC_TIME_VARYING());
then
(jactype,true);
case (_,_,SOME(jac))
equation
//str = BackendDump.dumpJacobianStr(SOME(jac));
//print("analyze Jacobian: \n" +& str +& "\n");
b = jacobianNonlinear(vars, jac);
// check also if variables occure in if expressions
((_,false)) = Debug.bcallret3(not b,traverseBackendDAEExpsEqnsWithStop,eqns,varsNotInRelations,(vars,true),(vars,false));
//print("jac type: JAC_NONLINEAR() \n");
then
(BackendDAE.JAC_NONLINEAR(),false);

case (_,_,SOME(jac))
equation
true = jacobianConstant(jac);
b = rhsConstant(vars,eqns);
jactype = Util.if_(b,BackendDAE.JAC_CONSTANT(),BackendDAE.JAC_TIME_VARYING());
//print("jac type: " +& Util.if_(b,"JAC_CONSTANT()","JAC_TIME_VARYING()") +& "\n");
then
(jactype,true);

case (_,_,SOME(jac)) then (BackendDAE.JAC_TIME_VARYING(),false);
case (_,_,NONE()) then (BackendDAE.JAC_NO_ANALYTIC(),false);
end matchcontinue;
Expand Down Expand Up @@ -6595,7 +6602,7 @@ algorithm
((e,false,(vars,b)));
case ((e as DAE.CALL(expLst=expLst),(vars,b)))
equation
// check if vars not in condition
// check if vars occurs not in argument list
((_,(_,b))) = Expression.traverseExpListTopDown(expLst, getEqnsysRhsExp2, (vars,b));
then
((e,false,(vars,b)));
Expand Down Expand Up @@ -6865,7 +6872,7 @@ public function getEqnsysRhsExp "function: getEqnsysRhsExp

Retrieve the right hand side expression of an equation
in an equation system, given a set of variables.
Uses f(x) = g(x) -> 0 = f(x)-g(x) -> x=0 -> rhs= f(0)-g(0).
Uses A1*x + b1= A2*x + b2 -> 0 = (A1 - A2)*x+(b1-b2) -> x=0 -> rhs= A*0+b=b.
Does not work for nonlinear Equations.

inputs: (DAE.Exp, BackendDAE.Variables /* variables of the eqn sys. */)
Expand Down Expand Up @@ -6918,7 +6925,7 @@ algorithm
((e,false,(repl,vars,funcs,b)));
case ((e as DAE.CALL(expLst=expLst),(repl,vars,funcs,b)))
equation
// check if vars not in condition
// check if vars not in expList
((_,(_,b))) = Expression.traverseExpListTopDown(expLst, getEqnsysRhsExp2, (vars,b));
(e,b) = getEqnsysRhsExp3(b,e,(repl,vars,funcs,true));
then
Expand Down

0 comments on commit d8bf384

Please sign in to comment.