Contents

operspec

Operating point specifications

Syntax

opspec = operspec(sys)

Description

opspec = operspec(sys) returns the operating point specifications object for steady state operating point analysis using findop. The Simulink® model must be open.

Input Arguments

sys

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

Output Arguments

opspec

Operating point specification object.

After creating the operating point object, you can modify the operating point states and input levels. For example, opspec.States(1).Known = 1 specifies that the first model state value is known, and the value of the known state opspec.States(1).x = 2.

The operating point object has these properties:

  • Model — Simulink model name. String.

  • States — State operating point specification. Vector of data structures, where each data structure represents the supported states of one Simulink block. (For a list of supported states for operating point objects, see Simulink Model States Included in Operating Point Object.)

    Each States structure has these fields:

    x

    Simulink block state values, specified as a vector of states. This vector includes all supported states.

    When you set the value of a state that you want fixed during operating-point search with findop, also set the Known field of the States property for that state to 1.

    Known

    Known state value specification:

    • 1 — Known value that is fixed during operating point search.

    • 0 (default) — Unknown value to be found by optimization.

    When you set this field to 1 to fix a state during operating-point search, also specify the desired operating-point value of that state using the x field of the States structure.

    SteadyState

    Steady state value specification:

    • 1 (default) — Equilibrium state.

    • 0 — Nonequilibrium state.

    Min

    Minimum bounds on the state value, specified as a scalar or vector.

    Max

    Maximum bounds on the state value, specified as a scalar or vector.

    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

    Vector indicating whether each state is inside a reference model:

    • 1 — State is inside a reference model.

    • 0 — State is in the current model file.

  • Inputs — Input level specifications at the operating point. Vector of input specification objects, where each object represents the input levels of one root-level inport block in the Simulink block. Each input specification object has these properties:

    u

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

    Also set the Known field of the Inputs property for known input levels that remain fixed during operating point search.

    Known

    Known input level specification:

    • 1 — Known input level that is fixed during operating point search.

    • 0 (default) — Unknown input level to be found by optimization.

    Also specify the known operating point input levels using the u property of the input specification object.

    Min

    Minimum bounds on the input level, specified as a scalar or vector.

    Max

    Maximum bounds on the input level, specified as a scalar or vector.

    Description

    Inport block input description, specified as a string.

    Block

    Inport block name.

    PortWidth

    Number of inport block signals.

  • Outputs — Output level specifications at the operating point. Vector of output specification objects, where each object represents one output specification per root-level output block in the Simulink block. You can constrain additional output levels using addoutputspec to add another output specification.

    Each output specification object has these properties:

    y

    Outport block output levels at the operating point, specified as a vector of output levels.

    Also set the Known field of the Outputs property for known output levels that remain fixed during operating point search.

    Known

    Known output level specification:

    • 1 — Known output level constraint that must be met during operating point search.

    • 0 (default) — Unknown input level to be found by optimization.

    Also specify the known operating point output levels using the y property of the output specification object.

    Min

    Minimum bounds on the output level, specified as a scalar or vector.

    Max

    Maximum bounds on the output level, specified as a scalar or vector.

    Description

    Outport block input description, specified as a string.

    Block

    Outport block name.

    PortWidth

    Number of outport block signals.

  • Time — Time instants for evaluating the time-varying functions in the 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.

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.

Operating Point (Trim Analysis) With Output Constraint

This example shows how to use addoutputspec to specify an output constraint to the operating point specification object for computing the operating point.

  1. Open Simulink model.

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

    opspec = operspec(sys)

    By default, opspec specifies that the operating point is at steady state, or equilibrium.

     Operating Specification for the Model scdspeed.
     (Time-Varying Components Evaluated at time t=0)
    
    States: 
    ----------
    (1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
          spec:  dx = 0,  initial guess:         0.543
    (2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
          spec:  dx = 0,  initial guess:           209
    
    Inputs: 
    ----------
    (1.) scdspeed/Throttle  perturbation
          initial guess: 0            
    
    Outputs: None 
    ----------

    operspec extracts the default operating point of the Simulink model with two states and one root-level inport block. There are no root-level outport blocks or output constraints.

  3. Fix the first output port of the Vehicle Dynamics to 2000 RPM.

    opspec = addoutputspec(op_spec,'scdspeed/rad//s to rpm',1);
    opspec.Outputs.Known = 1;
    opspec.Outputs.y = 2000;
  4. Find the operating point that meets this specification.

    op = findop(sys,op_spec)
     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-013 (0)
    (2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
          x:           209      dx:    -8.48e-012 (0)
    
    Inputs: 
    ----------
    (1.) scdspeed/Throttle  perturbation
          u:       0.00382    [-Inf Inf]
    
    Outputs: 
    ----------
    (1.) scdspeed/rad//s to rpm
          y:        2e+003    (2e+003)

More About

expand all

Tips

  • Use get to display the operating point specification object properties.

Was this topic helpful?