Closed modelica-trac-importer closed 6 years ago
Comment by peter.nilsson on 15 Dec 2011 07:22 UTC Ignore my comment about using the seeds as boolean indicators since the subset to be computed is already defined in the v_ref input vector. But the request for a use case showing why the seeds are useful, remains.
Modified by dietmarw on 19 Mar 2012 10:26 UTC
Modified by dietmarw on 7 Sep 2012 10:18 UTC
Comment by otter on 3 Dec 2012 00:51 UTC I corrected one example by stating that the environment (not mentioned: the environment is a Modelica model) provides a wrapper function with seeds and then the environment calls this wrapper function with different seeds.
To be more clear (the following explanation is not in the specification): When importing an FMU in Modelica, then in Modelica an equation y=f(x,u) would be defined and additionally a function that computes the derivative of this equation. However, the Modelica tool calls this derivative function and then uses seeds to distinguish which of the derivative to compute. It is not possible in Modelica (and would also not be practical) to provide several derivative functions. Therefore, the "seeds" design is a must, if an FMU shall be imported in Modelica.
Another reason (not mentioned in the specification) is that iterative sparse matrix methods do not compute the Jacobian but the product of a Jacobian with a vector. The seeds in the getDirectionalDerivative function is then the vector with which the Jacobian is multiplied.
Changelog removed by otter on 3 Dec 2012 00:51 UTC
Modified by dietmarw on 19 Mar 2012 10:26 UTC 2.1.8, page 25-26
fmiStatus fmiGetDirectionalDerivative
See the example:
[Example: Assume an FMU has the output equations
and this FMU is connected, so that y1,u1,u3 appear in an algebraic loop. Then the nonlinear solver needs a Jacobian and this Jacobian can be computed (without numerical differentiation) provided the partial derivative of y1 with respect to u1 and u3 is available. Depending on the environment where the FMUs are connected, these derivatives can be provided (a) with one function call to compute the directional derivatives with respect to these two variables (in other words z=y1, v = {u1, u3}) and then the environment uses appropriate seed values zero and one ... ]
How could this be possible with one function call? One wants the vector [dy1/du1 dy1/du2] but can only get a linear combination, i.e. a scalar in this case, with a single function call. Does the text mean one function call to fmiGetPartialDerivatives?
The example does not motivate why the seeds (dv) must be of type fmiReal. Without context beyond the draft, I don't understand why not fmiBoolean would suffice. I can see that Boolean seeds would be useful for optimizing the implementation, that given those, could omit computing corresponding subsets of the Jacobian. (I cannot come up with such use cases with more than a single 1 in the seed vector though). But when are general directional derivatives needed? Some motivation would be useful.
Reported by peter.nilsson on 14 Dec 2011 10:05 UTC 2.1.8, page 25-26
fmiStatus fmiGetDirectionalDerivative
See the example:
[Example: Assume an FMU has the output equations
and this FMU is connected, so that y1,u1,u3 appear in an algebraic loop. Then the nonlinear solver needs a Jacobian and this Jacobian can be computed (without numerical differentiation) provided the partial derivative of y1 with respect to u1 and u3 is available. Depending on the environment where the FMUs are connected, these derivatives can be provided (a) with one function call to compute the directional derivatives with respect to these two variables (in other words z=y1, v = {u1, u3}) and then the environment uses appropriate seed values zero and one ... ]
How could this be possible with one function call? One wants the vector [dy1/du1 dy1/du2] but can only get a linear combination, i.e. a scalar in this case, with a single function call. Does the text mean one function call to fmiGetPartialDerivatives?
The example does not motivate why the seeds (dv) must be of type fmiReal. Without context beyond the draft, I don't understand why not fmiBoolean would suffice. I can see that Boolean seeds would be useful for optimizing the implementation, that given those, could omit computing corresponding subsets of the Jacobian. (I cannot come up with such use cases with more than a single 1 in the seed vector though). But when are general directional derivatives needed? Some motivation would be useful.
Migrated-From: https://trac.fmi-standard.org/ticket/70