Initialization of a Dymola FMU in Simulink

无人久伴 提交于 2019-12-04 06:18:19

问题


I have encountered an issue while trying to simulate a model using an fmu file in Simulink:

I am using the Modelon FMI toolbox for a Dymola/Simulink interface to import a Model-Exchange type fmu file (version 1.0) into the Simulink model. I have a Matlab m-file that programmatically simulates the model sequentially, saving the final internal states of the model for initialization in the next simulation. The first iteration of the simulation runs without errors, but on the second iteration, Matlab returns the following errors at the call for the simulation:

module = partial_run_sim2/BasicModels.System_model_final_Sim, log level = ERROR: [][FMU status:Error] fmiInitialize: dsblock_ failed, QiErr = 1
module = partial_run_sim2/BasicModels.System_model_final_Sim, log level = ERROR: [][FMU status:Error] Possible errors (non-exhaustive): 1. The license file was not found. Use the environment variable "DYMOLA_RUNTIME_LICENSE" to specify your Dymola license file. 2. The model references external data that is not present on the target machine, at least not with the same location. Error reported by S-function 'sfun_fmu_me_1_0' in 'partial_run_sim2/BasicModels.System_model_final_Sim': fmiInitialize returned with an error in initialize_fmu_model_first_time. See the Command Window for more information printed by the FMU model.

I know that my licenses for Dymola and the FMI toolbox are up-to-date.

The simulation call in the m-file is:

simOut_itr = sim(model, model_cs); 

Where “model” is the Simulink .slx model file and “model_cs” is a Simulink Configuration Setting variable. I have set the Configuration such that the model loads initial states from the workspace, and I have saved the previous iterations final states to that workspace variable. This action occurs for the first iteration as well, though the initial states are the same as the default initial states in the fmu file. I suspect that the first iteration runs without issue because the initialization is the same as the default value, but the subsequent iteration has a different initialization value, which does not agree with the fmu block.

I am aware of the ability to simulate the fmu file in Matlab using the fmi functions, but these methods do not allow for as much transparency into the system states, which hinders the sequential simulation. I am open to any methods that allow this kind of simulation, however.

Any suggestions with regard to initializing the system states in fmu files in Matlab/Simulink are much appreciated. Thank you.


回答1:


I think I have encountered this error before, but not with the FMI Toolbox.

I had issues initializing a Dymola generated FMU more than once in a for-loop very similar to what you described above with the output of one initialization as the input for the next.

Give some random (but reasonably good values) and initialize the model just once such that the initialization is not the same as the default value.

If this works, then in all likelihood, the problem might be in multiple-initializations. Perhaps, you can unload the model at the end of each initialization and then load it again at the beginning of the each loop?

If nothing works, perhaps u can use JModelica.org (open source platform from Modelon) to get the output of these initializations into a mat-file and then use it in MATLAB for subsequent work. I know this is not ideal, but might save you some time while you wait for some answers here.



来源:https://stackoverflow.com/questions/16152546/initialization-of-a-dymola-fmu-in-simulink

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