pyFMI parameter change don't change the simulation output

▼魔方 西西 提交于 2019-12-11 12:25:52

问题


I'm changing the initial 2 parameter values (over the range of possible values) with pyFMI and simulate the model response I can see that my response is affected only by 1 variable change and not by the other but if I simulate the model only with the second variable (that is not changing in inital simulations) I can clearly see the effect on the model response.

model.reset()
model=load_fmu('Series_0Resistance.fmu')
tstart = model.get_default_experiment_start_time() #### start time of the model
tstop = model.get_default_experiment_stop_time() #### Stop time of the model
Rshunt=0.09141 # Initial values of parameters ( not affecting the simulation response while simulated with the second parameter)
Rserie=0.00012 # Initial values of parameters (affecting the simulation response)                    
Rserie_traj                  = np.array([[tstart,Rserie]])
Rshunt_traj                  = np.array([[tstart,Rshunt]])
input_object = ('champPV.param2diodes.Rserie',Rserie_traj,
                'champPV.param2diodes.Rshunt',Rshunt_traj)
opts = model.simulate_options ()
opts['ncp']=266### The number of output points
opts["CVode_options"]["store_event_points"] = True
model_try=model.simulate(options=opts, input=input_object,final_time=tstop )
results=(model_try['champPV.Pmpp_DC'])
plt.plot(results)

But if I simulate my model response only with the parameter (that is not affecting the simulation response in the above case) I can see clear model response differences.Would welcome any hints how to resolve this.

global model
model.reset()
model=load_fmu('Series_0Resistance.fmu')
tstart = model.get_default_experiment_start_time() #### start time of the model
tstop = model.get_default_experiment_stop_time() #### Stop time of the model
Rshunt=0.9141 # Initial values of parameters 
Rshunt_traj                  = np.array([[tstart,Rshunt]])
input_object = ('champPV.param2diodes.Rshunt',Rshunt_traj)
opts = model.simulate_options ()
opts['ncp']=266### The number of output points
opts["CVode_options"]["store_event_points"] = True
model_try=model.simulate(options=opts, input=input_object,final_time=tstop )
results=(model_try['champPV.Pmpp_DC'])
plt.plot(results)

回答1:


The input object is not defined correctly, it should be:

traj         = np.array([[tstart,Rserie, Rshunt]])
input_object = (['champPV.param2diodes.Rserie', 'champPV.param2diodes.Rshunt],traj)

However, in your case this is not needed as you only want to set two parameters, so I'd suggest that you simply remove the input object and before you do the simulation call:

model.set('champPV.param2diodes.Rserie', Rserie)
model.set('champPV.param2diodes.Rshunt', Rshunt)


来源:https://stackoverflow.com/questions/53647494/pyfmi-parameter-change-dont-change-the-simulation-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!