Dedalus: a Flexible Framework for Numerical Simulations with Spectral

Dedalus: a Flexible Framework for Numerical Simulations with Spectral

PHYSICAL REVIEW RESEARCH 2, 023068 (2020) Dedalus: A flexible framework for numerical simulations with spectral methods Keaton J. Burns Massachusetts Institute of Technology Departments of Mathematics and Physics, Cambridge, Massachusetts 02139, USA and Center for Computational Astrophysics, Flatiron Institute, New York, New York 10010, USA Geoffrey M. Vasil School of Mathematics and Statistics, University of Sydney, Sydney, New South Wales 2006, Australia Jeffrey S. Oishi Bates College Department of Physics and Astronomy, Lewiston, Maine 04240, USA Daniel Lecoanet Princeton Center for Theoretical Science and Princeton University Department of Astrophysical Sciences, Princeton, New Jersey 08544, USA Benjamin P. Brown University of Colorado Laboratory for Atmospheric and Space Physics and Department of Astrophysical and Planetary Sciences, Boulder, Colorado 80309, USA (Received 22 May 2019; accepted 30 November 2019; published 23 April 2020) Numerical solutions of partial differential equations enable a broad range of scientific research. The Dedalus project is a flexible, open-source, parallelized computational framework for solving general partial differential equations using spectral methods. Dedalus translates plain-text strings describing partial differential equations into efficient solvers. This paper details the numerical method that enables this translation, describes the design and implementation of the codebase, and illustrates its capabilities with a variety of example problems. The numerical method is a first-order generalized tau formulation that discretizes equations into banded matrices. This method is implemented with an object-oriented design. Classes for spectral bases and domains manage the discretization and automatic parallel distribution of variables. Discretized fields and mathematical operators are symbolically manipulated with a basic computer algebra system. Initial value, boundary value, and eigenvalue problems are efficiently solved using high-performance linear algebra, transform, and parallel communication libraries. Custom analysis outputs can also be specified in plain text and stored in self-describing portable formats. The performance of the code is evaluated with a parallel scaling benchmark and a comparison to a finite-volume code. The features and flexibility of the codebase are illustrated by solving several examples: the nonlinear Schrödinger equation on a graph, a supersonic magnetohydrodynamic vortex, quasigeostrophic flow, Stokes flow in a cylindrical annulus, normal modes of a radiative atmosphere, and diamagnetic levitation. DOI: 10.1103/PhysRevResearch.2.023068 I. INTRODUCTION more intriguing are possible combinations of several of the above [4,5]. Partial differential equations (PDEs) describe continuum Apart from a small handful of closed-form solutions, the processes. The continuous independent variables typically vast majority of PDEs require serious numerical and compu- represent space and time, but can also represent more abstract tational intervention. A wide variety of numerical algorithms quantities such as momentum, energy, age of a population, solve PDEs through the general approach of discretizing its or currency. The ability to equate the infinitesimal rates continuous variables and operators to produce a finite-sized of change of different quantities produces endless possible algebraic system yielding an approximate solution. Finite applications. Important examples include wave propagation, element, finite volume, and finite difference methods are com- heat transfer, fluid flow, quantum mechanical probability flux, mon schemes that discretize the domain of the PDE into cells chemical and nuclear reactions, biological phenomena, finan- or points and derive algebraic relations between the values cial markets [1], or social/population dynamics [2,3]. Even at neighboring cells or points from the governing equations. These methods can accommodate complex geometries (such as the flow around an aircraft), but can be difficult to imple- Published by the American Physical Society under the terms of the ment for complex equations and typically converge relatively Creative Commons Attribution 4.0 International license. Further slowly as additional cells or points are added. distribution of this work must maintain attribution to the author(s) In contrast, spectral methods discretize variables by ex- and the published article’s title, journal citation, and DOI. panding them in a finite set of basis functions and derive 2643-1564/2020/2(2)/023068(39) 023068-1 Published by the American Physical Society BURNS, VASIL, OISHI, LECOANET, AND BROWN PHYSICAL REVIEW RESEARCH 2, 023068 (2020) equations for the coefficients of these functions. These meth- products of spectral series and symbolically specify systems ods are well-suited to many equation types and provide of PDEs on those domains. The code then produces a sparse rapidly converging solutions (e.g., exponential for smooth discretization of the equations and automatically parallelizes functions) as additional modes are included. However, spec- the solution of the resulting model. The Dedalus codebase tral methods are typically limited to simple geometries (such is open-source, highly modular, and easy to use. While its as boxes, cylinders, and spheres). Recent literature has devel- development has been motivated by the study of turbulent oped sparse representations of equations that are substantially flows in astrophysics and geophysics, Dedalus is capable of better conditioned and faster than traditional dense collocation solving a much broader range of PDEs. To date, it has been techniques [6–12]. These features make spectral methods an used for applications and publications in applied mathematics attractive choice for scientists seeking to study a wide variety [18–22], astrophysics [23–38], atmospheric science [39–44], of physical processes with high precision. biology [45–47], condensed matter physics [48,49], fluid dy- While computing capacities have grown exponentially over namics [50–61], glaciology [62], limnology [63], numerical the past few decades, the progression of software development analysis [64–67], oceanography [68–72], planetary science has been more gradual. Many software packages have chosen [73,74], and plasma physics [75–82]. one or a few closely related PDEs and focused on creating We begin this paper with a review of the fundamental highly optimized implementations of algorithms that are well- theory of spectral methods and a description of the specific suited to those choices. These solvers usually hardcode not numerical method employed by Dedalus (Sec. II). We then only the PDE but also the dynamical variables, choice of provide an overview of the project and codebase using a input control parameters, integration scheme, and analysis simple example problem (Sec. III). Sections IV–X detail the output. While many world-class simulation codes have been implementations of the fundamental modules of the codebase, developed this way, often scientific questions lead beyond with a particular emphasis on its systems for symbolic equa- what a dedicated code can do. This is not always because of a tion entry and automatic distributed-memory parallelization. lack of computational power or efficiency, but often because Although these sections describe essential details of the code, continued progress requires an alternative model, dynamical a careful reading is not necessary to begin using Dedalus. variable reformulation, or more exotic forms of analysis. Finally, Sec. XI demonstrates the features and performance Simulation packages with flexible model specification also of the codebase with a parallel scaling analysis, a comparison address an underserved scientific niche. It is often straight- to a finite volume code, and example simulations of nonlinear forward to write serial codes to solve simple one-dimensional waves on graphs, compressible magnetohydrodynamic flows, equations for particular scientific questions. It is also worth- quasigeostrophic flow in the ocean, Stokes flow in cylindri- while to invest multiple person-years building codes that solve cal geometry, atmospheric normal modes, and diamagnetic well-known equations. However, it can be difficult to justify levitation. spending significant time developing codes for novel models that are initially studied by only a few researchers. We believe II. SPARSE SPECTRAL METHODS this leaves many interesting questions unaddressed simply A. Fundamentals of spectral methods from a local cost-benefit analysis. Flexible toolkits can lower the barrier to entry for a large number of interesting scientific 1. Spectral representations of functions applications. A spectral method discritizes functions by expanding them The FENICS [13] and FIREDRAKE [14] packages both al- over a set of basis functions. These methods find broad low users to symbolically enter their equations in variational application in numerical analysis and give highly accurate and form and produce finite-element discretizations suitable for efficient algorithms for manipulating functions and solving forward-modeling and optimization calculations. These are differential equations. The classic reference Boyd et al. [83] very powerful tools for solving wide ranges of PDEs in covers the material in this section in great detail. complicated geometries, however they remain less efficient Consider a complete orthogonal basis {φn(x)} and the than spectral methods for many PDEs in simple geometries. associated inner product (φn,φm )φ ∝ δn,m. The

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    39 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us