Documentation Center

  • Trials
  • Product Updates

Contents

findop

Steady-state operating point from specifications (trimming) or simulation

Syntax

[op,opreport] = findop(sys,opspec)
[op,opreport] = findop(sys,opspec,options)
op = findop(sys,tsnapshot)

Description

[op,opreport] = findop(sys,opspec) returns the steady-state operating point of the model that meets the specifications opspec. The Simulink® model must be open. If opspec is a vector of operating points specifications, findop returns a vector of corresponding operating points.

[op,opreport] = findop(sys,opspec,options) searches for the operating point of the model using additional optimization algorithm options specified by options.

op = findop(sys,tsnapshot) simulates the model and extracts operating points at the simulation snapshot time instants (snapshots) tsnapshot.

Input Arguments

sys

Simulink model name, specified as a string inside single quotes (' ').

opspec

Operating point specification object for the model sys, specified using operspec.

opspec can also be a vector of operating point specification objects. If opspec is a vector of operating points specifications, findop returns a vector of corresponding operating points. In this case, findop needs to compile the model only once. Using a vector of operating points allows you to find multiple trimmed operating points without the overhead of compiling the model for each trimming computation.

options

Algorithm options, specified using findopOptions.

tsnapshot

Simulation snapshot time instants when to extract the operating point of the model, specified as a scalar or vector.

Output Arguments

op

Operating point object.

After creating the operating point object, you can modify the operating point states and input levels. For example, op.States(1).x stores the state values of the first model state, and op.Inputs(1).u stores the input level of the first inport block.

The operating point object has these properties:

  • Model — Simulink model name. String.

  • States — State operating points of the Simulink model. Vector of data structures, where each data structure represents the states of one Simulink block. Each States structure has these fields:

    x

    Simulink block state values, specified as a vector of states.

    Ts

    (Only for discrete-time states) Sample time and offset of each Simulink block state, specified as a vector.

    Description

    Block state description, specified as a string.

    Nx (read only)

    Number of states in the Simulink block.

    Block

    Simulink block name.

    SampleType

    State time rate can have the values:

    • 'CSTATE' — Continuous-time state

    • 'DSTATE' — Discrete-time state.

    inReferencedModel

    Determine whether the sates is inside a reference model:

    • 1 — State is inside a reference model.

    • 0 — State is in the current model file.

  • Inputs — Input levels at the operating point. Vector of data structures, where each data structure represents the input levels of one root-level inport block in the Simulink block. Each Inputs data structure has these fields:

    u

    Inport block input levels at the operating point, specified as a vector of input levels.

    Description

    Inport block input description, specified as a string.

    Block

    Inport block name.

    PortWidth

    Number of inport block signals.

  • Time — Time instants for evaluating the time-varying functions in the model.

If opspec is a vector of operating point specification objects, then op is a vector of corresponding operating points.

opreport

Optimization results report object.

This report displays automatically even when you suppress the output using a semicolon. You can avoid displaying the report by using findopOptions to set the DisplayReport field in options to 'off'.

The opreport object has these properties:

  • ModelModel property value of the op object.

  • InputsInputs property value of the op object.

  • OutputsOutputs property value of the op object with the addition of yspec, which is the desired y value.

  • StatesStates property value of the op object with the addition of dx, which are the state derivative values.

  • TimeTime property value of the op object.

  • TerminationString — Optimization termination condition, stored as a string.

  • OptimizationOutput — Optimization algorithm results, returned as a structure with these fields:

    iterations

    Number of iterations performed during the optimization

    funcCount

    Number of function evaluations performed during the optimization

    lssteplength

    Size of line search step relative to search direction (active-set optimization algorithm only)

    stepsize

    Displacement in the state vector at the final iteration (active-set and interior-point optimization algorithms)

    algorithm

    Optimization algorithm used

    firstorderopt

    Measure of first-order optimality, for the trust-region-reflective optimization algorithm; [ ] for other algorithms

    constrviolation

    Maximum of constraint functions

    message

    Exit message

    For more information about the optimization algorithm, see the Optimization Toolbox™ documentation.

Examples

Steady-State Operating Point (Trimming) From Specifications

This example shows how to use findop to compute an operating point of a model from specifications.

  1. Open Simulink model.

    sys = 'watertank';
    load_system(sys);
  2. Create operating point specification object.

    opspec = operspec(sys)

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

     Operating Specification for the Model watertank.
     (Time-Varying Components Evaluated at time t=0)
    
    States: 
    ----------
    (1.) watertank/PID Controller/Integrator
          spec:  dx = 0,  initial guess:             0
    (2.) watertank/Water-Tank System/H
          spec:  dx = 0,  initial guess:             1
    
    Inputs: None 
    ----------
    
    Outputs: None 
    ----------

    operspec extracts the default operating point of the Simulink model with two states. The model does not have any root-level inport blocks and no root-level outport blocks or output constraints.

  3. Configure specifications for the first model state.

    opspec.States(1).SteadyState = 1;
    opspec.States(1).x = 2;
    opspec.States(1).Min = 0;

    The first state must be at steady state and have an initial value of 2 with a lower bound of 0.

  4. Configure specifications for the second model state.

    opspec.States(2).Known = 1;
    opspec.States(2).x = 10;

    The second state sets the desired height of the water in the tank at 10. Configuring the height as a known value keeps this value fixed when computing the operating point.

  5. Find the operating point that meets these specifications.

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

    opreport describes how closely the optimization algorithm met the specifications 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:             0 (0)
    
    Inputs: None 
    ----------
    
    Outputs: None 
    ----------

    dx indicates the time derivative of each state. The actual dx values of zero indicate that the operating point is at steady state. The desired dx value is in parentheses.

 

Steady-State Operating Point to Meet Output Specification

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

  1. Open Simulink model.

    sys = 'scdspeed';
    open_system(sys);
  2. Create operating point specification object.

    opspec = operspec(sys);

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

  3. Configure the output specification.

    blk = [sys '/rad//s to rpm'];
    opspec = addoutputspec(opspec,blk,1);
    opspec.Outputs(1).Known = true;
    opspec.Outputs(1).y = 2000;
    

    addoutputspec adds to the operating point specification an output specification for the output of the block rad/s to rpm. This output specification, stored in opspec.Outputs(1), allows you to specify a fixed output value for that block as part of the operating point specification. Setting the Known attribute of the output specification to true ensures that the fixed output level is a constraint in the operating point search.

  4. Find the operating point that meets the output specification.

    op = findop(sys,opspec);
    bdclose(sys);
     Operating Point Search Report:
    ---------------------------------
    
     Operating Report for the Model scdspeed.
     (Time-Varying Components Evaluated at time t=0)
    
    Operating point specifications were successfully met.
    States: 
    ----------
    (1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
          x:         0.544      dx:      2.66e-13 (0)
    (2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
          x:           209      dx:     -8.48e-12 (0)
    
    Inputs: 
    ----------
    (1.) scdspeed/Throttle  perturbation
          u:       0.00382    [-Inf Inf]
    
    Outputs: 
    ----------
    (1.) scdspeed/rad//s to rpm
          y:         2e+03    (2e+03)

    The search report shows that the operating point search was successful. op is an operating point object that specifies a steady-state operating point for the model scdspeed, in which the output of the rad/s to rpm block is 2000.

 

Operating Points for Multiple Specification Sets

Find operating points for multiple operating point specifications with a single model compilation.

Each time you call findop, the software compiles the Simulink model. To find operating points for multiple specifications, you can give findop a vector of operating point specifications. Then findop only compiles the model once.

  1. Open Simulink model.

    sys = 'scdspeed';
    open_system(sys);
  2. Create operating point specification object.

    opspec1 = operspec(sys);

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

  3. Configure the output specification.

    blk = [sys '/rad//s to rpm'];
    opspec1 = addoutputspec(opspec1,blk,1);
    opspec1.Outputs(1).Known = true;
    opspec1.Outputs(1).y = 1500;
    

    opspec1 specifies a stead-state operating point in which the output of the block rad/s to rpm is fixed at 500.

  4. Create and configure additional operating point specifications.

    opspec2 = copy(opspec1);
    opspec2.Outputs(1).y = 2000;
    
    opspec3 = copy(opspec1);
    opspec3.Outputs(1).y = 2500;
    

    Using the copy command creates an independent operating point specification that you can edit without changing opspec1. Here, the specifications opspec2 and opspec3 are identical to opspec1, except for the target output level.

  5. Find the operating points that meet each of the three output specifications.

    opspecs = [opspec1,opspec2,opspec3];
    ops = findop(sys,opspecs);
    bdclose(sys);

    Pass the three operating point specifications to findop in the vector opspecs. When you give findop a vector of operating point specifications, it finds all the operating points with only one model compilation. ops is a vector of operating point objects for the model scdspeed that correspond to the three specifications in the vector.

 

Initialize Steady-State Operating Point Search Using Simulation

This example shows how to use findop to compute an operating point of a model from specifications, where the initial state values are extracted from a simulation snapshot.

  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.

 

Steady-State Operating Points at Simulation Snapshots

This example shows how to use findop to extract operating points of a model from specifications snapshots.

  1. Open Simulink model.

    sys = 'magball';
    load_system(sys);
  2. Extract an operating point from simulation at 10 and 20 time units.

    op = findop(sys,[10,20]);
  3. Display the first operating point.

    op(1)
     Operating Point for the Model magball.
     (Time-Varying Components Evaluated at time t=10)
    
    States: 
    ----------
    (1.) magball/Controller/PID Controller/Filter
          x: 5.47e-007    
    (2.) magball/Controller/PID Controller/Integrator
          x: 14           
    (3.) magball/Magnetic Ball Plant/Current
          x: 7            
    (4.) magball/Magnetic Ball Plant/dhdt
          x: 8.44e-008    
    (5.) magball/Magnetic Ball Plant/height
          x: 0.05         
     
    Inputs: None 
    ----------
  4. Display the second operating point.

    op(2)
     Operating Point for the Model magball.
     (Time-Varying Components Evaluated at time t=20)
    
    States: 
    ----------
    (1.) magball/Controller/PID Controller/Filter
          x: 2.07e-007    
    (2.) magball/Controller/PID Controller/Integrator
          x: 14           
    (3.) magball/Magnetic Ball Plant/Current
          x: 7            
    (4.) magball/Magnetic Ball Plant/dhdt
          x: 3.19e-008    
    (5.) magball/Magnetic Ball Plant/height
          x: 0.05         
     
    Inputs: None 
    ----------
 

View Operating Point Object

This example shows how to use get to display the operating point states, inputs, and outputs.

sys = 'watertank';
load_system(sys);
op = operpoint(sys)
get(op.States(1))
 

Synchronize Simulink Model Changes With Operating Point Specification

This example shows how to use update to update an existing operating point specification object after you update the Simulink model.

  1. Open Simulink model.

    sys = 'scdspeedctrl';
    open_system(sys);
  2. Create operating point specification object.

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

    opspec = operspec(sys);
  3. In the Simulink Editor, double-click the Reference Filter block. Change the Numerator of the transfer function to [100] and the Denominator to [1 20 100]. Click OK.

  4. Find the steady state operating point that meets these specifications.

    op = findop(sys,opspec)

    This command results in an error because the changes to your model are not reflected in your operating point specification object:

    ??? The model scdspeedctrl has been modified and the operating point
    object is out of date.  Update the object by calling the function
    update on your operating point object.
  5. Update the operating point specification object with changes to the model. Repeat the operating point search.

    opspec = update(opspec);
    op = findop(sys,opspec)
    bdclose(sys);

    After updating the operating point specifications object, the optimization algorithm successfully finds the operating point.

Alternatives

As an alternative to the findop command, find operating points using the Linear Analysis Tool. See the following examples:

More About

expand all

Steady-State Operating Point (Trim Condition)

A steady-state operating point of the model, also called equilibrium or trim condition, includes state variables that do not change with time.

A model might have several steady-state operating points. For example, a hanging pendulum has two steady-state operating points. A stable steady-state operating point occurs when a pendulum hangs straight down. That is, the pendulum position does not change with time. When the pendulum position deviates slightly, the pendulum always returns to equilibrium; small changes in the operating point do not cause the system to leave the region of good approximation around the equilibrium value.

An unstable steady-state operating point occurs when a pendulum points upward. As long as the pendulum points exactly upward, it remains in equilibrium. However, when the pendulum deviates slightly from this position, it swings downward and the operating point leaves the region around the equilibrium value.

When using optimization search to compute operating points for a nonlinear system, your initial guesses for the states and input levels must be in the neighborhood of the desired operating point to ensure convergence.

When linearizing a model with multiple steady-state operating points, it is important to have the right operating point. For example, linearizing a pendulum model around the stable steady-state operating point produces a stable linear model, whereas linearizing around the unstable steady-state operating point produces an unstable linear model.

Tips

  • Initialize operating point search at a simulation snapshot or a previously computed operating point using initopspec.

  • Linearize the model at the operating point op using linearize.

Algorithms

By default, findop uses the optimizer graddescent_elim. To use a different optimizer, change the value of OptimizerType in options using findopOptions.

findop automatically sets these Simulink model properties for optimization:

  • BufferReuse = 'off'

  • RTWInlineParameters = 'on'

  • BlockReductionOpt = 'off'

After the optimization completes, Simulink restores the original model properties.

See Also

| | | |

Tutorials

Was this topic helpful?