Changeset dd0c8bd4 in OpenModelica


Ignore:
Timestamp:
2016-03-21T13:39:36+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:
5d60737
Parents:
34e4a4c
git-author:
vruge <vruge@…> (03/21/16 13:39:36)
git-committer:
hudson <openmodelica@…> (03/21/16 13:39:36)
Message:

improved ExpressionSolve

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Compiler/BackEnd/ExpressionSolve.mo

    rad1689a rdd0c8bd4  
    111111
    112112protected function solveSimpleEquationsWork
    113   input BackendDAE.Equation inEqn;
     113  input output BackendDAE.Equation eqn;
    114114  input BackendDAE.Var var "solve eq with respect to var";
    115115  input BackendDAE.Shared shared;
    116   output BackendDAE.Equation outEqn;
    117116  output Boolean solved;
    118117
     
    120119  DAE.ComponentRef cr;
    121120  DAE.Exp e1,e2,varexp,e;
    122 
    123121  BackendDAE.EquationAttributes attr;
    124122  DAE.ElementSource source;
    125   list<DAE.Statement> asserts = {};
    126 algorithm
    127   BackendDAE.EQUATION(exp=e1, scalar=e2, source=source,attr=attr) := inEqn;
     123algorithm
     124  BackendDAE.EQUATION(exp=e1, scalar=e2, source=source,attr=attr) := eqn;
     125  if not (Types.isIntegerOrRealOrSubTypeOfEither(Expression.typeof(e1)) and Types.isIntegerOrRealOrSubTypeOfEither(Expression.typeof(e2))) then
     126    return ;
     127  end if;
    128128  BackendDAE.VAR(varName = cr) := var;
    129129  varexp := Expression.crefExp(cr);
     
    133133  end if;
    134134
     135  (e1, e2) := preprocessingSolve(e1, e2, varexp, SOME(shared.functionTree), NONE(), 0);
     136
    135137  try
    136     (e1, e2) := preprocessingSolve(e1, e2, varexp, SOME(shared.functionTree), NONE(), 0);
    137   else
    138     // no number
    139   end try;
    140 
    141   try
    142     (e, asserts) := solve2(e1, e2, varexp, SOME(shared.functionTree), NONE());
    143     source := DAEUtil.addSymbolicTransformationSolve(true, source, cr, e1, e2, e, asserts);
    144     outEqn := BackendEquation.generateEquation(varexp, e, source, attr);
     138    e := solve2(e1, e2, varexp, SOME(shared.functionTree), NONE());
     139    source := DAEUtil.addSymbolicTransformationSolve(true, source, cr, e1, e2, e, {});
     140    eqn := BackendEquation.generateEquation(varexp, e, source, attr);
    145141    solved := true;
    146142  else
    147143    //eqn is change by possible simplification inside preprocessingSolve for solve the eqn with respect to varexp
    148144    //source := DAEUtil.addSymbolicTransformationSimplify(true, source, DAE.PARTIAL_EQUATION(e1), DAE.PARTIAL_EQUATION(e2));
    149     outEqn := BackendEquation.generateEquation(e1, e2, source, attr);
     145    eqn := BackendEquation.generateEquation(e1, e2, source, attr);
    150146    solved := false;
    151147  end try;
     
    303299                         end matchcontinue;
    304300
    305  eqnForNewVars := List.appendNoCopy(eqnForNewVars, eqnForNewVars1);
    306  newVarsCrefs := List.appendNoCopy(newVarsCrefs, newVarsCrefs1);
     301 if isPresent(eqnForNewVars) then
     302   eqnForNewVars := List.appendNoCopy(eqnForNewVars, eqnForNewVars1);
     303   newVarsCrefs := List.appendNoCopy(newVarsCrefs, newVarsCrefs1);
     304 end if;
    307305
    308306end solveWork;
Note: See TracChangeset for help on using the changeset viewer.