Documentation

Steady-State Operating Points (Trimming) from Specifications

Steady-State Operating Point Search (Trimming)

You can compute a steady-state operating point (or equilibrium operating point) using numerical optimization methods to meet your specifications. The resulting operating point consists of the equilibrium state values and model input levels.

Optimization-based operating point computation requires you to specify initial guesses and constraints on the key operating point states, input levels, and model output signals.

You can usually improve your optimization results using simulation to initialize the optimization. For example, you can extract the initial values of the operating point at a simulation time when the model reaches the neighborhood of steady state.

Optimization-based operating point search lets you specify and constrain the following variables at equilibrium:

  • Initial state values

  • States at equilibrium

  • Maximum or minimum bounds on state values, input levels, and output levels

  • Known (fixed) state values, input levels, or output levels

Your operating point search might not converge to a steady-state operating point when you overconstrain the optimization. You can overconstrain the optimization by specifying incompatible constraints or initial guesses that are far away from the desired solution.

You can also control the accuracy of your operating point search by configuring the optimization algorithm settings.

 Examples and How To

 More About

Which States in the Model Must Be at Steady State?

When configuring a steady-state operating point search, you do not always need to specify all states to be at equilibrium. A pendulum is an example of a system where it is possible to find an operating point with all states at steady state. However, for other types of systems, there may not be an operating point where all states are at equilibrium, and the application does not require that all operating point states be at equilibrium.

For example, suppose you build an automobile model for a cruise control application with these states:

  • Vehicle position and velocity

  • Fuel and air flow rates into the engine

If your goal is to study the automobile behavior at constant cruising velocity, you need an operating point with the velocity, air flow rate, and fuel flow rate at steady state. However, the position of the vehicle is not at steady state because the vehicle is moving at constant velocity. The lack of steady state of the position variable is fine for the cruise control application because the position does not have significant impact on the cruise control behavior. In this case, you do not need to overconstrain the optimization search for an operating point by require that all states should be at equilibrium.

Similar situations also appear in aerospace systems when analyzing the dynamics of an aircraft under different maneuvers.

Steady-State Operating Points from State Specifications

This example shows how to compute a steady-state operating point, or equilibrium operating point, by specifying known (fixed) equilibrium states and minimum state values.

This example finds an operating point of a magnetic ball model at which the height of a levitating magnetic ball remains stable at a desired height of 0.05 m.

 Code Alternative

  1. Open the Simulink® model.

    sys = 'magball';
    open_system(sys)

    In this model, the height of the magnetic ball is represent by the plant output, h. Trim the model to find a steady state operating point at which h = 0.05.

  2. In the Simulink Editor, select Analysis > Control Design > Linear Analysis.

    The Linear Analysis Tool for the model opens.

  3. In the Linear Analysis Tool, in the Operating Point drop-down list, select Trim Model.

    By default, in the States tab, the software specifies all model states to be at equilibrium, as shown by the check marks in the Steady State column. The Inputs and Outputs tabs are empty because this model does not have root-level input and output ports.

  4. Specify a fixed height for the magnetic ball.

    In the States tab, select Known for the height state.

    The height of the ball matches the reference signal height (specified in the Desired Height block as 0.05). Since it is known value, the height remains fixed during optimization.

  5. Limit the plant current to positive values.

    Enter 0 for the Minimum bound of the Current state.

    Since a positive current is required to raise the height of the ball, setting he lower bound to 0 limits the optimization solution to the plant operating range.

  6. Click Start trimming to compute the operating point.

    The software uses numerical optimization to find the operating point that meets your specifications.

    The Trim progress viewer shows that the optimization algorithm terminated successfully. The (Maximum Error) Block area shows the progress of reducing the error of a specific state or output during the optimization.

    A new variable, op_trim1, appears in the Linear Analysis Workspace.

  7. Double-click op_trim1 in the Linear Analysis Workspace to evaluate whether the resulting operating point values meet the specifications.

    In the State tab, the Actual Value for each state falls within the Desired Value bounds. The actual height of the ball is 0.05 m, as specified.

    The Actual dx column shows the rates of change of the state values at the operating point. Since these values are at or near zero the states are not changing, showing that the operating point is in a steady state.

 Related Examples

 More About

Steady-State Operating Point to Meet Output Specification

This example shows how to find a steady-state operating point specified by constraint on the value of a block output..

  1. Open the Simulink model.

    sys = 'scdspeed';
    open_system(sys);

    For this example, find a steady-steate operating point at which the engine speed is fixed at 2000 rpm.

  2. In the Simulink Editor, select Analysis > Control Design > Linear Analysis.

  3. In the Linear Analysis Tool, in the Operating Point drop-down list, click Trim Model.

  4. In the Trim the model dialog box, click the Outputs tab to examine the linearization outputs for scdspeed.

    Currently, there are no linearization outputs specified.

  5. Specify the desired signal constraint for the operating point.

    Mark the output signal from the rad/s to rpm block as an output constraint. To do so, in the Simulink Editor, right-click the signal and select Linear Analysis Points > Trim Output Constraint.

    The signal constraint marker appears in the model, indicating that the signal is available for trimming to an output constraint. The signal now appears in the Trim the model dialog, under the Outputs tab.

  6. Specify a value for the output costraint.

    Select Known and specify 2000 rpm for the engine speed value. Press Enter.

  7. Click Start trimming to find a steady-state operating point that meets the specified output constraint.

  8. Double-click op_trim1 in the Linear Analysis Workspace to evaluate whether the resulting operating point values meet the specifications.

    In the State tab, the Actual dx values are at or near zero, showing that the operating point is in a steady state.

    Click on the Output tab.

    The Actual Value and the Desired Value are both 2000 RPM, showing that the output constraint has been satisfied.

 Related Examples

 More About

Initialize Steady-State Operating Point Search Using Simulation Snapshot

Initialize Operating Point Search Using Linear Analysis Tool

This example shows how to use the Linear Analysis Tool to initialize the values of an operating point search using a simulation snapshot.

If you know the approximate time when the model reaches the neighborhood of a steady-state operating point, you can use simulation to get state values to use as the initial conditions for numerical optimization.

  1. Open the Simulink model.

    sys = ('watertank');
    open_system(sys)

  2. In the Simulink Editor, select Analysis > Control Design > Linear Analysis.

  3. In the Linear Analysis Tool, in the Operating Point drop-down list, click Take Simulation Snapshot.

  4. In the Enter snapshot times to linearize dialog box, enter 10 in the Simulation snapshot times field to extract the operating point at this simulation time.

  5. Click Take Snapshots to take a snapshot of the system at the specified time.

    The snapshot, op_snapshot1, appears in the Linear Analysis Workspace and contains all of the system state values at the specified time.

  6. In the Linear Analysis tab, in the Operating Point drop-down list, click Trim Model.

    The Trim the model dialog box opens.

  7. Initialize the operating point states with the simulation snapshot values.

    Click Import.

  8. In the mport initial values and specifications dialog box, select op_snapshot1 and click Import.

    The state values displayed in the Trim the model dialog box update to reflect the imported values.

  9. Click Start trimming to find the optimized operating point using the states at t = 10 as the initial values.

  10. Double-click op_trim1 in the Linear Analysis Workspace to evaluate whether the resulting operating point values meet the specifications.

    The Actual dx values are at or near zero, showing that the operating point is at a steady state.

Initialize Operating Point Search (MATLAB Code)

This example show how to use initopspec to initialize operating point object values for optimization-based operating point search.

  1. Open the Simulink model.

    sys = 'watertank';
    load_system(sys);
  2. Extract an operating point from simulation after 10 time units.

    opsim = findop(sys,10);
  3. Create operating point specification object.

    By default, all model states are specified to be at steady state.

    opspec = operspec(sys);
  4. Configure initial values for operating point search.

    opspec = initopspec(opspec,opsim);
  5. Find the steady state operating point that meets these specifications.

    [op,opreport] = findop(sys,opspec)
    bdclose(sys);

    opreport describes the optimization algorithm status at the end of the operating point search.

     Operating Report for the Model watertank.
     (Time-Varying Components Evaluated at time t=0)
    
    Operating point specifications were successfully met.
    States: 
    ----------
    (1.) watertank/PID Controller/Integrator
          x:          1.26      dx:             0 (0)
    (2.) watertank/Water-Tank System/H
          x:            10      dx:     -1.1e-014 (0)
    
    Inputs: None 
    ----------
    
    Outputs: None 
    ----------

    dx, which is the time derivative of each state, is effectively zero. This value of the state derivative indicates that the operating point is at steady state.

 Related Examples

 More About

Compute Steady-State Operating Points for SimMechanics Models

This example shows how to compute the steady-state operating point of a SimMechanics™ model from specifications.

    Note:   You must have SimMechanics software installed to execute this example on your computer.

  1. Open the SimMechanics model.

    sys = 'scdmechconveyor';
    open_system(sys);

  2. Double-click the Env block to open the Block Parameters dialog box. This block represents the operating environment of the model.

  3. Add an output port to the model with constraints that must be satisfied to ensure a consistent SimMechanics machine.

    In the Parameters tab, set the Analysis mode to Trimming. Click OK.

  4. In the Simulink Editor, select Analysis > Control Design > Linear Analysis.

  5. In the Linear Analysis Tool, in the Operating Point drop-down list, click Trim Model.

    The Trim the model dialog box appears.

    By default, the software specifies all model states to be at equilibrium, as shown in the Steady State column.

  6. In the Outputs tab, select Known to set all constraints to 0.

    The listed outputs were added to the system when the Env block Analysis mode was set to Trimming. These output error signals must be constrained to zero during the steady-state operating point search.

You can now specify additional constraints on the operating point states and input levels, and find the steady-state operating point for this model.

After you finish the steady-state operating point search for the SimMechanics model, reset the Env block Analysis mode to Forward dynamics.

 Related Examples

Batch Compute Steady-State Operating Points Reusing Generated MATLAB Code

This example shows how to batch compute steady-state operating points for a model using generated MATLAB® code. You can batch linearize a model using the operating points and study the change in model behavior.

If you are new to writing scripts, use the Linear Analysis Tool to interactively configure your operating points search. You can use Simulink Control Design™ to automatically generate a script based on your Linear Analysis Tool settings.

  1. Open the Simulink model.

    sys = 'magball';
    open_system(sys);
  2. In the Simulink Editor, select Analysis > Control Design > Linear Analysis.

    The Linear Analysis Tool for the model opens.

  3. In the Linear Analysis Tool, in the Operating Point drop-down list, click Trim Model.

    The Trim the model dialog box opens.

    By default, the software specifies all model states to be at equilibrium, as shown in the Steady State column.

  4. In the States tab, select the Known check box for the magball/Magnetic Ball Plant/height state.

  5. Click Start trimming to compute the operating point using numerical optimization.

    The Trim progress viewer shows that the optimization algorithm terminated successfully. The (Maximum Error) Block area shows the progress of reducing the error of a specific state or output during the optimization.

  6. In the Trim the model dialog box, click Generate MATLAB Script

    The MATLAB Editor window opens with an automatically generated script.

  7. Modify the script to trim the model at multiple operating points.

    1. Remove unneeded comments from the generated script.

    2. Define the height variable, height, with values at which to compute operating points.

    3. Add a for loop around the operating point search code to compute a steady-state operating point for each height value. Within the loop, before calling findop, update the reference ball height, specified by the Desired Height block.

    Your script should now look similar to this:

    %% Specify the model name
    model = 'magball';
    
    %% Create the operating point specification object.
    opspec = operspec(model);
    
    % State (5) - magball/Magnetic Ball Plant/height
    % - Default model initial conditions are used to initialize optimization.
    opspec.States(5).Known = true;
    
    %% Create the options
    opt = findopOptions('DisplayReport','iter');
    
    %% Specify ball heights at which to compute operating points
    height = [0.05;0.1;0.15];
    
    %% Loop over height values to find the corresponding operating points
    for i=1:length(height)
        % Set the ball height in the specification
        opspec.States(5).x = height(i);
        
        % Update the model ball haight reference parameter
        set_param('magball/Desired Height','Value',num2str(height(i)));
        
        % Trim the model
        [op(i),opreport(i)] = findop(model,opspec,opt);
    end

    After running this script, op contains operating points corresponding to each of the specified height values.

 See Also

Change Operating Point Search Optimization Settings

This example shows how to control the accuracy of your operating point search by configuring the optimization algorithm.

Typically, you adjust the optimization settings based on the operating point search report, which is automatically created after each search.

 Code Alternative

  1. In the Linear Analysis Tool, open the Linear Analysis tab. In the Operating Point drop-down list, click Trim Model.

  2. In the Trim the model dialog box, select the Options tab.

  3. Configure your operating point search by selecting an optimization method and changing the appropriate settings.

    This table lists the most common optimization settings.

Optimization StatusOption to ChangeComment
Optimization ends before completing (too few iterations)Maximum iterationsIncrease the number of iterations
State derivative or error in output constraint is too largeFunction tolerance or Constraint tolerance (depending on selected algorithm)Decrease the tolerance value

    Note:   You can get help on each option by right-clicking the option label and selecting What's This?.

 Related Examples

 More About

Was this topic helpful?