Machine Learning for Numerical Stabilization of Advection-Diffusion
Total Page:16
File Type:pdf, Size:1020Kb
Machine learning for numerical stabilization of advection-diffusion PDEs Courses: Numerical Analysis for Partial Differential Equations - Advanced Programming for Scientific Computing Margherita Guido, Michele Vidulis Suprevisor: prof. Luca Ded`e 09/09/2019 Contents 1 Introduction5 2 Problem: SUPG stabilization and Isogeometric analysis7 2.1 Advection-diffusion problem.......................7 2.1.1 Weak formulation and numerical discretization using FE...8 2.2 SUPG stabilization............................9 2.2.1 A Variational Multiscale (VMS) approach...........9 2.3 Isogeometric analysis........................... 11 2.3.1 B-Spline basis functions..................... 11 2.3.2 B-Spline geometries....................... 11 2.3.3 NURBS basis functions..................... 12 2.3.4 NURBS as trial space for the solution of the Advection-Diffusion problem.............................. 12 2.3.5 Mesh refinement and convergence results............ 12 3 Artificial Neural Networks 15 3.1 Structure of an Artificial Neural Network............... 15 3.1.1 Notation.............................. 15 3.1.2 Design of an ANN........................ 16 3.2 Universal approximation property.................... 17 3.3 Backpropagation and training...................... 17 3.3.1 Some terminology........................ 17 3.3.2 The learning algorithm..................... 18 4 A Neural Network to learn the stabilization parameter 21 4.1 Our Neural Network scheme....................... 21 4.2 Mathematical formulation of the problem............... 22 4.3 Expected results............................. 24 4.4 Implementation aspects......................... 24 4.4.1 Keras............................... 24 4.4.2 C++ libraries........................... 25 5 Isoglib and OpenNN 27 5.1 Structure of IsoGlib........................... 27 5.1.1 Definition of the problem.................... 27 5.1.2 Main steps in solving process.................. 28 5.1.3 Export and visualization of the results............. 28 5.2 Structure of OpenNN.......................... 28 5.2.1 Uses of the library........................ 28 5.2.2 Vectors and matrices....................... 29 5.2.3 DataSet class........................... 29 5.2.4 NeuralNetwork class....................... 30 5.2.5 TrainingStrategy class..................... 30 5.2.6 LossIndex class......................... 30 5.2.7 OptimizationAlgorithm class................. 31 5.2.8 Backpropagation......................... 31 3 4 CONTENTS 6 Implementation: interface of OpenNN and IsoGlib 35 6.1 SUPG solver in IsoGlib......................... 35 6.1.1 Our test class: SUPGdata .................... 35 6.1.2 SUPGLocalMatrix class..................... 36 6.2 New OpenNN classes........................... 36 6.2.1 IsoglibInterface class..................... 36 6.2.2 Customized loss function: OutputFunction class....... 38 6.3 SUPG example in OpenNN....................... 42 6.3.1 Data of the problem....................... 42 6.3.2 Training.............................. 42 6.3.3 Testing.............................. 43 7 Numerical Tests 45 7.1 Training of the network......................... 46 7.2 Prediction of the SUPG parameter................... 47 7.3 Analysis of the results.......................... 48 7.4 L2 error trend in a different PDE.................... 50 8 Conclusions 53 Bibliography 55 Chapter 1 Introduction High-order numerical methods for the approximation of advection–diffusion PDEs based on Galerkin finite element may be affected from numerical instabilities, which occur as spurious oscillations and compromise the solution accuracy. A stabilized and strongly consistent method named Streamline Upwind Petrov- Galerkin Method (SUPG) can be obtained by adding a further term to the Galerkin approximation (see (HB82) and (Q17, chap.13)). This term includes an elementwise stabilization parameter that should be carefully determined, since an exact formula defining its optimal value is still lacking. Through the years, several approximations of this coefficient have been proposed: we present the simplest and most used, trying to frame the ideas that lead to their definition (see (HSF18) and (C97)). The aim of our work is to exploit the universal approximation power of the Arti- ficial Neural Networks to reconstruct a suitable approximation of such stabilization parameter. We train an Artificial Neural Network, implemented inside the C++ li- brary OpenNN (OpenNN), so that, once the parameters characterizing the problem and its discretization are known, we predict an optimal value of the stabilization parameter. To train our network we developed a customized loss function that re- quires several numerical resolution of the stabilized PDE, for which we employ a C++ library (IsoGlib), based on Isogeometric analysis (CHB09). We start presenting the problem in its theoretical framework, describing the family of PDE equations we want to solve, some instability issues and how they can be confined, constructing a theoretical background for this problem. In Chapter2 we will also introduce Isogeometric Analysis, the technique that will be used to solve numerically the PDEs problems. Chapter3 is devoted to the description of Artifi- cial Neural Networks and the algorithm involved in their training, with particular attention to the description of how we designed our customized Neural Network. In Chapter4 our original problem is formalized, with the purpose of putting in com- munication the world of EDPs with the one of ANNs, and describing the effort we made to realize our project. Chapter5 contains a description of the libraries used for the implementation (OpenNN and IsoGlib), while in Chapter6 we will present the classes we developed to interface them. Numerical results are presented in Chapter 7 to demonstrate the performance of this network-based technique and results are critically discussed comparing them with the known formulas. At the end (Chapter 8) , possible further developments of this technique are presented. Indeed we start from the implementation of a neural network that works on a simplified version of the PDE problem but, once this network is tested, we already have in mind how to customize it for more complicated problems. 5 Chapter 2 Problem: SUPG stabilization and Isogeometric analysis 2.1 Advection-diffusion problem Advection–diffusion PDEs (see (Q17, chap.13)) are used to model a wide range of phenomena such as semiconductor devices modeling, magnetostatics and electro- static flows, heat and mass-transfer and flows in porous media related to oil and groundwater applications. The linear advection–diffusion equation on a domain d Ω Ď R “ 2; 3 is a boundary value problem of the form: Lu “ ´divpµpxqruq ` bpxq ¨ ru “ f in Ω (2.1) #u “ 0 on BΩ where µpxq and bpxq are respectively the diffusion and advection coefficent. In many practical applications, the diffusion term ´divpµpxqruq is dominated by the transport term bpxq ¨ ru. In such cases the solution can give rise to boundary layers, namely regions, generally close to the boundary of Ω, where the solution is characterized by strong gradients. From a numerical point of view, solving these types of advection-dominated problems using Galerkin Finite Element method leads to nonphysical oscillation near the boundary layers. An example of this phe- nomenon can be seen in 2.1, obtained using the following data µ “ 10´4; β “ r1; 1s in Ω “ p0; 1q2 and a forcing term f such that the exact solution is given by: px´0:5q2`py´0:5q2´ 1 ? 16 uex “ ´atan µ A challenging problem is to find numerical scheme that works´ well in all types¯ of regime, without increasing the computational effort to solve the PDE problem. The goal of this project is to find an innovative way to code the SUPG stabi- lization method, exploiting Artificial Neural Networks to select the best value of the stabilization parameter. 7 8CHAPTER 2. PROBLEM: SUPG STABILIZATION AND ISOGEOMETRIC ANALYSIS Figure 2.1: Numerical oscillations in 2D 2.1.1 Weak formulation and numerical discretization using FE 1 Let V “ H0 pΩq be the reference Sobolev space, let a : V ˆ V Ñ R be the bilinear form apu; vq “ µru ¨ rv dΩ ` b ¨ ruv dΩ »Ω »Ω and let F : V Ñ R be the linear functional F pvq “ fv dΩ »Ω The weak formulation of problem (2.1) reads Find u P V : apu; vq “ F pvq @v P V (2.2) The existence of a unique solution follows from the Lax-Milgram Theorem. By choosing a suitable family tVh; h ¡ 0u of finite dimensional subspaces of V we can state the Galerkin formulation of the problem: Find uh P Vh : apuh; vhq “ F pvhq @vh P Vh (2.3) that is well posed thanks to the previous analysis. Moreover the Galerkin error inequality gives: M ku ´ u k ¤ inf kv ´ v k (2.4) h V α vhPVh h V µ0 where α “ 2 and M “ kµkL8pΩq ` kbkL8pΩq are the coercivity and continuity 1`CΩ constant of ap¨; ¨q, given µ0 the lower bound for the diffusive coefficient µ. M By the definitions of α and M, the upper-bounding constant α of the error becomes larger (and, correspondingly, the estimate 2.4 meaningless) as the ratio kbk L8pΩq grows and tends to infinity. This happens in the advection dominated kµkL8pΩq regime: in such cases the Galerkin method can give inaccurate solutions, presenting numerical oscillations. The dimensionless coefficient that measures the relation between transport and diffusion is called Peclet number and is defined as |b|h e “ (2.5) P 2µ being h the dimension of the mesh. To understand the significance of the Peclet number it can be useful to look at the 1D problem: ´µu2 ` bu1 “ 0; 0 ă x ă 1 #up0q “ 0; up1q “ 1 2.2. SUPG STABILIZATION 9 exppbx{µq´1 The exact solution of this problem is given by upxq “ exppb{µq´1 . When b " µ the solution is close to zero on almost all of the interval, except for the boundary layer that generates in a neighborhood of x “ 1. It can be shown that the Finite Element solution is monotone if and only if the condition Pe ¤ 1 is satisfied: in practice, in order to avoid oscillations h has to be chosen small enough to solve the boundary layer, which, in turn, becomes thinner as the ratio b{µ tends to infinity. In figure 2.2 different trends of the solution to vary of the magnitude of the Peclet number.