Heat Exchanger Surrogates for a Vapor Compression System

Given the computationally intensive nature of heat exchanger simulators, utilizing a data-driven surrogate model for efficiently computing the heat exchanger outputs is desirable. This study focuses on developing integrated surrogate models of heat exchangers for a vapor compression system in Modelica. The surrogate models are designed to serve as steady-state equivalents based on an efficient physics-based model calibrated using reference data from a more advanced simulation model. Sub-sequently, the calibrated model was employed to generate the training and testing data for developing Gaussian Process (GP) and Multi-Layer Perceptron (MLP) surro-gates. The findings indicate that GPs exhibit high accuracy when applied to the heat exchanger’s outputs with smooth behavior. GPs also demonstrate excellent data efficiency compared to MLPs. In cases where the GP struggles to model specific outputs effectively, MLPs are able to capture the more complex behavior. Moreover, hyper-parameter optimization is employed to identify optimal MLP topologies. Finally, the fast and compact surrogate model was integrated into the Modelica/Dymola environment. This adaptation allowed the surrogate models to be directly combined with the physical model of the heat exchanger.


Introduction
In thermal systems, amid the most common components, heat exchangers are arguably the most challenging units to simulate from the numerical point of view due to the complex thermal and fluid-dynamic phenomena involved (e.g.fluid phase changes).Different approaches exist to model heat exchangers, but in general, the level of accuracy should increase with the level of detail considered in the model.
This work explores the development of heat exchanger surrogate models to be used within the Modelica environment.In this sense, a flexible heat exchanger model (Ablanque et al. 2022), adapted to simulate an air-to-refrigerant condenser, has been used to train and evaluate surrogate models.The specific condenser studied is part of a vapor compression system which, in turn, is included in an aircraft Environmental Control System (ECS).
Various neural networks and deep learning techniques have been implemented to model different aspects of heat exchangers.(Abbassi and Bahar 2005) use a shallow neural network to model the thermodynamics of an evaporative condenser.(Romero-Méndez et al. 2016) model convective heat transfer rate that occurs during the evaporation of a refrigerant flow using a neural network.
In this work, surrogate models have been developed for each target variable of the heat exchanger.Gaussian Process (GP) regression models have been constructed for target variables exhibiting smooth behavior due to GP's data efficiency and strong interpolation abilities for smooth functions.A Multi-Layer Perceptron (MLP) Neural Network Model has been employed for more challenging target variables with highly non-linear behavior.To enhance the performance of the MLP, hyperparameter optimization on the network architecture has been conducted.The performance of the proposed surrogate models has been demonstrated, and the advantages of hyperparameter tuning have been highlighted in the context of surrogate modeling.
Finally, the fast and compact surrogate model was successfully integrated into the Modelica/Dymola environment.This adaptation enabled the direct integration of the surrogate models with the physical model of the heat exchanger.

Description
The structure implemented for the heat exchanger model is aimed to provide high flexibility in terms of geometries, participating fluids (i.e., liquids, gases, and two-phase refrigerants), and phenomenologies such as evaporation and condensation.The model layout consists of two specific sub-components for calculating fluid flows which are thermally linked via an additional sub-component that stands for the solid parts.Figure 1 shows the scheme for an airto-refrigerant condenser.The calculation of the fluid flow sub-component is based on a steady-state approach.The model discretization distinguishes three different zones, namely, superheated gas, two-phase, and sub-cooled liquid, as shown in Figure 2 for a condensation case.The aforementioned model zones can exist or not depending on the fluid inlet and outlet conditions so that the heat exchanger switches between different operating modes.The pressure drop for the whole heat exchanger is calculated from a traditional approach (i.e., ṁ=K∆P α ) where ∆P represents the pressure drop.The parameters K and α are previously determined from reference data.
The energy conservation equation is solved considering constant pressure and constant solid temperature.The calculation is conducted sequentially from zone to zone (if the heat calculated for the current zone is higher than the maximum heat allowed for this zone, the calculation will continue to the next zone.Otherwise, the calculation will terminate in the current zone).For single-phase zones, the heat flow rate between the fluid and the solid part Qsingle is calculated based on an ε-NTU method (Incropera and DeWitt 1996) in order to optimize the calculation speed and to avoid unrealistic temperature values: where C stands for the thermal capacity ratio and ε corresponds to the heat exchange effectiveness.For two-phase zones, the heat flow rate ( Qtwo ) is calculated from a standard approach based on a heat transfer coefficient (α), the temperature difference between the solid and the saturated fluid, and the heat transfer area (A): The calculation of the solid sub-component is based on a transient approach.It is calculated considering a unique solid temperature (T ), the solid mass (M), the solid mean specific heat capacity (c p ), and the heat rate transferred with the two fluids: The complete resolution is carried out by means of the default differential/algebraic system solver of Dymola.The heat exchanger's overall thermal response is dynamic as it combines the steady-state approach used for both flows with the dynamic approach considered for the solid part.Artificial relaxations can also be applied to the energy conservation equation of both flows to further overcome the negative impact of the absence of dynamic terms.The pressure drop equation is not only used to calculate the mass flow rate but also to approximate the phase saturation limits needed for the energy conservation equation.

Numerical Assessment and Tests
The current model has been developed to simulate different types of heat exchangers included in large thermal architectures consisting of multiple systems.Therefore, the need to meet demanding numerical requirements was crucial for its successful use in the aforementioned environments.The main requirements include robustness at initialization, robustness to any boundary conditions and/or signal types, robustness to conduct simulations at any particular simulation set-up parameter (e.g., interval length), the capacity of both fluids to handle null mass flow rate as well as reversed flows, and ability to handle changes of the expected heat flow direction.The model is a suitable platform to generate large quantities of training data and tests for the surrogate models due to its numerical characteristics.Proceedings of the Modelica Conference 2023 October 9-11, 2023, Aachen, Germany DOI 10.3384/ecp204599

Initialization and steady-state tests
A complete data set of cases has been generated to test the robustness of the model during initialization and the correct resolution for steady-state conditions.The data set has been built-up taking into account different values for all the boundary conditions (i.e., air and refrigerant inlet parameters) covering the whole physical range of possibilities and all its possible combinations.The data set also takes into consideration different fluid boundary condition types (see Figure 3) and different values for the interval length.The data set consists of 1296 cases (216 cases for each combination of boundary condition type and interval length).The simulation stop time is set at 2000 seconds so that the steady-state condition can be reached.The results have shown that the model initialization is successful for all the cases without being affected by the combination of boundary values or the interval length value.

Transient tests
Similarly to the initialization studies, many tests have been conducted to assess the model's numerical robustness for other crucial transient conditions.Some illustrative examples are presented.Figure 4 shows the results for a test where both the null mass flow rate and the reversed flow capacities are tested.This particular case corresponds to a transient simulation where the refrigerant is operating at a particular mode and is forced to experience flow direction changes and null mass flow rate at different moments.

Model validation
The accuracy of the condenser model has been comprehensively assessed.In this sense, a full set of reference data of 4766 cases has been provided from an advanced heat exchanger numerical model and used to compare the predictions.The parameter used for the comparisons is the so-called Prediction Error (PE) which characterizes the difference between the model-predicted value and the reference value of a particular variable.The local PE is a percentage value, and for the heat flow, it is evaluated as follows: To assess the accuracy regarding the whole data, an averaged PE is used, the so-called Mean Prediction Error (MPE), which is defined as follows: Table 1 shows the mean prediction error for the heat flow predicted by the condenser model.The results show good accuracy as the MPE for the whole data is 2.49 (this value decreases significantly as the less accurate results are not being considered).

Surrogate Modeling
Surrogate modeling aims to develop data-driven regression models that emulate complex systems or processes.This compact surrogate can then be used for real-time analysis, optimization, or prediction without the need for resource-intensive direct simulation of the system.In a regression problem, an input set is denoted as The goal is to construct a model that can predict the value of y := f (x * ) for an unobserved point x * .
The prediction is denoted as ŷ.In this study, two techniques are employed to build predictive models of the heat exchanger system, namely Gaussian Processes and Multi-Layer Perceptrons.

Gaussian Process Regression
Gaussian Process (GP) (Rasmussen and Williams 2018) is a common data-efficient surrogate for regression problems.A GP is specified by a mean m(x) and covariance function k(x, x ′ ).Given pair of input sets X and its evaluation on the system simulations, GP can be defined as: For the choice of the kernel function, the Matérn 5/2 kernel (Handcock and Stein 1993) is used as it does not put strong smoothness assumptions on the unknown function to be approximated (Genton 2002).The Matérn 5/2 kernel is defined as: where γ is a scale parameter, and l is a lengthscale parameter for the kernel function.
Training the GP model involves estimating the hyperparameters θ .In this case, θ contain the parameters of k(x, x ′ ).Maximum Likelihood Estimation (MLE) is used to estimate the hyperparameters: The predictive mean µ (X ⋆ ) and the predictive variance σ 2 (X ⋆ ) of a new, untested data point X * is calculated as: where K xx = k(x i , x j ), K ⋆x = k(x ⋆i , x j ), and K ⋆⋆ = k(x ⋆i , x ⋆ j ).The predictive mean of the GP is used as the surrogate model prediction ŷ.Moreover, the predictive variance could prove beneficial for quantifying uncertainty, which increases trust in the outcome and enables decision-making, optimization, or anomaly detection.For Gaussian process regression, the GPFlow library (G.Matthews et al. 2017) is used, and the MLE is optimized using the Limited memory Broyden-Fletcher-Goldfarb-Shanno Bounded (LBFGS-B) optimizer (C.Zhu et al. 1997).

Multi Layer Perceptron
The Multi Layer Perceptron (MLP) (Hinton 1989) is a popular class of deep learning neural network architectures used for regression tasks.While it is not as data efficient as GP, it can capture more complex, non-linear relationships between input and output variables.It also scales well to the size of the data set compared to GP w.r.t.computational complexity.MLP is a versatile choice for surrogate modeling when a larger data set is available.
An MLP comprises an Input Layer, L Hidden Layers, and an Output Layer.The Input Layer matches the dimensionality of the input data, while the Output Layer matches the dimensionality of the target function.Generally, an MLP (Prince 2023) can be described as: where b l and W l are the bias term and weight parameters of the network at l th layer, and a, is the activation function.
Rectified Linear Unit (ReLU) (Fukushima 1969) is used for a and defined as a(x) = max(0, x) To find the optimal parameters (b l and W l ), the ADAM (Kingma and Ba 2015) optimizer is used.Specifically for this study, The base architecture of the MLP was set to 150, 100, and 50 neurons for each of the three hidden layers respectively, as illustrated in Figure 6.The Scikit-learn machine learning library (Pedregosa et al. 2011) is used to train the MLP surrogates.

Heat Exchanger Surrogate Models
Steady-state equivalent surrogate models for the heat exchanger have been developed and tested using data sets derived from the physical simulator.A heat exchanger model incorporating mass flow rate and pressure approach was used in this case.The input-output diagram of the surrogate models is illustrated in Figure 7.

Generating the data sets
Data collection for the heat exchanger surrogate models has been performed by evaluating the physical model developed in the Modelica framework.The data sets are described in Table 2 and 3 respectively.In total, four data sets were prepared.The first two data sets, consisting of 150 and 80,000 points, were drawn using the Halton random sequence (Owen 2017).The remaining two data sets consist of 40,000 and 100,000 random points for hyperparameter optimization and validation of the surrogate model, respectively (Gramacy 2020).

Surrogate Modeling Results
The performance of the surrogate models is evaluated in terms of their predictive accuracy.Furthermore, hyperparameter optimization was conducted for the Multi-Layer Perceptron (MLP) to improve the performance of the surrogate models.

Performance Comparison
Surrogate models have been developed and benchmarked for all of the outputs of the heat exchanger.In particular, four different surrogate model scenarios are executed to select the surrogate model with the best performance.The considered surrogate model scenarios are: • MLP trained on 80,000 points (MLP-80K).
The Root Mean Squared Error (RMSE) is used as a metric to evaluate the surrogate models on testing data sets of 100,000 points.The RMSE formula is presented in equation 13.The full result of the benchmark is shown in Table 4.The surrogate model with the lowest RMSE is used for each output as the final surrogate mode.Almost all MLP-80K models have the best RMSE compared to the other methods, except for the Pb_air output.In this case, GP is superior to MLP.Thus, all outputs are modeled using MLP with 80,000 data points except for Pb_air.

Neural Network Hyperparameter Optimization
To explore the potential of MLP models in more detail, a hyperparameter optimization step was performed.
HyperParameter Optimization (HPO) (Yu and H. Zhu 2020; Morales-Hernández, Van Nieuwenhuyse, and Rojas Gonzalez 2022) for the MLP has been conducted using the Optuna framework (Akiba et al. 2019).The optimized hyperparameters are the learning rate and the architecture: the number of the hidden layer, the number of neurons of the hidden layers, and the activation function.Full specification of the MLP hyperparameter search space is presented in Table 5.The HPO was conducted with a budget of 250 iterations.The training data consisted of 80,000 points, while the cost function was defined as the loss value on a randomly sampled validation data set of 40,000 points.The optimal hyperparameters identified through HPO process are presented in Table 6.
Finally, the complete comparison of the Base-MLP and the optimal architecture found by the HPO (i.e., HPO-MLP) is presented in Table 7.It should be noted that the same hyperparameter setting from the previous section (MLP-80K) was used for the Base-MLP.
6 Modelica integration of the surrogate models The resulting surrogate models have been integrated in the Modelica framework.To accomplish this, the optimal parameters obtained during training are stored as matrices on MATLAB ('.mat') files, as they are compatible with the Modelica framework.For the GP model, these files store the training data, kernel parameters, and precom-puted terms that are independent of newly observed data (i.e., K −1 XX Y ).This speeds up the computation of predictions since the expensive matrix inverse operation does not need to be recalculated every time a new point needs to be predicted.Additionally, for the MLP model, the resulting W l and b l terms are saved, along with the activation functions at each layer for the HPO-MLP.The integration process utilizes OpenModelica (Fritzson et al. 2005) and can also be adapted to Dymola.The command 'readRealMatrix' imports the matrix, and 'readMatrixSize' is used to retrieve the dimensions of the matrices.The surrogate model prediction routine was then implemented in Modelica using equations 10 and 12 for GP and MLP, respectively.The adapted Modelica surrogate prediction function block is shown in Fig. 8 where the six inputs required by the function are shown.The only input that this function block requires is the path where the '.mat' file can be found.9, and it can be seen that the outputs are exactly matching.This generates trust to integrate the surrogate model in future applications where the heat exchanger will be used.

Conclusion
A heat exchanger model implemented in Modelica and adapted to simulate an air-to-refrigerant condenser has been validated and used to train and evaluate different surrogate models to mimic their steady-state behavior.The surrogate models are developed using Gaussian Process (GP) and Multi-Layer Perceptron (MLP) models.GPs are employed to capture the linear behavior of some heat exchanger outputs, while MLPs are utilized to handle other outputs with more complex, non-linear behavior.Additionally, hyperparameter optimization for the MLP architecture has been conducted, which led to significant improvements compared to the standard architecture.As a proof of concept, the surrogate models were also integrated in the Modelica/Dymola environment such that they can be directly augmented with physical models.
In this specific study, the surrogate model does not exhibit a substantial improvement in calculation time compared to the physical model.This limitation can be attributed to the fast nature of the physical model employed here.However, in cases with more complex physical models such as the distributed method, it will provide a large reduction in calculation time.Nonetheless, the surrogate model played a crucial role in ensuring calculation stability.Some of the factors that contribute to instability include operating modes transitions, empirical and corrector factor transitions, as well as thermophysical properties near the saturation dome, among others.
Future research will concentrate on constructing transient surrogate models to represent the transient behavior of the heat exchanger model explicitly.This can be ac-complished by employing more suitable surrogate modeling techniques, such as non-stationary Gaussian Processes or Autoregressive Models like Long Short-Term Memory Neural Networks.

Figure 4 .
Figure 4. Null mass flow rate and reversed flow test example.

Figure 5
Figure5shows illustrative results for a test where many
where d is the dimensionality Session 6-A: Thermodynamic and energy systems applications 5 DOI 10.3384/ecp204599 Proceedings of the Modelica Conference 2023 October 9-11, 2023, Aachen, Germany

Figure 6 .
Figure 6.Architecture of the MLP used in this paper.

Figure 7 .
Figure 7. Heat exchanger surrogate model Inputs and Outputs.

Table 2 .
Heat exchanger surrogate model inputs domain.

Table 3 .
Specification of the heat exchanger surrogate.

Table 4 .
Testing Root Mean Squared Error (RMSE) of all compared methods.

Table 5 .
Hyperparameter search space for the HPO.

Table 7 .
Root Mean Squared Error (RMSE) of Base-MLP and HPO-MLP.Ten repetitions have been conducted to validate the robustness of the optimized model.
the original Python code for the surrogate model prediction.The results of this test are presented in Fig.