## 3 Proposed Methodology
### Learning and Locking Reference Systems with Machine Learning
#### 3.3.2 Reference Condition Modelling: Individual Components and the System as a Whole
Figure 5 shows the proposed training of the boiler PINN (\(PINN_{Bo}\)), which is fed with the reference data of fluid inlet temperature (\(T_{3}^{REF}\)), water flow rate (\(\dot{m}_{Bo}^{REF}\)) known from the equipment activation state \(\big{(}on/off_{Bo}^{OF}\big{)}\) and the outdoor temperature (\(T_{env}\)); the objective is to learn a model that predicts the fuel consumption (\(\dot{F}_{1}^{pred}\)) and the fluid outlet temperature (\(T_{2}^{pred}\)). In addition, the following physical constraints are added:  
1. Conservation of mass, where a steady state is assumed;
2. Conservation of energy, which considers that the energy input from the fuel is transferred to the fluid, according to the specific performance (\(\dot{F}\cdot\gamma_{Bo}=\dot{m}_{Bo}^{REF}\cdot c_{p}\cdot\Big{(}T_{2}^{pred} -T_{3}^{REF}\Big{)}\));
3. Steady state exergy balance, which can capture irreversibilities and inefficiencies of the system, especially relevant to capture thermal inertia and heat dissipation effects (\(0=\frac{\dot{F}\cdot\dot{m}_{Bo}}{\dot{T}_{j}}+\dot{m}_{Bo}^{REF}\cdot\Big{(} s_{3}\big{(}T_{3}^{REF}\big{)}-s_{2}\Big{(}T_{2}^{pred}\Big{)}\Big{)}+\dot{\sigma}_{ Bo}\));
4. The regularisation of derivatives representing thermal inertia, where additional terms are added to model the temporal change in output or input temperature and to capture thermal inertia. Penalising, for example, abrupt non-physical changes (\(\frac{\dot{\vartheta}T_{3}^{pred}}{\dot{\sigma}t}<\varepsilon\)), being \(\varepsilon\) a pre-specified threshold. The loss function to be minimised is the weighted sum of the loss in the data (\(L_{data}\)) and the losses in the physical constraints (\(L_{energy},L_{entropy},L_{inertia}\)). With \(L_{data}\) being the difference between the neural network predictions and the known output data, and \(\alpha,\beta,\gamma,\delta\) the hyperparameters that weight the importance of each term. The following expression shows the loss function of the system:  
\[L=\alpha\cdot L_{data}+\beta\cdot L_{energy}+\gamma\cdot L_{entropy}+\delta \cdot L_{inertia} \tag{1}\]  
Thus, the model of each component is individually trained to fulfil thermodynamic laws and once validated, it is \"locked\" to prevent it from learning from future data with possible degradations. The model, once incorporated in the diagnosis procedure, is used to detect future anomalies by feeding it with input data from components in operating condition (\(\dot{\chi}_{j}^{OP}\)), potentially degraded. Therefore, the output of the locked reference operator model of the \(i\) component predicts the ideal behaviour of the component, which will be used to calculate its reference unit consumption (\(k_{i}^{B,ref}\)), and any significant discrepancy between the predictions and the actual measurements in the operating condition (\(k_{i}^{A,op}\)) is interpreted as an anomaly. The quantification of these discrepancies between operation and reference is performed by setting thresholds based on historical statistics or safety limits. During the PINN training process, the value of the defined loss function (Equation (1)) is gradually decreased until the desired value is reached and then the model is validated  
Figure 5: Proposal to train the operators as a boiler reference PINN. with reference data that have not been used in the training process. This results in optimal generalisation, by ensuring that the PINN responds correctly to patterns that have not been used in its training.