Unexpected NaN output from power block

10 views (last 30 days)
Quint
Quint on 17 Dec 2024
Commented: Quint on 18 Dec 2024
While building my model I came across the following integrator error:
  • Derivative of state '1' in block 'simpie/Motor & PI Current Controller/Integrator' at time 4.519405258285984 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)
After some investigation I found by setting the INF or NaN block output to warning that there are NaN values that are contaminating my feedback loop which in turn raises the integrator error. By setting the INF or NaN block output setting to warning I tried to figure out where the first NaN value comes from. This raises the following error:
An error occurred during simulation and the simulation was terminated
Caused by:
From reading the documentation about the power block, it became clear that the block will output a NaN value from an NaN input. I assume that there is no NaN input into the power block since this is the first NaN output. I tried to use the isnan block to monitor the generated NaN value without succes. The block does not recognice any NaN output. The error occurs at a specific point in time where the value into the power block for the base come close to zero (See the included figure). The exponent is a constant.
Strangely the simulation works fine for t<1 which also has an input of 0 for the power block.
Does anyone have a clue what causes this problem and how to fix it?
Thank you in advance
  3 Comments
Walter Roberson
Walter Roberson on 17 Dec 2024
I suggest that instead of testing using isnan() that you instead test ~isfinite() as that also tests for +/- inf
Quint
Quint on 17 Dec 2024
Here is my simulink model file with corresponding data. I tried the isfinite() function without succes. Additionally, the problem arises when the base of the power block is almost zero. I kind of fixed the issue to round the value before the powerblock to zero when it almost reaches zero. There are still some NaN values in my simulation but now it does not crash anymore.

Sign in to comment.

Accepted Answer

Vinay
Vinay on 18 Dec 2024
Edited: Vinay on 18 Dec 2024
Hi @Quint,
The occurrence of 'NaN' output when the base of the power block is close to zero is due to the "Power Signedness" functionality of the power block.
To avoid the 'NaN' output when an even order root is used as the power value, the "Signed power" option should be enabled.
Refer to the below documentation of power block for more details on the "Signed Power" functionality:
I hope this would resolve the issue!

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!