MATLAB: Does the Algebraic Constraint block not constrain the input to zero in Simulink 4.1 (R12.1)

r12.1simulink

The Algebraic Constraint block does not constrain the input to zero in Simulink 4.1 (R12.1).

Best Answer

The issue is being caused by the fact that Simulink resolves the algebraic loop using a Newton-Raphson iteration, which works well when the initial condition (given in the block) is close to a solution. The problem is that you do not always know a good initial condition, and the resulting Newton-Raphson iteration often does not converge, leaving a "z" value that does not give f(z)=0. This is not a bug in Simulink since all nonlinear solution methods sometimes fail to converge for certain problems and certain initial conditions.
As a workaround, a new type of algebraic loop solver has been added to Simulink 5.0 (R13). To use this solver, at the MATLAB prompt type,
set_param(model,'AlgebraicLoopSolver',solverOption);
where solver option can be either 'TrustRegion' (the default), or 'LineSearch'. Both the default loop solver, and the new line search method are variants of a Newton-Rhaphson method. The hidden parameter 'AlgebraicLoopSolver' was made available in Simulink 6.2 (R14SP2). For more information on algebraic loop solvers in Simulink, see the Related Solution "How exactly does Simulink 6.0 (R14) and Simulink 6.1 (R14SP1) solve algebraic loops?"