Numerically Solving Partial Differential Equations

Similar documents
Scientific Computing: An Introductory Survey

where is the Laplace operator and is a scalar function.

PDE Solvers for Fluid Flow

Math background. Physics. Simulation. Related phenomena. Frontiers in graphics. Rigid fluids

Chapter 3. Finite Difference Methods for Hyperbolic Equations Introduction Linear convection 1-D wave equation

Partial differential equations

2.2. Methods for Obtaining FD Expressions. There are several methods, and we will look at a few:

Additive Manufacturing Module 8

Parallel Programming in C with MPI and OpenMP

Introduction to Partial Differential Equations

Diffusion / Parabolic Equations. PHY 688: Numerical Methods for (Astro)Physics

Some notes about PDEs. -Bill Green Nov. 2015

A Finite Volume Code for 1D Gas Dynamics

Introduction to PDEs and Numerical Methods: Exam 1

Numerical modelling of phase change processes in clouds. Challenges and Approaches. Martin Reitzle Bernard Weigand

Numerical Solutions for Hyperbolic Systems of Conservation Laws: from Godunov Method to Adaptive Mesh Refinement

INTRODUCTION TO FINITE ELEMENT METHODS ON ELLIPTIC EQUATIONS LONG CHEN

ME Computational Fluid Mechanics Lecture 5

Basic Aspects of Discretization

Lecture 16: Relaxation methods

Intro to Research Computing with Python: Partial Differential Equations

Computational Astrophysics

Computational Seismology: An Introduction

Applied Mathematics 205. Unit III: Numerical Calculus. Lecturer: Dr. David Knezevic

Numerik 2 Motivation

Advanced Vectorization of PPML Method for Intel Xeon Scalable Processors

Finite Volume Method

Numerical Solutions of Partial Differential Equations

The one-dimensional equations for the fluid dynamics of a gas can be written in conservation form as follows:

Discretization of PDEs and Tools for the Parallel Solution of the Resulting Systems

Numerical Methods for Partial Differential Equations CAAM 452. Spring 2005

Practical in Numerical Astronomy, SS 2012 LECTURE 9

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 13

Hydraulic Modelling for Drilling Automation

Numerical Methods for Engineers and Scientists

The Center for Astrophysical Thermonuclear Flashes. FLASH Hydrodynamics

Image Reconstruction And Poisson s equation

Partial Differential Equations II

Multi-D MHD and B = 0

Shock Waves & Solitons

Chapter 10 Exercises

Numerical Methods for Conservation Laws WPI, January 2006 C. Ringhofer C2 b 2

D03PEF NAG Fortran Library Routine Document

Finite Volume Schemes: an introduction

The Lattice Boltzmann method for hyperbolic systems. Benjamin Graille. October 19, 2016

Finite Difference Methods (FDMs) 2

Arches Part 1: Introduction to the Uintah Computational Framework. Charles Reid Scientific Computing Summer Workshop July 14, 2010

Poisson s equation. Lab 1. Poisson s equation in two dimensions

AMS 529: Finite Element Methods: Fundamentals, Applications, and New Trends

Computational Astrophysics 7 Hydrodynamics with source terms

First, Second, and Third Order Finite-Volume Schemes for Diffusion

FDM for wave equations

Numerical Methods in Geophysics. Introduction

Gas Dynamics: Basic Equations, Waves and Shocks

Elements of Matlab and Simulink Lecture 7

Chapter 1. Introduction to Nonlinear Space Plasma Physics

Solving PDEs: the Poisson problem TMA4280 Introduction to Supercomputing

Introduction LECTURE 1

A Numerical Study of Some Parallel Algebraic Preconditioners

Advanced numerical methods for nonlinear advectiondiffusion-reaction. Peter Frolkovič, University of Heidelberg

Block-Structured Adaptive Mesh Refinement

Numerical Solutions to Partial Differential Equations

ECE539 - Advanced Theory of Semiconductors and Semiconductor Devices. Numerical Methods and Simulation / Umberto Ravaioli

The RAMSES code and related techniques 4. Source terms

Wave propagation methods for hyperbolic problems on mapped grids

PROBLEM SET. Heliophysics Summer School. July, 2013

Numerical Modelling in Fortran: day 9. Paul Tackley, 2017

Fluid Dynamics. Massimo Ricotti. University of Maryland. Fluid Dynamics p.1/14

Scalable Domain Decomposition Preconditioners For Heterogeneous Elliptic Problems

Weighted Essentially Non-Oscillatory limiters for Runge-Kutta Discontinuous Galerkin Methods

Computational Fluid Dynamics. PHY 688: Numerical Methods for (Astro)Physics

Self-similar solutions for the diffraction of weak shocks

Earth System Modeling Domain decomposition

CS 542G: The Poisson Problem, Finite Differences

Introduction to Computational Fluid Dynamics

Chapter 9 Implicit integration, incompressible flows

7 Hyperbolic Differential Equations

Lecture Introduction

Clawpack Tutorial Part I

Basics on Numerical Methods for Hyperbolic Equations

Numerical Methods for PDEs

The RAMSES code and related techniques I. Hydro solvers

SOLVING ELLIPTIC PDES

Level Set and Phase Field Methods: Application to Moving Interfaces and Two-Phase Fluid Flows

Restrictive Taylor Approximation for Gardner and KdV Equations

Finite difference methods. Finite difference methods p. 1

Solving PDEs with freefem++

FUNDAMENTALS OF FINITE DIFFERENCE METHODS

Poisson Equation in 2D

An Overview of Fluid Animation. Christopher Batty March 11, 2014

Variability of Stencil Computations for Porous Media

Relevant self-assessment exercises: [LIST SELF-ASSESSMENT EXERCISES HERE]

ADI iterations for. general elliptic problems. John Strain Mathematics Department UC Berkeley July 2013

Advection / Hyperbolic PDEs. PHY 604: Computational Methods in Physics and Astrophysics II

RESEARCH HIGHLIGHTS. WAF: Weighted Average Flux Method

LECTURE # 0 BASIC NOTATIONS AND CONCEPTS IN THE THEORY OF PARTIAL DIFFERENTIAL EQUATIONS (PDES)

Two-Dimensional Unsteady Flow in a Lid Driven Cavity with Constant Density and Viscosity ME 412 Project 5

Time stepping methods

Riemann Solvers and Numerical Methods for Fluid Dynamics

Computational Fluid Dynamics-1(CFDI)

Transcription:

Numerically Solving Partial Differential Equations Michael Lavell Department of Applied Mathematics and Statistics Abstract The physics describing the fundamental principles of fluid dynamics can be written in the form of partial differential equations. This study approximates each of the three types of PDE s using finite difference methods and solves each type in parallel on Hyades, a supercomputer at UC Santa Cruz. A 1D advection equation and a 2D diffusion equation are solved with MPI and a 2D poisson equation is solved with openmp. 1 Introduction Partial differential equations are a formulation of how a set of variables and their derivatives behave with respect to each other. When these variables represent properties of a given system, it is possible to predict how the system will behave over time. For example, if u is pressure, the advection equation u t + au x = 0 represents the propagation of pressure through a 1D spatial domain with finite propagation speed a. Achieving exact solutions for such problems is incredibly difficult and sometimes impossible. However, there are tools that allow us to build numerical models capable of solving partial differential equations, and subsequently, predict how systems evolve. In this study, we use the finite difference scheme to discretize the spatial domain, temporal domain, and the three different types partial differential equations. Using the parallel libraries, MPI and openmp, we can split the computational work load between a team processors on the Hyades cluster. This allows us to quickly pursue a numerical solution of a given problem. 1

2 Pursuing Numerical Solution to PDEs The finite difference scheme provides a means of discretizing the spatial and temporal domains of the system. Using this method, we construct numerical schemes that approximate the solution at a given point in time and space and explicitly define the advancement of a single cell for the three types of partial differential equations: hyperbolic, parabolic, and elliptic. U n i u(x i, t n ) The term u(x i, t n ) generally represents a state variable, such as pressure or temperature, however, in the case of the poisson equation it is a time invariant variable, such as gravitational or electrostatic potential. 2.1 Hyperbolic Equation We solve the 1D advection equation u t + au x = 0 defined on Ω = [x a, x b ], t 0 with the discretization x i = x a + (i 1 ) x, i = 0, 1,..., N + 1 2 t n = n t, n = 0, 1,..., M establishing a cell centered configuration with guard cells. The advection equation describes the finite propagation of information through space. Using a strict set of cells at t = n, we can approximate a cell at t = n + 1. We use the Centered, Downwind, and Upwind schemes to study the advection of a continuous and discontinuous profile. Upwind: U n+1 = Ui n a t x (U i n Ui 1 n ) Downwind: Ui n+1 = Ui n a x (U i+1 n U i n) Centererd: Ui n+1 = Ui n a t x (U i+1 n U i 1 n ) The Upwind scheme is the only stable scheme as illustrated in Figure 1. Using MPI, we split the 1 dimensional array Ui n between a team of processors in order to minimize computation time. Data must be passed between processors since the boundary cells on a processor require the boundary cells from the next processor in order to advance. 2.2 Parabolic Equation The parabolic type PDE we will consider is the diffusion equation u t = κ 2 u where κ is the diffusion coefficient. Derived using finite difference methods, the Forward Euler method explicitly defines the solution Ui n+1 at the next time step. Ui,j n+1 = Ui,j n + t +U n i,j+1 h 2 Ui+1,j n 4Ui,j n +Ui 1,j n Ui,j 1 n 2

Figure 1: The Upwind scheme is stable. The shock maintains it s sharp profile and the continuous sine profile holds it shape after a full period. The Downwind and Centered schemes are unstable and are solved for only 10 iterations to show divergent behavior. 3

The discretized 2-dimensional spacial domain is split evenly along the y-axis and distributed evenly amongst the available number of processors. Advancing a cell on the boundary, U i,k where k = (N + 2)/(number of processors), requires U i,k+1. Since this is true for i = 0, N + 1, an array is passed between processors and when implemented with MPI it is necessary to define a new MPI TYPE. A processor in the middle of the domain will send and receive the new data type from both the processor in front of and behind it. The diffusion equation evolves the initial profile given by ( ( )) x2 u 0 (x, y) = A exp 2σx 2 + y2 2σy 2. This can be interpreted as a pressure distribution with a region of high pressure in the middle and low pressure on the boundary. As expected the profile diffuses with time. See Figure 3. Figure 2: 2D diffusion initial profile. Due to poor communication when running on more than two processors, the diffusion solver did not scale well. Figure 4 shows the incorrect solution for the diffusion solver on 8 processors. 2.3 Elliptic Equation The third equation we solve is the Poisson equation. 2 u = f 4

Figure 3: Diffusion equation. The evolution of a normal distribution of a state variable over 500,000 iterations. On two processors: 9.71093750 seconds. Figure 4: Broken diffusion solver due to poor communication between processors. 5

Unlike the parabolic or hyperbolic PDE s, the elliptic PDE is independent of time. In fact, it is the steady state solution of the diffusion equation. Time invariant properties such as gravitational potential and electrostatic potential are described using the poisson equation: Gravitational Potential: 2 φ = 4πGρ Electrostatic Potential: 2 φ = ρ ɛ Solving these equations for the scalar gravitational and electrostatic potential field requires knowing the mass distribution and charge density distribution respectively. We will study a system with two point masses and a system with a single mass that varies with radius. Using a five point stencil for 2 u, we discretize the poisson equation. Let h = x = y, then U i+1,j 2U i,j + U i 1, x 2 + U i,j+1 2U i,j + U i,j 1 y 2 = f i,j U new = 1 4 [U i,j 1 + U i,j+1 + U i+1,j + U i 1,j h 2 f i,j ]. This scheme, run in parallel with openmp, achieves convergent solutions for both initial scalar fields. Figure 5: Poisson equation. Potential well of a mass or charge distribution that decreases in density as radius increases. 6

Figure 6: Poisson equation. Potential well of two point masses/charges. 3 Code Execution To set up the diffusion and advection solvers edit the runtime parameters located in the main section of pyrun pde.py in the /pyrun directory. Then, execute with python pyrun pde.py This will make clean, compile, and execute the Fortran code located in objects and plot the results. The poisson solver is located in the /gravity directory. Choose the desired spatial discretization and the source term in the main section of pyplot.py and match these parameters with the equivalent variables initialized in grav solver.f90. Enter the following to compile, execute, and plot. gfortran -fopenmp grav solver.f90 -o solver.exe./solver.exe python pyplot.py 7

4 Discussion Numerically solving partial differential equations using the finite difference approximation produces a scheme that is easily parallelizable and scales well. We look at the 1D advection equation partitioned into N = 256 cells for a brief scaling analysis. Running on two processors the program required 15.3 seconds to converge to the true solution. Running on eight processors the same calculation required 7.3 seconds. Unlike the diffusion solver, the advection solver efficiently communicates information between processors. Large computational fluid dynamics codes require efficient communication, convergent numerical schemes, and appropriately managed computer architectures. Solving partial differential equation s in parallel on supercomputers is a vital first step towards building robust numerical models. 8