
Enforcing Dirichlet boundary conditions in PINNs and VPINNs A PREPRINT
Most of the existing PINN approaches enforce the essential (Dirichlet) boundary conditions by means of additional
penalization terms that contribute to the loss function, these are each multiplied by constant weighting factors. See
for instance [
11
,
12
,
13
,
18
,
35
,
38
,
41
,
47
,
49
]; note that this list is by no means exhaustive, therefore we also refer
to [
4
,
10
,
31
] for more detailed overviews of the PINN literature. However, such an approach may lead to poor
approximation, and therefore several techniques to improve it have been proposed. In [
32
] and [
43
], adaptive scaling
parameters are proposed to balance the different terms in the loss functions. In particular, in [
32
] the parameters are
updated during the minimization to maximize the loss function via backpropagation, whereas in [
43
] a fixed learning
rate annealing procedure is adopted. Other alternatives are related to adaptive sampling strategies (e.g., [
26
,
40
,
14
]) or
to specific techniques such as the Neural Tangent Kernel [44].
Note that although it is possible to automatically tune these scaling parameters during the training, such techniques
require more involved implementations and in most cases lead to intrusive methods since the optimizer has to be
modified. Instead, in this paper, we focus on three simple and non-intrusive approaches to impose Dirichlet boundary
conditions and we compare their accuracy and efficiency. The proposed approaches are tested using standard PINN and
interpolated VPINN which have been proven to be more stable than standard VPINNs [6].
The main contributions of this paper are as follows:
1.
We present three non-standard approaches to enforce Dirichlet boundary conditions on PINNs and VPINNs,
and discuss their mathematical formulation and their pros and cons. Two of them, based on the use of an
approximate distance function, modify the output of the neural network to exactly impose such conditions,
whereas the last one enforces them approximately by a weak formulation of the equation.
2.
The performance of the distinct approaches to impose Dirichlet boundary conditions is assessed on various
test cases. On average, we find that exactly imposing the boundary conditions leads to more efficient and
accurate solvers. We also compare the interpolated VPINN to the standard PINN, and observe that the different
approaches used to enforce the boundary conditions affect these two models in similar ways.
The structure of the remainder of this paper is as follows. In Section 2, the PINN and VPINN formulations are described:
first, we describe the neural network architecture in Section 2.1 and then focus on the loss functions that characterize
the two models in Section 2.2. Subsequently, in Section 3, we present the four approaches to enforce the imposition
of Dirichlet boundary conditions; three of them can be used with both PINNs and VPINNs, whereas the last one is
used to enforce the required boundary conditions only on VPINNs because it relies on the variational formulation.
Numerical results are presented in Section 4. In Section 4.1, we first analyze for a second-order elliptic problem the
convergence rate of the VPINN with respect to mesh refinement. In doing so, we demonstrate that when the neural
network is properly trained, identical optimal convergence rates are realized by all approaches only if the PDE solution
is simple enough. Otherwise, only enforcing the Dirichlet boundary conditions with Nitsche’s method or by exactly
imposing them via approximate distance functions ensure the theoretical convergence rate. In addition, we compare
the behavior of the loss function and the
H1
error while increasing the number of epochs, as well as the behavior of
the error when the network architecture is varied. In Section 4.2, we show that it is also possible to efficiently solve
second-order parametric nonlinear elliptic problems. Furthermore, in Sections 4.3– 4.5, we compare the performance of
all approaches on PINNs and VPINNs by solving a linear elasticity problem and a stabilized Eikonal equation over an
L-shaped domain, and a convection problem. Finally, in Section 5, we close with our main findings and present a few
perspectives for future work.
2 PINNs and interpolated variational PINNs
In this section, we describe the PINN and VPINN that are used in Section 4. In particular, in Section 2.1 the neural
network architecture is presented, and the construction of the loss functions is discussed in Section 2.2.
2.1 Neural network description
In this work we compare the efficiency of four approaches to enforce Dirichlet boundary conditions in PINN and
VPINN. The main difference between these two numerical models is the training loss function; the architecture of the
neural network is the same and is independent of the way the boundary conditions are imposed.
In our numerical experiments we only consider fully-connected feed forward neural networks with a fixed architecture.
Such neural networks can be represented as nonlinear parametric functions
uNN :RNin →RNout
that can be evaluated
via the following recursive formula:
x∗
i=σiAix∗
i−1+bi, i = 1,2, . . . , L. (2.1)
2