4
votes

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].

1

1 Answers

4
votes

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)