Modeling Considerations with Algebraic Loops
Managing Large Models with Artificial Algebraic Loops
Adopt these design techniques for large models with algebraic loops:
Avoid creating loops that contain discontinuities or data types other than double. The algebraic loop solver is gradient-based and must solve algebraic constraints to high precision.
Develop a scheme for clearly identifying atomic subsystems as having direct feedthrough or not having direct feedthrough. Use a visual scheme such as color coding the blocks or defining a block naming convention.
If you plan to generate code for your model:
Enable the Minimize artificial algebraic loop occurrences parameter for all atomic subsystems.
Clear the Single output/update function (Simulink Coder) parameter and select the Minimize artificial algebraic loop occurrences parameter for all referenced models.
When possible, make sure that no input ports in the atomic subsystems and referenced models connect directly to blocks that have direct feedthrough.
Avoid using the Bus Creator block or the Mux block to combine paths that have direct feedthrough and paths that do not have direct feedthrough. The software might not be able to eliminate any resulting artificial algebraic loops. Instead, consider separating the paths that have direct feedthrough and the paths that do not have direct feedthrough in separate subsystems.
Use Bus Selector blocks to pass only the required signals into atomic subsystems.
Model Blocks and Direct Feedthrough
When a Model block is part of a cycle, and the block has direct feedthrough, an algebraic loop can result. An algebraic loop in a model is not necessarily an issue, but it can give unexpected results. See:
Highlight Algebraic Loops in the Model for information about seeing algebraic loops graphically.
The Model Configuration Parameters: Diagnostics pane Algebraic loop option for information on detecting algebraic loops automatically.
Referenced Model Structure and Model Block Direct Feedthrough Caused
A Model block can have direct feedthrough due to the structure of the referenced model. Where direct feed through results from the structure of the referenced model and causes an unwanted algebraic loop, you can:
Eliminate artificial algebraic loops using techniques described in:
Manually insert the number of Unit Delay blocks needed to break the algebraic loop.
Direct Model Block Feedthrough Caused by Model Configuration
The Single output/update function (Simulink Coder)
parameter controls whether code generated for Generic Real Time
(grt) and Embedded Real Time (ert) targets
contains a single function to combine output and update or separate functions for
output and update. For more information, see Configure Generated C Function Interface for Model Entry-Point Functions (Simulink Coder).
By default, the Single output/update function parameter is enabled. When Single output/update function is enabled, Model blocks have a combined output and update function. As a result of combining the output and update functions, all input ports of the Model block have direct feedthrough, regardless of the structure of the referenced model. Where an unwanted algebraic loop or artificial algebraic loop results, you can:
Clear the Single output/update function parameter in the referenced model. The code for the Model block then has separate output and update functions, eliminating direct feedthrough caused by combining the output and update functions.
Select the Minimize artificial algebraic loop occurrences parameter in the referenced model.
Manually insert one or more Unit Delay blocks as needed to break the algebraic loop.
Changing Block Priorities When Using Algebraic Loop Solver
During the updating phase of simulation, Simulink® determines the simulation execution order of block methods. This block invocation ordering is the execution order.
If you assign priorities to nonvirtual blocks to indicate to Simulink their execution order relative to other blocks, the algebraic loop solver does not honor these priorities when attempting to solve any algebraic loops.