modelica / fmi-standard

Specification of the Functional Mock-up Interface (FMI)
https://fmi-standard.org/
Other
274 stars 85 forks source link

Final review of FMI2.0.1 RC #623

Closed chrbertsch closed 5 years ago

chrbertsch commented 5 years ago

Please inspect the PDF documents of the RC (see below) and comment in case of errors or possible improvements - ASAP but before Oct 1st. In case we do not find blockers, we plan to vote on the release in the FMI steering committee on Oct 2nd.

//Updated files due to misssing pages FunctionalMockupInterface_v2.0.1_RC1.pdf FunctionalMockupInterface_v2.0.1_RC1_with_changemarks.pdf

// Update 2019-09-25 10:43CEST FunctionalMockupInterface_v2.0.1_RC2.pdf FunctionalMockupInterface_v2.0.1_RC2_with_changemarks.pdf FunctionalMockupInterface_v2.0.1-Diff_RC1_RC2.pdf

// Update 2019-09-27 21:22CEST : RC3 added FunctionalMockupInterface_v2.0.1_RC3.pdf FunctionalMockupInterface_v2.0.1_RC3_with_changemarks.pdf FunctionalMockupInterface_v2.0.1-Diff_RC2_RC3.pdf

// Update 2019-10-01 18:41CEST : RC4 added FunctionalMockupInterface_v2.0.1_RC4.pdf FunctionalMockupInterface_v2.0.1_RC4_with_changemarks.pdf FunctionalMockupInterface_v2.0.1-Diff_RC3_RC4.pdf

// Update 2019-10-02 12:24 CEST : RC5 added FunctionalMockupInterface_v2.0.1_RC5.pdf FunctionalMockupInterface_v2.0.1_RC5_with_changemarks.pdf FunctionalMockupInterface_v2.0.1-Diff_RC4_RC5.pdf

// Update 2019-10-06 15:20 CEST: RC6 added (figure numbers fixed) FunctionalMockupInterface_v2.0.1_RC6.pdf FunctionalMockupInterface_v2.0.1_RC6_with_changemarks.pdf FunctionalMockupInterface_v2.0.1-Diff_RC5_RC6.pdf

Please comment on the latest documents

chrbertsch commented 5 years ago

Ah, just saw we have to use the "Create bookmarks using .... headings" with this option it is there. Will be included in RC4.

nickbattle commented 5 years ago

@chrbertsch I don't see contents with either RC1, 2 or 3.

chrbertsch: fixed in principle, see below

chrbertsch commented 5 years ago

@chrbertsch I don't see contents with either RC1, 2 or 3.

@nickbattle What about this: test_bookmarks.pdf

chrbertsch: fixed in principle, see below

clagms commented 5 years ago

@chrbertsch I don't see contents with either RC1, 2 or 3.

@nickbattle What about this: test_bookmarks.pdf

It's a bit strange on SumatraPDF: image Same thing in Acrobat Reader.

nickbattle commented 5 years ago

Yes, I'm seeing the same thing as @clagms: a burst of section "1." empty entries, followed by a plausible contents for the remainder. And "Figure 13" for some reason. This is Okular on Linux.

chrbertsch commented 5 years ago

It's a bit strange on SumatraPDF:

no, get it also with Adobe acrobat image

I get the same with Adobe PDF export. So this must be part information contained in the word document.

Could someone with better Word 2016 knowledge than I have please give a hint?

nickbattle commented 5 years ago

The "1s" are all on page 7. This is where the table of contents is located in Word, so I suspect that is causing it. The rogue "Figure 13" and the individuals listed at the end are also being picked up as a "heading". My guess is that these entries (and perhaps the contents too?) have a "Heading" style? It might be possible to change this to something that isn't a heading style?

clagms commented 5 years ago

Thank you for these hints @nickbattle ! When exporting the pdf on my machine (word for office 365) I get something that looks a little bit better: image

Now trying to figure out which styles are being picked up by word to export the bookmarks.

nickbattle commented 5 years ago

@clagms It's probably anything that inherits from "heading" - just a guess though. What style are those names in the appendix?

hyumo commented 5 years ago

chrbertsch: fixed, see below

clagms commented 5 years ago

@clagms It's probably anything that inherits from "heading" - just a guess though. What style are those names in the appendix?

@nickbattle that's exactly what it is :)

Below are some of the elements I had to change the style to "normal" in order to get rid of these spurious headers (note the page numbers). Maybe you can right-click in the Heading 1 style and select all instances: image Or you can open the navigation pane and go straight to those elements.

image image

Here's the doc and generated pdf, after these issues have been corrected. You can see the changes I made in the docx. FunctionalMockupInterface.docx FunctionalMockupInterface.pdf

I guess the spurious "1."'s are caused by the same problem.

nickbattle commented 5 years ago

@clagms Confirmed that your modified PDF has a correct table of contents, as viewed in Okular. So that's probably the fix you need, @chrbertsch.

I could fix individual problems, but then when I fix the others, the already fixed ones re-apper. Do not understand what word does here. Current workaround : deletel the "1.".s manually

filip-stenstrom commented 5 years ago

Page reference: RC3

clagms commented 5 years ago

In the mathematical model of a co-sim FMU: image please clarify that $m_{ido}$ stands for the model input derivative order.

chrbertsch: fixed, see below

clagms commented 5 years ago

Is Feedthrough Supported?

Please clarify the FMI 2.x Co-simulation support for feed-through.

First we need a definition of feedthrough.

Given an Co-simulation FMU instance $c$ , the input $u_c$ feeds-through to output $y_c$ when there exist two different values $v_1, v_2$ and FMU state $s_c$, such that $$get_c(set_c(s_c, u_c, v_1), y_c) \neq get_c(set_c(s_c, u_c, v_2), y_c)$$ where:

Here are some properties of the feed-through:

Note that this definition of feed-through is well accepted, and it means the exact same thing as "algebraic dependency".

Also note that any ODE that has an output equation of the form: $$\dot{x} = F(x, u)$$ $$y = G(x, u)$$

has feed-through.

This definition is therefore consistent with [Kubler2000], that RC3 claims to be consistent with.

Now let's look at the RC3 text regarding feedthrough.

Right at the beginning, it says:

Support many and nested FMUs: A simulator may run many FMUs in a single simulation run and/or multiple instances of one FMU. The inputs and outputs of these FMUs can be connected with direct feedthrough. Moreover, an FMU may contain nested FMUs.

Setting aside the fact that "direct feedthrough" is redundant with "feedthrough", this induces the reader into thinking that FMI CS supports feedthrough. I would argue that supporting feedthrough is a necessary feature to export Modelica models, in

Expressivity: The FMI provides the necessary features that Modelica®, Simulink® and SIMPACK® models1 can be transformed to an FMU.

Then, in the definition of the causality attribute, the words algebraic relationship are used:

"output": The variable value can be used by another model or slave. The algebraic relationship to the inputs is defined via the dependencies attribute of <fmiModelDescription><ModelStructure><Outputs><Unknown>.

Leading the reader to believe that any dependency declared in the ModelStructure, is a feedthrough dependency, and therefore satisfies the definition I put above.

In fact, in the definition of the ModelStructure, it says:

Attribute dependencies defines the dependencies of the outputs from the knowns at the current super dense time instant in Event and in Continuous-Time Mode (ModelExchange) and at the current Communication Point (CoSimulation).

Again, the reader might think that this means there is an algebraic (an instant) dependency between knowns and unknowns.

Thankfully, in the mathematical definition of the FMU for co-simulation, we observe:

1569853059558

Which tells the reader that there is no feedthrough in that model (i.e., the output $y{i+1}$ does not depend algebraically on the input $u{i+1}$).

However, the text immediately after says

Definition (4.1) is consistent with the definition of co-simulation by (Kübler, Schiehlen 2000)

which is not true. Equation (4.1) clearly forbids feedthrough, and [Kubler2000] has the equation:

1569853204517

(apologies for the scribbles).

This equation clearly shows the feed-through.

Moreover, later in the standard, there is a remark:

There is the additional restriction in \emph{slaveInitialized} state that it is not allowed to call fmi2GetXXX functions after fmi2SetXXX functions without an fmi2DoStep call in between

Which makes it clear that feedthrough is not supported, which is also claimed in https://github.com/modelica/fmi-standard/issues/117#issuecomment-430378201.

If indeed the intent is not to support feedthrough in the FMI co-simulation, then I suggest that the parts I've highlighted above be rewritten to avoid giving this idea.

Moreover, note that the mathematical definition of FMU co-simulation forbids the use of a Gauss-Seidel master algorithm. This is because a Gauss Seidel algorithm will produce an input $u_{i+1}$ to one of the FMUs that is at the timestamp $i+1 = t+H$, violating the assumptions in Equation (4.1). This also means that solving algebraic loops on the output variables is something that requires rollback (whereas, with feedthrough, rollback would not be needed).

To summarize the changes:

I hope this helps! :)

PS - This issue has been discussed with, and approved by @CThuleHansen .

Refs:

[Kubler2000] - Kübler, R., and W. Schiehlen. 2000. “Two Methods of Simulator Coupling.” Mathematical and Computer Modelling of Dynamical Systems 6 (2): 93–113. https://doi.org/10.1076/1387-3954(200006)6:2;1-M;FT093.

Gomes, Cláudio, Casper Thule, Levi Lucio, Hans Vangheluwe, and Peter Gorm Larsen. 2019. “Generation of Co-Simulation Algorithms Subject to Simulator Contracts.” In 3rd Workshop on Formal Co-Simulation of Cyber-Physical Systems, to be published. Oslo, Norway.

chrbertsch: See below

clagms commented 5 years ago

Input Approximation Ambiguity

Please clarify the FMI 2.x Co-simulation on what FMUs should assume about the timestamp of their inputs.

Interpolations and Extrapolations are two different function approximation schemes.

The flag canInterpolate inputs may confuse the reader into thinking that an FMU mathematical model requires inputs $u_{i+1}$ before the execution of the doStep function.

This is not the case: 1569858328676

What I think this flag means is that the FMU can approximate the input function over the interval $t$ to $t+H$. In that case, maybe a name "canApproximateInputs" would be more adequate.

Also, a strict interpretation of the mathematical model means that the Gauss Seidel master algorithm is not a valid FMI Cosim algorithm, because such algorithm will compute $u_{i+1}$ at time $t$, before starting the execution of $ɸ_i$.

Also, which inputs are being approximated by the FMU? All continuous inputs? Or just some?

This is because, as stated in Section 4.1.2., an FMU can be a combination of a hybrid ODE and a sampled data system. In that case, it is not necessarily the case that all continuous inputs are being approximated by the FMU.

I would argue that whether an input can be approximated or not is information on each variable (I haven't thought through the exact conditions on that variable), and not information about the FMU.

Thank you very much for all the work on reviewing these issues! :)

PS - This issue has been discussed with, and approved by @CThuleHansen .

chrbertsch: see below

beutlich commented 5 years ago
clagms commented 5 years ago

In the description of "unbounded", it says

during time integration, the variable gets a value much larger than its nominal value nominal.

But the meaning of "much larger" is not specified anywhere else. How does one know that an FMU implements this attribute correctly?

see below

nickbattle commented 5 years ago

or else is returned by the fmi2GetXXX functions // what does "else" refer to? p34

The wording is a bit awkward, but I read it to mean that either a value is set (with fmi2SetXXX) or "else" retrieved (with fmi2GetXXX) relative to the unit specified. I think it would mean the same if the "else" was removed.

chrbertsch: fixed, see below

chrbertsch commented 5 years ago

or else is returned by the fmi2GetXXX functions // what does "else" refer to? p34

The wording is a bit awkward, but I read it to mean that either a value is set (with fmi2SetXXX) or "else" retrieved (with fmi2GetXXX) relative to the unit specified. I think it would mean the same if the "else" was removed.

I undstand this sentence in a way that both setting and getting the varibal is w.r.t to the unit. So I would replace the "or else" by "and"

If a variable is associated with a Unit, then the value of the variable has to be provided with the fmi2SetXXX functions and is returned by the fmi2GetXXX functions with respect to this Unit.

Please comment, if you agree or disagree with this understanding and proposal.

chrbertsch commented 5 years ago

In the description of "unbounded", it says

during time integration, the variable gets a value much larger than its nominal value nominal.

But the meaning of "much larger" is not specified anywhere else. How does one know that an FMU implements this attribute correctly? @clagms : Even though this is not clearly defined, we cannot fix this in a bugfix release 2.0.1 by clearly defining it, as this could invalidate existing 2.0 implementations. If you consider this topic important, please open a new ticket for FMI 3.0.

filip-stenstrom commented 5 years ago

or else is returned by the fmi2GetXXX functions // what does "else" refer to? p34

The wording is a bit awkward, but I read it to mean that either a value is set (with fmi2SetXXX) or "else" retrieved (with fmi2GetXXX) relative to the unit specified. I think it would mean the same if the "else" was removed.

I undstand this sentence in a way that both setting and getting the varibal is w.r.t to the unit. So I would replace the "or else" by "and"

If a variable is associated with a Unit, then the value of the variable has to be provided with the fmi2SetXXX functions and is returned by the fmi2GetXXX functions with respect to this Unit.

Please comment, if you agree or disagree with this understanding and proposal.

This makes sense to me

antvl commented 5 years ago

Regarding clarifications of the mathematical model for Co-simulation:

The current input variables ... (in case of continuous-time variables), where $m_{ido}$ stands for the the model input derivative order.

As already stated in this paragraph extrapolation only applies to continuous-time input variables. Is is clear enough?

chrbertsch: adding sentence The current input variables ... (in case of continuous-time variables), where $m{ido}$ stands for the the model input derivative order. in RC4_

clagms commented 5 years ago

Thank you for the thorough reply, and for paying attention to this topic @antvl !

As already stated in this paragraph extrapolation only applies to continuous-time input variables. Is is clear enough?

Unfortunately, it is still not enough, as one can have continuous time variable that are being approximated, while others are not. Or does the standard constraint the implementation of the FMU to either implement approximation in all continuous time variables, or on none? If so, please maybe make this clearer to tool providers.

Within this schema, the approximation of input variables is considered as interpolation.

Maybe I did not explain this properly. Consider an FMU A, that implements an input interpolation scheme. When FMU A is at time $t$, and a setReal is called in that FMU A, the FMU A will assume that it is receiving an input that was computed by another FMU B that is already at time $t+H$. This assumption has to be made because there is no way of knowing the timestamp of an input when a call is made to setReal. We may argue that the timestamp of a value corresponds to the timestamp of the internal state of the FMU that computed it (although one has to be careful with this definition, and more details are given in the paper cited below). If that is correct (I cannot think of any other way of defining the timestamp of a value, but I'm all ears for alternatives!), then the Co-simulation model should depict a "+1" on the $u$ var, as shown in blue: image This shows that the gauss seidel is not allowed by the math description of the standard.

Now I try to show why, even if it is allowed, there is an ambiguity in the standard.

When a doStep is called, FMU A will compute an interpolation (think of a linear interpolation, for instance).

Now imagine the exact same FMUs A and B being used in a Jacobi co-simulation. That same FMU A is still making the assumption that the value it gets is from a "future" timestamp, and will consequently perform an interpolation on it. However, when a Jacobi cosim is used, any approximation on the inputs needs to be an extrapolation. Without explicit timestamps on the inputs, the implementation of a interpolation is different than the implementation of an extrapolation. The following figure is an attempt at depicting the difference on the inputs that FMU A will give to its internal numerical solver, when used correct (top) and incorrectly (bottom): image

I also attach the paper where me and the co-authors have hopefully explain this matter a little bit better 😋 cosimcpspaper.pdf

chrbertsch: see below

antvl commented 5 years ago

We could add the following sentence:

Differents input variables may have different interpolation order.

chrbertsch: inclduded clarification sentence Differents input variables may have different interpolation order. For additional topics please add a new issue

CThuleHansen commented 5 years ago

See https://github.com/modelica/fmi-standard/issues/440#issuecomment-536975569 related to set inputs in instantiated mode

chrbertsch: see comment there

chrbertsch commented 5 years ago
* Inconsistent XML word format in Example 4 Page 65

Corrected to image @hyumo please check. If you have findings please propose the correct formatting

* Figure number errors starting from Figure 332, then 443, 554, 665, 776, 887, ...

Figure 332 --> changed to Figure 3, 443 --> 4, 554 --> 5, 665 --> 6 and all other occurences that I found

* In Figure 3 `t` and `E` are overlapping

Will be fixed in RC4

* Inconsistent syntax highlighting in pseudo code example 3.2.4

fixed in RC4, only "// comments" see. e.g. image

chrbertsch commented 5 years ago

If a variable is associated with a Unit, then the value of the variable has to be provided with the fmi2SetXXX functions and is returned by the fmi2GetXXX functions with respect to this Unit. ... This makes sense to me

Will change to "and" in RC4

GallLeo commented 5 years ago

Would be nice to put the new "Modelica Association" and "FMI" logos on the title page? https://github.com/modelica/BackOffice/tree/master/Task006_CI/Designer/Logo/Print (Project leaders do have access to this repo; I'll store the new logos in the general MA repo, as soon as we have it set up)

chrbertsch commented 5 years ago

@GallLeo image included in RC5

chrbertsch commented 5 years ago

Changes RC4--> RC5:

Add new MA and FMI Logo. Add missing #392 to word document

Known issue in RC5: figure numbers

beutlich commented 5 years ago

@chrbertsch Can you please edit the issue topic since Oct. 1st is in past.

chrbertsch commented 5 years ago

RC5 was accepted on Oct 2nd by the FMI steering committee (with the addition that formatting changes may be done before the release process within MA will be initiated).

The currently last known formatting issues is the figure numbering. The root cause has been identified by an incorrect change in numbering already detected in comment https://github.com/modelica/fmi-standard/issues/623#issuecomment-534034916 (@andreas-junghanns , you were right and I corrected my comment there) in combination with a bug of word regarding figure numbering in combination with tracked changes (https://superuser.com/questions/717022/ms-word-figure-numbers-are-wrong) This will be fixed in RC6

chrbertsch commented 5 years ago

Figure numbers fixed in RC6, see above