You can compute a steady-state operating point of a Simulink® model by specifying constraints on the model states, outputs, and inputs, and by finding a model operating condition that satisfies these constraints. For more information on steady-state operating points, see About Operating Points and Compute Steady-State Operating Points.
To find an operating point for your Simulink model, you can programmatically trim your model using the findop
, as shown in this example.
Alternatively, you can trim your model in the:
Steady State Manager. For more information, see Compute Operating Points from Specifications Using Steady State Manager.
Model Linearizer. For more information, see Compute Operating Points from Specifications Using Model Linearizer.
In this example, you compute an operating point to meet output specifications. Using a similar approach, you can define state or input specifications. Also, you can define a combination of state, output, and input specifications; that is, you do not have to use, for example, only state specifications.
For more information on trimming your model to meet specifications, see Compute Steady-State Operating Points from Specifications.
Open the Simulink model.
mdl = 'scdspeed';
open_system(mdl)
Create a default operating point specification for the model.
opspec = operspec(mdl)
Operating point 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 ----------
Since there are no root-level outputs in the model, the default operating point specification object has no output specifications.
For this example, specify a known steady-state engine speed. To do so, add an output specification at the output of the rad/s to rpm block.
opspec = addoutputspec(opspec,'scdspeed/rad//s to rpm',1);
Specify a known value of 2000
rpm for the output constraint.
opspec.Outputs(1).Known = 1; opspec.Outputs(1).y = 2000;
View the updated operating point specification.
opspec
Operating point 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: ---------- (1.) scdspeed/rad//s to rpm spec: y = 2e+03
Find an operating point that meets these specifications.
op1 = findop(mdl,opspec);
Operating point search report: --------------------------------- Operating point search 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 operating point search report shows that the specifications were met successfully, and that both states are at steady state as expected (dx
= 0).
You can also specify bounds for outputs during trimming. For example, suppose that you know that there is a steady-state condition between 1900
and 2100
rpm. To trim the speed to this range, modify the operating point specifications.
opspec.Outputs(1).Min = 1900; opspec.Outputs(1).Max = 2100;
In this case, since you do not know the output value, specify the output as unknown. You can also provide an initial guess for the output value.
opspec.Outputs(1).Known = 0; opspec.Outputs(1).y = 2050;
Find an operating point that meets these specifications.
op2 = findop(mdl,opspec);
Operating point search report: --------------------------------- Operating point search 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.99e-13 (0) (2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s x: 209 dx: -9.9e-13 (0) Inputs: ---------- (1.) scdspeed/Throttle perturbation u: 0.005 [-Inf Inf] Outputs: ---------- (1.) scdspeed/rad//s to rpm y: 2e+03 [1.9e+03 2.1e+03]
The operating point search report shows that the specifications were met successfully.
After trimming your model, you can:
Linearize your model at the resulting operating point. For more information, see Linearize at Trimmed Operating Point.
Simulate your model at the resulting operating point. For more information, see Simulate Simulink Model at Specific Operating Point.
addoutputspec
| findop
| operspec