Documentation Center

  • Trial Software
  • Product Updates

Contents

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.

 Code Alternative

  1. Open 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 tab, click Trim Model. Then click Specifications.

    The Specifications for trim dialog box opens.

    By default, 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. 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). This height value should remain fixed during the optimization.

  5. Enter 0 for the minimum bound of the Current state.

  6. Click to compute the operating point.

    This action 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 Linear Analysis Workspace to evaluate whether the resulting operating point values meet the specifications.

    The Actual dx values are about 0, which indicates that the operating point meets the steady state specification.

    The Actual Value of the states falls within the Desired Value bounds.

  8. (Optional) To automatically generate a MATLAB® script, click Trim and select Generate MATLAB Script.

    The generated script contains commands for computing the operating point for this example.

 Related Examples

 More About

Steady-State Operating Point to Meet Output Specification

This example shows how to specify an output constraint of an engine speed for computing the engine steady-state operating point.

  1. Open Simulink model.

    sys = 'scdspeed';
    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 tab, click Trim Model. Then click Specifications.

    The Specifications for trim dialog box appears.

  4. Examine the linearization outputs for scdspeed in the Outputs tab.

    Currently there are no outputs specified for scdspeed.

  5. In the Simulink Editor, right-click the output signal from the rad/s to rpm block. Select Linear Analysis Points > Trim Output Constraint.

    This action adds the output signal constraint marker to the model.

    The output signal from the rad/s to rpm block now appears under the Outputs tab.

  6. Select Known and enter 2000 RPM for the engine speed as the output signal value. Press Enter.

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

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

    In the States tab, the Actual dx values are either zero or about zero. This result indicates that the operating point meets the steady state specification.

    In the Outputs tab, the Actual Value and the Desired Value are both 2000.

 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 the state values to be used as the initial condition for numerical optimization.

  1. Open Simulink model.

    sys = ('watertank');
    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 tab, click Operating Point Snapshot

    The Operating Point Snapshots tab opens.

  4. Enter 10 in the Simulation Snapshot Times field to extract the operating point at this simulation time. Press Enter.

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

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

  5. In the Linear Analysis tab, click Trim Model. Then click Specifications.

    The Specifications for trim dialog box appears.

  6. Click Import.

    The Import initial values and specifications dialog opens.

  7. Select op_snapshot1 and click Import to initialize the operating point states with the values you obtained from the simulation snapshot.

    The state values displayed in the Specifications for trim dialog box update to reflect the new values.

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

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

    The Actual dx values are near zero. This result indicates that the operating point meets the steady state specifications.

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 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 installed SimMechanics software 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.

  3. In the Parameters tab, select Trimming as the Analysis mode. Click OK.

    This action adds an output port to the model with constraints that must be satisfied to a ensure a consistent SimMechanics machine.

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

    The Linear Analysis Tool for the model opens.

  5. In the Linear Analysis tab, click Trim Model. Then click Specifications.

    The Specifications for trim dialog box appears.

    By default, the software specifies all model states to be at equilibrium (as shown in the Steady State column). The Outputs tab shows the error constraints in the system that must be set to zero for steady-state operating point search.

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

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 steady-state operating point search for the SimMechanics model, reset the Analysis mode to Forward dynamics in the Env block parameters dialog box.

 More About

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. Open the Linear Analysis Tool for the model.

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

  3. Open the Specifications for trim dialog box.

    In the Linear Analysis tab, click Trim Model. The Trim Model tab should open.

    Click Specifications.

    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 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. Click Generate MATLAB Script in the Trim list to automatically generate a MATLAB script.

    The MATLAB Editor window opens with the generated script.

  7. Edit the script:

    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, you must update the reference ball height, specified by the Desired Height block.

    Your script should now look similar to this (excluding most comments):

    function [op,opreport] = myoperatingpointsearch
    
    %% Specify the model name
    sys = 'magball';
    load_system(sys)
     
    %% Create operating point specification object
    opspec = operspec(sys)
     
    % 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 the ball heights at which to compute operating points
    height = [0.05;0.1;0.15];
    
    %% Loop over height values to find the corresponding steady-state 
    %% operating points
    for ct = 1:numel(height)
        % Set the ball height in the specification
        opspec.States(5).x = height(ct);
        
        % Update model parameter
        set_param('magball/Desired Height','Value',num2str(height(ct)));
        
        % Trim the model
        [op(ct),opreport(ct)] = findop(sys,opspec,opt);
    end

 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. Click Trim Model and click Optimization Options.

    This action opens the Options for trim dialog box.

  2. Change the appropriate optimization 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?