Next Article in Journal
Ethanol–Hydrogen Reactivity Management for High-Efficiency, Low-Emission Reactivity-Controlled Compression Ignition Engines: A Systematic Review of Combustion, Control, and Life Cycle Impact
Previous Article in Journal
Long-Run Relationships Between Economic Growth, Urbanization, Renewable Energy, and CO2 Emissions in Greece
Previous Article in Special Issue
Towards a Positive Energy District: Energy Efficiency Strategies for an Existing University Campus
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Hybrid White-Box/Black-Box Modeling and Control of a CO2 Heat Pump System Using Modelica and Deep Learning: A Case Study on Return-Water Temperature Control

1
Department of Energy and Process Technology, Norwegian University of Science and Technology, 7034 Trondheim, Norway
2
Department of Energy and Petroleum Engineering, University of Stavanger, 4019 Stavanger, Norway
*
Author to whom correspondence should be addressed.
Energies 2026, 19(4), 908; https://doi.org/10.3390/en19040908
Submission received: 24 November 2025 / Revised: 5 January 2026 / Accepted: 31 January 2026 / Published: 9 February 2026

Abstract

This study presents a hybrid modeling framework integrating a deep learning-based black-box model of a CO2 heat pump with a physics-based white-box system model developed in Modelica. The approach reduces the complexity of thermodynamic modeling while maintaining system-level accuracy. A deep neural network (DNN) trained on measured data predicts outlet temperatures and compressor power, coupled with the Modelica model through the Functional Mock-up Unit (FMU) interface. The framework was applied to a ground-source CO2 heat pump system in Oslo, Norway, to evaluate hysteresis-based control strategies with different return temperature ranges (20–50 °C, 20–55 °C, 20–70 °C) and flow rates (1.3–1.5 kg/s). Results showed similar total heating but 25% lower compressor energy use for the 20–50 °C, 1.5 kg/s case compared to 20–70 °C. Temperature-based control improved coefficient of performance (COP) of the heat pump, while narrower temperature ranges and lower flow rates enhanced tank stratification and heat utilization. The findings demonstrate the effectiveness of the hybrid model for dynamic simulation and control optimization of CO2 heat pump systems.

1. Introduction

The growing emphasis on sustainable energy transition has accelerated the need for innovative and intelligent heating technologies, particularly within the building sector. Heat pumps represent one of the most promising low-carbon solutions, but their efficiency and operational performance depend strongly on the development of advanced and adaptive control algorithms. To achieve such optimization, it is essential to establish an accurate, robust, and computationally efficient system model that can support real-time control, large-scale simulation, and predictive applications. However, for CO2 heat pump systems, achieving both high fidelity and computational tractability in a system-level model remains challenging, especially when control-oriented simulations are required.
Recent systematic reviews have highlighted a rapid growth of AI-driven methods (machine learning, deep learning, and hybrid approaches) for HVAC and heat pump energy management since 2018, covering applications in control, optimization, and maintenance, while also stressing challenges such as robustness, interpretability, and deployment readiness [1]. International guidelines, including the IPMVP [2], ASHRAE Guideline 14-2002 [3], and CIBSE TM63, provide systematic methodologies for developing and validating building energy models. These frameworks generally categorize modeling approaches into three types: white-box (physics-based), black-box (data-driven), and grey-box. The distinction among these models lies in how physical knowledge and governing equations are incorporated into their structure and simulation environment [4].
White-box models use fundamental physical equations—typically heat and mass balance relationships—to describe system dynamics. Because of their transparent internal structure, they allow dynamic and modular coupling between components [5]. Developing such models, however, requires detailed information on building geometry, envelope properties, HVAC configurations, internal heat gains, occupancy schedules, equipment specifications, and climate data. TRNSYS and Modelica are among the most established tools for constructing white-box models [6]. TRNSYS provides a flexible, modular platform ideal for transient simulations, while the object-oriented structure and libraries of Modelica such as Buildings and IDEAS enable multi-domain simulation of thermal, electrical, and control systems. These platforms are widely adopted in co-simulation and digital twin applications to support advanced control and optimization tasks [7]. Nevertheless, white-box modeling can be computationally demanding and complex due to its dependence on detailed physical data and extensive equation solving. In the case of CO2 heat pumps, developing a detailed white-box model is especially complex. The open-source Modelica libraries (e.g., IDEAS, Buildings) typically include generic vapor compression heat pump models based on subcritical refrigerants, which cannot accurately reproduce transcritical CO2 behavior. More advanced CO2-specific modules exist in certain commercial libraries (e.g., TIL, ClaRa), but they require paid licenses and detailed manufacturer data—including compressor maps, isentropic efficiencies, and gas cooler design parameters—that are often unavailable or proprietary [8]. This difficulty is also reflected in recent efforts on transient, experimentally validated modeling of transcritical CO2 heat pumps, which highlight the strong nonlinear dynamics that must be captured for control-relevant studies [9]. These limitations make direct physical modeling of CO2 heat pumps costly, time-consuming, and uncertain.
Conversely, black-box models rely purely on empirical relationships between input and output data without explicitly applying physical laws. They range from simple regression models [10] to sophisticated deep learning algorithms [11,12]. Such models are advantageous when physical system parameters are unavailable or when fast, low-resource computation is needed. In building energy research, black-box methods are frequently used for control optimization and performance prediction [13]. For transcritical CO2 heat pumps specifically, surrogate modeling using artificial neural networks has been demonstrated as a way to replace computationally heavy cycle simulations while preserving high prediction accuracy over relevant operating envelopes [14]. Notably, such CO2 heat pump surrogates have been explicitly designed for reintegration into Modelica workflows (e.g., via FMU-based interfaces) to enable faster system-level simulations for operational optimization [15]. Data-driven heat pump management has also progressed toward deployment-oriented pipelines, where predictive models are combined with anomaly detection to enable adaptive operation strategies validated on multiple real installations [16]. However, they depend heavily on data quality and often lack interpretability, limiting their ability to represent underlying physical mechanisms. More importantly for control studies, purely black-box models are often difficult to embed into a physically consistent system simulation environment, which limits their ability to evaluate system-level control impacts (e.g., cycling, stratification, and long-horizon energy use). Hybrid approaches that couple physics-based cycle representations with deep-learning surrogates and parameter identification have therefore attracted increasing attention, as they can improve computational efficiency while retaining physically meaningful structure for diagnostics and control-related use [17].
Recently, the rapid development of data-driven modeling has also accelerated progress in intelligent control and system optimization for building energy systems. By combining modeling with control algorithms, researchers have demonstrated that data-informed control strategies can substantially enhance the operational efficiency of complex energy systems, such as heat pumps. Control optimization has therefore become a key approach to improving the performance and energy efficiency of heating and cooling systems. Advanced control strategies have been successfully applied across a wide range of energy systems, achieving improvements in areas such as occupant thermal comfort [18,19,20], peak load reduction [21], and overall energy savings [22]. Among these, model-based control methods have demonstrated particular effectiveness due to their ability to provide fast and adaptive responses [23]. For heat pump systems, researchers have increasingly explored the integration of model-based and data-driven control techniques. For transcritical CO2 heat pump cycles, recent work has coupled model predictive control with recurrent neural network (RNN/LSTM) reduced models to enable fast online optimization while accounting for the strong nonlinearities of the transcritical process [24]. These studies primarily target cycle-level setpoint optimization and fast prediction for online control, which motivates complementary system-level frameworks that can quantify how supervisory control choices propagate to tank stratification, long-horizon energy use, and operational flexibility. Liu et al. [25] developed a model-based control framework for a CO2 heat pump with thermal energy storage, reducing total energy use by 19.3% [26]. Sazon et al. [14] employed an artificial neural network as a surrogate model for CO2 heat pump control, while Wang et al. [27] optimized the COP of an air-source CO2 heat pump through a Modelica-based data-driven control-oriented model. Similarly, Kudela et al. [28] and Kumar et al. [29] demonstrated that advanced control algorithms could significantly reduce prediction errors and improve the average COP by up to 50%. Other studies have extended model-based control methods to different heat pump configurations—such as absorption or air-source systems—reporting notable gains in energy cost and performance [30,31,32]. Despite these advancements, research on control optimization for water-to-water CO2 heat pump systems remain limited. Existing studies largely focus on experimental validation [33], economic assessments [34], or alternative refrigerant cycles [35,36], while few address control optimization under dynamic operational conditions. Moreover, developing an effective optimization strategy for model-based control of CO2 heat pumps is challenging due to their transcritical nature, high nonlinearity, and computational intensity.
Building upon these gaps, this study proposes a hybrid white-box/black-box simulation and control framework for a water-to-water CO2 heat pump system. The hybrid approach replaces the physically complex CO2 heat pump model with a deep neural network (DNN) surrogate trained on measured operational data, while the remaining system—including building, water tank, and borehole components—is modeled in Modelica. This framework enables dynamic simulation of different control strategies with high accuracy and low computational cost. The primary contribution of this work lies in the integration of a validated data-driven heat pump surrogate into a physics-based system model to enable control-relevant, long-horizon system-level evaluation. The hysteresis control cases are presented as a baseline to demonstrate the value of this integrated framework. In this work, multiple hysteresis-based temperature and flow control strategies were tested to evaluate their influence on system energy use, stratification, and flexibility. To avoid a broad and loosely connected scope, the results and discussions in this paper are deliberately organized around (1) validating the DNN-based heat pump surrogate within the hybrid Modelica environment, and (2) using the validated hybrid model to quantify how hysteresis-based temperature/flow on–off control affects system-level energy use and operational behavior.
The structure of this paper is outlined as follows. Section 2 introduces the overall methodology, including the development of the hybrid model and the implementation of the control strategies. Section 3 presents the model validation process and the performance results under different control conditions. Section 4 presents an in-depth discussion of the results and outlines recommendations for future research, while Section 5 concludes the paper by summarizing the key findings.
Key innovations of this work are:
(1)
a validated DNN surrogate for a computationally complex CO2 heat pump trained on operational data;
(2)
a hybrid integration of the surrogate into a physics-based Modelica system to enable dynamic, long-horizon simulations;
(3)
a control-oriented evaluation of hysteresis-based strategies (baseline) quantifying energy use, stratification, and cycling frequency, providing a reference for future MPC design.

2. Methodology

2.1. Heating System

This study was based on a Norwegian demonstration project located at Voldsløkka School in Oslo, as illustrated in Figure 1. The facility spans an area of approximately 11,100 m2 and employs a CO2-based ground-source heat pump system to provide space heating. Thermal energy was extracted from a borehole field and upgraded through two gas coolers—a high-temperature and a low-temperature unit—before being distributed throughout the building. A 400 L buffer tank was connected to the high-temperature gas cooler to store excess heat.

2.2. CO2 Heat Pump

The CO2 heat pump involves complex thermodynamic processes; a simplified workflow is shown in Figure 2a. The unit comprises four compressors and two gas coolers. The compressors raise the CO2 to high temperature and pressure (red) and reject that heat in the high-temperature gas cooler (HTGC) and low-temperature gas coolers (LTGC). The HT gas cooler supplies space heating to the building, while the LT gas cooler supplies the air-handling unit for the ventilation system. The refrigerant then expands across the valve so its pressure and temperature drop (green/blue), passes through the receiver, which separates liquid from vapor and provides a stable liquid feed, flows through the evaporator to pick up heat from the source loop, and finally returns to the compressors. The compressors’ electricity use can reach about 80 kW. Using a full year of field data (Figure 2b), the average COP is 3.09; the regression fit shows that for every additional kilowatt of compressor power, the gas cooler delivers ≈ 3.1 kW of heat.

2.3. Black Box CO2 Heat Pump Model

A DNN-based surrogate model was created to represent the CO2 heat pump behavior under various operational conditions, as illustrated in Figure 3. The input variables of the model include mass flow rates and the inlet temperatures of the HTGC m ˙ H T g , T H T g , i n , LTGC m ˙ L T g , T L T g , i n , and evaporator m ˙ e , T e , i n , The corresponding outputs are the outlet temperatures T H T g , o u t , T L T g , o u t , T e , o u t and the compressor power P . The DNN structure consists of three hidden layers with 128, 128, and 64 neurons, all activated with ReLU functions, followed by an output layer using the same activation. All inputs were normalized to a [0, 1] interval via min–max scaling. About 10% of the processed dataset was held out as an independent test set and was not used during model development. The remaining 90% was used for model development, and within this subset, 70% was used for training and 30% for validation. The model was optimized using the Adam algorithm (learning rate = 0.001) with mean squared error (MSE) as the loss function, and early stopping was applied to avoid overfitting. Evaluation through mean absolute error (MAE) and comparison with measured data confirmed that the DNN could accurately reproduce the nonlinear behavior of the CO2 heat pump. Detailed evaluation metrics can be found in the previous study [37]. A hyperparameter optimization step was carried out prior to model finalization. Candidate configurations were evaluated using the validation set, and the final architecture and training settings were chosen as the ones achieving the lowest validation loss and stable convergence, with early stopping applied to reduce overfitting risk. The selected hyperparameters correspond to the best-performing model in our tuning experiments and are used throughout the remainder of the manuscript. The key hyperparameters for the final model can be found in Table 1 and Table 2.
The DNN model was implemented in Python 3.11 using the Keras library. To couple it with the Modelica-based Dymola environment, the trained model (saved in .h5 format) was imported into MATLAB 2024a using the importKerasNetwork function and subsequently loaded into Simulink. A fixed-step solver was configured to allow FMU generation, after which the neural network FMU was exported and integrated into Dymola. This setup enabled co-simulation between the data-driven black-box model and the remaining white-box components of the thermal system.

2.4. White Box System Model

Aside from the CO2 heat pump, a comprehensive white-box model was developed in the Dymola environment using the IDEAS library to represent the coupled thermal behavior of the building, stratified water tank, and borehole subsystems, as illustrated in Figure 4a.
These subsystems were interconnected to reproduce the actual operational logic of the case study, where heat and cooling exchanges respond dynamically to real-time thermal demand and available energy sources. Detailed descriptions of the modeling framework can be found in the previous study [38].
In this work, a hysteresis-based Boolean control scheme was implemented to control the return water flow between the building loop and the high-temperature gas cooler as shown in Figure 4b. The control strategy switches the compressor on or off according to the measured return water temperature. It consists of a Hysteresis block, several logical components (and, not, booleanToReal), and a FirstOrder filter. The hysteresis block defines upper and lower temperature bounds for activating and deactivating the heating demand signal, effectively avoiding excessive on–off cycling and maintaining stable operation. The Boolean logic components integrate this temperature signal with system status conditions, ensuring that the compressor is enabled only when both temperature and operational requirements are satisfied. The FirstOrder element smooths the variation in the mass flow rate, producing a gradual control response that mitigates numerical fluctuations and better represents the inertia of the hydraulic system. Collectively, these elements establish a robust control framework that balances thermal stability, numerical convergence, and physical realism in system operation.
In this study, four control scenarios were designed to assess how different control logics affect the overall system performance. The selected cases combine various hysteresis temperature ranges and mass flow rates supplied to the water tank: (1) 20–70 °C with a flow rate of 1.5 kg/s, (2) 20–50 °C with a flow rate of 1.5 kg/s, (3) 20–55 °C with a flow rate of 1.5 kg/s, and (4) 20–50 °C with a flow rate of 1.3 kg/s.
The selected threshold ranges for the return water temperature to the high temperature gas cooler (20–50 °C, 20–55 °C, and 20–70 °C) were chosen to reflect both common space-heating operating practice and realistic equipment operating envelopes. Specifically, the lower threshold 20 °C and upper thresholds of 50 °C and 55 °C represent typical low-to-medium temperature operation for hydronic space heating and are consistent with widely used European rating temperature levels [39]. The 70 °C upper threshold was intentionally included as an extreme, upper-limit sensitivity case. Under return-water-based hysteresis control in space-heating applications, the return temperature rarely reaches such a high level; therefore, this wide-band setting leads to near-continuous heat pump operation and serves as a practical “almost-uncontrolled” baseline. This extreme case is not intended as a recommended operating setpoint, but rather to highlight the performance impact of an excessively high upper temperature limit.
In the implemented hysteresis control, the CO2 heat pump switches off when the return water temperature to the high-temperature gas cooler exceeds the upper threshold and switches back on once the temperature drops below the lower threshold. The specified mass flow rate represents the water flow supplied to the tank during the active operation of the heat pump.
These conditions were selected to represent a broad spectrum of control behaviors that are typically encountered in real thermal system operations. The variations in the hysteresis temperature range reflect different control sensitivities—wider ranges (e.g., 20–70 °C) emphasize stability and reduced switching frequency, while narrower ranges (e.g., 20–50 °C) improve temperature precision and faster system responsiveness. Similarly, the two flow rate settings were chosen to explore the impact of hydraulic conditions on heat transfer efficiency and thermal stratification within the storage tank. A higher flow rate (1.5 kg/s) promotes stronger mixing and faster heat delivery, whereas a lower flow rate (1.3 kg/s) helps maintain temperature layering and potentially improves system efficiency. Together, these four representative cases provide a balanced framework for understanding how control thresholds and flow dynamics jointly affect energy performance and operational stability.

3. Results

3.1. Black Box Model Validation

The validation results of the black-box DNN model for the CO2 heat pump are illustrated in Figure 5. Panel (a) shows the comparison between the predicted and measured outlet temperatures of the high-temperature gas cooler, while panel (b) presents the prediction accuracy for the compressor power. The results demonstrate that the DNN model achieved strong predictive capability for both thermal and electrical outputs. For the high-temperature gas cooler, the coefficient of determination R2 reached 0.967, with a regression slope of 0.942 and a normalized mean bias error (NMBE) of 0.79%, indicating that the model can accurately capture the nonlinear thermal behavior of the CO2 cycle. The coefficient of variation in the root mean square error (CV-RMSE) was 3.75%, further confirming high consistency between the predicted and measured temperatures.
For compressor power prediction, the model also performed well, achieving an R2 value of 0.886 and a regression slope of 0.908. Although slightly lower than the thermal output prediction, the results still exhibit a strong linear correlation with measured data, with small deviation at higher power ranges likely due to the dynamic load variations during transient operation. Overall, the validation metrics confirm that the developed DNN-based surrogate model reliably reproduces the thermodynamic and electrical performance of the CO2 heat pump, providing sufficient accuracy for system-level simulation and control integration.
P p r e d = 0.908 · P m e a s + 0.83
where P p r e d (kW) is the predicted compressor power from the DNN model, P m e a s (kW) is the measured compressor power, 0.908 is the regression slope, 0.83 (kW) is the regression intercept, and R2 is the coefficient of determination describing the goodness-of-fit of the regression.
Since the monthly compressor electricity use is obtained by accumulating power over time, the same linear relationship propagates to the monthly energy use as:
E p r e d = 0.908 · E m e a s + 0.83 t
where E p r e d (kWh) is the monthly electricity use computed from the predicted compressor power, E m e a s (kWh) is the corresponding (unknown) monthly electricity use associated with the measured compressor power, and t (h) is the cumulative compressor on-time over the month (i.e., the total duration during which the compressor is operating). The term 0.83 · t therefore represents the energy contribution (kWh) caused by the regression intercept over the total on-time.
Rearranging Equation (2), a regression-based bias-corrected estimate of the monthly compressor electricity use can be obtained as:
E m e a s = E p r e d 0.83 · t 0.908

3.2. Comparison of Control Strategies

Figure 6 presents the seven-day simulation results of the CO2 heat pump system under four control configurations, showing (a) the return water temperature to the HTGC, (b) the corresponding heat rate, (c) compressor power, and (d) mass flow rate supplied to the storage tank.
The return temperature control results demonstrate distinct operational patterns for each strategy. The 20–70 °C case (brown line) features wide temperature swings and long operation cycles, while the 20–50 °C cases (red and blue lines) display more frequent cycling within a narrower temperature range. The 20–55 °C control (green line) achieves an intermediate behavior, balancing operation time and response frequency. Importantly, all four cases maintained comparable overall heat delivery to the building system, indicating that the main difference lies not in heating capacity but in control-driven energy use.
The heat rate of the HTGC remains similar across all cases, confirming that thermal demand was adequately met in each scenario. However, the compressor power profiles reveal that the 20–50 °C cases have more intermittent operation, leading to periods of zero power use during system shutdowns. In contrast, the 20–70 °C case operates for longer durations at higher power levels, which, despite smoother operation, results in greater cumulative energy use. The 20–50 °C, 1.3 kg/s case (blue line) further reduces the total energy input by maintaining a lower active power level and allowing longer off-periods without compromising total heat supply. Over the 7-day period, the two 20–50 °C cases exhibited the highest cycling activity, with average cycling frequencies of 4.00 cycles/day (20–50 °C, 1.5 kg/s) and 1.29 cycles/day (20–50 °C, 1.3 kg/s), compared with 2.00 cycles/day for the 20–55 °C, 1.5 kg/s case and 1.43 cycles/day for the 20–70 °C, 1.5 kg/s case (28, 9, 14, and 10 total starts over 7 days, respectively.
The total compressor energy use for the four control strategies is summarized show in Table 3. The 20–50 °C, 1.5 kg/s condition achieved the lowest total energy use, demonstrating that a narrower hysteresis temperature range allows the system to operate intermittently with longer off periods, thereby reducing cumulative compressor operation time. In contrast, the 20–70 °C case exhibited the highest energy use due to continuous compressor operation over a wider temperature span. The 20–55 °C case achieved moderate savings, while the 20–50 °C, 1.3 kg/s case consumed slightly more energy than the 1.5 kg/s counterpart, likely because the lower flow rate required longer operating durations to satisfy the same heat demand. Overall, these results emphasize that careful coordination of temperature control range and flow rate can effectively reduce system energy use without compromising heating performance.
To assess the impact of compressor power prediction uncertainty on the aggregated monthly electricity-use values in Table 3, a regression-based bias-propagation check using the on-time extracted from the power trajectories (t ≈ 591.7 h for 20–50 °C, 1.5 kg/s and t ≈ 710.2 h for the other three cases) was performed. The resulting correction indicates that the monthly electricity use would increase only slightly, by about 2.8–3.8% across the four scenarios (e.g., 7762.5 → 8008.2 kWh and 10,286.0 → 10,679.0 kWh). Importantly, the ranking among the control strategies remains unchanged, and the key comparative conclusion is robust: the relative saving of 20–50 °C, 1.5 kg/s versus 20–70 °C, 1.5 kg/s changes only marginally from 24.53% to 25.01% after correction.
The relationship between heating rate and compressor power under two control scenarios—(a) 20–50 °C and (b) 20–70 °C, both operating at a mass flow rate of 1.5 kg/s—is shown in Figure 7. Note that Figure 7 aggregates all operating points over the full one-month simulation horizon. In the 20–50 °C case (Figure 7a), where hysteresis control is applied, the heat pump exhibits a more compact distribution of data points with a steeper slope, indicating that a larger heating output is achieved for a given compressor power. This implies an overall higher COP. The controlled system operates within an optimized temperature range, preventing unnecessary compressor operation at high temperatures, which typically reduces efficiency. In contrast, the 20–70 °C case (Figure 7b) shows a wider spread and lower slope in the data distribution. Because the return water temperature seldom reaches the 70 °C threshold, the heat pump remains active continuously, leading to higher compressor energy use for similar heating outputs. These results demonstrate that implementing temperature-based control can improve the efficiency of the heat pump by maintaining operation within its optimal thermodynamic range, thereby enhancing the system COP and reducing energy waste.
Figure 8 presents the 24–h thermal stratification profiles of the storage tank under three representative control cases: (a) 20–70 °C, 1.5 kg/s, (b) 20–50 °C, 1.5 kg/s, and (c) 20–50 °C, 1.3 kg/s. The case with a hysteresis range of 20–55 °C is not shown, as its behavior closely resembles that of the 20–50 °C condition.
The 20–70 °C case exhibits a nearly uniform temperature distribution across all ten tank layers throughout the day, indicating that continuous heat pump operation results in significant mixing and weak stratification as shown in Figure 8. Because the heat pump rarely shuts down under this wide control range, the tank lacks sufficient idle periods to develop or maintain thermal layering. This leads to high overall temperatures but limited thermal storage efficiency, as much of the heat is directly circulated rather than stored.
In contrast, Figure 8b demonstrates that the 20–50 °C case achieves a more pronounced stratification pattern. The narrower hysteresis range allows periodic shutdowns of the heat pump, enabling the tank to experience alternating charging and discharging phases. Distinct temperature differences between layers emerge during these cycles, showing that the tank can store and release heat more effectively while maintaining temperature stability.
Further comparison with the 20–50 °C, 1.3 kg/s case in Figure 8c reveals that reducing the flow rate enhances stratification even further. Two simple quantitative indicators are used to characterize stratification in this case: the vertical temperature spread across the tank (≈1.8 K) and the post-heat-pump shut-off cooling time lag between the top and bottom layers (≈0.9 h). The lower mass flow results in weaker turbulence and slower mixing, which helps preserve thermal layers within the tank. This condition supports more efficient heat utilization, as the upper layers maintain higher temperatures while the lower layers remain relatively cool, allowing for greater effective storage potential.
Overall, these results indicate that a narrower hysteresis control and moderate reduction in flow rate can improve thermal stratification, enhance energy storage utilization, and contribute to overall system energy savings without compromising the total heat supplied.

4. Discussion

The results of this study demonstrate the effectiveness and practicality of integrating a data-driven black-box model with a physics-based white-box model for simulating complex CO2 heat pump systems. This hybrid modeling approach avoids the challenges associated with building a detailed physical model of the CO2 heat pump—such as the need for extensive thermodynamic equations, proprietary component data, and computationally heavy simulation—while maintaining high fidelity in representing system dynamics. By embedding the DNN-based black-box model within the Modelica white-box framework, the model captures both the physical interactions between subsystems and the operational response of the heat pump under different control strategies. This structure strikes an optimal balance between accuracy and computational efficiency, enabling system-level simulation and control analysis that would be difficult to achieve using a purely physical or purely data-driven model.
The simulation results primarily focus on the HTGC section, which dominates the heating load for space heating in the case building. The LTGC, which mainly supplies ventilation heating, was not explicitly analyzed in this work. However, since both gas coolers interact thermodynamically through the same CO2 cycle, future research should incorporate simultaneous control and optimization of both the space heating and air-handling unit loops. This will allow a more comprehensive understanding of system-level performance and enable coordinated energy management between thermal and ventilation demands, especially under varying outdoor and occupancy conditions.
Regarding control, the hysteresis-based on/off logic applied in this study proved to be simple, robust, and computationally efficient. It successfully maintained system stability and temperature control within defined thresholds. However, this method only considers temperature as a control variable, limiting its capability to account for broader system objectives such as dynamic electricity pricing, user comfort preferences, or load-shifting potential. Future work will extend this framework toward model predictive control (MPC), which can integrate real-time forecasting of electricity prices, weather conditions, and heating demands. Such an approach will enable multi-objective optimization of system performance, energy cost, and flexibility. Hysteresis control is adopted in this study as a transparent and widely used baseline for on/off heat pump operation, enabling a clear interpretation of cycling behavior and energy impacts under different temperature/flow settings. While more advanced strategies such as MPC could further improve performance by optimizing actions over a prediction horizon, implementing MPC is beyond the scope of the present manuscript. Instead, the primary aim here is to establish and validate a computationally efficient hybrid model that is suitable for long-horizon simulation and constitutes the necessary foundation for future MPC implementation. Accordingly, the hysteresis-based results reported in this paper are intended as a baseline reference against which future MPC-oriented control designs will be evaluated.
The hybrid modeling and control results highlight that optimizing the control strategy can significantly reduce the overall energy use of the CO2 heat pump system without compromising heating performance. However, it is also important to acknowledge that while such control approaches—particularly those involving frequent compressor on/off cycles—can achieve short-term energy savings, they may introduce additional mechanical wear and reduce component lifespan due to repetitive start-stop operations. In real-world applications, this trade-off between energy efficiency and mechanical durability must be carefully managed. Future research should therefore consider multi-objective optimization frameworks that integrate both energy use and equipment longevity into the control design. Incorporating constraints related to compressor cycling frequency, start-up delays, or equivalent operating hours into predictive control formulations would allow a more balanced strategy.
Finally, from a modeling accuracy perspective, the DNN-based heat pump model demonstrated excellent predictive capability for outlet temperatures, particularly in the high-temperature gas cooler, but showed slightly lower accuracy in compressor power prediction. In the current hysteresis control framework, this limitation had little impact since control actions were primarily temperature-driven. However, in future MPC or optimization-based control implementations—where accurate power prediction directly influences energy cost and performance optimization—this deviation may introduce uncertainty in the predictive control process. Therefore, improving the power prediction accuracy or incorporating uncertainty quantification methods will be an important focus in future developments.

5. Conclusions

This study developed a hybrid white-box/black-box modeling framework for a CO2 heat pump system, integrating a deep neural network-based heat pump model with a Modelica-built thermal system. The hybrid approach effectively preserved both physical realism and computational efficiency, enabling accurate simulation of system-level interactions without the need for complex thermodynamic modeling. The results demonstrated that all control strategies achieved similar heat delivery, but significant differences were observed in energy use. The 20–50 °C, 1.5 kg/s control configuration achieved the lowest total compressor energy use (7762.5 kWh), showing that narrower hysteresis control improves energy efficiency by reducing unnecessary compressor operation. Moreover, the analysis of compressor power versus heating rate indicated that temperature-based control also led to a higher COP, reflecting more efficient energy conversion compared to the uncontrolled case (20–70 °C). The tank analysis revealed that smaller flow rates and tighter temperature ranges enhance the temperature stratification and heat utilization. Overall, the proposed framework provides a practical and accurate platform for dynamic simulation and control optimization of CO2 heat pump systems, offering a foundation for future studies on predictive and multi-objective control strategies.

Author Contributions

Conceptualization, G.S.; methodology, G.S. and Q.Z.; software, G.S. and Q.Z.; validation, G.S.; formal analysis, G.S.; investigation, G.S. and N.N.; resources, N.N.; data curation, G.S.; writing—original draft preparation, G.S.; writing—review and editing, G.S. and N.N.; visualization, G.S.; supervision, N.N.; project administration, N.N.; funding acquisition, N.N. All authors have read and agreed to the published version of the manuscript.

Funding

This work was conducted within the framework of the collaborative projects “Key technologies and demonstration of combined cooling, heating and power generation for low-carbon neighbourhoods/buildings with clean energy—ChiNoZEN” and “Climate Positive Circular Communities—ARV.” The authors gratefully acknowledge the financial support provided by the Research Council of Norway (ENERGIX program, project no. 304191), the Ministry of Science and Technology of China (project no. 2019YFE0104900), and the European Union Horizon 2020 Research and Innovation Programme (grant agreement no. 101036723, ARV project).

Data Availability Statement

Restrictions apply to the availability of these data. Data were obtained from [the building management of Voldsløkka skole in Oslo] and are available [from the corresponding author upon reasonable request] with the permission of [the building management of Voldsløkka skole].

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
DNNDeep Neural Network
FMUFunctional Mock-up Unit
COPCoefficient of Performance
HTGCHigh-Temperature Gas Cooler
LTGCLow-Temperature Gas Cooler
MPCModel Predictive Control

References

  1. Aghili, S.A.; Rezaei, A.H.M.; Tafazzoli, M.; Khanzadi, M.; Rahbar, M. Artificial Intelligence Approaches to Energy Manage-ment in HVAC Systems: A Systematic Review. Buildings 2025, 15, 1008. [Google Scholar] [CrossRef]
  2. Cowan, J. International performance measurement and verification protocol: Concepts and Options for Determining Energy and Water Savings-Vol. I. In International Performance Measurement & Verification Protocol; Efficiency Valuation Organization (EVO): Washington, DC, USA, 2002; Volume 1. [Google Scholar]
  3. ASHRAE. Guideline 14-2002: Measurement of Energy and Demand Savings; ASHRAE: Atlanta, GA, USA, 2002. [Google Scholar]
  4. Arendt, K.; Jradi, M.; Shaker, H.R.; Veje, C. Comparative analysis of white-, gray-and black-box models for thermal simulation of indoor environment: Teaching building case study. In Building Performance Analysis Conference and SimBuild: Co-Organized by ASHRAE and IBPSA-USA; ASHRAE: Atlanta, GA, USA, 2018; pp. 173–180. [Google Scholar]
  5. Ruiz, G.R.; Bandera, C.F.; Temes, T.G.-A.; Gutierrez, A.S.-O. Genetic algorithm for building envelope calibration. Appl. Energy 2016, 168, 691–705. [Google Scholar] [CrossRef]
  6. Elmqvist, H.; Boudaud, F.; Broenink, J.; Brück, D.; Ernst, T.; Fritzson, P.; Jeandel, A.; Juslin, K.; Klose, M.; Mattsson, S. ModelicaTM—A Unified Object-Oriented Language for Physical Systems Modeling. A Unified Object-Oriented Language for Physical Systems Modeling: Tutorial and Rationale, Version 1.3; Modelica Design Group: Lund, Sweden, 1999. [Google Scholar]
  7. Shahcheraghian, A.; Madani, H.; Ilinca, A. From white to black-box models: A review of simulation tools for building energy management and their application in consulting practices. Energies 2024, 17, 376. [Google Scholar] [CrossRef]
  8. Suite, T. TLK Energy. The Library for Thermodynamic Systems. Available online: https://tlk-energy.de/en/software/til-suite (accessed on 12 January 2025).
  9. Liang, J.; Li, T. Detailed Transient Study of a Transcritical CO2 Heat Pump for Low-Carbon Building Heating. Buildings 2025, 15, 3489. [Google Scholar] [CrossRef]
  10. Ciulla, G.; D’Amico, A. Building energy performance forecasting: A multiple linear regression approach. Appl. Energy 2019, 253, 113500. [Google Scholar] [CrossRef]
  11. Mocanu, E.; Nguyen, P.H.; Gibescu, M.; Kling, W.L. Deep learning for estimating building energy consumption. Sustain. Energy Grids Netw. 2016, 6, 91–99. [Google Scholar] [CrossRef]
  12. Sun, Y.; Haghighat, F.; Fung, B.C. A review of the-state-of-the-art in data-driven approaches for building energy prediction. Energy Build. 2020, 221, 110022. [Google Scholar] [CrossRef]
  13. Hopfe, C.J.; McLeod, R.S.; Rollason, T. Opening the black box: Enhancing community design and decision making processes with building performance simulation. In Proceedings of the Building Simulation 2017, IBPSA, San Francisco, CA, USA, 7–9 August 2017; pp. 920–929. [Google Scholar]
  14. Sazon, T.A.S.; Zhang, Q.; Nikpey, H. Development of a surrogate model of a trans-critical CO2 heat pump for use in operations optimization using an artificial neural network. In IOP Conference Series: Materials Science and Engineering; IOP Publishing: Bristol, UK, 2023; Volume 1294. [Google Scholar]
  15. Sazon, T.A.; Zhang, Q.; Nikpey, H. Comparison of different strate-gies for operating a solar-assisted ground-source CO2 heat pump system for space and water heating. Energy Convers. Manag. X 2024, 22, 100604. [Google Scholar]
  16. Rahal, M.; Ahmed, B.S.; Renström, R.; Stener, R.; Wurtz, A. Data-driven heat pump management: Combining machine learning with anomaly detection for residential hot water systems. Neural Comput. Appl. 2025, 37, 16203–16229. [Google Scholar] [CrossRef]
  17. Rousseau, P.; Laubscher, R. A Condition-Monitoring Methodology Using Deep Learning-Based Surrogate Models and Parameter Identification Applied to Heat Pumps. Math. Comput. Appl. 2024, 29, 52. [Google Scholar] [CrossRef]
  18. Song, G.; Melikov, A.K.; Zhang, G.; Bivolarova, M.P. Human response to the bed thermal environment generated by a ventilated mattress combined with local heating. Build. Environ. 2023, 241, 110461. [Google Scholar] [CrossRef]
  19. Song, G.; Ai, Z.; Liu, Z.; Zhang, G. A systematic literature review on smart and personalized ventilation using CO2 concentration monitoring and control. Energy Rep. 2022, 8, 7523–7536. [Google Scholar] [CrossRef]
  20. Song, G.; Ai, Z.; Zhang, G.; Peng, Y.; Wang, W.; Yan, Y. Using machine learning algorithms to multidimensional analysis of subjective thermal comfort in a library. Build. Environ. 2022, 212, 108790. [Google Scholar] [CrossRef]
  21. Turner, W.; Walker, I.; Roux, J. Peak load reductions: Electric load shifting with mechanical pre-cooling of residential buildings with low thermal mass. Energy 2015, 82, 1057–1067. [Google Scholar] [CrossRef]
  22. Vakiloroaya, V.; Samali, B.; Fakhar, A.; Pishghadam, K. A review of different strategies for HVAC energy saving. Energy Convers. Manag. 2014, 77, 738–754. [Google Scholar] [CrossRef]
  23. Salakij, S.; Yu, N.; Paolucci, S.; Antsaklis, P. Model-Based Predictive Control for building energy management. I: Energy modeling and optimal control. Energy Build. 2016, 133, 345–358. [Google Scholar] [CrossRef]
  24. Salame, A.A.H.; Peralez, J.; Nadri, M.; Dufour, P.; Lemort, V. Model Predictive Control-Based Optimization of a Transcritical CO2 Thermal Compressor Heat Pump Cycle Using a RNN-based Reduced Model. J. Process Control, 2025; in press. [Google Scholar]
  25. Liu, F.; Deng, J.; Pan, W. Model-based dynamic optimal control of an ejector expansion CO2 heat pump coupled with thermal storages. Energy Procedia 2018, 152, 156–161. [Google Scholar] [CrossRef]
  26. Liu, F.; Zhu, W.; Zhao, J. Model-based dynamic optimal control of a CO2 heat pump coupled with hot and cold thermal storages. Appl. Therm. Eng. 2018, 128, 1116–1125. [Google Scholar] [CrossRef]
  27. Wang, W.; Zhao, Z.; Zhou, Q.; Qiao, Y.; Cao, F. Model predictive control for the operation of a transcritical CO2 air source heat pump water heater. Appl. Energy 2021, 300, 117339. [Google Scholar] [CrossRef]
  28. Kudela, L.; Špiláček, M.; Pospíšil, J. Multicomponent numerical model for heat pump control with low-temperature heat storage: A benchmark in the conditions of Central Europe. J. Build. Eng. 2023, 66, 105829. [Google Scholar] [CrossRef]
  29. Kumar, D.M.; Catrini, P.; Piacentino, A.; Cirrincione, M. Integrated thermodynamic and control modeling of an air-to-water heat pump for estimating energy-saving potential and flexibility in the building sector. Sustainability 2023, 15, 8664. [Google Scholar] [CrossRef]
  30. Staudt, S.; Unterberger, V.; Gölles, M.; Wernhart, M.; Rieberer, R.; Horn, M. Control-oriented modeling of a LiBr/H2O absorption heat pumping device and experimental validation. J. Process Control 2023, 128, 103024. [Google Scholar] [CrossRef]
  31. Wang, W.; Hu, B.; Wang, R.; Luo, M.; Zhang, G.; Xiang, B. Model predictive control for the performance improvement of air source heat pump heating system via variable water temperature difference. Int. J. Refrig. 2022, 138, 169–179. [Google Scholar] [CrossRef]
  32. Kuboth, S.; Heberle, F.; Weith, T.; Welzl, M.; König-Haagen, A.; Brüggemann, D. Experimental short-term investigation of model predictive heat pump control in residential buildings. Energy Build. 2019, 204, 109444. [Google Scholar] [CrossRef]
  33. Xu, X.X.; Chen, G.M.; Tang, L.M.; Zhu, Z.J. Experimental investigation on performance of transcritical CO2 heat pump system with ejector under optimum high-side pressure. Energy 2012, 44, 870–877. [Google Scholar] [CrossRef]
  34. Xu, Y.; Mao, C.; Huang, Y.; Shen, X.; Xu, X.; Chen, G. Performance evaluation and multi-objective optimization of a low-temperature CO2 heat pump water heater based on artificial neural network and new economic analysis. Energy 2021, 216, 119232. [Google Scholar] [CrossRef]
  35. Gudjonsdottir, V.; Ferreira, C.I.; Rexwinkel, G.; Kiss, A.A. Enhanced performance of wet compression-resorption heat pumps by using NH3-CO2-H2O as working fluid. Energy 2017, 124, 531–542. [Google Scholar] [CrossRef]
  36. Baek, C.; Heo, J.; Jung, J.; Cho, H.; Kim, Y. Performance characteristics of a two-stage CO2 heat pump water heater adopting a sub-cooler vapor injection cycle at various operating conditions. Energy 2014, 77, 570–578. [Google Scholar] [CrossRef]
  37. Song, G.; Zhang, Q.; Nord, N. Integrating Deep Learning with Modelica for a CO2 Heat Pump System: A Hybrid Modeling Case Study in Oslo. In Proceedings of the Resilient2025, Västerås, Sweden, 23–25 September 2025. [Google Scholar]
  38. Song, G.; Filonenko, K.; Wen, X.; Ebrahimy, R.; Nord, N. Modelica-based model predictive control for a CO2 heat pump system: Case study in Oslo. J. Build. Eng. 2025, 115, 114501. [Google Scholar] [CrossRef]
  39. CEN EN 14511-2:2022; Air Conditioners, Liquid Chilling Packages and Heat Pumps for Space Heating and Cooling and Process Chillers, with Electrically Driven Compressors—Part 2: Test Conditions. European Committee for Standardization: Brussels, Belgium, 2022.
Figure 1. Voldsløkka School. Photo: Annika Byrde.
Figure 1. Voldsløkka School. Photo: Annika Byrde.
Energies 19 00908 g001
Figure 2. CO2 heat pump. (a). System schematic. (b). Regression of gas cooler heat output versus compressor power for COP estimation.
Figure 2. CO2 heat pump. (a). System schematic. (b). Regression of gas cooler heat output versus compressor power for COP estimation.
Energies 19 00908 g002
Figure 3. Overview of the black box model of the CO2 heat pump system.
Figure 3. Overview of the black box model of the CO2 heat pump system.
Energies 19 00908 g003
Figure 4. White box system model in Modelica. (a). Detailed Modelica simulation of the CO2 heat pump system (thermal tank–building–geothermal–black-box heat pump). (b). Simplified structure used for hysteresis control.
Figure 4. White box system model in Modelica. (a). Detailed Modelica simulation of the CO2 heat pump system (thermal tank–building–geothermal–black-box heat pump). (b). Simplified structure used for hysteresis control.
Energies 19 00908 g004
Figure 5. Validation results. (a). HTGC outlet temperature validation. (b). Compressor power validation.
Figure 5. Validation results. (a). HTGC outlet temperature validation. (b). Compressor power validation.
Energies 19 00908 g005
Figure 6. Seven-day performance of the CO2 heat pump system under four control strategies. (a). return water temperature to the HTGC. (b). heat rate of the HTGC. (c). compressor power. (d). mass flow rate supplied to the tank.
Figure 6. Seven-day performance of the CO2 heat pump system under four control strategies. (a). return water temperature to the HTGC. (b). heat rate of the HTGC. (c). compressor power. (d). mass flow rate supplied to the tank.
Energies 19 00908 g006
Figure 7. Comparison of heating rate versus compressor power. (a). 20–50 °C, 1.5 kg/s. (b). 20–70 °C, 1.5 kg/s.
Figure 7. Comparison of heating rate versus compressor power. (a). 20–50 °C, 1.5 kg/s. (b). 20–70 °C, 1.5 kg/s.
Energies 19 00908 g007
Figure 8. Thermal stratification profiles of the storage tank under three control strategies: (a) 20–70 °C, 1.5 kg/s, (b) 20–50 °C, 1.5 kg/s, and (c) 20–50 °C, 1.3 kg/s.
Figure 8. Thermal stratification profiles of the storage tank under three control strategies: (a) 20–70 °C, 1.5 kg/s, (b) 20–50 °C, 1.5 kg/s, and (c) 20–50 °C, 1.3 kg/s.
Energies 19 00908 g008
Table 1. Dataset split and training hyperparameters.
Table 1. Dataset split and training hyperparameters.
CategoryHyperparameterFinal Value
Data splitValidation fraction0.30
Random seed42
Model typeModel familyFeed-forward ANN
OptimizationOptimizerAdam
Learning rate0.001
ObjectiveLoss functionMSE
MonitoringMetricsMAE
Training scheduleMax epochs200
Batch size32
Early stoppingPatience5
Restore best weightsTrue
Table 2. DNN architecture hyperparameters.
Table 2. DNN architecture hyperparameters.
Layer IndexLayer TypeUnitsActivationInput/Output ShapeNotes
0InputInput: (6,)6 input features
1Dense128ReLU(6,) → (128,)Hidden layer 1
2Dense128ReLU(128,) → (128,)Hidden layer 2
3Dense64ReLU(128,) → (64,)Hidden layer 3
4 (output)Dense4ReLU(64,) → (4,)4 outputs
Table 3. The energy use of the compressor power for the whole month.
Table 3. The energy use of the compressor power for the whole month.
Control Conditions20–50 °C, 1.5 kg/s20–70 °C, 1.5 kg/s20–55 °C, 1.5 kg/s20–50 °C, 1.3 kg/s
Power electricity use (kWh)7762.510,2868807.59498.3
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Song, G.; Zhang, Q.; Nord, N. Hybrid White-Box/Black-Box Modeling and Control of a CO2 Heat Pump System Using Modelica and Deep Learning: A Case Study on Return-Water Temperature Control. Energies 2026, 19, 908. https://doi.org/10.3390/en19040908

AMA Style

Song G, Zhang Q, Nord N. Hybrid White-Box/Black-Box Modeling and Control of a CO2 Heat Pump System Using Modelica and Deep Learning: A Case Study on Return-Water Temperature Control. Energies. 2026; 19(4):908. https://doi.org/10.3390/en19040908

Chicago/Turabian Style

Song, Ge, Qian Zhang, and Natasa Nord. 2026. "Hybrid White-Box/Black-Box Modeling and Control of a CO2 Heat Pump System Using Modelica and Deep Learning: A Case Study on Return-Water Temperature Control" Energies 19, no. 4: 908. https://doi.org/10.3390/en19040908

APA Style

Song, G., Zhang, Q., & Nord, N. (2026). Hybrid White-Box/Black-Box Modeling and Control of a CO2 Heat Pump System Using Modelica and Deep Learning: A Case Study on Return-Water Temperature Control. Energies, 19(4), 908. https://doi.org/10.3390/en19040908

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop