Skip to content

Fmi2 directional derivatives - #807

Open
davidhjp01 wants to merge 5 commits into
masterfrom
fmi2-directional-derivatives
Open

davidhjp01 wants to merge 5 commits into
masterfrom
fmi2-directional-derivatives

Conversation

@davidhjp01

Copy link
Copy Markdown
Contributor

Add FMI 2 directional derivative support

Summary

Adds validated FMI 2.0 directional-derivative support to
fmi::v2::slave_instance, lifecycle-aware FMU state handling, deterministic
fixture coverage, and the dependency/CI updates required to build and test it.

Changes

  • Add provides_directional_derivatives() and
    get_directional_derivative().

  • Read and cache directional-derivative metadata from
    modelDescription.xml.

  • Validate lifecycle, value-reference type, reference validity, and seed and
    sensitivity sizes before calling the FMU.

  • Compute the Jacobian-vector product:

    sensitivity = d(unknowns) / d(knowns) * seed
    
  • Accept FMI OK and Warning; surface Discard, Error, Fatal, and
    Pending as errors.

  • Preserve caller output when the FMU call fails.

  • Track instantiated, initialization, step, and terminated states.

  • Serialize lifecycle state in export scheme 1 while retaining safe scheme 0
    compatibility.

  • Add cleanup and ownership checks for imported FMU state.

Test coverage

  • Add a deterministic FMI 2 Co-Simulation fixture with three Real inputs, two
    Real outputs, a fixed 2-by-3 Jacobian, configurable statuses, a call counter,
    and a non-Real reference.
  • Extend fmi_v2_fmu_unittest for lifecycle behavior, expected derivatives,
    reordered references, invalid inputs, status handling, output preservation,
    and unsupported capabilities.
  • Build the pinned Reference-FMUs v0.0.41 and package the fixture as
    Fmi2Derivatives.fmu; expose them through REFERENCE_FMU_V2_DIR.

Dependency and CI updates

  • Upgrade FMI Library to ~3.0.4 and proxyFMU to 0.4.3@osp/testing.

Use FMI Library 3.0.4 and carry the repository CI/package updates needed by the FMI 3 stack.
Implement validated FMI 2 directional derivatives with a dedicated fixture, reference-FMU wiring, and contract tests.
@davidhjp01 davidhjp01 self-assigned this Sep 18, 2026
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.

1 participant