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 nondouble data types. The algebraic loop solver is gradient-based and must solve algebraic constraints to high precision.
Develop a scheme for clearly identifying atomic subsystems as direct feedthrough or not direct feedthrough. Use a visual scheme such as coloring the blocks or defining a block-naming convention.
If you plan to generate code for your model, enable the Minimize algebraic loop occurrences parameter for all atomic subsystems. When possible, make sure that the input ports for the atomic subsystems are connected directly to non-direct-feedthrough blocks.
Avoid combining non-direct-feedthrough and direct-feedthrough paths using the Bus Creator or Mux blocks. The software might not be able to eliminate any resulting artificial algebraic loops. Instead, consider clustering the non-direct-feedthrough and direct-feedthrough objects 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 error, 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.
Direct Model Block Feedthrough Caused by Referenced Model Structure
A Model block can be a direct feed through block due to the structure of the referenced model. Where direct feed through results from sub model structure, and causes an unwanted algebraic loop, you can:
Automatically eliminate the algebraic loop 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
Generic Real Time (
grt) and Embedded Real Time
ert) based targets provide the Single
output/update function option on the Configuration
Parameters dialog. This option controls whether generated code has
separate output and update functions, or a combined output/update function.
Configure Generated C Function Interface for Model Entry-Point Functions (Simulink Coder) for information about separate and combined output and update functions.
Single output/update function (Simulink Coder) for information about specifying whether code has separate or combined functions.
When Single output/update function is enabled (default), a Model block has a combined output/update function. The function makes the block a direct feed through block for all inports, regardless of the structure of the referenced model. Where an unwanted algebraic loop results, you can:
Disable Single output/update function. The code for the Model block then has separate output and update functions, eliminating the direct feed through and hence the algebraic loop.
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.