## 3 Thermal Controller Design
### Long Short-Term Memory Neural Network  
The LSTMNN was specifically designed to address the vanishing and exploding gradient problems that conventional RNNs encounter when processing long sequences. It features three critical gates: the forget gate, input gate, and output gate. The forget gate discards irrelevant data, ensuring that only valuable information is retained. The input gate regulates the amount of new information added to memory, while the output gate manages how much information is sent to the next hidden state, which is crucial for making accurate predictions. Additionally, the LSTMNN maintains a cell state that acts as a memory highway, allowing essential information to flow across many time steps without significant alteration. This design enables the LSTMNN to capture long-term dependencies, effectively overcoming the limitation of a standard RNN. The ability of the forget gate to reset cell states prevents unnecessary information from accumulating, making the model robust for long-sequence tasks. The mathematical representations of the gates are in the following forms [25]:  
\[F_{t}=\sigma\Big{(}w_{f}[h_{t-1},\ x_{t}]+b_{f}\Big{)} \tag{4}\]  
\[I_{t}=\sigma(w_{i}[h_{t-1},\ x_{t}]+b_{i}) \tag{5}\]  
\[O_{t}=\sigma(w_{o}[h_{t-1},\ x_{t}]+b_{o}) \tag{6}\]  
Furthermore, the new hidden state and the updated cell state can be mathematically represented as  
\[h_{t}=O_{t}\text{tanh}(C_{t}) \tag{7}\]  
\[C_{t}=\Big{(}F_{t}\cdot C_{t-1})+\Big{(}I_{t}\cdot\dot{C}_{t}\Big{)} \tag{8}\]  
\[\dot{C}_{t}=\text{tanh}\{w_{c}[h_{t-1},\ x_{t}]+b_{c}\} \tag{9}\]  
\[\sigma(x)=\frac{e^{x}}{1+e^{x}} \tag{10}\]  
\[\text{tanh}(x)=\frac{e^{x}-e^{-x}}{e^{x}+e^{-x}} \tag{11}\]  
Figure 2: Thermal controller based on FLC: (**a**) control block diagram; (**b**) membership function for temperature; (**c**) membership function for temperature difference; (**d**) membership function for chilled water flow rate.  
where \(\sigma\) and tanh are activation functions. \(\sigma\) is the sigmoid function, with values in the range of [0, 1], and tanh is the hyperbolic tangent function, with values in the range of [\(-\)1, 1].  
In this study, an LSTMNN was utilized to process and predict time series data, capitalizing on its ability to effectively capture temporal dependencies. Through the design of gate mechanisms, the LSTMNN retains long-term dependencies while filtering out irrelevant data, thereby improving the accuracy and efficiency of the time series prediction models. Each gate receives inputs from the previous hidden state (\(h_{t}\)) and the current input (\(x_{t}\)), including the ambient temperature around the electrolysis stack, the power of the electrolysis stack, the flow rate of the chilled water, the temperature difference measured each time for the electrolysis stack, and the temperature of the electrolysis stack. These inputs are concatenated and passed through the sigmoid function, which determines the new candidate values applied to the cell state. The weight matrices \(w_{f}\), \(w_{i}\), and \(w_{o}\), along with the corresponding bias vectors \(b_{f}\), \(b_{i}\), and \(b_{o}\), control the activation values of the forget gate, input gate, and output gate. The weight matrix \(w_{c}\) and bias vector \(b_{c}\) manage the updates to the cell state.