2025 Volume 38 Issue 2
Article Contents

Yapeng Zhang, Zipeng An, JingChun Wang, Yao Wang, Rui-Xue Xu, GuanHua Chen, Xiao Zheng. Machine Learning Density Functional Compatible with Dispersion Correction for Non-Covalent Interactions†[J]. Chinese Journal of Chemical Physics, 2025, 38(2): 140-148. doi: 10.1063/1674-0068/cjcp2502013
Citation: Yapeng Zhang, Zipeng An, JingChun Wang, Yao Wang, Rui-Xue Xu, GuanHua Chen, Xiao Zheng. Machine Learning Density Functional Compatible with Dispersion Correction for Non-Covalent Interactions†[J]. Chinese Journal of Chemical Physics, 2025, 38(2): 140-148. doi: 10.1063/1674-0068/cjcp2502013

Machine Learning Density Functional Compatible with Dispersion Correction for Non-Covalent Interactions†

  • Corresponding author: E-mail: xzheng@fudan.edu.cn
  • Received Date: 16/02/2025
    Available Online: 27/04/2025
通讯作者: 陈斌, bchen63@163.com
  • 1. 

    沈阳化工大学材料科学与工程学院 沈阳 110142

  1. 本站搜索
  2. 百度学术搜索
  3. 万方数据库搜索
  4. CNKI搜索

Figures(3)  /  Tables(1)

Article Metrics

Article views(229) PDF downloads(0) Cited by(0)

Access History

Machine Learning Density Functional Compatible with Dispersion Correction for Non-Covalent Interactions†

Abstract: Machine learning (ML) has demonstrated significant potential in enhancing the predictive capabilities of density functional theory methods. In this study, we develop an ML model for correcting B3LYP-D, a density functional approximation that incorporates dispersion corrections for non-covalent interactions. This model utilizes semilocal electron density descriptors, and is trained with accurate reference data for both relative and absolute energies. Extensive benchmark tests reveal that the ML correction substantially enhances the generalization ability of the B3LYP-D functional, improving the predictions of atomization and dissociation energies for complex molecular systems. It retains the accuracy of B3LYP-D in predicting reaction barrier heights and non-covalent interactions while enabling efficient, fully self-consistent field calculations. This work signifies a promising advancement in the development of ML-corrected functionals that surpass the performance of traditional B3LYP-D.

    • Density functional theory (DFT) has been widely adopted for studying electronic structures of complex systems, with applications spanning physics, chemistry, and life sciences [1-6]. The continuous development of accurate exchange-correlation (XC) functionals is crucial for enhancing the effectiveness of DFT methods. However, significant challenges persist in both physically derived and semi-empirical density functional approximations (DFAs).

      In recent years, integrating machine learning (ML) with DFT, known as ML-DFT [7-12], has been proposed as a means to enhance the performance of DFT methods. For instance, neural network (NN) models have been employed to optimize semi-empirical parameters in DFAs [13] such as B3LYP [14-16] and LC-BLYP [17]. Nagai et al. have utilized NNs within the Kohn-Sham framework to map density descriptors across different rungs of Jacob’s ladder to their corresponding XC energy densities [18]. Kirkpatrick et al. have leveraged NNs to fit a functional under fractional charge and spin constraints, leading to improved predictions for thermochemistry and strong correlation effects, while also correcting delocalization errors [19]. Moreover, Brockherde et al. have applied ML algorithms within the Hohenberg-Kohn theorem framework to directly fit potential-density and potential-energy mappings, effectively bypassing the need for Kohn-Sham equations [20].

      Recently, we have developed an ML-corrected DFA approach [8, 9]. Our method constructs an ML model that corrects existing DFAs using semilocal descriptors of electron density and its derivatives. The ML-corrected B3LYP significantly improves predictions of total energies (TEs) for atoms and molecules and atomization energies (AEs) while enabling fully self-consistent-field (SCF) calculations [9]. However, the previously developed ML-corrected B3LYP functional cannot accurately describe non-covalent interactions (NCIs).

      NCIs, such as van der Waals (vdW) forces and $ \pi $-$ \pi $ interactions, are prevalent in many chemical systems. Although their magnitudes are smaller than those of thermochemical energies, they play a crucial role in determining chemical properties and functionality [21, 22]. Consequently, developing correction schemes for these weak interactions remains an active area of research, which has led to the creation of various methods. These methods include random phase approximation (RPA) [23, 24], doubly hybrid functionals [25-30], van der Waals density functionals (vdW-DF) [31-33], exchange-hole dipole moment model (XDM) [29, 34], and Grimme’s DFT-D methods [35-39]. Among these, the latest DFT-D4 [38, 39] incorporates environment-dependent atomic charges, significantly improving the description of dispersion interactions and enhancing accuracy across a wide range of chemical systems.

      In this work, we aim to address two key questions: (i) How does the ML-corrected B3LYP functional perform if the empirical dispersion correction is directly added to the XC energy? (ii) Without reparameterizing the dispersion correction, how can we modify the ML model to enhance the predictive accuracy of ML-corrected B3LYP?

      For the convenience of discussion, throughout this paper, the ML-corrected B3LYP functional proposed in Ref.[9] is referred to as B3LYPML. The B3LYP functional corrected by DFT-D4 is denoted as B3LYP-D, and the ML-corrected B3LYP with additional correction by DFT-D4 is referred to as B3LYPML-D. The ML-corrected B3LYP-D is denoted as B3LYP-DML. Three of these functionals incorporate ML corrections: B3LYPML, B3LYPML-D, and B3LYP-DML, all of which use NNs for the ML corrections. The key distinction is that B3LYPML-D includes the DFT-D4, while B3LYPML does not, despite both having identical NN parameters for their ML corrections. The difference between B3LYPML-D and B3LYP-DML lies in the different NN parameters used for their respective ML corrections.

      The remainder of this paper is organized as follows: Section II describes the methodology for constructing an ML-corrected functional that integrates with empirical corrections for non-covalent interactions. This includes details on the NN methods and computational aspects. Section III presents the results and related discussion. Finally, Section IV offers a summary of the work.

    II.   METHODOLOGY
    • Denoting the energy calculated by B3LYP-D as $E^{\mathrm{B3LYP\text{-}D}}$, the energy calculated by the B3LYP-DML method has the form of

      with

      where $ \Delta E_{\mathrm{D}} $ represents the empirical D4 dispersion correction for describing non-covalent interactions, and the ML correction to the XC energy is expressed as

      Here, the electron density $ \rho $ is defined as the sum of the down and up spin densities, $ \rho = \rho_{\downarrow} + \rho_{\uparrow} $. The three variables in $ \Delta \epsilon_{\text{XC}}^{\text{ML}} $ are the density descriptors used by the generalized gradient approximation (GGA), which include the Wigner-Seitz radius $ r_{s} = (4\pi\rho/3)^{-1/3} $, the relative spin polarization $ \zeta = (\rho_{\downarrow} - \rho_{\uparrow})/\rho $, and the reduced density gradient $s = \dfrac{|\nabla \rho|}{2(3 \pi ^{2})^{1/3} \rho^{4/3}}$ [40]. These three GGA-level descriptors are used to construct a semilocal mapping as follows,

      The SCF calculation integrates the ML correction into the SCF cycles. In contrast, the evaluation of the DFT-D4 term, $ \Delta E_{\mathrm{D}} $, does not participate in the iterative process. The semilocal mapping of Eq.(4) gives rise to a semilocal ML correction to the XC potential,

      Here, $ f^{\text{ML}}=\rho\Delta\epsilon^{\text{ML}}_{\rm XC} $ and $ \sigma = \uparrow,\downarrow $.

      The semilocal mapping described in Eq.(4) is represented by an NN. The NN inputs are referred to as samples, which consist of independent grid points from the numerical integration grids used in the density functional calculations. For each sample, the input generates three descriptors $ \{r_{s}, \zeta, s\} $ from $ \{\boldsymbol{\rho}_{\sigma}(\mathbf{r}), \nabla \boldsymbol{\rho}_{\sigma}(\mathbf{r})\} $. The ML-corrected DFA can be used in conventional SCF calculations and included in the training process.

      As shown in Table I, the training set primarily consists of four types of energy data: TEs, AEs, BDEs, and BHs. The structures and reference values for AE and TE are sourced from the G2-AE and G2-TE datasets [41], while BDE data are obtained from the BDE42 and BDE99 datasets [42]. For BHs, specifically for TS molecules, the structures and reference values come from the HTBH38 and NHTBH38 datasets [43-45]. The model trained on training set demonstrates optimal generalization performance on the validation set and is subsequently selected for further use.

      For the test set of the ML model, we use the TEST12 database, which was previously employed to benchmark DFAs in Ref.[9]. The TEST12 database consists of 12 well-established subsets, including G2-AE [41, 46, 47], which contains the AEs of 148 molecules; G3-HOF [46, 48], which provides the HOFs for 75 molecules; and P6-AE [49], which includes the AEs of platonic hydrocarbon cages $ \text{C}_n $ ($ n = 4, 6, 8, 10, 12, 20 $). Additionally, ALK-AE contains the AEs of 19 alkanes, while G2-IP [47] consists of 84 ionization potentials (IPs), and G2-EA [47] includes 58 electron affinities (EAs).

      The database also features ISO-20, which represents isomerization energies (IEs) for molecules containing one to four non-hydrogen atoms, and ISO-C, which includes the IEs of C20 and C24 in their ground-state geometries. Furthermore, BDE42 [42] provides BDE data for C–C, C–O, and C–N bonds in both small molecules and larger organic compounds, while BDE99 [49] extends this to 83 small molecules, covering various bond types such as H–C, H–O, and C–C. Lastly, HTBH38 [43-45] includes BHs for 38 hydrogen transfer reactions, whereas NHTBH38 [43-45] provides BHs for 38 non-hydrogen transfer reactions.

      All density functional calculations in this work are conducted using the Python-based Simulations of Chemistry Framework (PySCF) [50-53]. Unless otherwise noted, the density functional calculations use the Def2-TZVPD basis set [54-56], which is an extended version of the standard Def2-TZVP [55] basis set with added diffuse functions.

    • Gradient descent algorithms are commonly used to optimize NNs. Typically, the optimization process relies on reference data from experimental measurements or high-level quantum chemical calculations. However, directly applying standard backpropagation and gradient-based algorithms is challenging, as evaluating the ML correction for XC energy involves the SCF process, which obstructs error backpropagation. Given the current ML-corrected functional design, errors propagate only forward through the NN model. Therefore, a gradient-free optimization method, the particle swarm optimization (PSO) algorithm [41, 57, 58], implemented in the Nevergrad open-source library [59], is used to determine the weights of the ML model.

      The weights of the NN are denoted as $ \mathbf{w} $. Using the B3LYP-DML functional to perform density functional calculations yields a set of energy data for the species in the training set. The loss function $ \Omega(\mathbf{w}) $ is computed by comparing these energy values with the reference values:

      where

      Here, $\displaystyle\sum_{a\in m}$ denotes the sum over all constituent atoms of the $ m $th molecule. In Eq.(6), $ M $ denotes the number of AEs in the training set. The term $(\mathrm{AE})^{\mathrm{B3LYP\text{-} D_{ML}}}_{m}$ represents the AE of the $ m $th molecule as calculated using the B3LYP-DML method, while $ (\mathrm{AE})^{\mathrm{ref}}_{m} $ corresponds to the reference AE. Similarly, $ N $ represents the number of TEs in the training set, which includes both molecules and their constituent atoms. The term $E^{\mathrm{B3LYP\text{-} D_{ML}}}_{\mathrm{tot},n}$ refers to the TE of the $ n $th molecule or atom computed using B3LYP-DML, whereas $ E^{\mathrm{ref}}_{\mathrm{tot},n} $ denotes the corresponding reference value.

      In Eq.(7), the term $(\mathrm{AE})^{\mathrm{B3LYP\text{-} D_{ML}}}_{m}$ represents the AE of the $ m $th molecule as calculated using the B3LYP-DML method. The term $\displaystyle\sum\limits_{a\in m}{E}^{\mathrm{B3LYP\text{-} D_{ML}}}_{\mathrm{tot},a}$ represents the sum of the TEs of the atoms in the molecule, while ${E}^{\mathrm{B3LYP\text{-} D_{ML}}}_{\mathrm{tot},m}$ represents the TE of the $ m $th molecule as calculated using the B3LYP-DML method. In Eq.(8), $\mathrm{(BDE)}^{\mathrm{B3LYP\text{-}D_{ML}}}_{j}$ represents the $ j $th BDE for a certain chemical bond in a molecule, computed using B3LYP-DML. $E^{\mathrm{B3LYP\text{-}D_{ML}}}_{\mathrm{molecule},j}$ is the TE of the molecule associated with the $ j $th bond, while $E^{\mathrm{B3LYP\text{-}D_{ML}}}_{\mathrm{radical},i}$ denotes the TE of the $ i $th radical species generated through the cleavage of the $ j $th bond. In Eq.(9), $\mathrm{(BH)}^{\mathrm{B3LYP\text{-}D_{ML}}}_{k}$ denotes the BH for the $ k $th reaction. $E^{\mathrm{B3LYP\text{-}D_{ML}}}_{\mathrm{TS},k}$ is the TE of the TS, whereas $E^{\mathrm{B3LYP\text{-}D_{ML}}}_{\mathrm{reactant},i}$ denotes the TE of the $ i $th reactant species that contributes to the formation of the TS. Here, the reactant can be either a molecule or an atom.

      This study implements an NN model using the open-source PyTorch ML framework [60]. The network architecture is chosen to be $ 3 \times 40 \times 40 \times 40 \times 1 $, consisting of three input neurons representing the electron density descriptors $ \{r_{s}, \zeta, s\} $ and a single output neuron, as shown in FIG. 1. A three-hidden-layer configuration is selected to balance optimization efficiency and correction performance. For non-gradient optimization, the Nevergrad library [59] is used, with the PSO algorithm chosen due to its simplicity and efficiency. The PSO method optimizes the weights $ \mathbf{w} $ based on the loss function $ \Omega(\mathbf{w}) $ without requiring gradient information. The training process is illustrated in FIG. 1 and described as follows:

      (1) The weights of the NN at the $ i $-th step are denoted as $ \mathbf{w}_i $. When a sample from the training set is fed into the NN, the XC energy density $ \{\epsilon_{\text{XC}}^{i+1}(\mathbf{r}, \mathbf{w}_i)\} $ is obtained after the SCF calculation using the B3LYP-DML functional at the $ i $-th step.

      (2) Once $ \{\epsilon_{\mathrm{XC}}^{i+1}\left(\mathbf{r}, \mathbf{w}_{{i}}\right)\}$ has been obtained, the loss function is computed using Eq.(6). A decision is then made based on the criteria $\text{Loss} \leq y_1 \ {\rm{and}} e_{\text{scf}} \leq y_2$. If these criteria are met, the training is finished, and the NN parameters $ {{\bf{w}}}_{{{i}}} $ are finalized. If the conditions are not met, the parameters of the NN will continue to be optimized using the PSO algorithm. The process then returns to the initial step to repeat the optimization.

    • When evaluating the prediction error of DFAs on specific subsets, the distribution of the prediction error is unknown, but visualizing the data distribution is essential. Traditional histograms partition data into discrete bins, potentially obscuring underlying distribution characteristics. In contrast, kernel density estimation (KDE) [61, 62], a nonparametric method, does not assume a predefined data distribution and produces a smooth, continuous probability density function. This approach more accurately represents error distributions, capturing subtle features and trends. Consequently, KDE facilitates a clearer analysis of DFAs’ predictive performance across different subsets. KDE approximates the distribution using a kernel function:

      where $ x $ is the evaluation point, $ x_i $ are sample points, $ n $ is the sample size, $ h $ is the bandwidth, and $ K(\cdot) $ is the kernel function. The commonly used Gaussian kernel is:

      Scott’s rule [63] estimates the bandwidth as:

      where $ \sigma $ is the data’s standard deviation. The constant 1.06 is empirically determined by Scott [63].

      When evaluating the performance of DFAs, we employ the WTMAD-2 method proposed by Goerigk et al. [64]. The advantage of this method lies in its simultaneous consideration of two key factors: the single-point energy calculations within the subset and the number of molecules present. By incorporating both aspects, the WTMAD-2 method provides a more objective and comprehensive assessment of a functional’s overall performance on the database. The expression for WTMAD-2 is given by:

      Here, $ i $ labels a subset in the database, $ N_i $ represents the number of single-point energies in the $ i $-th subset, $ |\overline{\Delta E}|_i $ denotes the average absolute relative energy of the $ i $-th subset, and $ |\overline{\Delta E}| $ is the average magnitude of all single-point energies in the TEST12 database. In this work, the WTMAD-2 method is employed to evaluate the overall predictive accuracy of the TEST12 database.

    III.   RESULTS AND DISCUSSION
    • After training the NN and obtaining the optimal model, this ML correction is applied to B3LYP-D , and the performance of the resulting B3LYP-DML functional is evaluated on the TEST12 database.

      As demonstrated in FIG. 2, an analysis of WTMAD-2 values across the TEST12 database reveals significant performance differences among various functionals. The original B3LYP functional yields a WTMAD-2 of 43.5 kcal/mol, whereas B3LYP-DML successfully reduces this value to 25.7 kcal/mol. Notably, this reduction surpasses that achieved by B3LYPML , highlighting the superior overall performance of B3LYP-DML.

      A detailed examination of specific subsets where B3LYP-DML achieves substantial improvements reveals significant error reductions in P6-AE, ALK-AE, and ISO-C subsets. Additionally, the MADs are lower in HTBH38 and NHTBH38, both of which contain TS molecules. In the ALK-AE subset, the energies of linear alkanes are strongly influenced by NCIs between alkyl groups [65, 66]. The P6-AE and ISO-C subsets contain a large number of cage-like molecules, where steric effects, which are also related to NCIs, play a crucial role in determining total energy. By incorporating DFT-D4 during training, the model effectively accounts for errors associated with NCI-related subsets. The presence of TS molecules in the training set contributes to a reduction in the MADs for HTBH38 and NHTBH38, which in turn helps decrease the overall WTMAD-2. The performance of B3LYP-DML across these subsets leads to a significant reduction in the overall WTMAD-2 value, providing strong evidence of its effectiveness in accurately addressing complex molecular systems.

      In the performance evaluation of B3LYP-DML, the MAD increases in six out of twelve subsets compared to B3LYPML. More critically, the WTMAD-2 also exhibits a significant upward trend relative to B3LYPML, indicating some incompatibility when directly applying DFT-D4 to B3LYPML. Further investigation into the causes of the WTMAD-2 increase in B3LYPML-D identifies the G3-HOF, ALK-AE, and BDE99 subsets as key contributors. During the training of B3LYPML, the NN model did not explicitly account for NCIs. Consequently, error compensation likely occurred between the model’s intrinsic errors and NCI-related errors. In practical applications, the performance of B3LYPML appeared favorable, partly due to the mutual cancellation of these errors. However, when DFT-D4 is applied to B3LYPML-D, the NCI-related errors are corrected, exposing the previously masked intrinsic model errors, which ultimately leads to a significant increase in WTMAD-2.

      The results indicate that the B3LYP-DML exhibits superior overall performance, particularly in modeling complex molecular systems involving NCIs and TS species. In contrast, B3LYPML-D shows significant incompatibility when DFT-D4 is applied, primarily due to the lack of NCI considerations during NN training. This leads to a substantial increase in prediction errors.

    • The subsets G3-HOF, ALK-AE and ISO-C significantly contribute to the reduction in WTMAD-2 for B3LYP-DML, closely resembling the performance of B3LYPML. A closer examination of the KDE distribution reveals distinct differences between the two methods. Specifically, the KDE distribution of B3LYP-DML is more concentrated, indicating smaller error fluctuations and higher accuracy in predicting the relevant properties.

      When the DFT-D4 is directly applied to B3LYPML, the MAD increases substantially. This rise occurs because the initially favorable error performance of B3LYPML is partly due to compensatory cancellations between model errors and NCI-related errors. Once DFT-D4 corrects the NCI errors, previously masked intrinsic model errors become apparent, resulting in a significant increase in errors for B3LYPML-D. This is clearly reflected in FIG. 3(a), where the KDE distribution broadens and the extremes of the errors increase.

      Turning to FIG. 3(b), which presents the results for the ALK-AE subset, a notable change is observed after applying the DFT-D4 , the error distributions of both B3LYPML and B3LYP become significantly narrower, accompanied by a substantial decrease in the MAD of B3LYP. This suggests that DFT-D4 effectively accounts for non-covalent interactions in long-chain alkanes. However, due to error cancellation, the errors of B3LYPML increase after applying the DFT-D4, indicating an incompatibility between the ML correction and DFT-D4. In contrast, B3LYP-DML mitigates this incompatibility, thereby demonstrating its unique advantage in handling long-chain alkane systems.

      Next, considering FIG. 3(c), which illustrates the results for the ISO-C subset, it is evident that the KDE peaks of B3LYP and B3LYPML coincide, suggesting that the ML correction does not effectively account for steric effects in cage molecules. After applying the DFT-D4, the peaks of both B3LYP-DML and B3LYP-D remain aligned. However, the MAD of both methods decreases significantly, indicating that the DFT-D4 is crucial for improving steric effect predictions. Furthermore, B3LYP-DML exhibits the lowest MAD and the most concentrated KDE distribution, highlighting its enhanced predictive capability for the ISO-C subset. This improvement suggests that, beyond the benefits of the DFT-D4, B3LYP-DML provides a more reliable approach for accurately predicting the properties of cage molecules.

      For the BDE99 subset in FIG. 3(d), although the KDE distribution of the B3LYP-DML close to that of other functionals, we observed a slight reduction in the MAD. This suggests the effectiveness of incorporating BDEs into the training set. In the HTBH38 and NHTBH38 subsets, although the KDE distribution shapes remain similar, the KDE distribution of B3LYP-DML is slightly more concentrated than that of other functionals; see FIG. 3 (e) and (f). This indicates that integrating TS molecules data into the training set enhances the functional’s predictive accuracy for subsets containing TS molecules.

      The KDE analysis thus confirms that incorporating both BDEs and TS molecules into the training set leads to a modest performance improvement in B3LYP-DML for subsets containing BDEs and TS molecules, highlighting the critical influence of training set composition on method performance. Additionally, KDE analysis of the G3-HOF, ALK-AE, and ISO-C subsets reveals that B3LYP-DML effectively resolves the incompatibility between ML correction and DFT-D4 in the G3-HOF and ALK-AE subsets. Furthermore, in the ISO-C subset, B3LYP-DML demonstrates superior accuracy in predicting steric effects in cage molecules. Overall, expanding the training set and incorporating DFT-D4 during training significantly enhance the model’s predictive accuracy.

    IV.   CONCLUSION
    • In this paper, the ML-corrected DFAs, including B3LYPML, B3LYPML-D, and B3LYP-DML, are benchmarked on the TEST12 database. The main conclusions are summarized as follows:

      (i) The suboptimal performance observed when directly applying DFT-D4 to B3LYPML stems from error cancellation. While B3LYPML benefits from compensating errors related to non-covalent interactions, the application of the DFT-D4 removes these compensations, thus revealing the underlying deficiencies in the model.

      (ii) The issue above is effectively addressed by adjusting the model parameters, expanding the training set, and retraining the model without the need to reparameterize DFT-D4. As a result, B3LYP-DML achieves better compatibility and enhanced predictive accuracy.

      To conclude, this study advances the field of ML-corrected functionals by developing models that significantly outperform the traditional B3LYP-D functional. By incorporating ML techniques, the research introduces enhancements that lead to more accurate predictions and improved performance across various chemical systems.

    Figure (3)  Table (1) Reference (66)

Catalog

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return