Skip to content

Clarify providesEvaluateDiscreteStates semantics - #2217

Open
clagms wants to merge 11 commits into
modelica:mainfrom
clagms:Clairfy_fmi3EvaluateDiscreteStates
Open

clagms wants to merge 11 commits into
modelica:mainfrom
clagms:Clairfy_fmi3EvaluateDiscreteStates

Conversation

@clagms

@clagms clagms commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain importer control over discrete-state evaluation, the call order required for up-to-date getter results, and the UpdateDiscreteStates fallback and clock deactivation consequences.

Align capability descriptions and algebraic-loop guidance, and remove the unsupported discrete-state manipulation claim.

Resolves: #2194

Changes

The following are screenshots of the most relevant changes.

Clocked Partition Specification (Section 2.2.8.3. Model Partitions and Clocked Variables)

clocked_variables

Algebraic Loops (Section 2.2.11. Algebraic Loops)

algebraic_loops

Event Mode Table (Section 2.3.5. State: Event Mode)

2 3 5_event_mode_table

Allowed function calls (just below table):

get_variables function_specification updateDiscreteStates

Tables 40 and 42

schema_spec

Example of Event Mode with Clocks (Section 4.3.4. Event Mode with Clocks)

The example was previously recording clocks after the call to FMI3UpdateDiscreteStates, which contradicts the standard, since those clocks would be de-activated by the call to FMI3UpdateDiscreteStates and therefore corresponding clocked variables would not be observable.

image

Explain importer control over discrete-state evaluation, the call order
required for up-to-date getter results, and the UpdateDiscreteStates
fallback and clock deactivation consequences.

Align capability descriptions and algebraic-loop guidance, and remove
the unsupported discrete-state manipulation claim.

Resolves: modelica#2194
@chrbertsch chrbertsch added this to the v3.0.3 milestone Nov 4, 2026
Comment thread docs/2_3_common_states.adoc Resolved
Comment thread docs/2_3_common_states.adoc Resolved

@masoud-najafi masoud-najafi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some phrases have been repeated. But globally it's fine.

Comment thread docs/2_3_common_states.adoc Resolved
Comment thread docs/2_3_common_states.adoc Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The transition rules allow stale evaluations and leave dependency tracing, Jacobians, and clocked-output sequencing unresolved.

4 open issues
What changed in this PR

Clarifies FMI’s Event Mode contract for providesEvaluateDiscreteStates, explaining how importers control discrete-state evaluation separately from getter-triggered computations.

Changes:

  • Specifies evaluation and getter calling order for current transition results.
  • Explains the fmi3UpdateDiscreteStates fallback and Clock deactivation consequences.
  • Aligns algebraic-loop and capability guidance, removing the unsupported state-manipulation claim.
File Description
docs/​4_4_co-simulation_schema.adoc Clarifies Co-Simulation capability semantics and calling-order requirements.
docs/​3_4_model_exchange_schema.adoc Adds matching Model Exchange capability guidance.
docs/​2_3_common_states.adoc Details evaluation ordering, fallback behavior, and clocked-value access.
docs/​2_2_common_mechanisms.adoc Aligns partition, selective-computation, and algebraic-loop guidance.

Review effort: Balanced

Comment thread docs/2_2_common_mechanisms.adoc Resolved
Comment thread docs/2_2_common_mechanisms.adoc Resolved
Comment thread docs/2_3_common_states.adoc Resolved
Comment thread docs/2_3_common_states.adoc Resolved
@masoud-najafi

masoud-najafi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

@clagms

Based on the paper shared by Karl (Link), the discrete-time state-space model can be expressed as:

$$x_k = f_{\text{disc}} (x_k, x_{k-1}, u_k)$$ $$0 = h(x_k, u_k)$$ $$y_k = g_{\text{event}}(x_k, u_k)$$

Implementation Note:
If providesEvaluateDiscreteStates is true and an algebraic loop occurs during an event iteration, IMHO, the importer MUST call fmi3UpdateDiscreteStates before calling getXX to evaluate $y_k$. Otherwise , this may lead to incorrect results, as the model could retrieve an outdated $u_k$ during the final evaluation inside fmi3UpdateDiscreteStates.

@clagms

clagms commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Notes from the FMI-design meeting 2026-11-30:

  1. We've agreed to look closer into the constraint of not allowing importers to query clocked variables outside their clock activation. Allowing this would simplify the implementation of the importer in case the capability flag is true, since it wouldn't require the importer to explicitly call evalDiscreteStates, and would allow the importer to query the values after the updateDiscreteStates call. Claudio will look into the impact of this (allowing importers to query clocked variables outside their clock activation) on the standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify the unique need for fmi3EvaluateDiscreteStates

7 participants