pyFMI 参数改变不改变模拟输出 [英] pyFMI parameter change don't change the simulation output

查看:73
本文介绍了pyFMI 参数改变不改变模拟输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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)

推荐答案

输入对象没有正确定义,应该是:

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)

这篇关于pyFMI 参数改变不改变模拟输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆