Table Of Contents

loadresΒΆ

Load results from Modelica simulation(s) and provide a Python interpreter to analyze the results.

This script can be executed at the command line. It will accept as arguments the names of result files or names of directories with result files. The filenames may contain wildcards. If no arguments are given, the script provides a dialog to choose a file or folder. Finally, it provides working session of IPython with the results preloaded. PyLab is directly imported (from pylab import *) to provide many functions of NumPy and matplotlib (e.g., sin() and plot()). The essential classes and functions of ModelicaRes are directly available as well.

Example:

To begin this example, copy this script (loadres) to the current directory along with the examples folder.

$ loadres examples
Valid: SimRes('.../examples/ChuaCircuit.mat')
Valid: SimRes('.../examples/ThreeTanks.mat')
Valid: LinRes('.../examples/PID.mat')
Simulation results have been loaded into sims[0] through sims[1].
A linearization result has been loaded into lin.

where ‘...’ depends on the local system.

You can now explore the simulation results or create plots using the methods in SimRes. For example,

>>> sims[0].get_FV('L.v')
-0.25352862
>>> sims[0].get_unit('L.v')
'V'

If a variable cannot be found, then suggestions are given:

>>> sims[0].get_description('L.vv')
L.vv is not a valid variable name.

Did you mean one of the these?
       L.v
       L.p.v
       L.n.v
>>> sims[0].get_description('L.v')
'Voltage drop between the two pins (= p.v - n.v)'

To return all values of a variable, use its string as an index:

>>> sim['L.v']
array([  0.00000000e+00, ... -2.53528625e-01], dtype=float32)

or an argument:

>>> sim('L.v')
array([  0.00000000e+00, ... -2.53528625e-01], dtype=float32)

To see all the methods, use

>>> help(sims[0])

or go to SimRes. To search for variable names, use names() with wildcards:

>>> sims[0].names('L.p*')
[u'L.p.i', u'L.p.v']

Likewise, you can explore the linearization result or create diagrams using the methods in LinRes:

>>> print lin
Modelica linearization results from ".../examples/PID.mat"
>>> lin.sys.A
matrix([[   0.,    0.],
        [   0., -100.]])