Skip to content

Commit

Permalink
[BE] update function call differentiation
Browse files Browse the repository at this point in the history
 - ticket5459
  • Loading branch information
kabdelhak authored and adrpo committed Sep 19, 2019
1 parent 57a0101 commit 14c3d12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions OMCompiler/Compiler/BackEnd/Differentiate.mo
Expand Up @@ -2093,6 +2093,17 @@ algorithm
String funcname, s1;
list<DAE.FuncArg> falst;

/* ticket5459
if the function call does not contain the cref, the derivative is zero
prevents failing of this function
- Maybe not only for SIMPLE_DIFFERENTIATION ?
*/
case (_, _, _, BackendDAE.SIMPLE_DIFFERENTIATION(), _)
guard(not Expression.expHasCref(inExp, inDiffwrtCref))
algorithm
(e, _) := Expression.makeZeroExpression(Expression.arrayDimension(ComponentReference.crefTypeFull(inDiffwrtCref)));
then (e, inFunctionTree);

case (DAE.CALL(path=path,expLst=expl,attr=DAE.CALL_ATTR(tuple_=b,builtin=c,isImpure=isImpure,ty=ty,tailCall=tc)), _, _, BackendDAE.DIFFERENTIATION_TIME(), _)
equation
// get function mapper
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/FrontEnd/Expression.mo
Expand Up @@ -6784,7 +6784,7 @@ algorithm

case(DAE.CALL(path = Absyn.IDENT(name = "smooth"),expLst = {DAE.ICONST(i),e1}),(cr,false))
guard(i>1)
then (e1,true, (cr,true));
then (e1,true, (cr, expHasCref(e1,cr)));

case(DAE.CALL(), (cr,false))
guard(isEventTriggeringFunctionExp(inExp))
Expand Down

0 comments on commit 14c3d12

Please sign in to comment.