using ControlSystems
using RobustAndOptimalControl
using LinearAlgebra, Plots
s = tf("s")
G₁ = 1.5/(100s+1) |> ss
G₂ = 1/(50s+1) |> ss
## TODO: Form the generalized plant P
## TODO: Find the controller K using hinfsynthesize
## TODO: Simulate the closed-loop systemHomework
Base neutralization process
Your task is to design a feedback controller for a base neutralization system that operates in two stages, as illustrated in Fig. 1 below.
The bulk of the neutralization takes place in the first tank, where a large amount of acid (the control input u_1) is mixed with the basic solution (the disturbance variable d) to reduce the pH (the output variable y_1) to the approximate value of 10. In the second tank, the pH (the other output variable y_2) is further adjusted to a target value of around 7 by adding a small amount of acid (the other control input u_2).
The system can be modeled using the signal flow diagram in Fig. 2 below.
The transfer functions are given by G_1(s) = \frac{1.5}{100s+1}, \quad G_2(s) = \frac{1.0}{50s+1}.
Design a controller that ensures y_2 \approx r with a closed-loop bandwidth \omega_b = 1.0 rad/s, while also keeping u_2 small at low frequencies. The controller \bm{K} should be of the form \begin{bmatrix} u_1 \\ u_2 \end{bmatrix} = \bm{K}(s) \begin{bmatrix} -y_1 \\ r - y_2 \end{bmatrix}.
Formulate the control design problem within the \mathcal H_\infty signal-based framework, and then design the controller by solving the \mathcal H_\infty-optimization problem \operatorname*{minimize}_{\bm{K} \text{ stabilizing}} \lVert \mathcal{F}_\mathrm{l}(\mathbf{P}, \bm{K}) \rVert_{\infty}, where \mathbf{P} is the generalized plant, which includes the dynamics of the base neutralization process along with weighting functions used to express performance objectives. It maps the exogenous inputs (e.g., the reference r, the disturbance d) and the control inputs (u_1, u_2) to the performance outputs (such as the tracking error and the control effort) and to the measured signals used by the controller to compute the control inputs.
The operator \mathcal{F}_\mathrm{l}(\mathbf{P}, \bm{K}) denotes the lower linear fractional transformation, which represents the closed-loop transfer function from the exogenous inputs to the regulated outputs when the controller \bm{K} is connected to the generalized plant \mathbf{P} via feedback.
Tasks
You should follow these steps to complete the homework
Create the generalized plant \mathbf{P}(s) using the transfer functions G_1(s) and G_2(s), along with your chosen exogenous inputs, regulated outputs, and weighting filters. The weighting filters should be designed to ensure that the closed-loop system meets the performance objectives, such as reference tracking and control effort requirements.
Use the hinfsynthesize function from
RobustAndOptimalControl.jlto solve the \mathcal H_\infty-optimal control problem (some more related functions might be useful). This function will compute the optimal controller \bm{K} and the appropriate \gamma upper bound on the \mathcal H_\infty norm of the LFT. We suggest usingγrel = 1.05as the relative tolerance for the optimization.Prepare a concise report (
hw.pdf) and include the controller design code (hw.jl). Compress the report and code into a zip file namedhw.zipand submit it to the BRUTE system.
Report instructions
Your report should contain the following
A description of the generalized plant \mathbf{P}, including your choice of exogenous inputs, regulated outputs, and weighting functions. Briefly explain the reasoning behind your design choices.
Closed-loop performance analysis, namely show
- the time response of the output y_2 and control input u_2 to a step change in the reference r.
- the frequency response for a transfer function from the reference r to the output y_2, and from the reference r to the control input u_2.
Brief comment on whether the bandwidth and low-frequency control objectives were met, based on your plots.