Repository navigation
Add implcit DAE dependencies and peterson example for implicit DAE - #75
masoud-najafi wants to merge 12 commits into
Conversation
elmir-nahodovic
left a comment
There was a problem hiding this comment.
Thank you for writing this up! Please see my comments and suggestions below
Co-authored-by: Elmir Nahodovic <210350926+elmir-nahodovic@users.noreply.github.com>
Co-authored-by: Elmir Nahodovic <210350926+elmir-nahodovic@users.noreply.github.com>
Co-authored-by: Elmir Nahodovic <210350926+elmir-nahodovic@users.noreply.github.com>
Co-authored-by: Elmir Nahodovic <210350926+elmir-nahodovic@users.noreply.github.com>
Co-authored-by: Elmir Nahodovic <210350926+elmir-nahodovic@users.noreply.github.com>
|
@masoud-najafi it seems you applied my suggested changes, but then you reverted some of the changes with commit 8abe5fe do you want me to re-suggest the changes I proposed, or should I just commit them directly? |
wierd. go ahead. |
* Clarify that derivatives of states that appear as knowns in the residual equations MUST NOT be declared as ContinuousStateDerivative elements in the ModelStructure, since a ContinuousStateDerivative is defined as an unknown and we can't have a variable being known and unknown at the same time * Remove duplicated text * Reformulate that states, derivatives, algebraic are treated as knowns if they appear as dependencies of residual equations * Update dependenciesKind for implicit Roberts DAE
* Remove text on semi-explicit restriction * Update to 1.0.0.alpha.2 everywhere
elmir-nahodovic
left a comment
There was a problem hiding this comment.
I did some more updates to remove mention of semi-explicit as a restriction, and that we speak of alpha.2 in the main branch. In case users who read the dev version are not confused about whats in alpha.1 vs alpha.2
Otherwise it looks good to me now! Thanks @masoud-najafi
AnHeuermann
left a comment
There was a problem hiding this comment.
Good catch to move to v1.0.0-apha.2.
I like the option to have implicit formulation as well. Less work for me implementing this in my tool 😇
I did run @CodeRabbit on my machine to catch stuff like small typos. Instead it pointed out some inconsistencies we should have a look at.
| All elements defined in the core standard (https://fmi-standard.org/docs/3.0.2/#Output[`<Output>`], https://fmi-standard.org/docs/3.0.2/#ContinuousStateDerivative[`<ContinuousStateDerivative>`], https://fmi-standard.org/docs/3.0.2/#ClockedState[`<ClockedState>`], https://fmi-standard.org/docs/3.0.2/#InitialUnknown[`<InitialUnknown>`], https://fmi-standard.org/docs/3.0.2/#EventIndicator[`<EventIndicator>`]) retain their existing semantics in this manifest, with the additions that: | ||
|
|
||
| * Each element's `dependencies` attribute may now also reference <<AlgebraicVariable, algebraic variables>>. | ||
| * Each element's `dependencies` attribute may now also reference <<AlgebraicVariable, algebraic variables>>. For an implicit DAE formulation the <<Residual>> could have a dependency on a https://fmi-standard.org/docs/3.0.2/#derivative[`derivative` of a state]. In this case the `derivative` of that state *must not* appear as a https://fmi-standard.org/docs/3.0.2/#ContinuousStateDerivative[`<ContinuousStateDerivative>`] element under the <<ModelStructure>> defined here. |
There was a problem hiding this comment.
Note
CodeRabbit review on a local checkout
Preserve the state-vector declaration for implicit states.
FMI 3.0.2 uses entries to identify continuous states and define their API order. This rule removes those entries for implicit derivatives. (fmi-standard.org)
Line 24 says that this manifest replaces the core ModelStructure. The new Robertson manifest consequently declares neither differential state through the inherited mechanism. Define how importers identify and order implicit states before prohibiting these entries. Keep state declaration separate from explicit derivative computation.
There was a problem hiding this comment.
I do now know the best way to handle this. In my opinion if the derivatives are knowns in the implicit formulation, they should not appear as ModelStructure elements, since that is reserved for the unknowns of the model. @AnHeuermann you are right here that then the importer does not know the order of the derivatives and states.
Maybe we can include an element like the AlgebraicVariables for implicit DAEs, but for the derivatives or states, so that order is preserved. We should discuss this at the next meeting
(Or if someone has a good idea please commit one and we can discuss that at the meeting as well)
|
Thank you @AnHeuermann - although I usually don't like the way LLMs review - these comments are actually good and accurate. I will fix |
* Splitting mathematical_formulation in headers semi-explicit, implicit and constraints
* Defining index-1 for implicit DAEs
* You can call fmi3Set on derivatives if implicit
* Clarifying that algebraic variables are variables that appear as knowns and not differentiated in any unknown
* Updating partial derivative section for implicit that derivatives can appear as knowns
|
@AnHeuermann @masoud-najafi I have now updated according to the points from CodeRabbit. I resolved the conversations that I think are resolved, please review again and check if it is more consistent now. One point left: I don't know how we should handle the ordering for the API like |
The order of states in an ODE is determined by the order of the ContinuousStateDerivative elements in ModelStructure. We can preserve this ordering for the differential variables (i.e., they retain the same order as in the ODE), while ordering the algebraic variables according to their declaration order in the manifest file. Similarly, the residual vector follows the order in which the residuals are declared in the manifest file. Once this is finished, I wwould implement the implicit DAE to check if something else is required. |
I don't think this is the case in general for index-1 DAEs. The derivatives that appear in the implicit form and the derivatives that can be integrated in the semi-explicit form (or more directly the ODE form) don't have to be the same, depending on how the tool transforms the DAE. Say you start with the equations This is an implicit index-1 DAE, and the (i.e. no but might have exported the implicit DAE as above: I think this is what CodeRabbit meant with "Keep state declaration separate from explicit derivative computation" |
|
@masoud-najafi @AnHeuermann I think we can do as follows: The API for get/set continuous state derivatives are only allowed to be used for implicit DAEs if the FMU exposes these derivatives and states semi-explicitly through ContinuousStateDerivative elements (so a semi-implicit DAE ?). What I mean is that we must separate
I added a commit for it but we can remove it if we have a better way of describing or doing this |
|
-- The variables with the derivative attribute are not necessirily listed in the modelStructure, we do not care about those that are not listed in the ModelStruture, in ls-DAE. The order of states (which is also the order of state-derivatives) is defined in the modelStrcuture. This order is essential to communicate with the FMU via state-related APIs. If new xsd files are provided, I can start convert my test FMUs to implicit DAE and testing them. That would help to validate and find possible issues of the implicit DAE cases. |
|
@masoud-najafi I am no xsd expert, but from what I can tell we don't need to change anything in the xsd, right? The xsd doesn't add any restrictions on the dependencies for the |
|
After discussion on fmi-design in Munich, I am now more in favor of dropping support for implicit DAEs. Even though it is in principle not that complicated. We have to consider how it is combined with semi-explicit index 1 form, ode mode, and eventually initialization, event handling, higher index problems... The problems/considerations we have now to support implicit DAEs:
|
|
Looking through the issue I noticed that it seems that one of reasons for why transforming from implicit DAE to explicit DAE was problematic:
I agree with the second part. However, there are examples of implicit DAE that have multiple solutions where you select the solution only based on the guesses of the state derivatives (the simplest would be I now realized that "linearly implicit DAEs" would be an interesting option without that drawback (with constant mass-matrix or potentially a varying one). As discussed at the meeting we might still add an example. |
Related Issues
Changes
Checklist