## 3 Thermal Controller Design
### Fuzzy Logic Control Method
The output membership function \(\mu_{C_{i}}(z)\) of a rule is determined by the minimum value of the input membership degrees \(\mu_{A_{i}}(x)\) and \(\mu_{B_{i}}(y)\) through AND logic. Subsequently, all output fuzzy sets from rules are aggregated into a single fuzzy set. The aggregated output fuzzy set \(\mu_{C}(z)\) is obtained through the OR logic operation of the output membership degrees \(\mu_{C_{i}}(z)\) from each rule. Step 4: The centroid method for defuzzification converts the fuzzy output set generated during the inference process into a crisp output value. This method calculates the centroidof the fuzzy set to determine a specific output value. It considers the membership degrees \(\mu_{C}(z)\) of all points on the fuzzy set and calculates the weighted average position of these points, represented mathematically as  
\[Z_{centroid}=\frac{\sum_{z}z\cdot\mu_{C}(z)}{\sum_{z}\mu_{C}(z)} \tag{3}\]  
where \(Z_{centroid}\) is the crisp output value obtained by calculating the weighted average of \(z\), and \(\mu_{C}(z)\) represents the membership degree of \(z\) in the output fuzzy set \(C\). This precise value effectively represents the fuzzy output used for control decisions. In the experimental setup of this study, a thermal controller based on FLC with dual inputs and a single output was utilized, as shown in Figure 2a. The inputs represented the desired temperature (\(T^{*}\)) and temperature difference (\(e_{T}\)) in the electrolysis stack, respectively, while the output determined the required the flow rate of the chilled water. In the literature on stack temperature control, the temperature difference and its derivative are commonly used as dual inputs for FLC to achieve rapid cooling. However, in this study, using a large amount of chilled water for cooling was not suitable, as a high chilled water flow rate could have led to a rapid decrease in power output. Thus, using the derivative of the stack temperature difference as an input was not appropriate. The chilled water flow rate was chosen as the output because it was the main factor influencing the stack temperature. The FLC used adopted a design with dual inputs and single output, with triangular and trapezoidal membership functions. Hence, the membership functions for the dual inputs, the temperature and temperature difference in the electrolysis stack, and the single output, the chilled water flow rate, are shown in Figure 2b-d, respectively. A set of 25 fuzzy rules is defined in Table 1, where VS denotes very small, S denotes small, M denotes medium, B denotes big, and VB denotes very big. The main challenges in applying FLC to the hydrogen production thermal control system included designing appropriate membership functions and fuzzy rules, which can be complex due to the nonlinearities and uncertainties of the temperature variations in an electrolysis stack. Additionally, the computational demands of fuzzy inference can impact real-time performance, especially in systems that require quick responses. Integrating FLC with other control strategies, such as the LSTMNN algorithm, also requires careful calibration to avoid control conflicts. To address these challenges, it is important to select membership functions that accurately represent the characteristics of the input and output variables. For example, triangular and trapezoidal membership functions can effectively represent the temperature and temperature difference in the electrolysis stack and chilled water flow rate. The selection of these functions should be based on empirical data and expert knowledge and should be refined iteratively through testing to ensure optimal control performance. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Temperature Difference** & **Temperature** & **VS** & **S** & **M** & **B** & **VB** \\ \hline
**VS** & VS & VS & VS & VS & VS \\
**S** & VS & VS & VS & VS & VS \\
**M** & VS & S & M & B & M \\
**B** & S & S & M & B & VB \\ VB & M & M & B & VB & VB \\ \hline \hline \end{tabular}
\end{table}