Abstract
Physics-informed neural networks (PINN) have recently become attractive for solving partial differential equations (PDEs) that describe physics laws. By including PDE-based loss functions, physics laws such as mass balance are enforced softly in PINN. This paper investigates how mass balance constraints are satisfied when PINN is used to solve the resulting PDEs. We investigate PINN’s ability to solve the 1D saturated groundwater flow equations (diffusion equations) for homogeneous and heterogeneous media and evaluate the local and global mass balance errors. We compare the obtained PINN’s solution and associated mass balance errors against a two-point finite volume numerical method and the corresponding analytical solution. We also evaluate the accuracy of PINN in solving the 1D saturated groundwater flow equation with and without incorporating hydraulic heads as training data. We demonstrate that PINN’s local and global mass balance errors are significant compared to the finite volume approach. Tuning the PINN’s hyperparameters, such as the number of collocation points, training data, hidden layers, nodes, epochs, and learning rate, did not improve the solution accuracy or the mass balance errors compared to the finite volume solution. Mass balance errors could considerably challenge the utility of PINN in applications where ensuring compliance with physical and mathematical properties is crucial.
Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.Introduction
Partial differential equations (PDEs) are mathematical expressions that describe physical laws governing natural and engineered systems, such as heat transfer, fluid flow, and wave propagation. They are widely used to predict physical variables of interest in spatial and temporal domains. The solutions of PDEs are often combined with laboratory and field experiments to help stakeholders make informed decisions. Therefore, accurate estimation of variables of interest is critical. Numerous methods are used to solve PDEs, including analytical1,2,3, finite difference4,5, finite volume5,6,7, finite element5,8.
In recent times, there have been significant developments in machine learning and physics-informed machine learning methods, leading to the emergence of physics-informed neural networks (PINN)9,10,11,12,13 as a popular tool for solving partial differential equations (PDEs). The approach involves treating the primary variable in the PDE as a neural network. The underlying PDE is then discretized using auto-differentiation, and modern optimization frameworks are used to minimize a loss function. The loss function captures losses from the residual PDE and the initial and boundary conditions. Such PINN methods have been used to solve a wide range of scientific and engineering problems, including metamaterials, fluid dynamics, and geometries9,10,11,11,12,13,14,15,16,17,18,19,20,21.
These literature examples demonstrate that PINN can handle complex geometry quite effectively. However, it has been shown that training a PINN model is a computationally expensive process, and the resulting solutions are not always as accurate compared to numerical solutions11,22,23. For instance, the training process can take thousands of epochs, and the absolute error of forward solutions is approximately \(10^{-5}\) due to the difficulties involved in solving high-dimensional non-convex optimization problems23,24.
Several studies have examined the limitations of PINN in terms of computation time and accuracy. For example, Jagtap et al.22 addressed the accuracy issue of PINN by introducing an additional constraint term to the loss function that enforces continuity/flux across the subdomain boundaries. However, this additional term makes the model more complex to train, requiring more data and increased computational cost. On the other hand, Huang et al.25 focused on improving the training efficiency of PINN by incorporating multi-resolution hash encoding that provides locally-aware coordinate inputs to the neural network. However, this encoding method requires careful selection of hyperparameters and auto-differentiation, complicating training and post-training processes. A comprehensive study is required to evaluate how well PINN solutions satisfy balance laws, such as mass, momentum, and energy.
This study aimed to determine whether PINN conserved local and global mass and compared its performance with the FV method. For this purpose, we solved a steady-state 1D groundwater flow equation (diffusion equations) to calculate hydraulic heads using analytical, the two-point finite volume (FV), and PINN methods for homogeneous and heterogeneous media cases. We conducted hyperparameter tuning by generating an ensemble of 10,800 unique scenarios for each case using a grid search technique to explore all possible combinations of hyperparameters and find the best PINN model. Subsequently, we computed the accuracy of the FV and PINN models using performance metrics such as MSE, \( R^2\), MBE, and NSE(spatial), comparing the hydraulic heads calculated using the analytical solution. Finally, we investigated the integrity of the PINN models by computing Darcy’s flux, local mass balance error, and global mass balance error.
The paper is structured as follows: the section “Governing equations” provides the governing equations for groundwater flow and equations for mass balance error calculation. The section “Methodology” presents the analytical, two-point flux finite volume, and PINN solutions for the governing equations described in section “Governing equations”, hyperparameters tuning, and performance matrices. The section “Results and discussion” discusses the results for tuning PINN to find the best model, and compares the analytical, finite volume, and PINN solutions for the hydraulic head, Darcy’s flux, and mass balance error. Finally, conclusions are drawn in the section “Conclusions”.
Governing equations
The one-dimensional steady-state balance of mass for groundwater flow in the absence of sources and sinks within the flow domain is:
where, q(x) [L/T], follows the Darcy’s model given by:
where, h[L] is the piezometric head, x[L] is the coordinate, and K[L/T] is the hydraulic conductivity. Using Eqs. 1 and 2, the governing equation for the balance of mass becomes:
Equation 3 requires two boundary conditions for the head. Assuming a unit-length domain, if \(h_L, h_R\) are the heads at the left and right faces of the domain, then \(h(x=0) = h_L\) and \(h(x=1) = h_R\).
The model domain (\(x \in [0,1]\)) is discretized into a finite number of cells (NCells). Figure 1 shows the discretization for obtaining both the FV and PINN solutions. Assuming a unit area for the one-dimensional domain, the mass flux at face \(i-\frac{1}{2}\) (\(m_{\textrm{local}_{i-\frac{1}{2}}}\)), the local mass balance error (LMBE) in cell i, and the global mass balance error (GMBE) are:
where, \({\rho _w}\) \([M/L^3]\) is the density of water, \(q_{i-\frac{1}{2}}\) [L/T] is Darcy’s flux at face \(i-\frac{1}{2}\), \(x_{i-1/2}\) and \(x_{i+1/2}\) are locations of the faces where the Darcy fluxes are computed. For the sake of simplicity, we set \(\rho_w=1\)
Methodology
This section briefly describes the analytical, FV, and PINN methods to solve Eq. 3. We consider two scenarios – homogeneous (K is a constant) and heterogeneous (K varies with x) porous media.
Analytical solution
Considering K as constant and choosing \(h(x=0) = 0\) and \(h(x=1) = 0.9\) as the Dirichlet boundary conditions, the analytical solution can be derived as follows:
With K varies as a function of space as \( K(x) = (x + 0.5)^2/2.25\) (a non-negative convex function), the analytical solution for the heterogeneous scenario can be derived as:
Numerical solution using finite volume
For the homogeneous medium, the discretized forms of Eq. 3 using the two-point flux finite volume with a central difference for gradient, \(\frac{dh}{dx}\), are as follows:
while for the heterogeneous medium:
Along with the boundary conditions, \(h(x=0) = 0\), and \(h(x=1) = 0.9\), the linear systems of Eqs. 7 and 8 were solved using the LU decomposition method in SciPy Python package26.
PINN solution
The deep neural network (DNN) approximation of groundwater heads as a function of x, and weights and biases (\(\theta \)) of a neural network is:
DNN approximation of the governing Eq. 3 for the homogeneous case is given by:
while the heterogeneous case is
The loss function (accounting for the losses in the PDE residual and the residual due to the boundary conditions) without training data for the above scenarios is
The first term on the right-hand side in Eq. 12 is the loss due to the PDE residual at collocation points. The second term in Eq. 12 is loss due to the Dirichlet boundary condition. In this loss function, \({N_c}\) and \({N_D}\) represent the number of collocation points and the number of Dirichlet boundary conditions, respectively. \(x_i^C\) and \(x_i^D\) are the locations of the collocation points and Dirichlet boundaries, respectively.
If we include training data for the heads, an additional loss term is added in Eq. 12, and the overall loss function for this scenario become
This last term in Eq. 13 is the loss to match h(x) to the measurements \(h^{*}\). \({N_h}\) represents the number of head measurements/data. The head training data and Dirichlet boundary conditions are represented by \(h^*\) and \(g^*\). \(x_i^C, x_i^D, x_i^h\) are the locations of the collocation points, Dirichlet boundaries, and head data, respectively.
Figure 2 illustrates the PINN structure used in this study to solve partial differential equations describing 1D steady-state groundwater flow problems in homogeneous and heterogeneous porous media. The PINN solution, \(\hat{h}(x;\theta )\) (see Fig. 2), is obtained by
and the optimal solution is obtained by selecting the model with minimal loss through extensive hyperparameter tuning.
To develop PINN, multi-layer feed-forward DNNs27,28 are used. The hyperbolic tangent was used as the activation function because it is infinitely differentiable and facilitated for differentiating Eq. 3 twice. The remaining PINN hyperparameters are collocation points, learning rate, training data, and epoch numbers. Collocation points (\(x_i^C\)) in Eq. 13 are the locations in the model domain where PINN is trained for satisfying the PDE. We coincide these points with the FV cell centers for comparison its solution with analytical and numerical solutions. Training data are the observations/measurements or sampled values from an analytical solution used to train PINN. Epoch is one complete pass of the training dataset (PDE, BCs, ICs where needed, and the training data) through the optimization algorithm to train PINN. The learning rate is the step size at each epoch while PINN approaches its minimum loss. Our codes for PINN used the JAX python package29.
Hyperparameter tuning to find the best PINN model
To evaluate the performance of PINN solutions, we conducted detailed hyperparameter tuning. Hyperparameters are settings that control the PINN’s learning process, such as the learning rate in an optimization algorithm. They are distinct from process model parameters (e.g., permeability) learned from the data. Our approach involved varying several hyperparameters to generate an ensemble of 10,800 unique scenarios using grid search, which explores all possible combinations of hyperparameters to find the best PINN model within the search space. In grid search, we specified a grid of possible values for each hyperparameter you want to tune to define the search space. The search algorithm trains the PINN model on all possible combinations of hyperparameter values from the defined grid. The optimal set combines hyperparameter values that lead to the best performance metric (see Sec. "Performance metrics"). We aimed to identify the optimal PINN models for homogeneous and heterogeneous cases. We varied the hyperparameters, including the number of hidden layers, the number of nodes per hidden layer, the learning rates, the number of epochs, the number of collocation points, and the number of training data points for the head. Table 1 lists the values chosen for these parameters. To run 10,800 realizations, we used the high-performance computing cluster Tahoma30 at Environmental Molecular Sciences Laboratory, which enabled us to distribute the evaluation of different hyperparameter combinations across multiple processors. Tahoma has 184 Intel Cascade Lake nodes, each with a clock speed of 3.1 GHz. Each compute node has two 18-core sockets and 36 Intel Xeon Gold 6254 cores per node, and 384 GB of memory, giving 10 2/3 GB per core. By distributing the search, we could reduce the overall tuning time to less than 24 h to find the optimal hyperparameter set.
Performance metrics
In addition to the loss function, we used mean squared error (MSE), correlation coefficient (\(R^2\)), mean bias error (MBE), and Nash-Sutcliffe’s efficiency (spatial version of NSE) performance metrics31,32,33,34 to evaluate the performance of the PINN and FV methods. The MSE, \(R^2\), MBE, and NSE are given by:
where, n is the number of hydraulic heads, \(h_{\textrm{a}}\) is the head from the analytical solution, \(h_{\textrm{p}}\) is the predicted head from the PINN model, and \({\bar{h}}_{\textrm{a}}\) is the mean of heads derived from analytical solution. The values of the RMSE, \(R^2\), MBE, and spatial version of NSE would be, respectively, 0, 1, 0, 1 for a perfect model32,33. If the MBE is positive, it indicates that the model tends to overestimate the true values. If the MBE is negative, it suggests that the model tends to underestimate the true values. An MBE of zero implies that, on average, the model predictions are unbiased and align closely with the true values.
Results and discussion
This section will present the results of tuning the PINN’s hyperparameters to find the best model. We will then compare the tuned model’s performance with the analytical and FV solutions. Finally, we will assess the mass balance errors associated with the FV and PINN solutions for both homogeneous and heterogeneous cases.
Homogeneous porous media
Tuning PINN for homogeneous media
We trained physics-informed neural networks (PINN) for 10,800 different hyperparameter scenarios to find the best model for the homogeneous case. We used the loss metrics in Eq. 12 for PINN without training data and Eq. 13 for PINN with training data. The optimal set of hyperparameters was determined by selecting the scenario with the lowest loss value during PINN training. The hyperparameters considered included the following: the number of training data points (Fig. 3a), the number of hidden layers (Fig. 3b), the number of nodes per hidden layer (Fig. 3c), the learning rate (Fig. 3d), the number of epochs (Fig. 3e), and the number of collocation points (Fig. 3f). In our study, we trained the PINN model using 0, 7, 20, 40, 80, and 160 sets of training data to compare the performance of PINN with and without training data (see Fig. 3a). The results revealed that the PINN model trained without training data outperformed those trained with datasets. A PINN model out of 1800 trained neural architectures with no data achieved the lowest best loss value of \(1.83 \times 10^{-11}\). The best-performing PINN model trained with data sets out of 9,000 different architectures attained the lowest best loss value of \(2.23 \times 10^{-11}\) with 80 training data (see Table 2). Our thorough tuning analysis led us to focus on the best PINN model without training data, providing a robust basis for our discussion.
In Fig. 3b, it is clear that the tuned PINN achieved the lowest losses across scenarios with 1, 2, and 3 hidden layers. However, fewer hidden layers resulted in higher values when considering the upper bound of best losses (Fig. 3b). More hidden layers led to lower best loss values (Fig. 3b). This figure also illustrates that out of 3600 models, a PINN model with two hidden layers achieved the lowest best loss of \(1.83 \times 10^{-11}\) (Table 2). We investigated how changing the number of nodes (10, 25, and 50) in each hidden layer affected the optimal loss. As shown in Fig. 3c, a PINN model with 50 nodes per hidden layer achieved the lowest loss. Figure 3d shows that using relatively larger learning rates results in significantly lower best losses. A low learning rate, such as \(10^{-4}\), allows for the exploration of multiple local minima within the non-convex loss function, leading to high values for best loss (Fig. 3d). The learning rate \(10^{-2}\) yielded the best PINN model, achieving the lowest best loss of \(1.83 \times 10^{-11}\) (Fig. 3d). In Fig. 3e, it is evident that training the PINN models for a higher number of epochs results in lower best losses. For instance, training the PINN for only 10,000 epochs showed many scenarios with higher best losses (Fig. 3e). The lowest best losses were achieved when the PINN model was trained for 100,000 epochs (Fig. 3e).
Figure 3f illustrates that the number of collocation points has a relatively minor impact on achieving the lowest best loss. Notably, models with 41, 81, and 161 collocation points consistently attained the lowest loss values. We investigated the accuracy of the tuned PINN’s prediction and the finite volume (FV) solution with the analytical solution to determine the optimal number of collocation points using the mean squared error (MSE) metrics. Figure 4a illustrates that for all the collocation points, the MSE associated with FV solutions converged to double precision (\(< 10^{-28}\)), while the MSE of PINN predictions with the best PINN models at each collocation point exhibited a relatively higher value of MSE (\(\approx 10^{-13}\)). Notably, 41 collocation points achieved the lowest MSE value for the PINN model. Based on the above systematic study, we found that the best set of hyperparameters for the PINN model is two hidden layers, 50 nodes per hidden layer, a 0.01 learning rate, 100,000 epochs, 41 collocation points, and no training data.
Figure 4b shows the evolution of loss over the epochs of the PINN model during training with the best set of hyperparameters. This figure indicates that the loss value fluctuates significantly throughout the training process. Initially, the loss decreases rapidly, showing that the model is learning quickly and improving its predictions. However, periodic spikes in the loss value increase sharply before reducing again. This behavior could be due to several factors, including the optimizer’s dynamics, learning rate adjustments, or the loss landscape’s non-convex nature. Despite the frequent fluctuations, the overall long-term trend of the loss is downward, suggesting that the model is gradually improving its performance and reducing the error over time. By the end of the training period (at 100,000 epochs), the loss reaches very low values of \(1.83 \times 10^{-11}\) at 97,386 epochs. This indicates that the PINN has achieved a highly accurate fit to the underlying physical equations.
Hydraulic head solutions for the homogeneous media
The hydraulic heads at each collocation point were calculated using the best PINN model with the lowest loss. Additionally, the hydraulic heads at these points were computed using analytical and finite volume (FV) methods. The FV and the PINN solutions overlap the analytical solution (Fig. 5). Table 3 presents statistical analysis for performance evaluation of the FV and PINN methods with the corresponding analytical solution. This table shows that the FV and PINN methods can accurately approximate the true solution for the hydraulic head. The values of MSE, \(R^2\), MBE, and NSE(Spatial) between the analytical and FV solution are \(5.48 \times 10^{-31}\) (approximately the square of machine precision), 1.00, \(-1.54 \times 10^{-15}\), and 1.00, respectively. These metrics show that the FV solution is identical to the analytical solution, proving its accuracy and reliability. The very low MSE and the low MBE confirm that the FV method has minimal errors and biases. High \(R^2\) and NSE values further confirm the high precision and efficiency of the FV solution in approximating the analytical solution. Similarly, the values of MSE, \(R^2\), MBE, and NSE(Spatial) between the analytical and PINN predictions are \(5.27 \times 10^{-14}\), 1.00, \(-8.92 \times 10^{-7}\), and 1.00, respectively. These metrics collectively indicate that the PINN prediction is accurate and closely matches the analytical solution, similar to the Finite Volume (FV) method. Although the MSE for the PINN prediction is slightly higher than that for the FV solution, it is still very low, indicating minimal errors.
Darcy’s flux, local and global mass balance errors
Darcy’s flux is a key indicator that demonstrates the integrity of a numerical solution in porous media. For the steady-state problem, it should remain constant throughout the domain. We calculated Darcy’s fluxes at all nodes/collocation points within the model domain using Eq. 2. The Darcy’s fluxes computed from the FV and PINN solutions are nearly constant across the solution domain and closer to the analytical solution (Fig. 6a). The mean Darcy’s flux for the analytical, FV, and PINN methods are \(4.833 \times 10^{-2} [L/T]\), \(4.896 \times 10^{-2} [L/T]\), and \(4.896 \times 10^{-2} [L/T]\) respectively. The mean Darcy’s fluxes for the FV and PINN methods are slightly higher than that computed from the analytical solution (Table 4), suggesting numerical errors associated with the FV and PINN methods.
The Local Mass Balance Error (LMBE) and Global Mass Balance Error (GMBE) in the model domain were calculated using LMBE and GMBE equations for both FV and PINN solutions. Analytical solutions are exact solutions that do not incur round-off or numerical truncation errors. The LMBE and GMBE of the analytical solutions are zero due to the exactness of the solutions; therefore, they are not discussed here. The LMBEs of the FV solution range from 0 to \(4.46 \times 10^{-15}\) [M/TL\(^2\)], close to machine precision, with a mean LMBE of \(1.28 \times 10^{-15}\) [M/TL\(^2\)]. On the other hand, the LMBEs of the PINN prediction vary from 0 to \(4.46 \times 10^{-6}\) [M/TL\(^2\)], with an average LMBE of \(4.18 \times 10^{-7}\) [M/TL\(^2]\) (Fig. 6b, Table 4). The mean LMBE of PINN prediction is eight orders of magnitude higher than that of the FV solution. The GMBE of the FV and the PINN solutions are \(5.02 \times 10^{-14}\) and \(1.63 \times 10^{-5}\), respectively (Table 4). The GMBE of the PINN predictions is nine orders of magnitude higher than that of the FV solution.
The LMBE and GMBE for PINN are much higher than those of the FV solution, indicating that PINN do not conserve mass locally and globally (Table 1). This discrepancy is primarily due to the fact that FV imposes a strict constraint on the mass balance when solving Eq. 1. Although PINN accurately computes heads, it fails to balance the mass because it aims to minimize the residual contributions from the PDE and the BCs instead of setting these residuals to zero. Another potential reason for this mismatch is the neural network’s inability to optimize its weights and biases as the loss function value decreases due to the non-convex nature of PINN training.
Heterogeneous Porous Media
Tuning PINN for heterogeneous media
Similar to homogeneous media, we explored 10,800 hyperparameter scenarios to optimize PINN for the heterogeneous case. We utilized the loss metrics outlined in Eq. 12 for PINN without training data and the loss function in Eq. 13 for those with training data. The optimal hyperparameters were selected based on the lowest loss value during PINN training. The hyperparameters assessed included the number of training data points (Fig. 7a), the number of hidden layers (Fig. 7b), the number of nodes per hidden layer (Fig. 3c), the learning rate (Fig. 7d), the number of epochs (Fig. 7e), and the number of collocation points (Fig. 7f). In our hyperparameter tuning experiments, we trained the PINN model with 0, 7, 20, 40, 80, and 160 sets of training data to evaluate the performance of PINN with and without training data (see Fig. 7a). The results showed that the PINN model without training data performed better than those trained with data sets, similar to the homogeneous case. We trained a substantial number of 1,800 models without any data, and one of these models achieved the lowest best loss value of \(4.52 \times 10^{-11}\). In comparison, the best-performing PINN model with training data sets, out of 9000 models, reached the lowest best loss value of \(5.95 \times 10^{-11}\) with seven training data points (see Table 5). This comprehensive approach led us to focus on the best PINN model without training data for further analysis. In Fig. 7b, it is evident that the best losses for hidden layers 1, 2, and 3 can vary depending on other hyperparameter configurations. The data indicates that the PINN models achieved relatively low best losses. Specifically, out of 3600 models with two hidden layers, a PINN model attained the lowest best loss of \(4.52 \times 10^{-11}\) (refer to Table 5 for details). Adjusting the number of nodes (10, 25, and 50) in each hidden layer has similar effects to changing the number of hidden layers. Depending on the other hyperparameter configurations, the best losses may be higher or lower for all the nodes (see Fig. 7c). Out of 3600 models, a PINN model with ten nodes per hidden layer achieved the lowest best loss (see Fig. 7c). Figure 7d shows that using relatively larger learning rates leads to significantly lower best losses. For instance, a low learning rate, such as \(10^{-4}\), results in higher values for best loss. The best PINN model achieved the lowest best loss of \(4.52 \times 10^{-11}\) with a learning rate of \(10^{-1}\). In Fig. 7e, it is evident that training the PINN models for more epochs leads to lower best losses. Conversely, training with fewer epochs resulted in significantly higher best losses. The PINN models trained for 80,000, 90,000, and 100,000 epochs exhibited similar best-loss values. However, the model trained for 80,000 epochs achieved the lowest best losses. The lowest best loss for a PINN model was achieved with 11 collocation points (Fig. 7f). To determine the optimal number of collocation points for comparison, we analyzed the convergence of the PINN prediction and FV solution with the analytical solution. As detailed in Eq.15a, the mean squared error metric (MSE) was used to assess the accuracy. The MSE of the FV solution decreases as the number of collocation/grid points within the solution domain increases. Increasing the number of collocation/grid points allows the FV method to more accurately approximate the continuous partial differential equations governing the physical phenomena, resulting in a decrease in the MSE and an improvement in the solution’s accuracy (Fig. 8a). Also, the MSE of the best PINN model for 11, 21, and 41 is lower than that of the FV solutions, indicating the spatial resolution independence advantage of the PINN method in predicting accurate solutions (Fig. 8a). For further analysis and comparisons of PINN prediction with the FV solution, we selected 81 collocation points where the MSE of both methods is comparable (Fig. 8a). The MSE of the PINN prediction and FV for 81 collocation points are \(9.27 \times 10^{-13}\) and \(1.56 \times 10^{-12}\), respectively. Finally, we determined the best optimal hyperparameter values for the PINN model, which includes two hidden layers, 10 nodes, a 0.1 learning rate, 80,000 epochs, 81 collocation points, and 0 training data.
Figure 8b shows the changes in loss over the epochs of the PINN model during training with the best set of hyperparameters. The figure demonstrates that the loss fluctuates significantly during training. Initially, the loss decreases rapidly, indicating that the model is learning quickly and improving its predictions. However, periodic spikes in the loss value occur, increasing sharply before decreasing again. At the end of the 80,000-epoch training period, the loss reaches very low values of \(8.40 \times 10^{-9}\) at the 51,030-th epoch, indicating that the PINN has achieved a highly accurate fit to the underlying physical equations.
Hydraulic head solutions for the heterogeneous media
The best PINN model, which achieved the lowest loss, was used to calculate the hydraulic heads at each collocation point. Hydraulic heads at these points were also computed using the analytical and FV methods. The FV solution and the PINN prediction closely approximate hydraulic heads as in the analytical solution (Fig. 9). The performance evaluation matrics results reveal that the FV and PINN methods can accurately approximate the true solution for the hydraulic head (Table 6). For the FV solution, the performance metrics are as follows: the mean squared error (MSE) is \(9.27 \times 10^{-13}\), the coefficient of determination (\(R^2\)) is 1.00, the mean bias error (MBE) is \(2.09 \times 10^{-6}\), and the Nash-Sutcliffe efficiency (NSE) for spatial data is 1.00. These metrics indicate that the FV solution is very close to the analytical solution, demonstrating high accuracy and reliability. The low MSE and MBE confirm minimal errors and biases in the FV method. The perfect \(R^2\) and NSE values underscore the FV solution’s precision and efficiency in approximating the analytical solution. For the PINN prediction, the metrics are: MSE of \(1.56 \times 10^{-12}\), \(R^2\) of 1.00, MBE of \(3.47 \times 10^{-6}\), and \(NSE (\text {Spatial})\) of 1.00. These metrics indicate that the PINN prediction is highly accurate and closely matches the analytical solution. Although the MSE for the PINN prediction is slightly higher than that for the FV solution, it remains very low, suggesting minimal errors.
Darcy’s flux, local and global mass balance error
We calculated Darcy’s fluxes at all nodes/collocation points across the model domain to assess the solution’s reliability to the steady-state problem in the heterogeneous case. Darcy’s flux should remain constant throughout the model domain to uphold the solution in porous media. The average Darcy’s flux for the analytical, FV, and PINN methods are \(3.333 \times 10^{-2} [L/T]\), \(3.361 \times 10^{-2} [L/T]\), and \(3.361 \times 10^{-2} [L/T]\), respectively (Table 7). Due to numerical error, Darcy’s fluxes for the FV and PINN methods are slightly higher than those of the analytical solution (Fig. 10). We observed that while the mean Darcy’s fluxes of the FV and PINN solutions are the same, the Darcy’s fluxes of the PINN prediction are not constant for the PINN solution (Fig. 10a). These results indicate that while PINN can find accurate head predictions for the solution domain, it does not maintain the integrity of the solution.
The maximum and mean LMBE of the FV solution are \(2.43 \times 10^{-7}\) [M/TL\(^2\)] and \(5.73 \times 10^{-8}\) [M/TL\(^2\)], respectively, whereas the maximum and mean LMBE of the PINN prediction are \(7.71 \times 10^{-5}\) [M/TL\(^2\)] and \(2.05 \times 10^{-5}\) [M/TL\(^2\)] (Fig. 10b, Table 7). The PINN prediction’s mean LMBE is three orders higher than the FV solution’s. The GMBE of the FV and the PINN solutions are \(5.02 \times 10^{-14}\) and \(1.63 \times 10^{-5}\), respectively (Table 7). The GMBE of the PINN predictions is also three orders of magnitude higher than that of the FV solution.
The LMBE and GMBE for PINN are higher than those for the FV solution. This suggests that PINN does not conserve mass locally and globally (see Table 7). One of the main reasons for the significant difference in LMBE and GMBE between the FV and PINN solutions is that the FV method strictly enforces a mass balance constraint when solving Eq. 3. Although the PINN model accurately computes head values, it fails to maintain mass balance because its primary goal is to minimize the global residual contributions from the PDEs and BCs rather than setting these residuals exactly to zero.
Conclusions
PINN offers an alternative approach to solving physical problems described by partial differential equations. We examined whether PINN preserved local and global mass and assessed its performance against the FV method. This involved solving a steady-state 1D groundwater flow equation to determine hydraulic heads using analytical, FV, and PINN approaches for homogeneous and heterogeneous media scenarios. We fine-tuned hyperparameters by generating 10,800 unique scenarios per case through grid search. Subsequently, we evaluated FV and PINN accuracy using metrics like MSE, R2, MBE, and NSE(spatial) relative to the analytical solution for hydraulic heads. Lastly, we assessed the integrity of PINN models by analyzing Darcy’s flux and local and global mass balance errors.
In the case of homogeneous media, we determined the optimal configuration for the PINN model. This included two layers with 50 nodes per hidden layer, a learning rate 0.01, 100,000 epochs, 41 collocation points, and no training data through 10,800 hyperparameter tuning scenarios. The MSE, \(R^2\), MBE, and NSE(spatial) scores were found to be \(5.27 \times 10^{-14}\), 1.0, \(-8.92 \times 10^{-7}\), and 1.0 respectively. These scores indicate the reliability and accuracy of the PINN method in predicting hydraulic heads. Darcy’s fluxes with the FV and PINN methods appear similar and relatively constant, resembling the analytical solution. However, the fluxes are slightly higher than the analytical solution due to numerical truncation error. The mean LMBE and GMBE of the PINN prediction are 8 and 9 orders of magnitude higher, respectively, than those of the FV solution. These higher values of LMBE and GMBE for the PINN prediction suggest that the PINN method struggles to conserve mass locally and globally while solving a PDE problem.
We have selected the best set of hyperparameters for the PINN model based on convergence analysis and comparison with the FV solution for heterogeneous media case. This includes two hidden layers, ten nodes, a learning rate 0.1, 80,000 epochs, 81 collocation points, and no training data for PINN training and prediction. PINN demonstrated reliability and accuracy in predicting hydraulic head solutions in the heterogeneous case. The MSE, \(R^2\), MBE, and spatial NSE scores for the heterogeneous media case are \(1.56 \times 10^{-12}\), 1.0, \(3.47 \times 10^{-7}\), and 1.0, respectively. While the mean values of Darcy’s fluxes for the finite volume and PINN solutions are consistent, Darcy’s fluxes in the PINN prediction fluctuate within the solution domain. This fluctuation contradicts the expected behavior, as Darcy’s flux should remain constant throughout the solution domain for a steady-state problem. The fluctuation of Darcy’s flux in the PINN method indicates a lack of integrity in solving the problem. The mean LMBE and GMBE of the PINN prediction are three orders of magnitude higher than those of the FV solution. Similar to the homogeneous media case, PINN fails to conserve mass locally and globally while solving the Partial Differential Equation (PDE) for the heterogeneous media case.
In both homogeneous and heterogeneous cases, the significant difference in LMBE and GMBE between FV and PINN solutions stems from FV’s imposition of a strict mass balance constraint, whereas PINN achieves its solution by softly enforcing this constraint when solving PDE problems. Although PINN calculates accurate heads, it struggles to balance the mass because it aims to minimize the residual contribution from the PDE and the BCs instead of precisely setting these residuals to zero. Another potential reason for this discrepancy is the neural network’s inability to optimize its weights and biases as the loss function value decreases due to the non-convex nature of PINN training. These findings highlight the limitations of PINN in applications where local or global mass conservation is crucial.
Data availability
The data and codes used in the paper are available at https://gitlab.com/mlmamud/mass_balance_of_pinn.git upon publication.
Abbreviations
- PINN:
-
Physics-informed neural networks
- PDE:
-
Partial differential equation
- FV:
-
Finite volume
- DNN:
-
Deep neural network
- MSE:
-
Mean squared error
- LMF:
-
Local mass flux
- LMBE:
-
Local mass balance error
- GMBE:
-
Global mass balance error
- CP:
-
Collocation points
- TD:
-
Training data
References
Guo, W. Analytical solution of transient radial air flow to an extraction well. J. Hydrol. 194(1–4), 1–14 (1997).
Meleshko, S. V. Methods for Constructing Exact Solutions of Partial Differential Equations: Mathematical and Analytical Techniques with Applications to Engineering (Springer, New York, 2005).
Wexler, E. J. Analytical solutions for one-, two-, and three-dimensional solute transport in ground-water systems with uniform flow. U.S. Geological Survey, Technical Report (1989).
Richardson, L. F. On the approximate arithmetical solution by finite differences of physical problems involving differential equations, with an application to the stresses in a masonry dam. Proc. R. Soc. Lond. Ser. A Contain. Pap. Math. Phys. Character 83(563), 335–336. https://doi.org/10.1098/rspa.1910.0020 (1910).
Peiró, J. & Sherwin, S. Finite Difference, Finite Element and Finite Volume Methods for Partial Differential Equations (Springer, Dordrecht, 2005). https://doi.org/10.1007/978-1-4020-3286-8_127.
LeVeque, R. J. Finite Volume Methods for Hyperbolic Problems (Cambridge University Press, Cambridge, 2002).
Moukalled, F., Mangani, L. & Darwish, M. The Finite Volume Method in Computational Fluid Dynamics: An Advanced Introduction with OpenFOAM® and Matlab (Springer, New York, 2016).
Johnson, C. Numerical Solution of Partial Differential Equations by the Finite Element Method (Dover Publications, New York, 2009).
Lagaris, I. E., Likasa, A., & Fotiadi, D. I. Artifial neural networks for solving ordinary and partial differential equations. IEEE Trans. Neural Netw. 9(5), 987-100 (1998).
Lagaris, I. E., Likas, A. C. & Papageorgiou, D. G. Neural-network methods for boundary value problems with irregular boundaries. IEEE Trans. Neural Netw. 11(5), 1041–1049 (2000).
Raissi, M., Perdikaris, P., & Karniadakis, G. E. Physics informed deep learning (part I): Data-driven solutions of nonlinear partial differential equations, 11 (2017). [Online]. http://arxiv.org/abs/1711.10561
Chen, D. et al. FlowDNN: A physics-informed deep neural network for fast and accurate flow prediction. Front. Inf. Technol. Electron. Eng. 23(2), 207–219 (2022).
Lu, L., Meng, X., Mao, Z., & Karniadakis, G. E. DeepXDE: A deep learning library for solving differential equations, 7 (2019). [Online]. http://dx.doi.org/10.1137/19M1274067
Chen, Y., Lu, L., Karniadakis, G. E., & Negro, L. D. Physics-informed neural networks for inverse problems in nano-optics and metamaterials, 12 (2019). [Online]. https://doi.org/10.1364/OE.384875
Han, J., Jentzen, A., & W. E, Solving high-dimensional partial differential equations using deep learning, 7 (2017). [Online]. https://doi.org/10.1073/pnas.1718942115
Kakkar, S. Physics-informed deep learning for computational fluid flow analysis coupling of physics-informed neural networks and autoencoders for aerodynamic flow predictions on variable geometries, Ph.D. dissertation, Delft University of Technology (2022).
Liu, Z., Yang, Y., & Cai, Q.-D. Solving differential equation with constrained multilayer feedforward network, 4 (2019). [Online]. http://arxiv.org/abs/1904.06619
Rezaei, S., Harandi, A., Moeineddin, A., Xu, B.-X., & Reese, S. A mixed formulation for physics-informed neural networks as a potential solver for engineering problems in heterogeneous domains: comparison with finite element method, 6 (2022). [Online]. https://doi.org/10.1016/j.cma.2022.115616
Eivazi, H., Tahani, M., Schlatter, P. & Vinuesa, R. Physics-informed neural networks for solving Reynolds-averaged Navier–Stokes equations. Phys. Fluids 34(7), 7 (2022).
Kashefi, A. & Mukerji, T. Prediction of fluid flow in porous media by sparse observations and physics-informed PointNet, 8 (2022). [Online]. http://arxiv.org/abs/2208.13434
Giampaolo, F., De Rosa, M., Qi, P., Izzo, S. & Cuomo, S. Physics-informed neural networks approach for 1D and 2D Gray-Scott systems. Adv. Model. Simul. Eng. Sci. 9(1), 12 (2022).
Jagtap, A. D., Kharazmi, E. & Karniadakis, G. E. Conservative physics-informed neural networks on discrete domains for conservation laws: applications to forward and inverse problems. Comput. Methods Appl. Mech. Eng. 365, 6 (2020).
Chuang, P.-Y. & Barba, L. A. Experience report of physics-informed neural networks in fluid simulations: Pitfalls and frustration. In Proceedings of the 21st Python in Science Conference (SCIPY 2022) (2022).
Cuomo, S., di Cola, V. S., Giampaolo, F., Rozza, G., Raissi, M. & Piccialli, F. Scientific machine learning through physics-informed neural networks: Where we are and what’s next, 1 (2022). [Online]. http://arxiv.org/abs/2201.05624
Huang, X. & Alkhalifah, T. Efficient physics-informed neural networks using hash encoding, 2 (2023). [Online]. https://arxiv.org/abs/2302.13397v1
Virtanen, P. et al. SciPy 1.0: fundamental algorithms for scientific computing in python. Nat. Methods 17(3), 261–272 (2020).
Bebis, G. & Georgiopoulos, M. Feed-forward neural networks. IEEE Potentials 13(4), 27–31 (1994).
Svozil, D., Kvasnička, V. & Pospíchal, J. Introduction to multi-layer feed-forward neural networks. Chemom. Intell. Lab. Syst. 39(1), 43–62 (1997).
Bradbury, J., et al. JAX: Composable transformations of Python+NumPy programs, (2018). [Online]. http://github.com/google/jax
Environmental molecular science laboratory tahoma user guide. https://www.emsl.pnnl.gov/MSC/UserGuide/tahoma/tahoma_overview.html (2023).
Maroufi, H. & Mehdinejadiani, B. A comparative study on using metaheuristic algorithms for simultaneously estimating parameters of space fractional advection-dispersion equation. J. Hydrol. 602, 126757 (2021).
Gueymard, C. A. A review of validation methodologies and statistical performance indicators for modeled solar radiation data: Towards a better bankability of solar projects. Renew. Sustain. Energy Rev. 39, 1024–1034 (2014).
Behar, O., Khellaf, A. & Mohammedi, K. A review of studies on central receiver solar thermal power plants. Renew. Sustain. Energy Rev. 23, 12–39 (2015).
Sanikhani, H. et al. A comparative survey of monthly precipitation forecasting using computational intelligence techniques and statistical methods. Theoret. Appl. Climatol. 131, 799–816 (2018).
Acknowledgements
MLM and BA thank the U.S. Department of Energy’s Biological and Environmental Research Program for support through the SciDAC4 program. MLM also thanks the Center for Nonlinear Studies at Los Alamos National Laboratory. MLM, SK, and MKM thank the Environmental Molecular Sciences Laboratory (EMSL) for its support. EMSL is a DOE Office of Science User Facility sponsored by the Biological and Environmental Research program under Contract No. DE-AC05-76RL01830. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.
Author information
Authors and Affiliations
Contributions
Dr. Mamud: Conceptualization, code development, formal analysis, generating figures, writing and reviewing the manuscript. Dr. Mudunuru: Conceptualization, software, data analysis, manuscript—editing and reviewing, funding. Dr. Karra: Conceptualization, software, manuscript—editing and reviewing, funding. Dr. Ahmmed: Conceptualization, software, manuscript—editing and reviewing, funding.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher's note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Supplementary Information
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Mamud, M.L., Mudunuru, M.K., Karra, S. et al. Quantifying local and global mass balance errors in physics-informed neural networks. Sci Rep 14, 15541 (2024). https://doi.org/10.1038/s41598-024-65472-9
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s41598-024-65472-9
- Springer Nature Limited