Main Content

simscape.getLocalSolverFixedCostInfo

Determine iteration requirement when transitioning to fixed cost

Since R2021b

    Description

    example

    s = simscape.getLocalSolverFixedCostInfo(modelName) returns a structure array with the fields SolverPath and MaxIterations, which report the network path to the Solver Configuration block and the optimal value to enter in the Nonlinear iterations parameter of the Solver Configuration block. MaxIterations returns -1 if the simulation fails to converge.

    Examples

    collapse all

    This example uses the model from the Permanent Magnet DC Motor example to demonstrate how to use the simscape.getLocalSolverFixedCostInfo function. The function returns the number of iterations to enter in the Nonlinear iterations parameter of the Solver Configuration block.

    openExample('simscape/PermanentMagnetDCMotorExample')
    

    Once the model opens, double-click the Solver Configuration block. Check the Use local solver check box, and uncheck the Use fixed-cost runtime consistency iterations check box.

    Note

    If you leave Use fixed-cost runtime consistency iterations checked, the function only tries the number of iterations specified in the Nonlinear iterations parameter, otherwise it tries 100 iterations.

    Return to the Command Window.

    s = simscape.getLocalSolverFixedCostInfo('PermanentMagnetDCMotor')
    s = 
    
      struct with fields:
    
           SolverPath: 'PermanentMagnetDCMotor/Solver↵Configuration'
        MaxIterations: 2

    The MaxIterations field reports that this model requires 2 iterations per step to run as a fixed step, fixed cost simulation.

    Open the model, and check the Use fixed-cost runtime consistency iterations parameter box for the Solver Configuration block. Enter the value from the MaxIterations field for the Nonlinear iterations parameter. The model is now optimized for a fixed-step, fixed-cost solver.

    Input Arguments

    collapse all

    Model name as a character vector or string scalar. If the model is not on the MATLAB® path, the model name must include the full path.

    Data Types: char | string

    Assumptions and Limitations

    • The function does not support Simscape™ Multibody™ networks.

    • The function does not support rapid accelerator mode.

    • The function does not support fast restart.

    Version History

    Introduced in R2021b