Main Content

Design Optimization to Meet Step Response Requirements (GUI)

This example shows how to optimize controller parameters to meet step response design requirements using the Response Optimizer app. You specify the design requirements in a Check Step Response Characteristics block.

Model Structure

This example uses the watertank_stepinput model. This model includes the nonlinear Water-Tank System plant and a PI controller in a single-loop feedback system.

Open the model.

sys = 'watertank_stepinput';
open_system(sys)

Water-tank model with step input

To view the water tank model, open the Water-Tank System subsystem.

Water-tank System subsystem

This model represents the following water tank system.

Water-tank system diagram

Here:

  • Vol is the volume of water in the tank.

  • A is the cross-sectional area of the tank.

  • H is the height of water in the tank.

  • V is the voltage applied to the pump.

  • b is a constant related to the flow rate into the tank.

  • a is a constant related to the flow rate out of the tank.

Water enters the tank at the top at a rate proportional to the valve opening. The valve opening is proportional to the voltage, V, applied to the pump. The water leaves through an opening in the tank base at a rate that is proportional to the square root of the water height, H. The presence of the square root in the water flow rate results in a nonlinear plant. Based on these flow rates, the rate of change of the tank volume is:

ddtVol=AddtH=bV-aH

Design Requirements

The height of water in the tank, H, must meet the following step response requirements.

  • Rise time less than 2.5 seconds

  • Settling time less than 20 seconds

  • Overshoot less than 5%

Specify Step Response Requirements

To specify step response requirements, add a Check Step Response Characteristics block to the model. To do so, in the Simulink® model window, on Simulation tab, click Library Browser. In the Simulink Design Optimization list, select Signal Constraints.

Signal Constraints is selected in the Library Browser

Drag and drop the Check Step Response Characteristics block into the model window and connect the block to the output. The block is connected to the signal for which you want to specify design requirements.

Water-tank model with Check Step Response Characteristics block connected to the output

Double-click the Check Step Response Characteristics block to open the block parameters dialog box and specify the following requirements:

  • In Rise time (seconds), enter 2.5.

  • In Settling time (seconds), enter 20.

  • In % Overshoot, enter 5.

  • In Initial value, enter 1.

  • In Final value, enter 2.

Check Step Response Characteristics dialog box with the entered values

Click OK.

Instead of specifying time-domain requirements in the Check blocks, you can specify them in the Response Optimizer without adding blocks. For an example that uses this approach, see Design Optimization to Track Reference Signal (GUI).

Specify Design Variables

When you optimize the model response, the software modifies the design variable values to meet the design requirements. You specify which model parameters the software can modify.

To open a Response Optimizer session for this model, in the Simulink model window, in the Apps gallery, click Response Optimizer. Alternatively, in the Check Step Response Characteristics block parameters dialog box, click Response Optimization.

Response Optimizer window showing the time plot

The region bounded by black line segments in Time plot 1 shows the step response requirements that you specified in the Check Step Response Characteristics block.

To create a set of design variables, in the Design Variables Set list, select New.

Drop-down list for Design Variable Set

The Create Design Variables Set dialog box shows model parameters that you can use as design variables and indicates their locations within the model.

Create Design Variables Set dialog box

To add parameters to the design variable set, select Ki and Kp, and click the left arrow with C button.

Create Design Variables Set dialog box showing the added parameters Ki and Kp in a table along with their settings

The design variables list displays the following variable settings:

  • Variable — Variable name

  • Value — Current variable value

  • Minimum and Maximum — Variable bounds

  • Scale — Scaling factor for the variable

Limit the design variables to positive values. To do so, enter 0 for the minimum value of each variable in the corresponding Minimum field and press Enter on your keyboard.

Create Design Variables set dialog box showing minimum value of 0 in the table for all added parameters

Click OK. A new design variable DesignVars is created and appears in the Data area of Response Optimizer. You can click the variable to view its contents in the Variable Preview area.

DesignVars is selected in the Data area of the app and its preview is shown in the Preview area

If your model has many parameters, you can first use sensitivity analysis to determine the most influential parameters to optimize, or to obtain initial guesses for the design variables. For more information, see What Is Sensitivity Analysis? Using the Sensitivity Analyzer app, you can explore the response optimization design space by altering the design variables, identify the parameters that most influence the optimization problem, and compute initial values.

Optimize Model Response

To view the current response of the model, click Plot Model Response.

Model Response plot

The plot shows the model output, depicted by the blue line, lies outside the region of the specified step response.

To optimize the model response, click Optimize. The default optimization solver Gradient descent (fmincon) modifies the design variables at each iteration so that the simulated response lies within the design requirement line segments. For more information, see How the Optimization Algorithm Formulates Minimization Problems.

Optimization Progress Report

The message Optimization converged in the Optimization Progress Report indicates that the optimization solver found a solution that meets the design requirements within the tolerances and parameter bounds. For more information about the outputs displayed in the optimization, see Iterative Display.

Verify that the model output meets the step response requirements.

Model Response plot

The plot displays the last five iterations. The final response using the optimized variable parameter appears as the thick blue line. The optimized response lies in the white region bounded by the design requirement line segments and thus meets the requirements.

To view the optimized parameter values, click DesignVars in Model Workspace and view the updated values in the Variable Preview area. The optimized values of the design variables are automatically updated in the Simulink model.

Save the Session

After you optimize the model response to meet design requirements, you can save the Response Optimizer session which includes the optimized parameter values.

In the Response Optimizer, in the Response Optimization tab, in the Save Session drop-down list, select Save to model workspace.

Drop-down list for Save Session

In the Save Session window, specify the session name in the Session field.

To open the saved session, in the Response Optimizer for the model, in the Open Session drop-down list, click the Open from model workspace option.

Related Topics