## 10 Thermal Mixing Tank System
Figure 3: Response of outlet flow rate \(Q_{s}\) and outlet temperature \(T_{s}\) to reference signals and disturbances, both of the step type, using an incremental-1 control. by first filtering the discrete-time signal \(J(\theta(k))\) using a high-pass filter to remove the DC component. Next, the signal is demodulated by multiplying it with a discrete sinusoidal wave of the same frequency as the perturbation signal. Finally, the result is integrated using a step size \(\gamma\) to obtain a new estimate of the parameter \(\widehat{\theta}\). It is worth noting that the integrator acts as a low-pass filter. For the case of the thermal mixing tank system, the following cost function will be used:  
\[J(\theta)=\frac{1}{T}\left[\int_{0}^{T}e_{Q_{s}}^{2}(t,\theta)dt+0.01\int_{0}^ {T}e_{T_{s}}^{2}(t,\theta)dt\right]\]  
where \(\theta=\left[ \begin{array}{cccccc}R_{1}&R_{2}&Q_{1}&Q_{2}&Q_{3}&\ldots&Q_{7} \end{array} \right]\) and the scaling factor 0.01 is introduced to ensure that the output flow rate error \((e_{Q_{s}})\) and the output temperature error \((e_{T_{s}})\) contribute comparably to the cost function. In general, the magnitude of the temperature signal is approximately 10 times larger than that of the flow rate. As the cost function involves squared errors, this discrepancy is further amplified--potentially causing the temperature error to contribute up to 100 times more than the flow rate error. To address this imbalance, a weight of 0.01 is applied to the temperature term, effectively normalizing both error contributions to a similar scale. Therefore, the chosen scaling factor is not arbitrary; it ensures that both variables influence the optimization criterion in a balanced manner, despite their differing physical units and dynamic ranges. Once the cost function is defined, the initial values for the \(Q\) and \(R\) matrices are selected:  
\[Q=0.001 diag(\left[ \begin{array}{cccccc}0.1&0.1&1&1&1&1&1\\ \end{array} \right])\] \[R=diag(\left[ \begin{array}{cccccc}1&1&1\end{array} \right])\]  
The value of 0.001 was chosen through iterative testing because if it were larger, it caused failures in the controller; on the other hand, if it was too small, a good response was not obtained. Since \(R\) is the weighting matrix for the control action of the system and its variables have the same weight, \(R_{1}\) will change in the same way as \(R_{2}\). Similarly, for the \(Q\) matrix, only the values of \(Q_{1}\), \(Q_{2}\) and \(Q_{3}\) are varied, since multiple simulations have shown that variations in the remaining terms do not significantly affect the performance of the control system. In fact, it has been verified that the values from \(Q_{3}\) to \(Q_{7}\) can be set identically without degrading control quality. Thus, the configuration is as follows:  
\[Q_{initial}=\left[ \begin{array}{cccccc}R_{1}&Q_{1}&Q_{2}&Q_{3} \end{array} \right]=\left[ \begin{array}{cccccc}1&10^{-4}&10^{-4}&10^{-3}\end{array} \right]\]  
This simplifies the simulation run time and makes it less complicated to select appropriate values for \(\omega\), \(\alpha\) and \(\gamma\). It should be noted that \(\alpha_{i}\) and \(\gamma_{i}\) influence the stability and convergence of the method, and that \(\omega_{i}=a^{i}\pi\) where \(0<a<1\). The optimizer values are obtained through an iterative search to ensure that the method is stable and able to converge. These values are  
\[h =0.6\] \[\omega =\left[ \begin{array}{cccccc}2.8274&2.5447&2.2902&2.0612\\ \end{array} \right]\] \[\alpha =\left[ \begin{array}{cccccc}0&2\times 10^{-4}&0.8\times 10^{-5}&10^{-5 }\end{array} \right]\] \[\gamma =\left[ \begin{array}{cccccc}10&10&10&10\end{array} \right]\]where a value of \(a=0.9\) was chosen to calculate \(\omega_{i}\). It can also be seen that \(\alpha_{1}=0\), since it is intended to keep \(R_{1}=R_{2}=1\) so that their values remain unchanged throughout the entire iteration. This serves as a reference and allows the focus to be placed solely on the \(Q\) matrix.