MATLAB: Do I get algebraic loop error when using PV Array

Simscape

When I try to run the PV Array in Simscape, the following error is returned:
Block diagram 'pvArray' contains 1 algebraic loop(s). To see more details about the loops use the command Simulink.BlockDiagram.getAlgebraicLoops('pvArray') or the command line Simulink debugger by typing sldebug('pvArray') in the MATLAB command window. To eliminate this message, set Algebraic loop to "none".
Component:Simulink | Category:Block diagram warning
Found algebraic loop containing:
pvArray/PV Array/Diode Rsh/Product5 (algebraic variable)
pvArray/PV Array/Diode Rsh/Product2
pvArray/PV Array/Diode Rsh/Product1
pvArray/PV Array/Diode Rsh/Math Function
pvArray/PV Array/Diode Rsh/Add
pvArray/PV Array/Diode Rsh/Product
pvArray/PV Array/Diode Rsh/Add1
pvArray/powergui/EquivalentModel1/State-Space
pvArray/PV Array/I_PV/do not delete this gain
pvArray/PV Array/I Filter/First-Order Filter/Model/D
pvArray/PV Array/I Filter/First-Order Filter/Model/Sum1 (algebraic variable)
pvArray/PV Array/Product2
pvArray/PV Array/V_PV/do not delete this gain
pvArray/PV Array/V Filter/First-Order Filter/Model/D
pvArray/PV Array/V Filter/First-Order Filter/Model/Sum1
pvArray/PV Array/Add1 (algebraic variable)
Component:Simulink | Category:Model
An error occurred while running the simulation and the simulation was terminated
Caused by:
Algebraic state in algebraic loop containing 'pvArray/PV Array/I Filter/First-Order Filter/Model/Sum1' computed at time 3.5826011128367485E-8 is Inf or NaN. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)

Best Answer

The error is likely resulted from the algebraic loop inside the PV Array as described in this page:
By default the "Break algebraic loop in internal model" parameter is not selected. This means that the PV Array has an algebraic loop in it. If you use the block in a discrete system using large sample times, this algebraic loop is required to get an iterative, accurate solution for the highly nonlinear diode characteristics. For continuous system, when the PV array block is connected to a detailed power electronic converter where real switches are simulated, you need to specify a small sample time to get accurate resolution in PWM pulse generation (for example, 1e-6 sec with a 5 kHz PWM inverter).
If you do not want to break the algebraic loop and you know that your model is correct, please consider the following:
1) Reducing the error tolerances (Relative tolerance and Absolute tolerance in Solver tab of the Configuration Parameters) of the solver as suggested by the error message. This might slow down the computation.
2) Changing the solver to ode23tb which typically works better when you have Simscape components in your model.
Additionally, please be aware of the measurement filter time constant in the advanced tab for PV Array blocks. If the time constant is zero, the solver will have a harder time solving the model with an algebraic loop.
Related Question