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.