pyFMI Python simulation different number of output points

434 Views Asked by At

How to pricisely control the number of model outputs

I get an different number of output points based on different input parameters:

model = load_fmu("Trial.fmu") # 64 Bit generated FMU with Dymola+Buildsyspro 
tstart = model.get_default_experiment_start_time() #### START TIME 
tstop  =  model.get_default_experiment_stop_time() #### STOP TIME
opts = model.simulate_options () # Setting the output number of outputs
opts['ncp']=194 ## Want to have exactly 194 data points

foo is a function to convert parameters into the righ format thetaInit are the initial values of paramaters

results=model.simulate(input=foo(thetaInit),options=opts, start_time=tstart, final_time=tstop)

len(results['DC_Power')
267

Changing the initial parameters values by multiplying them with 0.9

results2=model.simulate(input=foo(thetaInit*0.9),options=opts, start_time=tstart, final_time=tstop)
len(results['DC_Power')
263

For calibration issues I need to have the same number of output points. If somebody has a clue how to control this.

1

There are 1 best solutions below

1
On BEST ANSWER

As Hans points out the extra points are likely due to events which are stored by default (on top of the ncp). Disabling storing of the event points can be done using:

model = load_fmu(...)
opts = model.simulate_options()
opts["CVode_options"]["store_event_points"] = False

res = model.simulate(options=opts)