@@ -255,6 +255,46 @@ algorithm
255255 end matchcontinue;
256256end differentiateExpCrefFunction;
257257
258+
259+ public function differentiateExpCrefFullJacobian "function: differentiateEquationTime
260+ Differentiates an equation with respect to the time variable."
261+ input DAE . Exp inExp;
262+ input DAE . ComponentRef inCref;
263+ input BackendDAE . Variables inVariables;
264+ input BackendDAE . Shared ishared;
265+ output DAE . Exp outExp;
266+ output BackendDAE . Shared oshared;
267+ algorithm
268+ (outExp, oshared) := matchcontinue(inExp, inCref, inVariables, ishared)
269+ local
270+ String msg;
271+ BackendDAE . Shared shared ;
272+ DAE . Exp dexp;
273+ DAE . FunctionTree funcs;
274+ BackendDAE . DifferentiateInputData diffData;
275+ BackendDAE . Variables knvars;
276+ case (_, _, _, _)
277+ equation
278+ funcs = BackendDAEUtil . getFunctions(ishared);
279+ knvars = BackendDAEUtil . getknvars(ishared);
280+ diffData = BackendDAE . DIFFINPUTDATA (NONE (), SOME (inVariables), SOME (knvars), NONE (), SOME ({}), NONE (), NONE ());
281+ (dexp, funcs) = differentiateExp(inExp, inCref, diffData, BackendDAE . FULL_JACOBIAN (), funcs);
282+ oshared = BackendDAEUtil . addFunctionTree(funcs, ishared);
283+ then (dexp, oshared);
284+ else
285+ equation
286+ // expandDerOperator expectes sometime that differentiate fails,
287+ // so the calling function need to take care of the error messages.
288+ // TODO: change that in expandDerOperator
289+ // Error.addSourceMessage(Error.INTERNAL_ERROR, {msg}, DAEUtil.getElementSourceFileInfo(DAE.emptyElementSource));
290+
291+ true = Flags . isSet(Flags . FAILTRACE );
292+ msg = " \n Differentiate.differentiateExpTime failed for " +& ExpressionDump . printExpStr(inExp) +& " \n\n " ;
293+ Debug . fprint(Flags . FAILTRACE , msg);
294+ then fail();
295+
296+ end matchcontinue;
297+ end differentiateExpCrefFullJacobian;
258298// =============================================================================
259299// further interface functions to differentiation
260300// - differentiateEquation
@@ -1027,6 +1067,14 @@ algorithm
10271067 then
10281068 (zero, inFunctionTree);
10291069
1070+ // D(y)/dx => 0
1071+ case (DAE . CREF (componentRef = cr, ty = tp), _, _, BackendDAE . FULL_JACOBIAN (), _)
1072+ equation
1073+ (zero,_) = Expression . makeZeroExpression(Expression . arrayDimension(tp));
1074+
1075+ // print("\nExp-Cref\n d(x)/d(x) = 1");
1076+ then
1077+ (zero, inFunctionTree);
10301078 // Constants, known variables, parameters and discrete variables have a 0-derivative, not the inputs
10311079 case ((e as DAE . CREF (componentRef = cr, ty = tp)), _, BackendDAE . DIFFINPUTDATA (knownVars= SOME (knvars)), _, _)
10321080 equation
@@ -1919,7 +1967,8 @@ algorithm
19191967 case (e as DAE . CALL (path = path,expLst = expl,attr= DAE . CALL_ATTR (tuple_= b,builtin= false ,isImpure= isImpure,ty= ty,tailCall= tc)), _, _, _, _)
19201968 equation
19211969 // s1 = ExpressionDump.printExpStr(e);
1922- // print("\nExp-CALL\n build-funcs force-inline: " +& s1);
1970+ // print("\nExp-CALL\n build-funcs force-inline: " +& s1);
1971+ failure(BackendDAE . FULL_JACOBIAN () = inDiffType);
19231972 (e,_,true ) = Inline . forceInlineExp(e,(SOME (inFunctionTree),{DAE . NORM_INLINE (),DAE . NO_INLINE ()}),DAE . emptyElementSource);
19241973 e = Expression . addNoEventToRelations(e);
19251974 (e, functions) = differentiateExp(e, inDiffwrtCref, inInputData, inDiffType, inFunctionTree);
@@ -1932,6 +1981,7 @@ algorithm
19321981 // TODO: FIXIT! expressionSolve and analyticJacobian don't
19331982 // return new functionTree, so we can't differentiate functions then.
19341983 failure(BackendDAE . SIMPLE_DIFFERENTAION () = inDiffType);
1984+ failure(BackendDAE . FULL_JACOBIAN () = inDiffType);
19351985
19361986 // get algorithm of the function
19371987 SOME (func ) = DAEUtil . avlTreeGet(inFunctionTree,path);
0 commit comments