Skip to Content
Applied SciencesApplied Sciences
  • Article
  • Open Access

28 February 2026

20 Pages

DDR-PINN: A Dynamic Domain–Gradient Reweighting Physics-Informed Neural Network

,
,
,
,
and
1
Faculty of Information Technology and Artificial Intelligence, Al-Farabi Kazakh National University, Almaty 050040, Kazakhstan
2
Institute of Industrial Electronics, Electrical Engineering and Energy, Faculty of Computer Science, Information Technology and Energy, Riga Technical University, 1048 Riga, Latvia
*
Author to whom correspondence should be addressed.

Abstract

Physics-informed neural networks (PINNs) solve partial differential equations (PDEs) by embedding physical conditions as soft penalties into the loss function. However, the coexistence of multiple loss components often leads to gradient conflicts, degrading convergence and solution accuracy. To address this issue, we propose a dynamic domain–gradient loss reweighting PINN (DDR-PINN). The proposed method introduces a dual-residual reweighting mechanism based on gradient variations, where adaptive weights are derived from the L2 norm of the dot product between loss gradients and residuals. These weights are further normalized through a nonlinear hyperbolic tangent transformation, enabling dynamic and balanced reweighting of interior, initial, and boundary domain losses throughout training. Extensive numerical experiments on PDEs with both Dirichlet and Neumann boundary conditions demonstrate that the DDR-PINN consistently outperforms the standard PINN, APINN, and VI-PINN with the fewest trainable parameters.

1. Introduction

In recent years, machine learning (ML) has achieved remarkable advancements, driven by rapid growth in data availability and computational power. As a representative data-driven approach, traditional ML technology extracts knowledge from massive datasets. However, its effectiveness is often constrained by the availability of high-quality labeled data and the limited interpretability of model mechanisms [1,2]. In contrast, physics-driven approaches rely on explicit governing equations and expert knowledge [3], which frequently lead to complex modeling processes and limited generalization performance. Therefore, the concept of physics-informed machine learning (PIML) has emerged as a promising framework that embeds prior physical knowledge into ML models, enabling accurate solutions for physical problems under limited or even data-free conditions [4,5]. Physics-Informed Neural Networks (PINNs) constitute a key research direction within PIML [6]. By incorporating partial differential equations (PDEs), boundary and initial conditions into the loss function, PINNs leverage automatic differentiation to approximate PDE solutions [7,8]. Owing to their mesh-free nature and flexibility, nowadays, PINNs have been successfully applied across a wide range of scientific and engineering fields, including materials science [9], mechanics [10,11], energy [12,13], and related fields [14,15,16].
Despite these advantages, PINNs continue to face several critical challenges, including high computational complexity, slow convergence, and limited training stability [17,18]. These issues primarily arise from the composite structure of the PINN loss function, which simultaneously incorporates interior PDE and boundary condition residuals. Training discrepancies in scale and numerical characteristics often lead to conflicting gradients and oscillatory convergence [19]. To address these challenges, researchers have conducted extensive efforts. Focused on critical regions or physical conditions, adjusting sampling or training strategies makes PINNs more effective. The DP-PINN+ [20] is a novel training framework for PINNs, which divides the training process into two phases based on specific time points. The DSAIS-PINN [21] makes PINNs focus on high-loss regions based on dynamic seed importance sampling. Meanwhile, architecture improvements can fully utilize the inherent potential of PINNs to strengthen the overall solving capability. The Deeper-PINN [22] alleviates the pathologies of PINN initialization by mapping features into a high-dimensional space with element multiplication. Causal PINNs [23] incorporate ResNet blocks into the architecture for mapping identity into residuals, making PINNs consistent with physical causal constraints. Furthermore, the loss function optimization can more directly mitigate conflicts and convergence challenges. The S-PINN [24] introduces a new loss function based on residuals of conserved quantities to alleviate conflicts in multi-layer co-optimization. VI-PINNs [25] output mean and variance, and incorporate the modified negative log-likelihood loss to achieve fast training. As discussed above, although PINN studies related to strategy adjustment and architectural optimization have achieved notable progress, they fail to fundamentally resolve the conflict among loss components, and convergence issues still exist in PDEs with complex boundary conditions or source terms.
To further alleviate convergence conflicts, extensive work has been developed on loss weight adjustment. The APINN [26] dynamically adjusts weights based on multi-task learning tasks. AdaPW [27] focuses on high-error sampling points by updating the weight distribution of PDE residuals and training status. BRDR-Weighting PINNs [28] balance residuals and learning rates to scale the original loss. The FPINN [29] computes Caputo fractional derivatives and outputs numerical solutions. The GVW-PINN [30] adaptively tunes weights based on the variance of gradients, which is constrained by the two-stage training strategy. The IPD-PINN adopts partial derivatives as branch neural networks for convergence guidance but raises model complexity [31]. Above all, the weight adjustment of PINNs is mainly focused on residuals and learning efficiency. However, the PINNs are the approximate approaches to the exact solutions for PDEs, and errors exist inevitably. Thus, the PINN should focus on regions with a high residual change rate, and those with large residuals. Importantly, though raising accuracy, most weight-adjusted PINN methods introduce additional hyperparameters, which complicate the modeling process.
To address these issues, we propose a dynamic domain reweighting-guided PINN (DDR-PINN) based on fusing gradients and residuals, aiming to alleviate potential conflicts between loss terms and accelerate the convergence of PINNs. Unlike existing adaptive PINNs focused on the residuals of the solution function, we guide PINNs via the gradient, which directly affects the partial derivatives in PDEs and shortens the error propagation path. The gradients and residuals are combined into the loss function to guide the PINN to converge towards regions with high variation intensity and large residuals. The main contributions of this paper are summarized as follows:
  • We propose a reweighting PINN without additional hyperparameters and trainable parameters, which alleviates loss term conflicts among the interior, initial, and boundary domains, achieving superior convergence stability and accuracy for PDE solving.
  • We design different loss functions for Dirichlet and Neumann boundary conditions, to distinguish between derivative loss and solution loss, extending the applicability of the DDR-PINN across diverse application scenarios.
  • We conduct comprehensive experiments on different PDEs, including 1D, 2D and 3D cases. The results show that the proposed DDR-PINN achieves the highest accuracy compared with the standard PINN, APINN, and VI-PINN with the fewest trainable parameters.
The structure of this paper is organized as follows: Section 2 introduces the relevant concepts of PDEs and the standard PINN. In Section 3, we describe the proposed DDR-PINN and its loss function. Section 4 details the experimental setup and compares the results of different PINNs in six inhomogeneous PDEs. In Section 4 and Section 5, we discuss and summarize the main conclusions.

3. Methodology

As illustrated in Figure 1, the DDR-PINN extends the standard PINN framework by computing the dot product between the gradient and unit vectors in different domains. The dot product of the gradient and the unit vector simultaneously reflect both the direction and magnitude of the projection of the solution function, but it is limited by convergence fluctuations. To avoid introducing extra training conflicts, we use the hyperbolic tangent function to map the L2 norm to the ( 0 ,   1 ) within each domain, and finally obtain the weights for each loss term.
Figure 1. The framework of DDR-PINN.
The gradient of u ^ = N u x , t ; λ is as follows:
∇ u ^ = ∂ u ^ ∂ X , ∂ u ^ ∂ t .
For example, when considering a two-dimensional PDE, Equation (6) can be expressed as follows:
∇ u ^ = ∂ u ^ ∂ x , ∂ u ^ ∂ y , ∂ u ^ ∂ t .
Here, the gradient is represented as a vector. Since the dot product can be interpreted as the projection of one vector onto another multiplied by its magnitude, we compute the dot product between the solution ∇ u ^ and the unit vector, to quantify the variation intensity of the gradient along the direction of the unit vector. Furthermore, as the ∂ u ^ / ∂ x = 0 ,   ∂ u ^ / ∂ y = 0 on the boundary domain, and ∂ u ^ / ∂ t = 0 on the initial domain, the dot product results in the interior domain, boundary domain, and initial domain are as follows:
D r = ∂ u ^ ∂ x + ∂ u ^ ∂ y + ∂ u ^ ∂ t ,
D b x = ∂ u ^ ∂ y + ∂ u ^ ∂ t ,
D b y = ∂ u ^ ∂ x + ∂ u ^ ∂ t ,
D i = ∂ u ^ ∂ x + ∂ u ^ ∂ y ,
where D r , D i are dot product results in the interior, initial domain, and D b x , D b y are dot products in the x boundary and y boundary, respectively. Then, D b = D b x , D b y T .
To ensure that residual information directly influences the weights without misleading effects, we directly multiply the square of the residual by the average of the L2 norm of the dot product. The aim of the square term is to amplify high residuals and attenuate low residuals, guiding the PINN convergence.
N r = 1 N r ∑ k = 1 N r ‖ D r k ‖ 2 ⋅ L r ,
N b = 1 N b ∑ k = 1 N b ‖ D b k ‖ 2 ⋅ L b ,
N i = 1 N i ∑ k = 1 N i ‖ D i k ‖ 2 ⋅ L i ,
N t = N r + N b + N i ,
where N r , N b , N i are the gradient-residual benchmark in interior, boundary and initial domains, respectively.
Here is the Dirichlet boundary example. To unify the magnitude of the weights and distinguish the PDE residual from the solution residual, we adopt two different equations for computing the PDE and boundary weights. The number of sampling points, as well as the magnitude of residuals and fluctuations in the interior domain, are typically much larger than those on the boundary. And the interior residual corresponds to the PDE loss, rather than a solution-value loss. Therefore, we use the overall proportion of interior domain samples as the baseline value for weighting. In contrast, the boundary and the initial domain loss both represent solution residuals, thus we treat them as a unified group. Finally, we apply a tanh transformation as a nonlinear smoothing to improve the situation that the basic raw proportions lead to large fluctuations. Meanwhile, the variation in tanh is relatively small within the interval [ 0 ,   0.5 ] , so we multiply the baseline value of the boundary and initial terms by a constant 2. The weights of loss terms under the Dirichlet boundary are as shown in Equations (16)–(18).
w r = tan h N r N t ,
w b = tan h 2 N b N b + N i ,
w i = tan h 2 N i N b + N i ,
L t = w r L r + w b L b + w i L i ,
where w r , w r , and w r are the weights of L r L r L r respectively.
For the Neumann boundary condition, it involves the derivative of the solution function. For instance, the constraints of the wave equation include the initial velocity. And the residual of the initial velocity corresponds to the partial derivative of the solution with respect to the independent variable. Thus, the initial velocity loss can be aligned with the PDE loss. Furthermore, we multiply the baseline value of the PDE loss and the initial velocity loss by a constant of 2 so that they are the same as other loss weights. The weights of loss terms under the Neumann boundary condition are given as follows:
N o = 1 N i ∑ k = 1 N i ‖ D i k ‖ 2 ⋅ L o
L o = 1 N i ∑ k = 1 N i ∂ u ^ k / ∂ t 0 − h X k , t 0 2
N t = N r + N b + N i + N o
w r = tan h 2 N r N t ,
w o = tan h 2 N o N t ,
L t = w r L r + w b L b + w i L i + w o L o ,
where N t = N r + N b + N i + N o , and N o = 1 N i ∑ k = 1 N i ‖ D i k ‖ 2 ⋅ L o . Taking the wave equation as an example, the initial velocity restricts the partial derivative of the solution function in the initial domain with respect to t and the loss fluctuation of the solution function is still reflected in the initial domain. Thus, we still adopt D i k for this part. Meanwhile, the additional loss term corresponds to the mean squared residual of the initial velocity L o = 1 N i ∑ k = 1 N i ∂ u ^ k / ∂ t 0 − h X k , t 0 2 .

4. Experiments

To evaluate the performance of the DDR-PINN, six PDEs covering 1D, 2D and 3D cases of two typical physical scenarios, heat equations and wave equations, are solved in experiments. In accordance with practical application requirements, all PDEs are inhomogeneous to characterize the existence of external or interior disturbance factors. The DDR-PINN is compared with three representative PINNs: the standard PINN [32] serves as the general benchmark, the APINN [26] as the benchmark for weight-optimized PINNs, and the VI-PINN [25] as the benchmark for loss function-optimized PINNs.

4.1. Setup

All PINNs adopted the same network architecture with 3 hidden layers with 30 neurons per layer, and the activation function is tanh. The optimizer is Adam. In addition, since PINNs sample different spatiotemporal points for the discretization of training and evaluation in the process of solving PDEs, the randomness of sampling and training may lead to unfair discrepancies among different experimental PINNs. To eliminate this potential unfairness, network parameters were initialized with the same random seed. To raise training efficiency, we adopt a step decay learning rate strategy where the initial learning rate is set to 0.001, and it is halved every 2000 training epochs. For each case, we present the exact solution and compare the solutions computed by the PINNs. All input coordinate points are randomly sampled within the domains, with the specific sampling sizes of the training set detailed in Table 1. The sampling ratio across distinct domains is kept consistent with that of the training set. There are 1000 points extracted from the test set to monitor model performance, which are exclusively used for mean squared error (MSE) evaluation. All PINNs were trained on an NVIDIA RTX 3060 graphics card. The Compute Unified Device Architecture (CUDA) library of the Graphics Processing Unit (GPU) was utilized to accelerate the computational speed, and the machine learning framework PyTorch 2.5.1 was adopted to construct the PINN frameworks.
Table 1. Hyperparameter settings for different PDEs. Here, Nr, Nb, Ni, Nt are the number of sampling points in the interior domain, boundary, initial, and test domain. λ is the hyperparameter of the modified negative log-likelihood in VI-PINN. Na is the hyperparameter of updating learning speed in APINN. The λ and Na are consistent with the original reference setting. Here 1D-H denotes the heat equation under 1D condition, and 1D-W denotes the wave equation under 1D condition. Similarly, the others with prefix 2D and 3D are heat equations and wave equations under 2D and 3D conditions.

4.2. Evaluation Metrics

We adopted two metrics, the MSE and L2-error (L2), and trainable parameters to evaluate the performance of all PINNs.
M S E = 1 N ∑ i = 1 N u i − u ^ 2 ,
L 2 − E r r o r = | | u − u ^ | | 2 | | u | | 2 ,
where | | ⋅ | | is the L2 norm. The evaluation results were as shown in Table 2.
Table 2. MSE and L2-error of different PDEs. Here, par is short for trainable parameters. Here 1D-H denotes the heat equation under 1D condition, and 1D-W denotes the wave equation under 1D condition. Similarly, the others with prefix 2D and 3D are heat equations and wave equations under 2D and 3D conditions.

4.3. 1D Heat Equation

The heat equation is a typical case of parabolic PDEs, and its solution can describe the time-dependent temperature distribution. The case with a source term is as follows:
u t + u x = 0.005 u x x + 2 π 1 − x cos 2 π t − sin 2 π t ,   x ϵ 0 ,   1 ,   t ϵ 0 ,   2 ,
u 0 , t = sin 2 π t u 1 , t = 0 u x , 0 = 0 ,
u x , y = 1 − x sin 2 π t ,   x ϵ 0 ,   1 ,   t ϵ 0 ,   2 .
In Figure 2a, the DDR-PINN achieves faster convergence, showing the smallest fluctuation. It can be clearly observed from Figure 2d that the primary parts causing fluctuations in the DDR-PINN are the boundary and initial domain. The value of the loss term becomes much smoother after the product operation between squared residuals and adaptive weights in Figure 2b. In Figure 2c, it can be seen that the variation in the mean L2 norm of the total derivative is relatively stable, except that the initial derivative domain undergoes a brief period with intense fluctuation in the early stage. Figure 2e shows that the proportional changes between residuals squared and loss, revealing that the interior domain dominates, followed by the boundary domain and the initial domain.
Figure 2. The process of PINNs for solving 1D heat equation: (a) all PINN loss, (b) DDR-PINN weights and learning rate with epochs, (c) DDR-PINN total derivative mean L2-norm, (d) DDR-PINN loss terms and residual values, (e) DDR-PINN loss ratio and residual ratio, (f) all PINNs MSE in the test set.
As illustrated in Figure 3, the exact solution exhibits distinct spatiotemporal evolution characteristics. Since dimensionless data are typically used in solving PDEs, negative values in the solution indicate temperatures below the reference value. In terms of extreme error values, the APINN performs the best, with a maximum absolute error of 0.018, and both the VI-PINN and DDR-PINN have 0.02. The errors of the DDR-PINN are uniformly distributed, and extreme errors occur with lower frequencies across the entire spatiotemporal domain, without exhibiting an obvious tendency for errors to increase with time.
Figure 3. The PINN solutions of the 1D heat equation: (a) standard PINN solution, (b) VI-PINN solution, (c) APINN absolute error, (d) DDR-PINN solution, (e) standard PINN absolute error, (f) VI-PINN absolute error, (g) APINN absolute error, (h) DDR-PINN absolute error.

4.4. 1D Wave Equation

The wave equation is a typical case of hyperbolic equations, which is used to describe the spatiotemporal distribution of various wave phenomena. To reflect the periodic variation in the equation, we selected one and a half periods in the time dimension. To adapt to the second-order characteristics of the wave equation and ensure the fairness of comparative experiments, we increased the number of epochs to 15,000, so that all PINNs can fully converge.
∂ 2 u ∂ t 2 = ∂ 2 u ∂ x 2 + π 2 x 1 − x cos π t − 2 cos π t + 2 ,   t ϵ 0 ,   3 ,   x ϵ 0 ,   1 .
u 0 , t = u 1 , t = u x , 0 = u 0 , x t = 0 ,
where the u 0 , x t denotes the initial velocity, which is a necessary condition for the wave equation to have a unique solution.
u t , x = x 1 − x 1 − cos π t ,   t ϵ 0 ,   3 ,   x ϵ 0 ,   1 .
As observed in Figure 4a, DDR-PINNs exhibit a relatively fast convergence process with minor fluctuations. It should be noted that, according to the analysis of Figure 4b, after 4000 epochs, the weights of the initial domain, boundary domain, and interior domain tend to stabilize. Therefore, the residuals of the boundary and initial domains, as well as the PDE residuals of the interior domain, are the main components contributing to the loss. As can be clearly observed in Figure 4d, the reweighting of the DDR-PINN exerts a significant impact on the initial domain. In contrast, the interior domain and boundary domain are barely affected. Finally, as can be observed in Figure 4f, after 3000 training iterations, the DDR-PINN performs the best among all PINNs and maintains its leading position consistently.
Figure 4. The process of PINNs for solving 1D wave equation: (a) all PINN loss, (b) DDR-PINN weights and learning rate with epochs, (c) DDR-PINN total derivative mean L2-norm, (d) DDR-PINN loss terms and residual values, (e) DDR-PINN loss ratio and residual ratio, (f) all PINNs MSE in the test set.
As shown in Figure 5, the exact solution of the 1D wave equation exhibits distinct peaks and valleys. According to the exact solution, the period of the 1D wave equation is 2, so the solution shows obvious periodicity over time within the time interval [0, 2] at the same spatial point. Meanwhile, the solution also presents fluctuation phenomena with spatial variation and is symmetric about x = 0.5 at the same time point. Figure 5 also presents the 1D wave equation solution absolute errors of different PINNs. The maximum value of the absolute error is 0.1, occurring in the APINN, while the maximum value of the absolute error in the DDR-PINN is 0.02. Overall, the absolute errors of all PINNs exhibit a tendency to expand with the increase in time, reaching the maximum at the upper time boundary. And the solution also attains local minima at the moments of period transition (t = 2).
Figure 5. The PINN solutions of the 1D wave equation: (a) standard PINN solution, (b) VI-PINN solution, (c) APINN absolute error, (d) DDR-PINN solution, (e) standard PINN absolute error, (f) VI-PINN absolute error, (g) APINN absolute error, (h) DDR-PINN absolute error.

4.5. 2D Heat Equation

The 2D heat transfer conduction–diffusion equation exhibits convection effects in two directions. Additionally, we set a time-varying heat source and boundary conditions:
∂ u ∂ t + 0.2 ∂ u ∂ x + 0.1 ∂ u ∂ y = 0.1 ( ∂ 2 u ∂ x 2 + ∂ 2 u ∂ y 2 ) + S ,   t ϵ 0 ,   2 ,   x , y ϵ 0 ,   1 ,
where the S = y 2 cos t − 0.4 π sin 2 π x + 0.4 π 2 cos 2 π x + 0.2 1 − y 1 − sin t .
u 0 , y , t = u 1 , y , t = y 2 sin t − y 2 + 3 u x , 0 , t = cos 2 π x + 2 u x , 1 , t = cos 2 π x + sin t + 1 u x , y , 0 = cos 2 π x − y + 2 ,
u x , y , t = cos 2 π x + y 2 sin t − y 2 + 2 ,   t ϵ 0 ,   2 π ,   x , y ϵ 0 ,   1 .
To solve the 2D PDE, we increased the number of training iterations to 20,000 again to ensure all of the PINNs fully converge. As shown in Figure 6a, the DDR-PINN still exhibits the best convergence stability and speed during the loss reduction process. In Figure 6c, the overall solution process is dominated by the interior domain, with the boundary domain ranking second by a narrow margin to the interior domain and the initial domain exerts a minor influence. Figure 6d illustrates that the influence of the interior domain and initial domain is reduced while the boundary domain is maintained after reweighting, resulting in the interior domain and boundary domain being basically at the same loss magnitude. This indicates that the PDE solution is significantly affected by the boundary, which is consistent with the complex boundary condition given above. As reflected in Figure 6f, the solution accuracy of both the APINN and the standard PINN fluctuates generally, while the VI-PINN and DDR-PINN show smaller fluctuations, and the DDR-PINN achieves the highest solution accuracy.
Figure 6. The process of PINNs for solving 2D heat equation: (a) all PINN loss, (b) DDR-PINN weights and learning rate with epochs, (c) DDR-PINN total derivative mean L2-norm, (d) DDR-PINN loss terms and residual values, (e) DDR-PINN loss ratio and residual ratio, (f) all PINNs MSE in the test set.
As illustrated in Figure 7, the exact solution of the 2D heat equation is visualized at 5 time slices, which are t = 0 ,   0.5 ,   1 ,   1.5 ,   2 . It can be seen that at each time slice, both the upper and lower boundaries of the solution exhibit periodic variations, while the left and right boundaries undergo constant heating. Additionally, with the passage of time, heat diffuses from the boundaries toward the center. It should be noted that the evaluation metric is calculated over the full-time domain, and only 5 time points are displayed here for clarity. The maximum absolute error is 0.07, occurring in the APINN, while the VI-PINN achieves the smallest maximum absolute error of 0.0175. For the standard PINN and DDR-PINN, their maximum absolute errors are 0.025 and 0.030, respectively. In terms of error distribution, the absolute errors of all PINNs are mainly concentrated in the boundary domain. For the DDR-PINN, the absolute errors are mainly concentrated on the right boundary at the initial time, with few errors distributed at other time points, demonstrating overall excellent solution accuracy.
Figure 7. The absolute error of PINN solutions for the 2D heat equation: (a) standard PINN solution absolute error, (b) VI-PINN solution absolute error, (c) APINN solution absolute error, (d) DDR-PINN solution absolute error.

4.6. 2D Wave Equation

To simulate practical application requirements, the 2D wave equation has a source term, and both initial conditions and initial velocity are 0, which is consistent with the conventional conditions of the wave equation:
∂ 2 u ∂ t 2 = ∂ 2 u ∂ x 2 + ∂ 2 u ∂ y 2 + sin π x sin π y sin 2 2 π t ,   t ϵ 0 ,   2 2 ,   x , y ϵ 0 ,   1 .
u 0 , y , t = u 1 , y , t = u x , 0 , t = u x , 1 , t = u x , y , 0 = 0 u x , y , 0 t = 0 ,
where the u x , y , 0 t denotes the initial velocity.
u x , y , t = 2 3 π 2 sin π x sin π y sin 2 2 π t − 1 2 sin 2 π t ,   t ϵ 0 ,   2 2 ,   x ϵ 0 ,   1 ,   y ϵ 0 ,   1 .
As shown in Figure 8a, compared with the 2D heat equation, the losses of all PINNs when solving the 2D wave equation exhibit more intense fluctuations during the training process. The DDR-PINN exhibits the fastest and most stable loss reduction. According to Figure 8e, with the increase in epochs, the loss proportion of the interior domain and initial velocity decreases, while the loss proportion of the boundary and initial domain increases, resulting in a final situation that the boundary domain loss dominates, then the interior domain loss follows, and the loss of the initial domain and initial velocity are rank last with a similarly small magnitude. Based on analysis of Figure 8d, the reweighting of the DDR-PINN exerts the most significant influence on the initial conditions, including the initial domain and initial velocity, which reduces their values of the loss term. The reason is that both their derivative weights and residual values are relatively low.
Figure 8. The process of PINNs for solving the 2D wave equation: (a) all PINN loss, (b) DDR-PINN weights and learning rate with epochs, (c) DDR-PINN total derivative mean L2-norm, (d) DDR-PINN loss terms and residual values, (e) DDR-PINN loss ratio and residual ratio, (f) all PINNs MSE in the test set.
Figure 9 presents the exact solution of the 2D wave equation. For clarity of observation, we also selected 5 time slices t = 0 ,   0.5 ,   1 ,   1.5 ,   2 to visualize. Since both the boundary and initial conditions are zero, the exact solution contains numerous zero-value domains. Meanwhile, it can be observed that the solution fluctuates between positive and negative values, exhibiting distinct oscillatory characteristics. Since the boundary conditions are zero, the errors are primarily focused on the central position of the interior domain. The DDR-PINN achieves the smallest maximum absolute error, 0.025. In terms of the temporal distribution, the absolute errors of the standard PINN, VI-PINN, and ACPINN are mainly concentrated at t = 0.5 ,   1 , while the DDR-PINN’s errors are concentrated at t = 1 ,   1.5 . Additionally, the DDR-PINN’s error is significantly smaller than that of the other PINNs at t = 2 .
Figure 9. The absolute error of PINN solutions for 2D wave equation: (a) standard PINN solution absolute error, (b) VI-PINN solution absolute error, (c) APINN solution absolute error, (d) DDR-PINN solution absolute error.

4.7. 3D Heat Equation

The heat source of the 3D heat equation is time-varying and periodically distributed in space.
∂ u ∂ t + 0.2 ∂ u ∂ x + 0.1 ∂ u ∂ y + 0.05 ∂ u ∂ z = 0.1 ( ∂ 2 u ∂ x 2 + ∂ 2 u ∂ y 2 + ∂ 2 u ∂ z 2 ) + S ,   t ϵ 0 ,   2 π ,   x , y , z ϵ 0 ,   1 ,
S 1 = cos t − 0.4 π sin 2 π x cos 2 π y cos 2 π z S 2 = − 0.2 π cos 2 π x sin 2 π y cos 2 π z S 3 = − 0.1 π cos 2 π x cos 2 π y sin 2 π z S 4 = 1.2 π 2 cos 2 π x cos 2 π y cos 2 π z ,
where the S = S 1 + S 2 + S 3 + S 4 . The case boundary condition and exact solution are as follows:
u 0 y z t = u 1 y z t = cos 2 π y cos 2 π z + sin t u x 0 z t = u x 1 z t = cos 2 π x cos 2 π z + sin t u x y 0 t = u x y 1 t = cos 2 π x cos 2 π y + sin t u x y 0 = cos 2 π x cos 2 π y cos 2 π z
u x , y , z , t = cos 2 π x cos 2 π y cos 2 π z + sin t ,   t ϵ 0 ,   2 π ,   x , y , z ϵ 0 ,   1 .
Figure 10 illustrates the solution process of the 3D heat equation. The number of epochs is increased to 25,000 for the stable convergence of PINNs. As shown in Figure 10a, the DDR-PINN exhibits the fastest convergence rate and superior stability, while the APINN delivers insufficient performance during training and in testing. We attribute this to the fact that multi-task learning fails to effectively balance the loss terms when dealing with multiple varying boundaries. This also demonstrates that if conflicts among loss terms are not alleviated adequately, the solution accuracy and efficiency will be significantly dropped, even resulting in a performance inferior to the standard PINN.
Figure 10. The process of PINNs for solving 3D heat equation: (a) all PINN loss, (b) DDR-PINN weights and learning rate with epochs, (c) DDR-PINN total derivative mean L2-norm, (d) DDR-PINN loss terms and residual values, (e) DDR-PINN loss ratio and residual ratio, (f) all PINNs MSE in the test set.
Figure 11 shows the exact solution and the results of PINNs for the 3D heat equation. Due to visualization constraints, we have only drawn the results at the intermediate time step (t = π). The solution of the PDE at the intermediate time step exhibits significant fluctuations with a maximum value of 1 and a minimum value of 0.75. The absolute errors of the DDR-PINN are relatively low, ranging from [0, 0.075]. The maximum absolute error is 0.6, located in the standard PINN, while the DDR-PINN achieves the smallest maximum absolute error of 0.175. Large errors of all PINNs are distributed at the boundaries, especially at the boundary intersections.
Figure 11. The absolute error of PINN solutions for 3D heat equation (t = π): (a) standard PINN solution absolute error, (b) VI-PINN solution absolute error, (c) APINN solution absolute error, (d) DDR-PINN solution absolute error.

4.8. 3D Wave Equation

The 3D wave equation is modified from the 2D wave equation. The boundary conditions include the Neumann boundary condition, the initial velocity, and Dirichlet conditions. The source term exhibits sinusoidal fluctuations spatiotemporally:
∂ 2 u ∂ t 2 = ∂ 2 u ∂ x 2 + ∂ 2 u ∂ y 2 + ∂ 2 u ∂ z 2 + S ,   t ϵ 0 ,   2 ,   x , y , z ϵ 0 ,   1
where S = − sin π x sin π y sin π z sin 2 π t .
u 0 , y , z , t = u 1 , y , z , t = 0 u x , 0 , z , t = u x , 1 , z , t = 0 u x , y , 0 , t = u x , y , 1 , t = 0 u x , y , z , 0 = 0 u x , y , z , 0 t = 3 − 2 π sin π x sin π y sin π z
u ( x , y , z , t ) = 1 π 2 s i n ( π x ) s i n ( π y ) s i n ( π z ) [ s i n ( 3 π t ) − s i n ( 2 π t ) ] ,   t ϵ [ 0 ,   2 ] ,   x , y , z ϵ [ 0 ,   1 ]
As shown in Figure 12a, the APINN exhibits the fastest and most stable loss reduction, followed by the DDR-PINN, and then the standard PINN and VI-PINN in the process of solving the 3D wave equation. However, the APINN fails to achieve satisfactory solution accuracy on the test set. Similarly to the 3D heat equation, the multi-task mechanism of the APINN results in a degraded generalization ability. Relatively, the DDR-PINN has a slower convergence rate in the early stage. According to Figure 12b, we think the reason is that the large weight fluctuations of the DDR-PINN in the early stage lead to slow model learning efficiency. As the number of epochs increase, both the convergence rate and accuracy of the DDR-PINN are improved.
Figure 12. The process of PINNs for solving 3D wave equation: (a) all PINN loss, (b) DDR-PINN weights and learning rate with epochs, (c) DDR-PINN total derivative mean L2-norm, (d) DDR-PINN loss terms and residual values, (e) DDR-PINN loss ratio and residual ratio, (f) all PINNs MSE in the test set.
Figure 13 presents the exact solution of the 3D wave equation at the intermediate time step (t = 2 / 2 ). It can be clearly observed that there are relatively high disturbance values in the interior domain, while the boundary values are zero, which is consistent with the Dirichlet boundary conditions. The APINN achieves the highest accuracy in the boundary solution, followed by the DDR-PINN. The maximum absolute error 0.035 occurs in the APINN, indicating that the APINN focuses on improving boundary accuracy but lacks sufficient learning for the interior domain, guided by a multi-task learning mechanism. Among PINNs, the DDR-PINN achieves the optimal balance solution accuracy between the interior and boundary domains, thus achieving higher accuracy on the test set.
Figure 13. The absolute error of PINN solutions for the 3D wave equation at the intermediate time step (t = √2/2): (a) standard PINN solution absolute error, (b) VI-PINN solution absolute error, (c) APINN solution absolute error, (d) DDR-PINN solution absolute error.

5. Discussion

In this section, we discuss the improvement, limitation and future work of the DDR-PINN.
  • The DDR-PINN directly reveals the primary part affecting convergence from the interior domain, boundary domain, and initial domain in the process of solving various dimension PDEs, explicitly providing a useful reference for focusing on domains characterized by high residuals and strong variations.
  • As research on PINNs advances, the algorithm complexity and the number of parameters deserve more attention. The DDR-PINN offers a viable pathway for solving high-order PDEs with complex geometric boundaries with enhanced solution accuracy, while the number of trainable parameters are regulated effectively.
  • The limitation lies in the performance of boundary value solving. Due to the oscillatory nature of the wave equation, gradients undergo drastic variations in the transition region between the interior domain and the boundary domain. Although we employed the hyperbolic tangent function for optimization, relatively large errors still persist in the 2D wave equation, which indicates that the DDR-PINN still has room for improvement in handling variable boundary conditions.
In summary, the DDR-PINN demonstrates distinct advantages specifically in scenarios characterized by strong differences between boundary conditions and governing equations with specific parameter requirements, whereas the drastic fluctuations in gradients undermine the stability of the solution process. In future work, we will attempt to further explore the latent space correlation between gradients and solution functions. By establishing a bidirectional mapping relationship between partial derivatives and spatiotemporal coordinates, the convergence of PINNs would be faster and more stable. Furthermore, the development of lightweight and modularized reweighted PINNs will also constitute a key direction for our subsequent investigations.

6. Conclusions

This study proposes the DDR-PINN, which innovatively integrates residual information and solution gradients for reweighting, guiding the PINN to focus on domains with large residuals and intense fluctuations. Then, the DDR-PINN is applied to solve heat equations and wave equations in six inhomogeneous PDEs, with Dirichlet and Neumann boundary conditions. The main conclusions of this paper are as follows:
  • DDR exhibits excellent generalization capability, achieving an MSE that outperforms other benchmark PINNs by 40.00%, 29.58%, and 52.10%, with the dimension from 1D to 3D when solving the inhomogeneous heat equation. For the inhomogeneous wave equation, it outperforms other benchmark PINNs by 66.96, 9.36%, and 1.30%.
  • Incorporating gradient-based reweighting proves to be effective in alleviating conflicts among loss terms. Across all experiments, the DDR-PINN exhibits noticeably faster convergence, together with a more stable fluctuation magnitude and frequency than other PINNs.
  • The DDR-PINN fully leverages the inherent automatic differentiation and residual mechanisms of the PINN framework, without additional hyperparameters for tuning, while exerting favorable control over the volume of trainable parameters.
This study also reveals a significant correlation between loss term conflicts and learning rate adjustments during PDE solving with PINNs, and that the appropriate addition of nonlinear transformations in PINNs exerts a positive effect. This provides directions for PINN-related work, and we will further explore the use of learning rates and gradient-based methods to address loss term conflicts in PINNs.

Author Contributions

Writing—original draft, validation, methodology, S.L.; supervision, formal analysis, B.G.; conceptualization, investigation, N.K.; writing—review and editing, C.Y., R.G. and U.G. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by EU RRF within project No. 5.2.1.1.i.0/2/24/I/CFLA/003 academic career doctoral grant, ID 1081. The APC was funded by the authors.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

All original contributions of this study are contained within the article; additional information is available from the corresponding author upon request.

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
PINNPhysics-Informed Neural Network
DDRDynamic Domain–Gradient Reweighting
PIMLPhysics-Informed Machine Learning
NNsNeural Networks
PDEsPartial Differential Equations

References

  1. Gong, Y.; Liu, G.; Xue, Y.; Li, R.; Meng, L. A Survey on Dataset Quality in Machine Learning. Inf. Softw. Technol. 2023, 162, 107268. [Google Scholar] [CrossRef] [Scilit]
  2. Han, H.; Wu, Y.; Wang, J.; Han, A. Interpretable Machine Learning Assessment. Neurocomputing 2023, 561, 126891. [Google Scholar] [CrossRef] [Scilit]
  3. Wu, Y.; Sicard, B.; Gadsden, S.A. Physics-Informed Machine Learning: A Comprehensive Review on Applications in Anomaly Detection and Condition Monitoring. Expert Syst. Appl. 2024, 255, 124678. [Google Scholar] [CrossRef] [Scilit]
  4. Karniadakis, G.E.; Kevrekidis, I.G.; Lu, L.; Perdikaris, P.; Wang, S.; Yang, L. Physics-Informed Machine Learning. Nat. Rev. Phys. 2021, 3, 422–440. [Google Scholar] [CrossRef] [Scilit]
  5. Meng, C.; Griesemer, S.; Cao, D.; Seo, S.; Liu, Y. When Physics Meets Machine Learning: A Survey of Physics-Informed Machine Learning. Mach. Learn. Comput. Sci. Eng. 2025, 1, 20. [Google Scholar] [CrossRef] [Scilit]
  6. Luo, K.; Zhao, J.; Wang, Y.; Li, J.; Wen, J.; Liang, J.; Soekmadji, H.; Liao, S. Physics-Informed Neural Networks for PDE Problems: A Comprehensive Review. Artif. Intell. Rev. 2025, 58, 323. [Google Scholar] [CrossRef] [Scilit]
  7. Song, Y.; Zhang, A. From Black Box to Physically Interpretable: Trustworthy Computing for AI-Driven Decision-Making and Control. J. Autom. Intell. 2025. [Google Scholar] [CrossRef] [Scilit]
  8. Oneto, L.; Ridella, S.; Anguita, D. Informed Machine Learning: Excess Risk and Generalization. Neurocomputing 2025, 646, 130521. [Google Scholar] [CrossRef] [Scilit]
  9. Vairo, T.; Cademartori, D.; Clematis, D.; Asensio, A.M.; Barbucci, A.; Carpanese, M.P. A Physics-Informed Neural Network (PINN) Predicting the Performance of Air Electrodes for Solid Oxide Cells: A Pilot-Scale Demonstration on Four Microstructures. Int. J. Hydrogen Energy 2025, 176, 151322. [Google Scholar] [CrossRef] [Scilit]
  10. Zhou, Y.; Song, H. Data-Driven Enhanced Rough Contact Mechanics: PINN Estimation of Gap Distribution across Length Scales for Partial Contacts. Tribol. Int. 2026, 214, 111100. [Google Scholar] [CrossRef] [Scilit]
  11. Luo, D.; Mo, H.; Li, Q.; Jin, X. Solution of Stress and Deformation Field and Inversion of Material Parameter for Gravity Dams Based on Physics-Informed Neural Networks. J. Comput. Sci. 2025, 89, 102613. [Google Scholar] [CrossRef] [Scilit]
  12. Roozbahani, M.S.; Soltani, M.; Sayah, M.R.; Shamloo, A.; Hannani, S.K. Design and Optimization of Heat Transfer Channel Using Physics-Informed Neural Networks (PINN) and Deep Gaussian Processes. Therm. Sci. Eng. Prog. 2025, 66, 104012. [Google Scholar] [CrossRef] [Scilit]
  13. Kütük, M.; Yücel, H. Energy Dissipation Preserving Physics Informed Neural Network for Allen–Cahn Equations. J. Comput. Sci. 2025, 87, 102577. [Google Scholar] [CrossRef] [Scilit]
  14. Chen, J.; Shi, Y.; Yu, Y. A C-PINN Method for Structural Seismic Response Modeling. Structures 2025, 82, 110422. [Google Scholar] [CrossRef] [Scilit]
  15. Sundar, R.; Lucor, D.; Sarkar, S. Sequential Learning Based PINNs to Overcome Temporal Domain Complexities in Unsteady Flow Past Flapping Wings. J. Fluids Struct. 2025, 139, 104421. [Google Scholar] [CrossRef] [Scilit]
  16. Zhou, X.; Li, Z.; Liu, X.; Wang, Y.; Liang, N.; Zhong, Z. Physics-Informed Neural Network (PINN) for Predicting the Temperature Field in High Geothermal Tunnels. Tunn. Undergr. Space Technol. 2026, 169, 107265. [Google Scholar] [CrossRef] [Scilit]
  17. Wang, Y.; Qiu, X.; Pei, Q.; Wang, J.; Zhang, P.; Bai, X. FAMAW-PINN: A Physics-Informed Neural Network Integrating Adaptive Loss Weighting with Firefly-Inspired Adaptive Point Movement. J. Comput. Phys. 2025, 542, 114363. [Google Scholar] [CrossRef] [Scilit]
  18. Wang, S.; Yu, X.; Perdikaris, P. When and Why PINNs Fail to Train: A Neural Tangent Kernel Perspective. J. Comput. Phys. 2022, 449, 110768. [Google Scholar] [CrossRef] [Scilit]
  19. Cao, F.; Guo, X.; Dong, X.; Yuan, D. WbPINN: Weight Balanced Physics-Informed Neural Networks for Multi-Objective Learning. Appl. Soft Comput. 2025, 170, 112632. [Google Scholar] [CrossRef] [Scilit]
  20. Yan, D.; He, L. DP-PINN+: A Dual-Phase PINN Learning with Automated Phase Division. J. Comput. Sci. 2025, 90, 102637. [Google Scholar] [CrossRef] [Scilit]
  21. Feng, W.; Hu, M.; Huang, R.; Tang, C.; Huang, S.; Lv, J. DSAIS-PINN: Dynamic Seeds Allocation Importance Sampling for Physics-Informed Neural Networks. Neurocomputing 2025, 648, 130578. [Google Scholar] [CrossRef] [Scilit]
  22. Jiang, F.; Hou, X.; Ye, J.; Xia, M. Deeper-PINNs: Unlocking the Power of Deep Physics-Informed Neural Networks. Appl. Soft Comput. 2025, 185, 114048. [Google Scholar] [CrossRef] [Scilit]
  23. Fan, M.-H.; Zhao, J.-H.; Ding, L.; Ma, X.-Y.; Fu, R.-L. Predicting Nonlinear Dynamic Systems by Causal Physics-Informed Neural Networks with ResNet Blocks. Neurocomputing 2025, 656, 131589. [Google Scholar] [CrossRef] [Scilit]
  24. Yang, T.; Qian, Z.; Hang, N.; Liu, M. S-PINN: Stabilized Physics-Informed Neural Networks for Alleviating Barriers between Multi-Level Co-Optimization. Comput. Methods Appl. Mech. Eng. 2025, 447, 118348. [Google Scholar] [CrossRef] [Scilit]
  25. Shan, B.; Li, Y.; Huang, S.-J. VI-PINNs: Variance-Involved Physics-Informed Neural Networks for Fast and Accurate Prediction of Partial Differential Equations. Neurocomputing 2025, 623, 129360. [Google Scholar] [CrossRef] [Scilit]
  26. Gao, B.; Yao, R.; Li, Y. Physics-Informed Neural Networks with Adaptive Loss Weighting Algorithm for Solving Partial Differential Equations. Comput. Math. Appl. 2025, 181, 216–227. [Google Scholar] [CrossRef] [Scilit]
  27. Li, W.; Wang, H.; Guan, H.; Zhou, R.; Zhang, C.; Tao, D. AdaPW: An Adaptive Point-Weighting Method for Training Physics-Informed Neural Networks. Comput. Math. Appl. 2025, 198, 255–273. [Google Scholar] [CrossRef] [Scilit]
  28. Chen, W.; Howard, A.A.; Stinis, P. Self-Adaptive Weights Based on Balanced Residual Decay Rate for Physics-Informed Neural Networks and Deep Operator Networks. J. Comput. Phys. 2025, 542, 114226. [Google Scholar] [CrossRef] [Scilit]
  29. Zhang, J.; Zhao, Y.; Tang, Y. Adaptive Loss Weighting Auxiliary Output FPINNs for Solving Fractional Partial Integro-Differential Equations. Phys. D Nonlinear Phenom. 2024, 460, 134066. [Google Scholar] [CrossRef] [Scilit]
  30. Zhang, L.; Liu, Q.; Zhang, R.; Yue, L.; Ding, Z. A Gradient-Variance Weighting Physics-Informed Neural Network for Solving Integer and Fractional Partial Differential Equations. Appl. Sci. 2025, 15, 11137. [Google Scholar] [CrossRef] [Scilit]
  31. Wang, L.; Lin, Y.; Yan, X.; Shao, Y.; Xu, Z.; Yang, C.; Fan, H.; Xie, Y.; Zheng, C. Modeling of Distributed Parameter Systems Based on Independent Partial Derivative-Physics-Informed Neural Network. Neurocomputing 2025, 642, 130396. [Google Scholar] [CrossRef] [Scilit]
  32. Raissi, M.; Perdikaris, P.; Karniadakis, G.E. Physics-Informed Neural Networks: A Deep Learning Framework for Solving Forward and Inverse Problems Involving Nonlinear Partial Differential Equations. J. Comput. Phys. 2019, 378, 686–707. [Google Scholar] [CrossRef] [Scilit]
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.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.