Skip to Main Content Skip to Search
Product Documentation

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.

[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) t.

Tips

Input Arguments

sys

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

opspec

Operating point specification object, specified using operspec.

options

Algorithm options, specified using linoptions.

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.

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 linoptions 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

     

    funcCount

    lssteplength

    stepsize

    algorithm

     

    firstorderopt

     

    constrviolation

     

    message

     

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

Definitions

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.

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 = '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.

  3. Configure the output specification.

    opspec.Outputs(1).y = 2000;
    opspec.Outputs(1).Known = true;
  4. Find the operating point that meets the output specification.

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

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 model window, 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.

Algorithms

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

findop automatically sets these Simulink model properties for optimization:

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

Alternatives

Use the Control and Estimation Tools Manager.

See Also

initopspec | linearize | linoptions | operspec

Tutorials

How To

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS