Git Product home page Git Product logo

fmicodegenerator's People

Contributors

benjaminrodenberg avatar ghorwin avatar pstelzig avatar syedfasihmohiuddin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fmicodegenerator's Issues

Run FMU through compliance checker

Automatically run generated FMU through compliance checker once built.

Make this option configurable with a command line argument to deploy.sh

Dependency List Seems Wrong

Hello, your project includes the ability to automatically generate Dependencies tags under the ModelStructure directory. However, I found that the project only associates all input variables with all output variables (because the dependList does not change during iteration to generate Dependencies), which seems to lead to incorrect dependency generation. Not all output variables depend on all input variables. I wonder if my understanding is correct. Can you answer my question?

Port FMICodeGenerator to C++

Convert Python code to C++ code to avoid the annoying PyQt compatibility problems (especially on Mac and Windows).

Simple ODE in FMU example

I have implemeted a simple Pendulom Example in the FMU generator and It worked. Now I would like to implementthe same logic but this time withuot depending on a internal time factor h , but depending ona external time factor which is giving by the simulator (in this case Matlab) or more direct by the <defaultExperiment. data placed on the modelDescription.xml.

Implementation of the Rungakutta Solver in to the UpdateIfModified Function

`

double g = m_realVar[FMI_PARA_g];
double l = m_realVar[FMI_PARA_l];
double b = m_realVar[FMI_PARA_b];
double m = m_realVar[FMI_PARA_m];
double Ang = m_realVar[FMI_LOCAL_Ang];
double vel = m_realVar[FMI_LOCAL_vel];



//Runga Kutta Method
double h=0.01;

double dx1,dx2,dx3,dx4,dx;
double dv1,dv2,dv3,dv4,dv;



dx1=h*vel;
dv1=h*dydx(Ang,vel,g,l,b,m);

dx2=h*(vel+0.5*dv1);
dv2=h*dydx(Ang+0.5*dx1,vel+0.5*dv1,g,l,b,m);

dx3=h*(vel+0.5*dv2);
dv3=h*dydx(Ang+0.5*dx2,vel+0.5*dv1,g,l,b,m);

dx4=h*(vel+dv3);
dv4=h*dydx(Ang+dx3,vel+dv1,g,l,b,m);

dx=(dx1+2*dx2+2*dx3+dx4)/6;
dv=(dv1+2*dv2+2*dv3+dv4)/6;

Ang=Ang+dx;
vel=vel+dv;

// output variables
m_realVar[FMI_OUTPUT_Ace] = Ang; 
   //Update Angle and Velocity values
m_realVar[FMI_LOCAL_Ang]=Ang;
m_realVar[FMI_LOCAL_vel]=vel;

`

With the ODE function

float dydx(double x, double v,double g,double l,double b, double m) { return((-(g/l)*sin(x))-(b/m)*v); }

Allow variable names with _ and numbers

reported by MathiasMalandain

A-Z, a-z only

When declaring variables, I got a message warning me that only ASCII characters A-Z and a-z could be used in variable names. I had to rename variables T_limit and k_P accordingly. Was it unobserved behavior so far? I would not expect so, as the warning message makes it really clear which characters can be used. The ability to use underscores in variable names would be hugely convenient.

Generally, allow all variable names that generated proper variable defines in C++ code.

Wizard page for variable definition

Second wizard page should show a table (QTableWidget) with variables. A plus and minus button are used to add new variables (minus button operates on currently selected row).

Columns:

  • Unique ID name
  • Unique C Macro name (generated from ID name, see pattern description below)
  • Type (Input, Output, Parameter)
  • Properties (showing comma-separeted list of properties)

Adapt deploy.sh from Math003 example to FMI_template

Copy the deploy.sh file from the Math003 example to the FMI_template directory, replace the specific names in the file with placeholders and adjust the python scripts to replace the placeholders with names o generated files.

dependList in modelStructureDefs

Hello, your project includes the ability to automatically generate Dependencies tags under the ModelStructure directory. However, I found that the project only associates all input variables with all output variables (because the dependList does not change during iteration to generate Dependencies), which seems to lead to incorrect dependency generation. Not all output variables depend on all input variables. I wonder if my understanding is correct. Can you answer my question?

generate.sh script does not work with spaces in description

When running

> generate.sh MyFMU --description "My FMU with spaces"

you get the error message:

usage: main.py [-h] [--description DESCRIPTION] modelName
main.py: error: unrecognized arguments: FMU with spaces

When running the Python script directly

> ../scripts/main.py MyFMU --description "My FMU with spaces"

it works.

Fix needed for passing quoted arguments to a shell script on to a python script.

Real value inputs and the compliance checker

Thanks for contributing this tool, it's really made my entry into the world of building an FMU straight forward.

I've run across a problem using Real's as input into my FMU and I'm not sure where the issue lies. I'm using the compliance checker 2.0.4 and when I turn on the -f flag I see that my first Real input on a given line of the input file is copied to all real variables. If I convert the model to use integers for the same field I don't see the problem. It's easy to suspect the problem lies with the compliance checker but I thought I'd ask here before posting there.

To be clear, here is what I see. Take a model with inputs A, B, C all reals and using the compliance checker with an input similar to:

"time","A","B","C"
0,1.0,2.0,3.0

The output file will show:

"time","A","B","C"
0,1.0,1.0,1.0

Print statements in my FMU confirm what I see in the output file. Again, if I use integers no issue, it really feels like a problem with the compliance checker but any insight you can provide is much appreciated.

How to use VS2022 to compile the code

Hi,

I compiled the code use VS2022 to the fmu file, and loaded it into openmodelica. But I got below issue.
[test_model: 0:0-0:0]: [Expected test0901_me_FMU to be a class, but found component instead.](omeditmessagesbrowser:///test_model?lineNumber=0)
Is that only support VS2015? Or how could I do just using VS2022 if possible?

CMAKE_C_COMPILER not set error

Hi when I attempt to generate an FMU, I get the following error:

CMAKE_C_COMPILER not set, after EnableLanguage\nCMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage\n'nmake' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n

What should I do?

FMU in Eclipse with MinGW Compiler

Hi everyone!

I am new in the area and I was interacting a little bit the source code using Eclipse IDE to generate FMUs. The exported DLL file works fine when I am using Microsoft Visual C++ compiler, but when I switched to MinGW compiler the .dll file does not work. I was checking the exported DLL file with Dependency Walker and I saw that the file has problems with Kernell32.dll and MSVCRT.dll. Is there any reason why it can't work with the MinGW compiler and if possible, what should I do to link the necessary libraries with the code to generate the DLL file?

Thank you all for the help.

Print outputs for major processing steps

Generate console output for major process steps:

  1. copy template directory structure and rename files
  2. substitute placeholders
  3. test-build FMU
  4. ...

This will help users fix problems in case something goes wrong.

Not possible to open results file: No such file or directory

Hi guys!

I generated an FMU from P_Controller tutorial, and tried to use it in Dymola, but the following error appears:
"Not possible to open file "Unnamed2.mat": No such file or directory".

Unnamed2.mat is an output file for storing simulation results in Dymola.

The log is:
[fmi2OK]: P_Control_fmu: fmi2SetupExperiment: Call of setup experiment.
[fmi2OK]: P_Control_fmu: fmi2EnterInitializationMode: Go into initialization mode.
[fmi2OK]: P_Control_fmu: Starting initialization.
[fmi2OK]: P_Control_fmu: Initialization complete.
[fmi2OK]: P_Control_fmu: fmi2ExitInitializationMode: Go out from initialization mode.
Simulation successfully terminated
Terminate signaled by FMU
Error: Terminate command at starting point.
[fmi2OK]: P_Control_fmu: fmi2Terminate: Terminate model.
[fmi2OK]: P_Control_fmu: fmi2FreeInstance: Model instance deleted.

At the same time, I could run fmuCheck on this FMU without any errors. It seems that OpenModelica and SimulationX work with this FMU well too.

It seems that only co-simulation works in Dymola. Model exchange fails.

What could it be?

The README and tutorial pages may need updating

Description

I started using FMICodeGenerator by following the instructions on this page, on a Lubuntu 22.04 (based on Ubuntu 22.04.2 LTS "Jammy") virtual machine. Several steps from this tutorial, as well as the README file itself, could not be performed, or not "as is".

Wrong dependencies

Everything I needed to make FMICodeGenerator work was already installed. However, I noticed several errors/discrepancies when trying to run the setup command for Python 3.x:

  • sudo apt get install ... will not work. The word get should be removed.
  • built-essential cannot be found. You likely meant build-essential.

Instructions on Ubuntu 21.04 or newer may be added: qt5-default is obsolete since at least 21.04.

No compliance checker

Command fmuCheck.linux64, used here, is not known to my VM, and I do not think that either the tutorial or the README file says anything about it. I will be exporting the FMU from another tool to make sure it works.

Create data structure to collect all input needed to configure FMI generator

Create a class FMIGenerator in file FMIGenerator.py that stores all properties needed to generate FMI:

  • model name
  • description
  • list of input vars (with attributes each)
  • list of output vars (with attributes each)
  • list of parameters (with attributes each)
  • number of integration states
  • weather a generic integrator should be inserted based on modelExchange() functionality

Start with a simple class holding only the currently supported parameters, populate a class instance with command line arguments and pass it to the generation function.

State handling in FMUs

FMICodeGenerator should handle and maintain states properly.

With "states", we need to distinguish between a) just regular states and b) integrated continuous variables.

a) This is handled already automatically. Whenever you store a value in any of the data maps

m_boolVar
m_realVar
m_integerVar
m_stringVar

these are stored and maintained in the FMU instance class object from one doStep() call to the next. Also, these states are stored in calls to serializeFMUstate() and restored in deserializeFMUstate(). Even if the master copies the FMU state and stores it into a file and later re-creates the FMU instance and restores data back from external memory - these states are restored as well.

b) support for continues variables is pending - for now a workaround would be to "reuse" the m_realVar map, but for larger fields this would be bad for performance. The plan is to add some integration library (CVODE?) into the code generator and then provide some integration functionality inside the FMU as well.

Wizard page for basic FMU properties

First wizard page shows input of:

  • FMU name
  • description
  • target directory

input is stored in FMU configuration data structure and used for FMU generation.

Consistency checks for basic FMU properties

Implement consistency checks:

  1. FMU name must not be empty
  2. FMU name must not hold characters that are forbidden as file names
  3. target directory must be a valid path
  4. if target path does not exist, yet, user must be asked to give permission to create the basic directory
  5. target subdirectory for generated FMU must not exist as file
  6. if target subdirectory for generated FMU exists (as directory), user must be asked to give permission to remove the old directory structure before creating the new one

Listing on FMI tools page

It would be good to list the tool on the FMI Tools page https://fmi-standard.org/tools/, as described here: https://github.com/modelica/fmi-standard.org/blob/main/CONTRIBUTING.md#updating-the-tools-list.

(The FMI Project also recommend to provide "compatibility information" for your tool https://github.com/modelica/fmi-standard.org/blob/main/CONTRIBUTING.md#compatibility-information . This will increase confidence of users in your FMI implementation.)

Thanks in advance!

Rename generated FMI to <modelName>.so or <modelName>.dll

According to specs, the FMU must be named

    <modelName>.so     # on Linux
    <modelName>.dylib  # on MacOS
    <modelName>.dll    # on Windows

The renaming can be done as part of the build or the deployment step.

Note: when developing with Qt Creator, the generated shared library files will always get a defined name.

Save/Restore FMIGenerator input variables

Need a function to store and restore the state of the FMIGenerator class into a file. This is needed for the wizard to save its current input and restore it at a later point (to continue adding FMI properties or to fix previous input without entering all input data again).

Implementation should be done in member functions write(self, filename) and read(self, filename).
Error handling during reading should be basic only (currently, we do not consider these "backup" files as user-edited data).

Wizard page for variable definitions

A wizard page should be created to allow users to specify variables and parameters.

Page should hold different table widgets for:

  • input variables
  • output variables
  • parameters

Each table should be editable via +/- buttons (to add/remove variables).

License of generated code

The license of the generated code, hence of the FMU, is GPL. Is this correct? The code generator itself is a BSD license which makes me wondering.

Scripts crashes when executed from repository root

Steps to reproduce:

  1. change to repository root

  2. testrun script with:

    scripts/main.py test0001

Output:

=> ./scripts/main.py testie
Traceback (most recent call last):
  File "./scripts/main.py", line 4, in <module>
    from FMIGenerator import FMIGenerator
  File "/Users/ghorwin/git/FMICodeGenerator/scripts/FMIGenerator.py", line 8, in <module>
    import send2trash as st
ImportError: No module named send2trash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.