A Natural Deep Ritz Method for Essential Boundary Value Problems
Abstract
Deep neural network approaches show promise in solving partial differential equations. However, unlike traditional numerical methods, they face challenges in enforcing essential boundary conditions. The widely adopted penalty-type methods, for example, offer a straightforward implementation but introduces additional complexity due to the need for hyper-parameter tuning; moreover, the use of a large penalty parameter can lead to artificial extra stiffness, complicating the optimization process. In this paper, we propose a novel, intrinsic approach to impose essential boundary conditions through a framework inspired by intrinsic structures. We demonstrate the effectiveness of this approach using the deep Ritz method applied to Poisson problems, with the potential for extension to more general equations and other deep learning techniques. Numerical results are provided to substantiate the efficiency and robustness of the proposed method.
keywords:
deep neural network , essential boundary value problem , deep Ritz method , penalty free , interfacial value problem1 Introduction
In recent years, there has been a rapidly growing interest in using deep neural networks (DNNs) to solve partial differential equations (PDEs). Early attempts to apply neural networks to differential equations date back over three decades, with Hopfield neural networks [11] being employed to represent discretized solutions [17]. Soon after, methodologies were developed to construct closed-form numerical solutions using neural networks [39]. Since then, extensive research has focused on solving differential equations with various types of neural networks, including feedforward neural networks [15, 27, 16, 26], radial basis networks [25], and wavelet networks [20]. With the advancement of deep learning techniques [10, 14, 9], neural networks with substantially more hidden layers have become powerful tools. Innovations such as rectified linear unit (ReLU) functions [6], generative adversarial networks (GANs) [7], and residual networks (ResNets) [9] exemplify these advances, showcasing the strong representational capabilities of DNNs [30, 18, 19, 37, 8, 33]. These developments have spurred the creation of numerous DNN-based methods for PDEs, including the deep Galerkin method (DGM) [35], deep Ritz method (DRM) [5], physics-informed neural networks (PINNs) [31], finite neuron method (FNM) [40], weak adversarial networks (WANs) [42], and mixed residual methods (MIM) [24]. These methods have been widely adopted across various applications, successfully addressing complex problems modeled by differential equations [5, 21, 32, 2, 22, 13, 41, 3].
In the design and implementation of neural network-based methods, the imposition of boundary conditions is a critical challenge. Notably, this issue is also encountered in certain classical numerical methods, such as finite element methods, where handling boundary conditions can be complex enough to require techniques like Nitsche’s method [28], later refined by Stenberg [36]. However, the challenges differ significantly in neural network-based approaches. Unlike classical numerical methods, which leverage basis functions or discretization stencils with compact supports or sparse structures, neural network methods utilize DNNs as trial functions, which are globally defined. Consequently, enforcing boundary conditions, even for problems that are straightforward in classical methods, becomes nontrivial due to the global structure of DNNs. For the natural boundary conditions, the deep Ritz method reformulates the original problem into a variational form, which can reduce the smoothness requirements and potentially lower the training cost by allowing natural boundary conditions to be imposed without additional operations. However, because the trial functions within the approximation sets are generally non-interpolatory, imposing essential boundary conditions remains a challenging task.
To date, three primary approaches have been developed for addressing essential boundary conditions in deep learning-based numerical methods. The first approach is the conforming method, which aims to construct neural network functions that exactly satisfy the essential boundary conditions [34, 2, 24]. Generally, the network function is represented as the combination of two parts: , one reflecting the essential boundary condition, and the other vanishing on the boundary by the aid of a “distance function” or a “geometry-aware” function . Both test and trial functions can be constructed this way. However, when the domain has a complicated boundary (or even not that complicated), it is not easy to construct a distance function to preserve the asymptotic equivalence.
Another one is the penalty method, which is a very general concept and belongs to the so-called nonconforming method [5, 31, 35, 43, 42, 12]. For this method, an additional surface term is introduced into the variational formulation to enforce the boundary conditions. Take the Poisson equation with Dirichlet boundary condition (1.1) as example:
(1.1) |
The deep Ritz method [5] minimize the following objective
(1.2) |
where and define the training data set in the domain and on the boundary, respectively. PINN method is a least square method for the strong form of the PDE, but the the handling of the essential boundary condition is similar to deep Ritz method:
(1.3) |
Careful balancing of terms within the functional framework is essential to ensure the well-posedness and accuracy of the scheme. Addressing this issue, the deep Nitsche method, as proposed in [21], applies Nitsche’s variational formula to second-order elliptic problems to avoid the use of a large penalty parameter. Nevertheless, some degree of tuning remains necessary for the penalty parameter, and a theoretical basis for determining an optimal penalty value is still absent.
In contrast to the penalty method, the Lagrange multiplier method addresses essential boundary conditions by treating them as constraints within the minimization process. This method has been effectively used to impose essential boundary conditions in finite element methods [1] and wavelet methods [4]. When the approximation function spaces are appropriately chosen satisfying the so-called inf-sup condition, this method can achieve optimal convergence rates [1, 4]. While the Lagrange multiplier method can also enforce boundary conditions in neural network-based methods, its effectiveness depends on the stable construction and efficient resolution of the extra constrained optimization problem.
In this paper, we introduce a novel neural network-based method for solving essential boundary value problems. Our approach involves transforming the original problem into a sequence of natural boundary value problems, which are then solved sequentially or concurrently using the deep Ritz method. Unlike the previously mentioned approaches, this technique constructs a new framework for imposing essential boundary conditions. We refer to this method as the natural deep Ritz method. This approach simplifies the training process and avoids introducing additional errors associated with boundary condition enforcement. To validate our method, we examine essential boundary and interface value problems for second-order divergence-form equations with constant, variable, or discontinuous coefficients, providing numerical examples that demonstrate the effectiveness.
Evidently, a primary ingredient of the proposed method lies in its adjoint approach to handling essential boundary conditions. This approach is grounded in the mathematical framework of the de Rham complex and its dual complex, which serve as foundational structures. By leveraging these complexes, which connect kernel spaces to specific range spaces, we can represent the difference between the solutions of natural and essential boundary value problems as the solution to another natural boundary value problem. This formulation allows us to construct a purely natural approach equivalent to the original problem.
While we do not delve extensively into the formal structure of the de Rham and dual complexes, it is important to highlight that our method diverges from the traditional mixed formulations common in classical numerical methods. Notably, we do not introduce the gradient of the unknown function as an auxiliary variable. Moreover, unlike classical mixed formulations, our approach avoids the need for constructing a saddle point problem, which would typically require rigorous continuous and discrete inf-sup conditions for stability and accuracy. In our framework, the solution is reduced to solving three elliptic subproblems using a standard machine learning algorithm. This approach eliminates the need for training an additional network to capture the boundary representation, tuning penalty parameters, or ensuring inf-sup conditions for a boundary Lagrangian multiplier. The conciseness of the present method is among its most significant advantages, both in theory and implementation.
The remaining parts of the paper are organized as follows. In Section 2, we present the equivalent natural boundary value problem formulation of the respective essential boundary value problems. In Section 3, the deep Ritz method based on the natural formulation, namely the natural deep Ritz methods, is given. Numerical experiments are presented in Section 4 to verify the proposed method. We end the paper with some concluding remarks in Section 5
2 A natural formulation of the essential boundary value problems
In this section, we derive natural formulations for the second-order problems of divergence form with constant, variable, and discontinuous coefficients, respectively; i.e., we rewrite the essential boundary value problems and interface value problems to a series of natural boundary value problems and interface value problems to solve. We are focused on Laplace problems on two-dimensional domains here, and the method can be generated to higher dimensions, as well as to other self-adjoint problems.
In this paper, stands for a simply connected domain with a boundary , and we use , , , , and for the standard Sobolev spaces.
2.1 Poisson equations of Dirichlet type
We first consider the model problem with constant coefficients: (1.1). Its variational formulation is to find , such that
(2.1) |
Here, stands for the duality between and . In the sequel, we use to denote dualities of different kinds, while the subscripts may be dropped when no ambiguity is introduced.
Theorem 2.1.
Let be the solution of (2.1), and be obtained by the four steps below:
-
1.
Find , such that
(2.2) where is any extension of onto such that for .
-
2.
Find a , such that
(2.3) Here, the scalar curl operator is defined as , and is a duality between and , which evaluates as the inner product on for sufficiently smooth functions.
-
3.
Find a , such that
(2.4) -
4.
Set , with for any such that .
Then .
Proof.
Remark 2.2.
-
1.
The solutions of the second and third steps are not unique up to constant, though, these solutions will give the same correct solution at the end of the algorithm.
-
2.
To obtain , we may solve for
-
3.
The last step can be done by least square.
Remark 2.3.
2.2 Elliptic problem with varying coefficient in divergence form
Let be a varying coefficient matrix such that
(2.8) |
We further consider a second order problem of divergence form:
(2.9) |
It is useful to rewrite . Note that, equipped with proper spaces, the operators and are adjoint operators of each other, and we write the variational formulation to be: find , such that
(2.10) |
Theorem 2.4.
Let be the solution of (2.10), and be obtained by the four steps below:
-
1.
Find , such that
(2.11) -
2.
Find a , such that
(2.12) -
3.
Find a , such that
(2.13) -
4.
Set , with for any such that .
Then .
Proof.
Note that the null space of coincides with the range of equipped with proper spaces, and the proof is the same as that of Theorem 2.1. ∎
2.3 A simple approach for the interface problem
We now consider the case that is discontinuous. Let be an interface that separates with ; see Figure 1 for an illustration. We use and for the outer unit normal vector and the corresponding unit tangential vector for , .

Assume to be discontinuous across . We consider the interface problem below:
(2.14) |
The variational formulation is to find , such that
(2.15) |
and
(2.16) |
Here is a duality between and , which evaluates as the inner product on for sufficiently smooth functions.
Theorem 2.5.
Proof.
By the first item, for , therefore, there exists such that . It follows that . Then
for any , and further
The assertion follows immediately. ∎
Remark 2.6.
Again, it is helpful to understand the procedure by figuring out the respective strong forms related to equations (2.17)-(2.19).
-
1.
By using integration by parts, we obtain the strong form of (2.17):
(2.20) -
2.
The boundary value problem corresponding to (2.18) is:
(2.21) - 3.
From these strong forms, we see clearly that and are both continuous functions but with derivative jumps on interface . This softens the jumps between and across on both function value and derivative jumps.
3 Natural deep Ritz methods
3.1 Natural deep Ritz method for Poisson equations with Dirichlet boundary conditions
Note that the three equations (2.2)-(2.3)-(2.4) in weak forms correspond to three elliptic equations with Neumann boundary conditions (2.5)-(2.6)-(2.7), which can be efficiently solved using Deep Ritz method without boundary penalty. Details are given in the following three steps. As usual, we use for the set of neural network functions outputting a 1-dim vector with a d-dim input vector.
-
1.
Find by optimizing
(3.1) where . and are the set of quadrature points and weights for domain and its boundary . Hereby, the term is added in the objective function to make the solution unique.
-
2.
Find by optimizing
(3.2) Again, the last term is added to make the solution unique.
-
3.
Find the solution by minimizing:
(3.3) The last term is a regularization term to make the integration of and on boundary equal to each other. Then, is a proper numerical approximation of .
3.2 Natural deep Ritz method for elliptic interface problems
For inteface problem defined in (2.17)-(2.18)-(2.19), it is more involved to design an efficient deep Ritz method. We will use similar approach as in the Poisson equations cases to solve (2.17)-(2.18), since both and has no jump of function values on the interface . We use two neural network functions to represent , since it contains jumps on the interface . We will solve (2.19) with two neural networks (or one neural network with two outputs ), one for each subdomain . The details are given below.
-
1.
Find by optimizing
(3.4) (3.5) where . , and are the set of quadrature points and weights for domain , boundary and interface .
-
2.
Find by optimizing
(3.6) Note that the last term is added to make the solution unique.
-
3.
Find the solution by minimizing: