FMI — BuildingsPy documentation

# FMI

This module provides functions to analyse FMUs.

`buildingspy.fmi.` `get_dependencies`(fmu_file_name)

  Return the input and state dependencies of an FMU as a dictionary.

  Fmu_file_name: | Name of the FMU file.

  Extracts the FMU `fmu_file_name` to a temporary directory, reads its modelDescription.xml file, and returns a dictionary with the dependencies of derivatives, outputs and initial unknowns.

  For example, if applied to an FMU that encapsulates the Modelica model

      block IntegratorGain "Block to demonstrate the FMU export"
        parameter Real k = -1 "Gain";
        Modelica.Blocks.Interfaces.RealInput u "Input";
        Modelica.Blocks.Interfaces.RealOutput y1
          "Output that depends on the state";
        Modelica.Blocks.Interfaces.RealOutput y2
          "Output that depends on the input";
        Real x(start=0) "State";
      equation
        der(x) = u;
        y1 = x;
        y2 = k*u;
      end IntegratorGain;

  The output will be as follows:

      >>> import os
      >>> import json
      >>> import buildingspy.fmi as f
      >>> fmu_name=os.path.join("buildingspy", "tests", "fmi", "IntegratorGain.fmu")
      >>> d=f.get_dependencies(fmu_name)
      >>> print(json.dumps(d, indent=2))
      {
        "Outputs": {
          "y1": [
            "x"
          ],
          "EventCounter": [],
          "y2": [
            "u"
          ],
          "CPUtime": []
        },
        "InitialUnknowns": {
          "y1": [
            "x"
          ],
          "EventCounter": [],
          "y2": [
            "k",
            "u"
          ],
          "der(x)": [
            "u"
          ],
          "CPUtime": []
        },
        "Derivatives": {
          "der(x)": [
            "u"
          ]
        }
      }