.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_example/p2f/beam/plot_lowlevel.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_example_p2f_beam_plot_lowlevel.py: Load an FMU =========== .. GENERATED FROM PYTHON SOURCE LINES 6-8 First, retrieve the path to the example FMU *deviation.fmu*. .. GENERATED FROM PYTHON SOURCE LINES 8-13 .. code-block:: Python import pyfmi import otfmi.example.utility path_fmu = otfmi.example.utility.get_path_fmu("deviation") .. GENERATED FROM PYTHON SOURCE LINES 14-15 Loading an FMU only requires the FMU name or path. .. GENERATED FROM PYTHON SOURCE LINES 15-18 .. code-block:: Python model = otfmi.fmi.load_fmu(path_fmu) .. GENERATED FROM PYTHON SOURCE LINES 19-23 If the FMU is both ModelExchange and CoSimulation, the CoSimulation type is favoured. This choice, **opposite to PyFMI's default**, enables the CoSimulation to impose a solver not available in PyFMI. .. GENERATED FROM PYTHON SOURCE LINES 25-26 All options of `pyfmi.load_fmu` can be passed on to otfmi: .. GENERATED FROM PYTHON SOURCE LINES 26-28 .. code-block:: Python print(help(pyfmi.load_fmu)) .. rst-class:: sphx-glr-script-out .. code-block:: none Help on method descriptor load_fmu in module pyfmi.fmi: load_fmu( fmu: Union[str, Path], log_file_name=None, kind='auto', log_level=2, allow_unzipped_fmu=False ) Helper method for creating a model instance. Parameters:: fmu -- Path to the fmu. log_file_name -- Filename for file used to save log messages. This argument can also be a stream if it supports 'write', for full functionality it must also support 'seek' and 'readlines'. If the stream requires use of other methods, such as 'drain' for asyncio-streams, then this needs to be implemented on the user-side, there is no additional methods invoked on the stream instance after 'write' has been invoked on the PyFMI side. The stream must also be open and writable during the entire time. Default: None = Generates automatically as _log.txt kind -- String indicating the kind of model to create. This is only needed if a FMU contains multiple models. Available options: - 'ME' - 'CS' - 'SE' - 'auto' Default: 'auto' (Chooses ME > CS > SE, if multiple are available) log_level -- Determines the logging output. Can be set between 0 (no logging) and 7 (everything). Default: 2 (log error messages) allow_unzipped_fmu -- If set to True, the argument 'fmu' can be a path specifying a directory to an unzipped FMU. The structure of the unzipped FMU must conform to the FMI specification. Default: False Returns:: A model instance corresponding to the loaded FMU. None .. GENERATED FROM PYTHON SOURCE LINES 29-31 For instance, enforce CoSimulation kind and specify the filename for the logs writing: .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: Python model = otfmi.fmi.load_fmu(path_fmu, kind="CS", log_file_name="deviation.log") .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. note:: otfmi `load_fmu` is an overlay of PyFMI `load_fmu` function. Hence the FMU loaded here upper benefits of all PyFMI's methods. .. GENERATED FROM PYTHON SOURCE LINES 39-41 For example, ``get_description`` is a PyFMI method (not re-implemented in otfmi): .. GENERATED FROM PYTHON SOURCE LINES 41-42 .. code-block:: Python model.get_description() .. rst-class:: sphx-glr-script-out .. code-block:: none 'Model from here: http://openturns.github.io/openturns/master/usecases/use_case_cantilever_beam.html' .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.083 seconds) .. _sphx_glr_download_auto_example_p2f_beam_plot_lowlevel.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_lowlevel.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_lowlevel.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_lowlevel.zip `