You can compute a steadystate 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.
Optimizationbased 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.
Optimizationbased 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 steadystate 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.
When configuring a steadystate 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.
This example shows how to compute a steadystate 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.
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.
In the Simulink Editor, select Analysis > Control Design > Linear Analysis.
The Linear Analysis Tool for the model opens.
In the Linear Analysis Tool, in the Operating
Point dropdown 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 rootlevel input and output ports.
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.
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.
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.
Doubleclick 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.
This example shows how to find a steadystate operating point specified by constraint on the value of a block output..
Open the Simulink model.
sys = 'scdspeed';
open_system(sys);
For this example, find a steadysteate operating point at which the engine speed is fixed at 2000 rpm.
In the Simulink Editor, select Analysis > Control Design > Linear Analysis.
In the Linear Analysis Tool, in the Operating
Point dropdown list, click Trim Model
.
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.
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, rightclick
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.
Specify a value for the output costraint.
Select Known and specify 2000
rpm
for the engine speed value. Press Enter.
Click Start trimming to find a steadystate operating point that meets the specified output constraint.
Doubleclick 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.
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 steadystate operating point, you can use simulation to get state values to use as the initial conditions for numerical optimization.
Open the Simulink model.
sys = ('watertank');
open_system(sys)
In the Simulink Editor, select Analysis > Control Design > Linear Analysis.
In the Linear Analysis Tool, in the Operating
Point dropdown list, click Take Simulation
Snapshot
.
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.
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.
In the Linear Analysis tab, in
the Operating Point dropdown list, click Trim
Model
.
The Trim the model dialog box opens.
Initialize the operating point states with the simulation snapshot values.
Click Import.
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.
Click Start trimming to find
the optimized operating point using the states at t = 10
as
the initial values.
Doubleclick 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.
This example show how to use initopspec
to
initialize operating point object values for optimizationbased operating
point search.
Open the Simulink model.
sys = 'watertank';
load_system(sys);
Extract an operating point from simulation after 10 time units.
opsim = findop(sys,10);
Create operating point specification object.
By default, all model states are specified to be at steady state.
opspec = operspec(sys);
Configure initial values for operating point search.
opspec = initopspec(opspec,opsim);
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. (TimeVarying 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/WaterTank System/H x: 10 dx: 1.1e014 (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.
This example shows how to compute the steadystate operating point of a SimMechanics™ model from specifications.
Note: You must have SimMechanics software installed to execute this example on your computer. 
Open the SimMechanics model.
sys = 'scdmechconveyor';
open_system(sys);
Doubleclick the Env
block to open
the Block Parameters dialog box. This block represents the operating
environment of the model.
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.
In the Simulink Editor, select Analysis > Control Design > Linear Analysis.
In the Linear Analysis Tool, in the Operating
Point dropdown 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.
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 steadystate
operating point search.
You can now specify additional constraints on the operating point states and input levels, and find the steadystate operating point for this model.
After you finish the steadystate operating point search for
the SimMechanics model, reset the Env block Analysis
mode to Forward dynamics
.
This example shows how to batch compute steadystate 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.
Open the Simulink model.
sys = 'magball';
open_system(sys);
In the Simulink Editor, select Analysis > Control Design > Linear Analysis.
The Linear Analysis Tool for the model opens.
In the Linear Analysis Tool, in the Operating
Point dropdown 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.
In the States tab, select the Known check box for the magball/Magnetic Ball Plant/height state.
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.
In the Trim the model dialog box, click Generate MATLAB Script
The MATLAB Editor window opens with an automatically generated script.
Modify the script to trim the model at multiple operating points.
Remove unneeded comments from the generated script.
Define the height variable, height
,
with values at which to compute operating points.
Add a for
loop around the operating
point search code to compute a steadystate 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.
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.
In the Linear Analysis Tool, open the Linear Analysis tab. In the Operating Point dropdown list, click Trim Model.
In the Trim the model dialog box, select the Options tab.
Configure your operating point search by selecting an optimization method and changing the appropriate settings.
This table lists the most common optimization settings.
Optimization Status  Option to Change  Comment 

Optimization ends before completing (too few iterations)  Maximum iterations  Increase the number of iterations 
State derivative or error in output constraint is too large  Function tolerance or Constraint tolerance (depending on selected algorithm)  Decrease the tolerance value 
Note: You can get help on each option by rightclicking the option label and selecting What's This?.
