Input to FMU using pyFMI

5 posts / 0 new
Last post
mneja
Offline
Joined: 2017-11-10
Input to FMU using pyFMI

Hi,

 

I would like to know if there is any way to give a (transient) input to an FMU using pyFMI. I want to feed my model transient input form a text file. In my model I can do this using CombiTimeTable in Modelica, but the file name with the table is not a parameter so cannot be changed once an FMU is made. Better then to have the table in Python and feed the contents to the FMU (which would need to supply time in return for interpolation in said table).

Can this be done?

chria
Offline
Joined: 2009-07-29
Hi,   Yes this is possible.

Hi,

 

Yes this is possible. Please see the PyFMI examples regarding inputs.

 

Best

/Christian

mneja
Offline
Joined: 2017-11-10
Thank´s, I found an example

Thank´s, I found an example (which oddly enough I hadn't before...  Just one last question, shall the inputs be specified in the model I subsequently export as an FMU, i.e. as interfaces (Real or whatever datatype they may be)?

Thanks again,

mneja

janpeter
Offline
Joined: 2010-09-11
Hi,Where do we find these

Hi,

Where do we find these PyFMI examples? Looked through the user manual but do not find.

Actually I would like to feed a time discete system with a file of data with regularly sampled data, and set the samplePeriod of the time discrete system to the samplePeriod in the file, and then read the data from the file and have that as input to the discrete time Modelica model. How do I do this?

Can we use Modelica.Blocks.Sources.CombiTimeTable in JModelica (ver 2.0)?

Jan Peter

janpeter
Offline
Joined: 2010-09-11
Hi, Now I have read through

Hi,

Now I have read through the manual again and find on page 31 that one can read a Python np.array at time of simulation and use that as an “external” input. It works fine for me, also.

But I have a few questions:

1) The way data from the “external” input can enter a model/block is to give parameter a value and that parameter name is given in the input_object. More “proper" would be to let that this “external” signal go through an declared input to a model/block, but that is not possible since then the system is not fully defined at time of compilation, and we want to be able to change input file with other signals to test without re-compilation.
Comments on how “proper” the JModelica solution is?

2) I have looked through the books of Tiller and Fritzson but what I can see the term “external” is only used with “external functions” and the concept of “external input” or similar I could not find. How could it be that this aspect is so “poorly” handled in Modelica? 

I can imagine that reading arrays and files is very dependent on the environment and OS Modelica works in, but that did not hinder Modelica to define “external functions” so I am quite bewildered, and tend to think I have missed something. Have I?

Jan Peter

Login or register to post comments