Changeset ad1689a in OpenModelica


Ignore:
Timestamp:
2016-03-21T10:21:18+01:00 (8 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
6bd48ef
Parents:
01b9dd9
git-author:
vruge <vruge@…> (03/21/16 10:21:18)
git-committer:
hudson <openmodelica@…> (03/21/16 10:21:18)
Message:

improved solveSimpleEquations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Compiler/BackEnd/ExpressionSolve.mo

    r473cb9ca rad1689a  
    6565
    6666public function solveSimpleEquations
    67   input BackendDAE.BackendDAE inDAE;
    68   output BackendDAE.BackendDAE outDAE = inDAE;
    69 protected
    70   BackendDAE.Equation eqn;
    71   BackendDAE.Var var;
    72   Integer iComp;
    73   Integer eindex,vindx;
    74   BackendDAE.StrongComponents comps;
    75   array<Integer> ass1 "eqn := ass1[var]";
    76   array<Integer> ass2 "var := ass2[eqn]";
    77   Boolean solved;
    78 
    79   list<BackendDAE.EqSystem> systlst = {};
    80 algorithm
    81 
    82  for syst in inDAE.eqs loop
    83    BackendDAE.MATCHING(comps=comps,ass1=ass1, ass2=ass2) := syst.matching;
    84    iComp := 1;
    85    for comp in comps loop
    86      if BackendDAEUtil.isSingleEquationComp(comp) then
     67  input output BackendDAE.BackendDAE DAE;
     68algorithm
     69
     70DAE.eqs := list( (match syst
     71              local
     72                BackendDAE.StrongComponents comps;
     73                array<Integer> ass1 "eqn := ass1[var]";
     74               array<Integer> ass2 "var := ass2[eqn]";
     75
     76   case BackendDAE.EQSYSTEM(matching = BackendDAE.MATCHING(comps=comps,ass1=ass1, ass2=ass2))
     77   algorithm
     78   comps := list( (match comp
     79     local
     80       BackendDAE.Equation eqn;
     81       BackendDAE.Var var;
     82       Integer eindex,vindx;
     83       Boolean solved;
     84       BackendDAE.StrongComponent tmpComp;
     85
     86    case BackendDAE.SINGLEEQUATION()
     87      algorithm
    8788       BackendDAE.SINGLEEQUATION(eqn=eindex,var=vindx) := comp;
    8889       eqn := BackendEquation.equationNth1(syst.orderedEqs, eindex);
    8990       var := BackendVariable.getVarAt(syst.orderedVars, vindx);
    90 
     91       tmpComp := comp;
    9192       if BackendEquation.isEquation(eqn) then
    92          (eqn,solved) := solveSimpleEquationsWork(eqn, var, outDAE.shared);
     93         (eqn,solved) := solveSimpleEquationsWork(eqn, var, DAE.shared);
    9394         syst.orderedEqs := BackendEquation.setAtIndex(syst.orderedEqs, eindex, eqn);
    9495
    9596         if not solved then
    96            comp := BackendDAE.EQUATIONSYSTEM({eindex}, {vindx}, BackendDAE.EMPTY_JACOBIAN() ,BackendDAE.JAC_NONLINEAR(), false);
    97            comps := List.replaceAt(comp, iComp, comps);
     97           tmpComp := BackendDAE.EQUATIONSYSTEM({eindex}, {vindx}, BackendDAE.EMPTY_JACOBIAN() ,BackendDAE.JAC_NONLINEAR(), false);
    9898         end if;
    99 
    10099       end if; // isEquation
    101      end if; // isSingleEquationComp
    102      iComp := iComp + 1;
    103    end for; //comp
    104   syst.matching := BackendDAE.MATCHING(ass1, ass2, comps);
    105   systlst := syst :: systlst;
    106  end for; // syst
    107 
    108  outDAE.eqs := listReverse(systlst); // listReverse needed?
     100       then tmpComp;
     101     else
     102       comp;
     103     end match) for comp in comps);
     104     syst.matching := BackendDAE.MATCHING(ass1, ass2, comps);
     105     then syst;
     106    else syst;
     107 end match)
     108for syst in DAE.eqs);
     109
    109110end solveSimpleEquations;
    110111
Note: See TracChangeset for help on using the changeset viewer.