Main Content

simscape.getLocalSolverFixedCostInfo

Determine iteration requirement when transitioning to fixed cost

    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.

    myModel = 'ssc_dcmotor';
    open_system(myModel)

    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. Then click OK.

    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(myModel)
    s = 
    
      struct with fields:
    
           SolverPath: 'ssc_dcmotor/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, and click OK. 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.

    Introduced in R2021b