【问题标题】:pyFMI parameter change don't change the simulation outputpyFMI 参数更改不会更改模拟输出
【发布时间】:2018-12-06 08:40:19
【问题描述】:

我正在使用 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)

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

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)

【问题讨论】:

    标签: python modelica dymola fmi pyfmi


    【解决方案1】:

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

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

    但是,在您的情况下,这不是必需的,因为您只想设置两个参数,所以我建议您在进行模拟调用之前简单地删除输入对象:

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

    【讨论】:

      猜你喜欢
      • 2020-12-11
      • 1970-01-01
      • 1970-01-01
      • 2013-05-28
      • 2015-12-14
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多