FMU 2.0 interaction - requires parallel "container" for parameter values etc?

80 views Asked by At

I work with pyfmi in Jupyter notebooks to run simulations and I like to work interactively and evaluate incremental changes in parameters etc. Long time ago I found it necessary to introduce a dictionary that work as a "container" for parameter and initial values. Now I wonder if here is a way to get rid of this "container" that after all is partly a parallel structure to "model"?

A typical workflow look like this:

    create a diagram where results from different simulations below should be shown

    model = load_fmu(fmu_model) 
    parDict['model.x_0'] = 1
    parDict['model.a'] = 2
    for key in parDict.keys(): model.set(key,parDict[key])
    sim_res = model.simulate(10)
    plot results...

    model = load_fmu(fmu_model) 
    parDict['model.x_0'] = 3
    for key in parDict.keys(): model.set(key,parDict[key])
    sim_res = model.simulate(10)
    plot results...

There is a function model.reset() that brings the state back to default values at compilation without loading again, but you need to do more than the following

    model.reset()
    parDict['model.x_0'] = 3
    for key in parDict.keys(): model.set(key,parDict[key])
    sim_res = model.simulate(10)
    plot results...

So,  this does NOT work... and after all parameters and initial values needs to be brought back and we still need parDict, but we may avoid the load-command though.

0

There are 0 answers