Skip to content

Improved HVAC Diagnostics

Enhancing HVAC Diagnostics with Scientific Machine Learning and First Principles Modeling

First Principles HVAC Modeling and Scientific Machine Learning Provide Improved Diagnostic Capabilities

Estimates of the quantity of refrigerant contained inside a vapor-compression cycle, as used in common air-conditioners or heat pumps, are valuable for a few distinct reasons.  First, the amount of refrigerant in a cycle affects its overall performance; insufficient refrigerant may result in the inability to provide adequate cooling or heating capabilities, while an excessive amount of refrigerant may result in excessive electrical power consumption.  Second, such information is needed by methods that assess and manage the environmental impact of refrigerants, which can have a climate impact between 100x and 2000x greater than CO2.  These considerations thus motivate the pursuit of methods to gain insights into this practical system information.

Unfortunately, the only direct means by which the total refrigerant mass may be measured involves its complete removal from a given unit of equipment for the purposes of weighing it.  This practice is quite disruptive to the system operation, and the invasive nature of this process represents its own risks for refrigerant release.  Methods to estimate the total quantity of refrigerant in the system using less invasive methods are therefore quite attractive. 

State estiERLmation methods provide one path to obtaining key insights into system operation using readily available measurements.  These methods effectively relate quantities that can be directly measured (e.g., temperatures and pressures) to quantities that cannot be directly measured (e.g., refrigerant mass) by using a mathematical model of the system under study.  This is accomplished by applying measurements of the system inputs to the inputs of the mathematical model, and then comparing model outputs to the measured system outputs.  Discrepancies between the measured and simulated model outputs are subsequently used to adjust the model so that the model predictions remain close to the measured data.  With a well-designed state estimator, the corrected model can then be used to predict other unmeasurable quantities of interest, such as refrigerant mass. 

One powerful tool for representing one for creating high-accuracy physics-based models of vapor-compression cycles is the Modelica language, which enables the methodical equation-based construction of large, complex system models from a set of component models with a correct mathematical structure.  Existing Modelica tools can manage the challenging numerics of the sets of hybrid differential algebraic equations that describe this equipment, with direction-switching fluid flows, conjugate heat transfer processes, and complex multiphysics behavior.  

While many Modelica tools have useful capabilities that may be used for advanced simulation and control design, they are not well-suited for use in the state estimation context.  Whereas state estimation techniques often require the computation of large sensitivity matrices at each solver step for numerically stiff systems, the monolithic nature of many Modelica compilers prevents such information from being accessed by the user.  Moreover, other numerical programming languages that would otherwise be candidates for implementing state estimators, such as Python, are not suited to equation-based system descriptions, and do not have solvers that can accurately and quickly solve the nonlinear differential algebraic equations that are encountered in the description of vapor-compression cycles.

The ModelingToolkit package and JuliaSim compiler provided MERL with a path to implementing state estimators based on equation-oriented models in the fully-featured scientific programming language of Julia.  The process of implementing those models using ModelingToolkit was relatively straightforward due to the similar designs of ModelingToolkit and Modelica, and these models simulated accurately and quickly because ModelingToolkit is integrated with the high-quality differential equation solvers in the SciML ecosystem.  As it is now possible to interact with the internals of these solvers, we were able to obtain the sensitivity information needed to implement state estimators and make further improvements needed for high-dimensional system models.  In addition, the automatic differentiation capabilities enabled by this connection to Julia provide more accurate estimates of the Jacobian than are possible with standard numerical approximations.  More details of this theoretical work are provided in the referenced publications.

We evaluated these state estimation methods on a simulation of a relatively small model of a vapor-compression cycle implemented in ModelingToolkit, with 278 equations, and found that they worked quite well.  Refrigerant mass estimates generated by these methods differed from the reference mass used in the simulation with less than 2% error by using a limited number of temperature and pressure sensors, despite variations in the actuator inputs (compressor or fan speed) or driving conditions (heat load, inlet air temperature).  These methods have significant promise to provide new diagnostic capabilities for practical equipment, and we are looking forward to further advances in our research that are enabled by the new opportunities provided by JuliaSim.


  1. Laughman, C.R., Deshpande, V.M., Qiao, H., Bortoff, S.A., Chakrabarty, A., "Digital Twins for Vapor Compression Cycles: Challenges & Opportunities", International Congress of Refrigeration (ICR), August 2023.
  2. Deshpande, V.M., Laughman, C.R., "Multi-pass Extended Kalman Smoother with Partially-known Constraints for Estimation of Vapor Compression Cycles", World Congress of the International Federation of Automatic Control (IFAC), July 2023.
  3. V. M. Deshpande, C. R. Laughman, Y. Ma and C. Rackauckas, "Constrained Smoothers for State Estimation of Vapor Compression Cycles," 2022 American Control Conference (ACC), Atlanta, GA, USA, 2022, pp. 2333-2340, doi: 10.23919/ACC53348.2022.9867269