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 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 drop-down list, click
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.
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 drop-down list, click
The Trim the model dialog box opens.
Initialize the operating point states with the simulation snapshot values.
In the Import initial values and specifications dialog box, select
op_snapshot1, and click
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.
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 shows how to initialize operating point values for optimization-based operating searches.
Open the Simulink model.
sys = 'watertank'; load_system(sys)
Simulate the model for ten time units and extract an operating point snapshot.
opsim = findop(sys,10);
Create an 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);
Operating point search report: --------------------------------- Operating point search report for the Model watertank. (Time-Varying Components Evaluated at time t=10) 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-14 (0) Inputs: None ---------- Outputs: None ----------
The time derivative of each state,
dx, is effectively zero. This value of the state derivative indicates that the operating point is at steady state.