Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Add differentiation of DAE.RSUB
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jan 3, 2018
1 parent 059c8c0 commit 47aad95
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions Compiler/BackEnd/Differentiate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -685,21 +685,30 @@ algorithm
then (res, functionTree);

// differentiate tsub
case DAE.TSUB(exp=e1, ix=i, ty=tp) equation
//se1 = ExpressionDump.printExpStr(inExp);
//print("\nExp-TSUB\nDifferentiate exp: " + se1);
case DAE.TSUB(exp=e1, ix=i, ty=tp)
algorithm
(res1, functionTree) := differentiateExp(e1, inDiffwrtCref, inInputData, inDiffType, inFunctionTree, maxIter-1);

(res1, functionTree) = differentiateExp(e1, inDiffwrtCref, inInputData, inDiffType, inFunctionTree, maxIter-1);
if not referenceEq(e1, res1) then
res := DAE.TSUB(res1, i, tp);
(res,_) := ExpressionSimplify.simplify1(res);
else
res := inExp;
end if;
then (res, functionTree);

res = DAE.TSUB(res1, i, tp);
(res,_) = ExpressionSimplify.simplify1(res);
//(res,_) = ExpressionSimplify.simplify(res);

//se1 = ExpressionDump.printExpStr(res);
//print("\nresults to exp: " + se1);
then (res, functionTree);
// differentiate tsub
case e1 as DAE.RSUB()
algorithm
(res1, functionTree) := differentiateExp(e1.exp, inDiffwrtCref, inInputData, inDiffType, inFunctionTree, maxIter-1);
if not referenceEq(e1.exp, res1) then
e1.exp := res1;
(e1,_) := ExpressionSimplify.simplify1(e1);
end if;
then (e1, functionTree);

// differentiate tuple
// differentiate tuple
case DAE.TUPLE(PR=expl) equation
//se1 = ExpressionDump.printExpStr(inExp);
//print("\nExp-TUPLE\nDifferentiate exp: " + se1);
Expand Down

0 comments on commit 47aad95

Please sign in to comment.