Table Of Contents

modelicares.multi

Functions to load and plot data from multiple simulation and linearization files at once

modelicares.multi.multiload(locations)

Load multiple Modelica simulation and/or linearization results.

Arguments:

  • locations: Input filename, directory, or list of these

    Wildcards (‘*’) may be used in the filename(s).

Returns:

  1. List of simulations (simres.SimRes instances)
  2. List of linearizations (linres.LinRes instances)

Either may be an empty list.

Example:

>>> from modelicares import *

# By file:
>>> multiload(['examples/ChuaCircuit.mat', 'examples/PID']) 
Valid: SimRes('...ChuaCircuit.mat')
Valid: LinRes('...PID.mat')
([SimRes('...ChuaCircuit.mat')], [LinRes('...PID.mat')])

# By directory:
>>> multiload('examples') 
Valid: SimRes('...ChuaCircuit.mat')
Valid: LinRes('...PID.mat')...
Valid: SimRes('...ThreeTanks.mat')
([SimRes('...ChuaCircuit.mat'), SimRes('...ThreeTanks.mat')], [LinRes('...PID.mat')])
modelicares.multi.multiplot(sims, suffixes='', dashes=[(1, 0), (3, 3), (1, 1), (3, 2, 1, 2)], **kwargs)

Plot data from multiple simulations in 2D Cartesian coordinates.

This method simply calls simres.SimRes.plot() from multiple instances of simres.SimRes.

A new figure is created if necessary.

Arguments:

  • sims: Simulation result or list of results (instances of simres.SimRes)

  • suffixes: Suffix or list of suffixes for the legends (see simres.SimRes.plot())

    If suffixes is None, then no suffix will be used. If it is None, then the base filenames will be used.

  • **kwargs: Propagated to simres.SimRes.plot() (and thus to base.plot() and finally matplotlib.pyplot.plot())

    The dashes sequence is iterated across all plots.

Example:

>>> from glob import glob
>>> from modelicares import SimRes, multiplot, saveall

>>> sims = map(SimRes, glob('examples/ChuaCircuit/*/*.mat'))
>>> multiplot(sims, title="Chua Circuit", label='examples/ChuaCircuits',
...           suffixes=['L.L = %.0f H' % sim.get_IV('L.L')
...                     for sim in sims], # Read legend parameters.
...           ynames1='L.i', ylabel1="Current") 
(<matplotlib.axes.AxesSubplot object at 0x...>, None)

>>> saveall()
Saved examples/ChuaCircuits.pdf
Saved examples/ChuaCircuits.png
plot of Chua circuit with varying inductance