Setup

In [1]:
#import sys
#sys.path.append('C:\Users\u0098668\Documents\Modelica\ModelicaRes')
In [2]:
from modelicares.exps.simulators import dymosim, fmi
from modelicares import SimResList, SimResSequence
%matplotlib inline
In [3]:
L = [100, 50, 20, 15] # Inductances

Dymosim

In [4]:
with dymosim(results_dir='ChuaCircuit/results') as simulator:
    simulator.run('ChuaCircuit/dymosim', StopTime=1)
    for l in L:   
        simulator.continue_run(1, {'L.L': l})

FMI

In [5]:
with fmi(results_dir='ChuaCircuit/results-fmu') as simulator:
    #simulator.run('ChuaCircuit/CSCVode.fmu', StopTime=1)
    simulator.run('ChuaCircuit/ChuaCircuit.fmu', StopTime=1)
    for l in L:   
        simulator.continue_run(1, {'L.L': l})
Simulation interval    : 0.0 - 1 seconds.
Elapsed simulation time: 0.036441 seconds.
Simulation interval    : 1.0 - 2.0 seconds.
Elapsed simulation time: 0.036377 seconds.
Simulation interval    : 2.0 - 3.0 seconds.
Elapsed simulation time: 0.034834 seconds.
Simulation interval    : 3.0 - 4.0 seconds.
Elapsed simulation time: 0.033969 seconds.
Simulation interval    : 4.0 - 5.0 seconds.
Elapsed simulation time: 0.034474 seconds.

Comparison

In [6]:
sequences = SimResList([SimResSequence('ChuaCircuit/results/1/dsres*'), 
                        SimResSequence('ChuaCircuit/results-fmu/1/dsres*')])
sequences.label = ["Dymosim", "FMI"]
sequences.plot('L.i', title="Effect of varying inductance during simulation,\nevaluated using Dymosim and FMI");