PyFMI | Functional Mock-Up Units both for Model Exchange | Mock library

 by   modelon-community Python Version: PyFMI-2.10.2 License: LGPL-3.0

kandi X-RAY | PyFMI Summary

kandi X-RAY | PyFMI Summary

PyFMI is a Python library typically used in Testing, Mock applications. PyFMI has build file available, it has a Weak Copyleft License and it has low support. However PyFMI has 8 bugs and it has 1 vulnerabilities. You can download it from GitHub.

PyFMI is a package for loading and interacting with Functional Mock-Up Units (FMUs) both for Model Exchange and Co-Simulation, which are compiled dynamic models compliant with the Functional Mock-Up Interface (FMI). See for more information. For a more indebt technical description of the features / functionality see:
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              PyFMI has a low active ecosystem.
              It has 115 star(s) with 35 fork(s). There are 16 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 9 open issues and 66 have been closed. On average issues are closed in 435 days. There are 5 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of PyFMI is PyFMI-2.10.2

            kandi-Quality Quality

              OutlinedDot
              PyFMI has 8 bugs (6 blocker, 0 critical, 1 major, 1 minor) and 558 code smells.

            kandi-Security Security

              PyFMI has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              PyFMI code analysis shows 1 unresolved vulnerabilities (0 blocker, 1 critical, 0 major, 0 minor).
              There are 3 security hotspots that need review.

            kandi-License License

              PyFMI is licensed under the LGPL-3.0 License. This license is Weak Copyleft.
              Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.

            kandi-Reuse Reuse

              PyFMI releases are available to install and integrate.
              Build file is available. You can build the component from source.
              It has 18983 lines of code, 960 functions and 41 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed PyFMI and discovered the below as its top functions. This is intended to give you an instant insight into PyFMI implemented functionality, and help decide if they suit your requirements.
            • Write the result
            • Get model variables
            • Return the names of the keys
            • Append res
            • Runs the bouncing ball model
            • Set the value of the variable
            • Return the final value of a variable
            • Get files in the archive
            • Return the platform name of the current platform
            • Return the maximum value of the model
            • Returns a list of time points that are linear variables
            • Returns a list of x - coordinate variables
            • Get the minimum value of the model
            • Returns the maximum value of the model
            • Return a list of all the variable s nominal attributes
            • Gets the nominal attribute of the model
            • Returns a list of u_linear_variables
            • Get the variable fixed attributes
            • Returns the u_islinear
            • Solve the fitted parameters
            • Returns the minimum value of the model
            • Check pyfmi packages
            • Set the options of the algorithm
            • Check extensions
            • Get the timepoints for the linear variable
            • Solves the simulation
            Get all kandi verified functions for this library.

            PyFMI Key Features

            No Key Features are available at this moment for PyFMI.

            PyFMI Examples and Code Snippets

            No Code Snippets are available at this moment for PyFMI.

            Community Discussions

            QUESTION

            PyFMI multiple inputs in Master simulation
            Asked 2021-Dec-01 at 14:19

            I am trying to simulate two FMUs with the one having inputs as CSV files by using the Master. What I have tried is the following:

            ...

            ANSWER

            Answered 2021-Dec-01 at 14:19
            def load(t):
                return 10, math.cos(t)
            
            input_object = ([(electricity_network, 'P_load1'),(electricity_network, 'P_load2')],load)
            

            Source https://stackoverflow.com/questions/68871151

            QUESTION

            FMU machine learning model
            Asked 2021-Sep-01 at 11:42

            I had some success in deploying my machine learning model (already trained) in a simulation environment (OpenModelica, in this context) via an external C-function.

            However, to standardise the process, I am aiming to use the FMI standard instead of the external C-function. Therefore I need to wrap my ML model as an FMU.

            Is there any way that I can do that? I read about PyFMI, however, it seems that it only controls the Co-simulation in a Python environment, instead of wrapping your ML model as an FMU.

            The goal is to produce FMU from a trained ML model, and then deploy this FMU in a simulation environment (OpenModelica, for example). Any help will be very much appreciated.

            Thanks

            ...

            ANSWER

            Answered 2021-Sep-01 at 11:42

            Let's say you have two Modelica models A and B.

            Source https://stackoverflow.com/questions/68969411

            QUESTION

            How to co-simulate fmu with a Python function?
            Asked 2021-Feb-26 at 13:59

            With Python libraries like FMPy I am able to simulate fmus (using fmpy.simulate_fmu) for given start_time and stop_time. In such case, the function simulate_fmu completes the simulation and return the time-series results.

            However, I want to create a closed loop between fmu and a Python function (i.e. in a Python script initialize the fmu, get the results from fmu after every 0.1s and based on that update the input value to the fmu for the next timestep). Is there a way to achieve this using existing libraries like fmpy or pyfmi?

            ...

            ANSWER

            Answered 2021-Feb-05 at 15:26

            The short answer is yes the tools you mention are set up to do what you are asking.

            A long answer can be found for FMPy:

            But the gist is to perform changes during simulation like you are asking the approach you want you need to go a layer deeper than simulate_fmu and use doStep and associated setup. The functions/approach needed for these are defined by the FMI standard while highler level implmentations like simulate_fmu are not and are therefore tool dependent implementations of the standard.

            The cliff notes are:

            • Prep the Simulation Inputs
              • e.g., unzip the FMU, define simulation setup, and instantiate the FMU

            Source https://stackoverflow.com/questions/66051450

            QUESTION

            PyFMI parameter estimation and handling of fixed model parameters different from default
            Asked 2020-Mar-09 at 13:37

            I have started to in PyFMI use parameter estimation with the procedure model.estimate() and works well.

            From the documentation (Andersson et al 2016) as well as practical use I understand that model parameters are taken from the compiled FMU-model if not estimated. It would have been very practical to have an option to provide a dictionary with a set of the fixed parameter values different from the default of the model. Is there any way to provide that?

            The current workflow is that for a larger model built up of parts from libraries, then you need to make a copy of these models and set parameters to the proper value in the code, and then compile it. It is a somewhat tedious procedure. Perhaps I have misunderstood something?

            Andersson et al (2016): "PyFMI: A Python package for…” https://portal.research.lu.se/portal/files/7201641/pyfmi_tech.pdf

            ...

            ANSWER

            Answered 2020-Mar-09 at 13:36

            From my contact Christian Winther at Modelon I learn that I understand the workflow right. He see also the advantage to have a possibility to have a list (or dictionary) of parameters that is changed from the default parameters and remain constant during parameter estimation. It may come in a future update.

            Source https://stackoverflow.com/questions/60150193

            QUESTION

            Is there a way to list of parameters of FMU (or of submodel in FMU) using the python libraries FMPy or pyFMI?
            Asked 2020-Mar-03 at 20:05

            I have a FMU of a model and the use case is to change parameter values of the FMU to see the impact on the results. Is there a way to list top level parameters of the FMU using either FMPy or pyFMI if I dont' have access to the Modelica model?

            One of the process I have been following is to open the FMU using FMPy.gui and go through the list of parameters and then use them in the script but I would like to know if there an easier way of doing it so that I can list then in the Jupyter notebook and change the parameters as needed?

            ...

            ANSWER

            Answered 2020-Mar-02 at 19:10

            In FMI there is no distinction between top level parameters and other parameters. To list all available parameters in the model using PyFMI (FMI 2.0):

            Source https://stackoverflow.com/questions/60492290

            QUESTION

            How to combine Python 3 with standard JModelica dependent on Python 2?
            Asked 2020-Feb-02 at 12:33

            I would like to install Python 3 with PyFMI at my Windows computer where I already have JModelica 2.10 with Python 2. My idea is thus to compile Modelica models to FMUs in Python 2 as necessary but then develop scripts in Python 3 to run the FMUs and visualise results. How do I best do this to avoid any conflict between the two Python environments?

            ...

            ANSWER

            Answered 2020-Feb-01 at 12:11

            JModelica 2.10 and Python 2 are already installed using the binary standard installation file for JModelica to Windows. It seems this gives a confined Python environment. Here conda is not used, but pip is included.

            I have made a test installation with Python 3 and PyFMI using Miniconda which seems actually to work and I would like to have comments on if here are potential problems to check or can be better done. I have not taken any steps to remove libraries from Python 2 related to PyFMI from the JModelica installation. I guess that can wait.

            I have done the following in Windows 10:

            1. Standard Windows-installer for JModelica 2.10 done some time ago.
            2. Install Python 3 environment “on top” using conda in the following way:

              a. Download Miniconda for Python3 from here https://docs.conda.io/en/latest/miniconda.html

              b. Install Miniconda3 and with that you get Python 3.x and some packages - but be careful to at early stage in installation and make the choice NOT to have the installation in any “path”. There are two boxes and I choose to leave both boxes un-marked.

              c. Can be good to first update conda by the command:

            Source https://stackoverflow.com/questions/59984821

            QUESTION

            PyFMI in Python 3 environment in Ubuntu 18.04
            Asked 2020-Feb-02 at 12:32

            My goal is to be able to run FMUs produced by OpenModelica in Ubuntu 18.04 and then run these with PyFMI in Python 3 environment.

            I follow the outline for PyFMI installation here https://jmodelica.org/pyfmi/installation.html.

            So far I have using Conda managed to install Python3, Numpy, Scipy, lxml and some other packages and made it work with some of my Python examples. But I would appreciate some detailed advice how to

            1. Install FMI Library - and I do not get how to setup the flag fmil-home
            2. Install Assimulo

            After that I guess we are ready to do from the installation outline “python setup.py install —fmil-home=/path/to/fmil"

            Appreciate some basic advice!

            ...

            ANSWER

            Answered 2020-Jan-09 at 18:22

            I had to compile everything to make it work so conda might be an easier solution. This worked for me:

            Source https://stackoverflow.com/questions/59582257

            QUESTION

            PyFMI different results between model exchange and co-simulation?
            Asked 2020-Jan-12 at 12:20

            When simulating the cartpole problem as an FMU in PyFMI I get different results giving the same input depending on if I use "model exchange" or "co-simulation". The ME results are correct, the CS results seem completely off.

            Model exchange results

            ...

            ANSWER

            Answered 2020-Jan-12 at 12:20

            In OpenModelica, Euler is currently the only supported solver when exporting co-simulation FMU's as stated here. Version 1.16 of OpenModelica should solve this issue.

            Source https://stackoverflow.com/questions/59685665

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install PyFMI

            You can download it from GitHub.
            You can use PyFMI like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/modelon-community/PyFMI.git

          • CLI

            gh repo clone modelon-community/PyFMI

          • sshUrl

            git@github.com:modelon-community/PyFMI.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Mock Libraries

            faker.js

            by Marak

            Faker

            by fzaninotto

            Mock

            by nuysoft

            faker

            by joke2k

            nock

            by nock

            Try Top Libraries by modelon-community

            fmi-library

            by modelon-communityC

            Assimulo

            by modelon-communityPython

            SEMLA

            by modelon-communityC

            impact-client-python

            by modelon-communityPython

            impact-webapp-example

            by modelon-communityJavaScript