Christopher Stuart
Christopher Stuart

Reputation: 23

Feedback loops using real signals: How to initialize the model?

I'm transferring a legacy model from Simulink to Dymola that includes a feedback loop where an output signal is passed back to the input for decay calculations. In Simulink, a memory block is used to create a one integration time step delay and also to initialize the signals. I attempted to use a unit step delay in Dymola, however we do not use a fixed-step solver and the model diverged. Fixed delay also did not work as expected

Are there any suggestions on how to pass the output to input while initializing properly? These signals are all of type "Real".

Upvotes: 2

Views: 664

Answers (1)

Markus A.
Markus A.

Reputation: 7525

The Memory block in Simulink delays a signal for one time step of the continuous integration (if not placed in an iterator subsystem). When combined with a variable-step solver, the result is a variable delay depending on the solver step size. In my opinion this is actually a pretty dangerous operation from the perspective of stability and repeatability.

In Dymola (and I assume OpenModelica) there is no equivalent block available, therefore I think it will not be possible to "exactly" reproduce the same behavior. I guess this would be difficult anyway, with the solver likely choosing different step-sizes.

Besides that, there is a good chance that you can just remove the block and connect the the feedback loop directly in any Modelica-based tool, as these will likely handle the algebraic loop symbolically and solve it for you. For initialization you could use a initial equation or the start attribute. Still it is a bit difficult to judge which solution would work well without some example code.

If closing the loop directly is not an option, I would suggest to use a FirstOrder (Modelica.Blocks.Continuous.FirstOrder) block instead of a delay. As this is a continuous block it should give better performance and more predictable behavior compared to the Memory block. As well it will enable you to initialize its output value with multiple options.

Upvotes: 5

Related Questions