from modelicares import SimRes, SimResList import numpy as np import matplotlib.pyplot as plt from pandas import DataFrame %matplotlib inline %precision 3 sim = SimRes('ThreeTanks.mat') sim.sankey(title="Sankey Diagrams of Modelica.Fluid.Examples.Tanks.ThreeTanks", times=[0, 50, 100, 150], n_rows=2, format='%.1f ', names=['tank1.ports[1].m_flow', 'tank2.ports[1].m_flow', 'tank3.ports[1].m_flow'], labels=['Tank 1', 'Tank 2', 'Tank 3'], orientations=[-1, 0, 1], scale=0.1, margin=6, offset=1.5, pathlengths=2, trunklength=10); sims = SimResList('*.mat', '*/*/*.mat') print(sims) sims.names has_inductor = lambda sim: 'L.L' in sim [has_inductor(sim) for sim in sims] sims.unique_names['L.L'] sims = SimResList(filter(has_inductor, sims)) print(sims) sims.find('L*v') has_small_inductance = lambda sim: 'L.L' in sim and sim['L.L'].value() < 14 sims['L.L'].value() sims[0]['L.L'].value() 'L.L' in sims sims[0] in sims print(sims[:2]) {"Final value of " + name: sims[name].FV() for name in ['C1.v', 'C2.v', 'L.v']} sims[0](['C1.v', 'C2.v', 'L.v']).FV() sim = SimRes('ChuaCircuit.mat') timeit sim['L.i'].values() timeit sim(['L.i']).values() Li = sim['L.i'] timeit Li.values() voltages = sim.find('^[^.]*.v$', re=True) timeit sim(voltages).values() v = sim(voltages) timeit v.values() d = DataFrame({'file size / B':[22273, 34990, 43027, 278277, 347461, 2332811, 3088223], 'load time / ms': [4.24, 2.97, 2.43, 13.6, 36.4, 68.6, 197]}) plt.plot(d['file size / B']/1e6, d['load time / ms'], 'o--') plt.title("File loading time using ModelicaRes\n" "Samsung ATIV Book 8, Intel Core i7-3635QM, Ubuntu 14.04") plt.xlabel('File size / MB') plt.ylabel('Loading time / ms') plt.grid(True) 4.5e9/(1e4*278.3e3) - 1