4

I have noticed that the output file from JModelica saves everything, which means that the complex models create enormous files, particularly for long simulations.

Is it possible to only save the relevant variables in the output file? I have read through the user manual but I cannot see where such an argument can be specified.

For example my model creates variables [a,b,c,d,e,f,g,time] but I only want to save [a,b,time].

alkey
  • 986
  • 4
  • 16
  • 33

1 Answers1

4

Indeed it is, in the user guide, section 5.3.2.2 "Options for Model Exchange FMUs", there is an argument to the simulation option object which controls this, it is called filter and has the description:

A filter for choosing which variables to actually store result for. The syntax can be found here. An example is filter = "*der" , store all variables ending with 'der' and filter = ["der", "summary*"], store all variables with "der" in the name and all variables starting with "summary".

Here's a complete answer where I simulate PIDController and only return the variables which ends with phi.

from pymodelica import compile_fmu
from pyfmi import load_fmu
n = compile_fmu("Modelica.Blocks.Examples.PID_Controller")
m = load_fmu(n)
opts = m.simulate_options()
opts['filter'] = '*.phi'
m.simulate(options=opts)
Jon S
  • 15,846
  • 4
  • 44
  • 45
  • 1
    Apologies if my question was trivial. The documentation I was referring to was http://www.jmodelica.org/assimulo_home/pyfmi_1.0/pyfmi.html and I was thrown by the Model Exchange Heading in the User Manual. However, your answer makes it much more clear. – alkey Feb 22 '18 at 15:51
  • The above links are both broken – Foad S. Farimani Oct 03 '19 at 23:16
  • 1
    @Foad I've updated the answer with correct link. Unfortunately the new link is to the user guide pdf as the HTML guide no longer seems to be available. As for the pyfmi documentation that alkey mentions, that can be found here: https://jmodelica.org/pyfmi/index.html – Jon S Oct 04 '19 at 05:33