pyFMI参数改变不改变模拟输出

2024-06-26 14:26:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我用pyFMI改变初始的2个参数值(在可能值的范围内),并模拟模型响应。我可以看到我的响应只受1个变量变化的影响,而不受其他变量的影响,但是如果我只用第二个变量模拟模型(在初始模拟中没有变化),我可以清楚地看到对模型的反应。在

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)

但是如果我只使用参数来模拟我的模型响应(在上述情况下不会影响模拟响应),我可以看到清晰的模型响应差异。会的欢迎有任何提示如何解决这个问题。在

^{pr2}$

Tags: ofthe模型inputgetmodeltimeoptions
1条回答
网友
1楼 · 发布于 2024-06-26 14:26:57

输入对象定义不正确,应为:

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

但是,在您的情况下,这是不需要的,因为您只想设置两个参数,所以我建议您只需删除输入对象,然后再执行模拟调用:

^{pr2}$

相关问题 更多 >