Feeding initial states to a FMU block (FMIKit) in MATLAB

537 views Asked by At

I am using Dymola 2020x to develop a thermal model and export the FMU to Simulink to simulate controllers. For implementing advanced controllers, I require an iteratively run framework, which helps to initialize the states after every iteration to the values at end of every previous simulation. This can be done within Dymola through “import initial” and “Continue” commands in the Simulation tab of Dymola. However, since I am designing the controller in MATLAB, I require a similar feature for that platform. The only way I know right now is to manually change the initial conditions in the FMU block, but since I have a lot of states, it would not be feasible to do it manually. Any scripting ideas are welcome as well.

All in all, I require a framework/method to be able to initialize states of my model through MATLAB/Simulink to the values I get after running a single iteration.

Some help would be appreciated.

1

There are 1 answers

0
Christian Bertsch On

Expose the initial conditions of the variables as parameters, and set them from MATLA Scripts with e.g.

FMIKit.setStartValue(gcb, 'step', 'true')

see https://github.com/CATIA-Systems/FMIKit-Simulink/blob/master/docs/fmu_import.md