Dedalus: An Open-Source Spectral Magnetohydrodynamics Code

Similar documents
The Magnetorotational Instability

School and Conference on Analytical and Computational Astrophysics November, Angular momentum transport in accretion disks

2 GOVERNING EQUATIONS

Momentum transport from magnetic reconnection in laboratory an. plasmas. Fatima Ebrahimi

Introduction to FARGO3D

Global magnetorotational instability with inflow The non-linear regime

EULERIAN DERIVATIONS OF NON-INERTIAL NAVIER-STOKES EQUATIONS

The Turbulent Rotational Phase Separator

Global Magnetorotational Instability with Inflow

Navier-Stokes equations

Incompressible MHD simulations

Prof. dr. A. Achterberg, Astronomical Dept., IMAPP, Radboud Universiteit

arxiv: v1 [physics.plasm-ph] 2 Nov 2018

Nonlinear MRI. Jeremy Goodman. CMPD/CMSO Winter School 7-12 January 2008, UCLA

Stellar Magnetohydrodynamics

Chapter 4: Fundamental Forces

ESS314. Basics of Geophysical Fluid Dynamics by John Booker and Gerard Roe. Conservation Laws

LES of Turbulent Flows: Lecture 3

Tutorial School on Fluid Dynamics: Aspects of Turbulence Session I: Refresher Material Instructor: James Wallace

Effects of Forcing Scheme on the Flow and the Relative Motion of Inertial Particles in DNS of Isotropic Turbulence

Magnetohydrodynamic Waves

NUMERICAL METHODS IN ASTROPHYSICS An Introduction

M.A. Aziz, M.A.K. Azad and M.S. Alam Sarker Department of Applied Mathematics, University of Rajshahi-6205, Bangladesh

PAPER 57 DYNAMICS OF ASTROPHYSICAL DISCS

Binary black-hole mergers in magnetized disks: Simulations in full general relativity

2. FLUID-FLOW EQUATIONS SPRING 2019

Vortices in accretion discs: formation process and dynamical evolution

Ideal Magnetohydrodynamics (MHD)

A generalised Ladyzhenskaya inequality and a coupled parabolic-elliptic problem

Numerical methods for the Navier- Stokes equations

The Orchestra of Partial Differential Equations. Adam Larios

Hydrodynamic Turbulence in Accretion Disks

Effects of Forcing Scheme on the Flow and the Relative Motion of Inertial Particles in DNS of Isotropic Turbulence

The Physics of Fluids and Plasmas

SOLAR MHD Lecture 2 Plan

Fundamentals of Fluid Dynamics: Elementary Viscous Flow

Formation and Long Term Evolution of an Externally Driven Magnetic Island in Rotating Plasmas )

Chapter 5. The Differential Forms of the Fundamental Laws

MHD turbulence in the solar corona and solar wind

Dead zones in protoplanetary discs

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

Lecture 1. Hydrodynamic Stability F. H. Busse NotesbyA.Alexakis&E.Evstatiev

Development of high vorticity structures in incompressible 3D Euler equations.

On the Global Attractor of 2D Incompressible Turbulence with Random Forcing

Journal of Fluid Science and Technology

Magnetized Accretion Discs and the Dwarf Nova Phenomenon

Simulation Study on the Generation and Distortion Process of the Geomagnetic Field in Earth-like Conditions

where G is Newton s gravitational constant, M is the mass internal to radius r, and Ω 0 is the

F q. Gas at radius R (cylindrical) and height z above the disk midplane. F z. central mass M

Experience with DNS of particulate flow using a variant of the immersed boundary method

Greg Hammett Imperial College, London & Princeton Plasma Physics Lab With major contributions from:

Application of Chimera Grids in Rotational Flow

Vorticity and Dynamics

Angular Momentum Transport in Quasi-Keplerian Accretion Disks

Nonequilibrium Dynamics in Astrophysics and Material Science YITP, Kyoto

EULER AND SECOND-ORDER RUNGE-KUTTA METHODS FOR COMPUTATION OF FLOW AROUND A CYLINDER

arxiv: v1 [astro-ph.he] 10 Jan 2012

V (r,t) = i ˆ u( x, y,z,t) + ˆ j v( x, y,z,t) + k ˆ w( x, y, z,t)

Vortex Dynamos. Steve Tobias (University of Leeds) Stefan Llewellyn Smith (UCSD)

Spectral Methods for Reaction Diffusion Systems

The large-scale magnetic field in protoplanetary disks

Multiscale Computation of Isotropic Homogeneous Turbulent Flow

Dynamics of Astrophysical Discs

Self-Organization of Plasmas with Flows

F. Marzari, Dept. Physics, Padova Univ. Planetary migration

α 2 )(k x ũ(t, η) + k z W (t, η)

The Pseudospectral Method

Macroscopic plasma description

Accretion Disks Angular momentum Now let s go back to black holes. Black holes being what they are, something that falls into one disappears without

Computational Astrophysics

Plasma Physics for Astrophysics

3 Generation and diffusion of vorticity

REE Internal Fluid Flow Sheet 2 - Solution Fundamentals of Fluid Mechanics

16. Solution of elliptic partial differential equation

Numerical Solutions to Partial Differential Equations

arxiv:astro-ph/ v1 6 Jul 2005

arxiv:astro-ph/ v1 31 Aug 1998

Magnetorotational Instability: Plans at MPA, IPP and TU Berlin

General introduction to Hydrodynamic Instabilities

fluid mechanics as a prominent discipline of application for numerical

Table of Contents. II. PDE classification II.1. Motivation and Examples. II.2. Classification. II.3. Well-posedness according to Hadamard

Euclidean invariance and weak-equilibrium condition for the algebraic Reynolds stress model

Protoplanetary Disks. Ernst Dorfi WS 2012

Buoyancy of magnetic fields in accretion disks

Entropy generation and transport

The Madison Dynamo Experiment: magnetic instabilities driven by sheared flow in a sphere. Cary Forest Department of Physics University of Wisconsin

Application of Reconstruction of Variational Iteration Method on the Laminar Flow in a Porous Cylinder with Regressing Walls

Instability theory of swirling flows with suction

Received: 5 September 2017; Accepted: 2 October 2017; Published: 11 October 2017

Accretion Disks Black holes being what they are, something that falls into one disappears without a peep. It might therefore seem that accretion onto

Statistical studies of turbulent flows: self-similarity, intermittency, and structure visualization

Intermittency of quasi-static magnetohydrodynamic turbulence: A wavelet viewpoint

d v 2 v = d v d t i n where "in" and "rot" denote the inertial (absolute) and rotating frames. Equation of motion F =

12.1 Viscous potential flow (VPF)

Quasi-Periodic Oscillations in Relativistic Tori

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

Scope of this lecture ASTR 7500: Solar & Stellar Magnetism. Lecture 9 Tues 19 Feb Magnetic fields in the Universe. Geomagnetism.

MULTISCALE ANALYSIS IN LAGRANGIAN FORMULATION FOR THE 2-D INCOMPRESSIBLE EULER EQUATION. Thomas Y. Hou. Danping Yang. Hongyu Ran

nek5000 massively parallel spectral element simulations

Lagrangian acceleration in confined 2d turbulent flow

Transcription:

Dedalus: An Open-Source Spectral Magnetohydrodynamics Code Keaton Burns University of California Berkeley Jeff Oishi SLAC National Accelerator Laboratory Received ; accepted

ABSTRACT We developed the magnetohydrodynamic (MHD) capabilities of Dedalus, an open-source Python-based hydrodynamics simulation, to explore and compare the properties of the standard and helical magnetorotational instabilities. Dedalus is a spectral code that uses external FFT libraries and parallelization with the goal of achieving speeds competitive with codes implemented in lowerlevel languages. This paper will outline the MHD equations as implemented in Dedalus, the methods taken to improve the performance of the code, and the initial results of our simulations. Contents 1 Introduction 3 2 Dedalus Development 3 2.1 MHD Equations.................................. 3 2.2 Spectral Implementation............................. 4 2.3 Temporal Integration............................... 5 2.4 Shearing Box................................... 6 2.5 FFTs and Parallelization............................. 9 3 Magnetorotational Instability Results 9 4 Conclusion 10 2

5 References 10 1. Introduction The magnetorotational instability (MRI) is a fluid instability that causes the onset of turbulence in magnetized disks and transports angular momentum outwards. It is believed to be an important mechanism in the physics of accretion disks. While not believed to exist in astrophysical disks, a second instability caused by a helical magnetic field has also been discovered. This helical magnetorotational instability (HRMI) may be easier to produce in ongoing laboratory experiments using liquid sodium. The applicability of such experiments to the processes in astrophysical disks is the subject of our investigation. 2. Dedalus Development Dedalus is an open-source spectral hydrodynamics code, written in Python 2.7. It was designed to be flexible and easy to use, with the FFTs handled by external libraries and/or parallelization to abate the performance penalties of using a high-level language. The code makes extensive use of object-oriented programming, facilitating the modular implementation of different domain representations and physics. In addition to the magnetohydrodynamics (MHD) physics described below, Dedalus is also currently being used to study linear cosmology and baryon acoustic oscillations -NEED REFERENCE-. Dedalus is currently hosted on a public bitbucket repository. 2.1. MHD Equations We begin with the equations governing incompressible MHD: the incompressible Navier-Stokes equation with the Lorentz force and viscosity, the induction equation with 3

magnetic diffusivity, mass continuity, and Gauss s law for magnetism (in Gaussian units, and with t indicating t ): Expanding the Lorentz force as t u + u u = p + F L + ν 2 u, (1) t B = (u B) + η 2 B, (2) u = 0, (3) B = 0, (4) F L = ( B) B 4π = B B 4π B2 8π, (5) Eq. (1) becomes t u + u u = P tot + B B 4π + ν 2 u, (6) P tot = p + B2 8π. (7) 2.2. Spectral Implementation In a periodic domain, any sufficiently smooth field variable can be represented by its discrete Fourier decomposition on the grid. That is, for some function f, we can write f(x, t) = k ˆf(k, t)e ix ik i, (8) ˆf(k, t) = x f(x, t)e ix ik i. (9) In Fourier space, the spatial derivatives in the governing equations transform to trivial multiplications: FT ik. Pseudospectral codes, such as Dedalus, use Fast Fourier Transforms (FFTs) to compute these spatial derivatives and transform the problem into a system of ordinary differential equations, which are then temporally integrated in Fourier space. 4

Taking the Fourier transforms of Eqs. (5), (3), and (4) yields t û = û u ik ˆ P tot B + B νk 2 û, (10) 4π ik û = 0, (11) ik ˆB = 0. (12) We then take the scalar product of ik with Eq. (10) to arrive at an expression for the total pressure: ˆ P tot = ik û u k 2 ik B B. (13) 4π k 2 Using the identity (A B) = A( B) B( A) + (B )A (A )B along with Eqs. (2), (3), and (4), we see t B = B u u B + η 2 B. (14) Taking the Fourier transform of Eq. (14), we arrive at the time-evolution equation for ˆB: t ˆB = B u u B ηk 2 B. (15) The nonlinear terms (û u, u B, B u, and B B) in Eqs. (10) and (15) are computed in real space. To eliminate aliasing effects, we employ the Orszag 2/3 rule, zeroing any mode with a k component greater than or equal to 2/3 of the Nyquist wavenumber in that direction. This zeroing is done before every reverse Fourier transform, after every forward Fourier transform, and at each temporal evolution. 2.3. Temporal Integration The ODEs produced by the physics modules, along with the initial conditions specified at the start of the simulation, form an initial value problem that is integrated using explicit 5

Runge-Kutta methods, specifically the second-order midpoint method. For simulations with viscosity and/or magnetic diffusivity, an integrating factor is used to evaluate the linear steps used to construct the Runge-Kutta stages. Consider Eq. (10) for a specified mode k, with the non-viscous terms considered to be constant during an integration step: t û(t) + νk 2 û(t) = RHS. (16) This is an equation of the form y (x) + P (x)y = Q(x), which has the exact solution y(x) = Q(x)M(x)dx, (17) M(x) where M(x) = e P (x)dx is called the integrating factor. Hence we find the solution of Eq. (16) at time t + dt to be û(t + dt) = [ û(t) + RHS ] dt νk 2 (eνk2 1) e νk2dt. (18) 2.4. Shearing Box To study the effect of the MRI, we perform local simulations where our domain represents a small part of an astrophysical disk. The domain is taken to be a co-rotating box, whose left edge is a distance r 0 from the axis of rotation, and whose length in each dimension is much less than this fiducial radius. In the co-rotating frame, we take the unit vector e x in the outward radial direction, and the unit vector e z along the axis of rotation. The box is rotating with an angular velocity Ω 0 = Ω 0 e z = Ω(r 0 )e z. The radial dependence of angular velocity in a Keplerian disk, Ω(r) = GMr 3/2, gives rise to a background linear shear flow in this domain: with the domain moving at the angular velocity of the left (inner) edge, the box will shear in the x direction with a velocity of 3Ω 2 0xe y, as shown in Fig. 1. This shear motivates the construction of a domain representation and a corresponding physics implementation to handle MHD in a box with an arbitrary local linear shear. 6

Fig. 1. Co-rotating local domain as viewed from an inertial frame. Lower angular velocity at larger radii results in a local linear shear across the x direction of the local domain. The size of the box relative to r 0 is exaggerated for clarity. Consider an arbitrary power-law shearing profile, Ω(r) = Cr S (which arises from an attractive force of magnitude C 2 r 2S+1 and gives rise to a linear background shear in the local frame with velocity SΩ 0 xe y. Hence C = GM and S = 3/2 for Keplerian rotation). In this case, the centrifugal ( Ω 0 (Ω 0 r) = Ω 2 0 re x ) and attractive ( C 2 r 2S+1 e x ) accelerations partially cancel (via approximations utilizing x, y, z r 0 ): a rad = (Ω 0 2 C 2 r 2S )re x 2SΩ 0 2 xe x. (19) With this radial acceleration and the Coriolis acceleration ( 2Ω 0 v), Eq. (1) for the velocity field in the rotating frame, v, becomes t v + v v = p + F L + ν 2 v 2SΩ 0 2 xe x 2Ω 0 v. (20) Decomposing v into the background shear flow and velocity perturbations (v = SΩ 0 xe y +u), Eq. (20) becomes t u + u u = p + F L + ν 2 u + 2Ω 0 u y e x (2 + S)Ω 0 u x e y SΩ 0 x y u. (21) 7

Due to the shear of our frame, the forward and reverse Fourier transforms become: ˆf(k, t) = x f(x, t)e i(x ik i SΩ 0 xtk y), (22) f(x, t) = k ˆf(k, t)e i(x ik i SΩ 0 xtk y), (23) to maintain periodicity along the shearing direction. Hence, we define the fixed-grid wavevector K as a function of the Lagrangian (shearing) wavevector k and time, K(k, t) = (k x SΩ 0 tk y, k y, k z ), and when transforming to Fourier space, the derivative operators become x i(k x SΩ 0 tk y ) = ik x, (24) The analogs of Eqs. (10) and (13) are then t û = û u ik ˆ P tot y ik y = ik y, (25) z ik z = ik z, (26) t t isω 0 xk y. (27) B + B νk 2 û + 2Ω 0 û y eˆx (2 + S)Ω 0 û x eŷ, (28) 4π ˆ P tot = ik ˆM K 2 ik ˆL 4π K 2iΩ 0û y K x + (1 + S)2iΩ 0û x K y. (29) 2 K 2 K 2 Eq. (14) becomes, in velocity perturbations, t B = B u u B + η 2 B + SΩ 0 B x e y SΩ 0 x y B, (30) and the analog of Eq. (15) becomes t ˆB = B u u B ηk 2 B + SΩ 0 ˆBx eŷ. (31) 8

2.5. FFTs and Parallelization Although Dedalus is written in Python, the FFTs dominate the computational cost of a simulation, meaning that optimizing the FFTs largely negates the performance penalties of using a high-level language, while maintaining ease of use and speed of development. Outsourcing the FFTs from Python to FFTW, a C-based library that optimizes FFT routines based on local hardware, results in a substantial speed improvement over Python s (i.e. numpy s) built-in FFT algorithms. Much greater gains can be made on a GPU using Nvidia s CUDA architecture to compute the FFTs and other calculations. Finally, MPI-based parallelization was implemented, allowing a single simulation to simultaneously run as many separate tasks. To achieve this, the computational domain is evenly divided among the N tasks along the k z direction in Fourier space. The reverse Fourier transform is then accomplished in a series of steps, as depicted in Fig. 2. First, each task performs a 2D IFFT in the k x and k y directions on its dataset, and the shearing phase shift as applied as in Eq. (23), if necessary. Second, an MPI All-To-All call is issued, in which each task evenly divides its data N times in the y direction, and sends the Nth slab to the Nth task. Each task then stacks the N slabs it has received, and performs a 1D IFFT in the k z direction. The resulting datasets have gone through a full 3D IFFT, and the data is evenly divided among the tasks along the y direction in real space. The parallelized forward transform is the reverse of this process. 3. Magnetorotational Instability Results Note: simulations in progress. I hope to have results by the end of the week. 9

Fig. 2. Task cuts along k z in Fourier space, MPI All-To-All call, task cuts along y in real space. 4. Conclusion Dedalus is among the first entirely open-source spectral MHD codes. The Python development environment facilitate ease of use and code development, and our emphasis on object-oriented techniques have helped make Dedalus a very modular code which can be easily adapted to study a variety of problems. The parallelized FFT algorithms, the use of external libraries, and the incorporation of GPU-based calculations using CUDA all contribute substantially to the performance of the code. With shearing-box MHD simulations underway, we hope to use Dedalus to help identify points of comparison and departure between current lab-based HMRI experiments and the standard MRI operating in astrophysical accretion disks. 5. References 10