atex style emulateapj v. 5/2/11 · preprint typeset using latex style emulateapj v. 5/2/11 phurbas:...

14
Draft version April 2, 2012 Preprint typeset using L A T E X style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION AND TESTS Colin P. M c Nally 2 , Jason L. Maron 1 , and Mordecai-Mark Mac Low 2 Department of Astrophysics, American Museum of Natural History New York, NY, USA Draft version April 2, 2012 ABSTRACT We present an algorithm for simulating the equations of ideal magnetohydrodynamics and other systems of differential equations on an unstructured set of points represented by sample particles. The particles move with the fluid, so the time step is not limited by the Eulerian Courant-Friedrichs-Lewy condition. Full spatial adaptivity is required to ensure the particles fill the computational volume, and gives the algorithm substantial flexibility and power. A target resolution is specified for each point in space, with particles being added and deleted as needed to meet this target. We have parallelized the code by adapting the framework provided by GADGET-2. A set of standard test problems, including 10 -6 amplitude linear MHD waves, magnetized shock tubes, and Kelvin-Helmholtz instabilities is presented. Finally we demonstrate good agreement with analytic predictions of linear growth rates for magnetorotational instability in a cylindrical geometry. This paper documents the Phurbas algorithm as implemented in Phurbas version 1.1. Subject headings: Magnetohydrodynamics (MHD), Methods: numerical, Hydrodynamics 1. INTRODUCTION In Maron et al. (2012, hereafter Paper I) we described an adaptive, Lagrangian, meshless, method for magne- tohydrodynamics (MHD). We now describe the parallel implementation of this algorithm and its tests, and dis- cuss its practical properties. The test problems used are selected from the accepted ones in the literature; many follow those documented for Athena 3 (Stone et al. 2008), and those used by T´ oth (2000), and Ryu & Jones (1995). The three goals of the tests are to verify the convergence to smooth solutions of the MHD equations, demonstrate the global conservation properties and shock errors, and finally to verify the ability of Phurbas to model the linear growth of magnetorotational instability correctly. In § 2.1 we describe how we have implemented our algorithm into a parallel code called Phurbas using the GADGET-2 code 4 (Springel 2005) as a basis. We de- scribe the tests that we have performed with this im- plementation in § 3. We summarize the results of the tests, and discuss the implications and future prospects for Phurbas-like methods in § 4. 2. IMPLEMENTATION OF THE ALGORITHM Phurbas is a parallel code using the Message Pass- ing Interface, following the patterns of the GADGET- 2 code (Springel 2005), which originally combined a smoothed particle hydrodynamics (SPH) treatment of gas dynamics with a tree solution of the Poisson equa- tion to follow N-body dynamics. The serial particle up- date module described in Paper I has been incorporated [email protected] [email protected] [email protected] 1 current address: North Carolina Museum of Natural Sci- ences, Raleigh, NC, USA 2 Department of Astronomy, Columbia University, New York, NY, USA 3 https://trac.princeton.edu/Athena/ 4 http://www.mpa-garching.mpg.de/gadget/ into a modified version of GADGET-2 that has been re-purposed to serve as a parallel framework. We re- fer to the version documented in this work as Phurbas version 1.1 to allow for the differentiation of future mod- ifications to the algorithm and the code. (We note that tests of Phurbas 1.0 were described in the first submitted version of this paper, posted to ArXiv as version 1 of this paper.) We summarize here the algorithm described in detail in Paper I. Phurbas solves the equations of ideal MHD, expressed in terms of Lagrangian time derivatives. The equations are discretized on an adaptive set of particles that carry values of the field variables (density ρ, velocity V, magnetic field B, and internal energy density σ). The particles move with the velocity V that they carry, mak- ing the Lagrangian formalism the natural description of the time evolution of the field variables. The evolution equations relate time derivatives of the field variables to their spatial derivatives. To calculate the spatial deriva- tives, Phurbas uses a local, third-order, polynomial, mov- ing least squares interpolation, using neighbor particle values drawn from a sphere of radius r f,i =2.3λ i about particle i, where λ i is the effective resolution parameter. A second order predictor-corrector scheme is used with the time derivatives obtained by applying the MHD equa- tions to the approximate spatial derivatives to advance the particle positions and variable values. Particles are added and deleted, filling voids and de- stroying clumps, to ensure that each sphere of radius r f is well sampled. On average, the particle creation and dele- tion results in at least one particle per volume λ 3 . The resolution parameter λ need not be constant in space or time, and each particle has an individual time step. In this sense Phurbas is fully adaptive both spatially and temporally. The time steps are independent of the bulk velocity of the flow. Spatial variation of the time steps is limited to prevent the penetration of short time step particles into regions of long time step particles. To obtain numerical stability, Phurbas integrates a arXiv:1110.0836v2 [astro-ph.IM] 30 Mar 2012

Upload: others

Post on 19-Mar-2020

39 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

Draft version April 2, 2012Preprint typeset using LATEX style emulateapj v. 5/2/11

PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II.IMPLEMENTATION AND TESTS

Colin P. McNally2, Jason L. Maron1, and Mordecai-Mark Mac Low2

Department of Astrophysics, American Museum of Natural History New York, NY, USA

Draft version April 2, 2012

ABSTRACT

We present an algorithm for simulating the equations of ideal magnetohydrodynamics and othersystems of differential equations on an unstructured set of points represented by sample particles. Theparticles move with the fluid, so the time step is not limited by the Eulerian Courant-Friedrichs-Lewycondition. Full spatial adaptivity is required to ensure the particles fill the computational volume, andgives the algorithm substantial flexibility and power. A target resolution is specified for each point inspace, with particles being added and deleted as needed to meet this target. We have parallelized thecode by adapting the framework provided by GADGET-2. A set of standard test problems, including10−6 amplitude linear MHD waves, magnetized shock tubes, and Kelvin-Helmholtz instabilities ispresented. Finally we demonstrate good agreement with analytic predictions of linear growth rates formagnetorotational instability in a cylindrical geometry. This paper documents the Phurbas algorithmas implemented in Phurbas version 1.1.Subject headings: Magnetohydrodynamics (MHD), Methods: numerical, Hydrodynamics

1. INTRODUCTION

In Maron et al. (2012, hereafter Paper I) we describedan adaptive, Lagrangian, meshless, method for magne-tohydrodynamics (MHD). We now describe the parallelimplementation of this algorithm and its tests, and dis-cuss its practical properties. The test problems used areselected from the accepted ones in the literature; manyfollow those documented for Athena3 (Stone et al. 2008),and those used by Toth (2000), and Ryu & Jones (1995).The three goals of the tests are to verify the convergenceto smooth solutions of the MHD equations, demonstratethe global conservation properties and shock errors, andfinally to verify the ability of Phurbas to model the lineargrowth of magnetorotational instability correctly.

In § 2.1 we describe how we have implemented ouralgorithm into a parallel code called Phurbas using theGADGET-2 code4 (Springel 2005) as a basis. We de-scribe the tests that we have performed with this im-plementation in § 3. We summarize the results of thetests, and discuss the implications and future prospectsfor Phurbas-like methods in § 4.

2. IMPLEMENTATION OF THE ALGORITHM

Phurbas is a parallel code using the Message Pass-ing Interface, following the patterns of the GADGET-2 code (Springel 2005), which originally combined asmoothed particle hydrodynamics (SPH) treatment ofgas dynamics with a tree solution of the Poisson equa-tion to follow N-body dynamics. The serial particle up-date module described in Paper I has been incorporated

[email protected]@[email protected]

1 current address: North Carolina Museum of Natural Sci-ences, Raleigh, NC, USA

2 Department of Astronomy, Columbia University, New York,NY, USA3 https://trac.princeton.edu/Athena/4 http://www.mpa-garching.mpg.de/gadget/

into a modified version of GADGET-2 that has beenre-purposed to serve as a parallel framework. We re-fer to the version documented in this work as Phurbasversion 1.1 to allow for the differentiation of future mod-ifications to the algorithm and the code. (We note thattests of Phurbas 1.0 were described in the first submittedversion of this paper, posted to ArXiv as version 1 of thispaper.)

We summarize here the algorithm described in detailin Paper I. Phurbas solves the equations of ideal MHD,expressed in terms of Lagrangian time derivatives. Theequations are discretized on an adaptive set of particlesthat carry values of the field variables (density ρ, velocityV, magnetic field B, and internal energy density σ). Theparticles move with the velocity V that they carry, mak-ing the Lagrangian formalism the natural description ofthe time evolution of the field variables. The evolutionequations relate time derivatives of the field variables totheir spatial derivatives. To calculate the spatial deriva-tives, Phurbas uses a local, third-order, polynomial, mov-ing least squares interpolation, using neighbor particlevalues drawn from a sphere of radius rf,i = 2.3λi aboutparticle i, where λi is the effective resolution parameter.A second order predictor-corrector scheme is used withthe time derivatives obtained by applying the MHD equa-tions to the approximate spatial derivatives to advancethe particle positions and variable values.

Particles are added and deleted, filling voids and de-stroying clumps, to ensure that each sphere of radius rf iswell sampled. On average, the particle creation and dele-tion results in at least one particle per volume λ3. Theresolution parameter λ need not be constant in space ortime, and each particle has an individual time step. Inthis sense Phurbas is fully adaptive both spatially andtemporally. The time steps are independent of the bulkvelocity of the flow. Spatial variation of the time stepsis limited to prevent the penetration of short time stepparticles into regions of long time step particles.

To obtain numerical stability, Phurbas integrates a

arX

iv:1

110.

0836

v2 [

astr

o-ph

.IM

] 3

0 M

ar 2

012

Page 2: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

2

modified version of the ideal MHD equations includinga bulk viscosity. The bulk viscosity coefficient is brokeninto two scalar fields. The first is scaled so that mo-tions near the grid scale are always damped. The secondadapts to provide damping in regions with large change,such as shocks and contact discontinuities. A diffusivecorrection term in the induction equation locally diffusesnonzero ∇·B away.

2.1. GADGET-2 Based Implementation

In this section we outline the changes made toGADGET-2 to adapt it to Phurbas, which serves alsoto highlight the differences in the infrastructure neededto support SPH and Phurbas. The largest modificationsare the removal of the SPH algorithm for evaluating thespatial derivatives, the addition of data passing and el-ements in the data structures needed for the PhurbasMHD algorithm, the modification to support additionand deletion of gas-type particles, the addition of mag-netic field variables, and a new main time advance loop.Additions to the input-output routines and global statis-tics were also made.

In GADGET-2 SPH, the sums required for value andgradient evaluation are computed in a distributed man-ner. The contribution to each sum from a set of neigh-bor particles can be computed on the processor wherethose neighbors reside, so that only the total value needbe communicated. For the Phurbas particle update, thevalues for all particles within rf,i of particle i must becommunicated to the process hosting particle i. Particlesare updated in batches, so within groups of ∼ 5, 000–10,000 particles duplicate neighbor communications canbe avoided.

Phurbas requires only a strict radius-based neighborsearch, unlike in GADGET-2 SPH where a mutualneighbor relation is required to achieve symmetric in-terparticle forces. The Phurbas neighbor search is alsoperformed on a fixed radius volume, so it does not neediterative refinement like the GADGET-2 SPH neighborsearch, which adapts the neighbor search radius to in-clude a target number of neighbors. In Phurbas, the mov-ing least squares interpolation and the particle adaptionalgorithm require information from the neighbor parti-cles of particle i to be retrieved to the host process ofparticle i. The set of particles used for these three pro-cedures is the same, the particles within rf .

Compared to GADGET-2 SPH particles, Phurbasparticles use somewhat more memory. Phurbas uses 56.5eight byte variables per particle as opposed to the 36.5used by GADGET-2 in double precision mode. Weretain the basic structures of GADGET-2 in that thevariables required for the neighbor tree construction arestored in a separate array from the fluid quantities. Asthe memory required to complete the retrieval of neigh-bor information can be much larger than in GADGET-2 SPH, and dynamically varies, we dynamically allo-cate buffers as needed to complete this step and freethe memory after the process is finished. Compared toGADGET-2 SPH, we have modified the code to avoidpersistent allocation of memory, which in particular al-leviates problems with computing the domain decompo-sition with large numbers of parallel processes.

The void search in Phurbas described in Paper I relieson computing distances to neighbor particles placed on

a 93 grid. This procedure gains in computational speedif the three-dimensional grid is implemented as a one-dimensional list in memory that is shortened each timea grid point is eliminated from consideration as a near-est neighbor. This minimizes the number of times eachgrid point must be accessed, while keeping the valuesarranged compactly in memory. We have implementedthis strategy by simply replacing the coordinates of anyeliminated point with the coordinates of the current lastpoint on the list and shortening the length of the list.GADGET-2 does not support dynamic particle addi-

tion and deletion. In Phurbas, we first perform a loadbalance on the list of particles to add to voids, in orderto distribute them among processes evenly. The parti-cles are created in free memory spaces on the processorswhere they are moved to by the load balance algorithm.Particles in clumps are deleted from the processors theyare resident on.

As we have now deleted some particles, and added oth-ers to essentially random processors, we perform a newglobal GADGET-2 load balance calculation, followed bya Peano-Hilbert ordering and tree build, as in the stan-dard GADGET-2 algorithm (Springel 2005). Doing thison the entire particle list brings the new particles to op-timal positions on the processors and provides neighborinformation for the subsequent processing stages.

The restriction of local time step variations only re-quires information from particle i to be sent to the hostprocesses of the neighbors of particle i.Time steps arerounded down to powers of two in order to use theGADGET-2 binary block time step scheme (Springel2005), and the increase in time step is limited with theGADGET-2 synchronized time step scheme.

The most significant optimization made has been forthe assembly of the left hand side matrix for the leastsquares fitting problem used in the polynomial interpo-lation. This has been explicitly loop-unrolled into verysimple FORTRAN designed to maximize the ability ofthe compiler to pipeline the instructions and optimizecache use. Despite the increased memory use comparedto GADGET-2 SPH, our experience has been that sim-ulations are computation limited rather than memorylimited.

Compared to dark matter dominated, cosmological, N-body problems, pure MHD fluid problems intrinsicallyrequire more work per particle per time step. For thehighest resolution run in the cylindrical geometry MRItest in the following section, we used ∼ 106 particleson 48 cores, 95% of which were typically active, non-boundary particles. This was run on the Texas AdvancedComputation Center Lonestar cluster, which consists ofnodes with dual Xeon Intel, hexacore, 3.33 GHz, 64-bit,Westmere processors (13.3 GFLOPS per core) intercon-nected with InfiniBand QDR. Phurbas took an average∼ 1.3×10−4 seconds for the serial procedures per particle(void and clump checks, moving least squares interpola-tions, time derivative calculations, and time integrationcorrector step). We note that the performance of thissection of the code depends highly on the compiler andoptimization settings used. The wallclock time per stepwas ∼ 5 seconds for a step involving ∼ 9.1 × 105 activeparticles, giving a speed of ∼ 2.6×10−4 seconds per par-ticle or 3.8 × 103 total updates per core per wallclocksecond, including adaptivity involving ∼ 1500 additions

Page 3: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

Phurbas MHD Code. II. Tests 3

and deletions. It should be noted that Phurbas version1.1 code has not yet been heavily optimized, so we believethe parallel overhead can be further reduced.

For a given application to be suitable for simulationwith Phurbas, the Lagrangian nature, adaptivity, andindividual time steps of Phurbas must offer a significantadvantage on a problem. Otherwise a high-order, grid-based method such as the Pencil Code (Brandenburg &Dobler 2002) is a more efficient choice, as it computesmore than 102 times more updates per core per second.

3. TESTS

We present in this section a series of tests that serveto verify the performance of Phurbas, and illustrate itsabilities and limitations. These include linear waves(Sec. 3.1), circularly polarized Alfven waves (Sec. 3.2),hydrodynamical and MHD shock tubes (Sec. 3.3),Kelvin-Helmholtz instabilities (Sec. 3.4), and cylindricalmagnetorotational instability (Sec. 3.5).

As Phurbas is meshless, it is an intrinsically three-dimensional algorithm. The performance and design cri-teria are different in different numbers of dimensions.Hence, even when tests have symmetries such that theycould be stated in a lower number of dimensions, we per-form them in fully three-dimensional domains to achieveresults reflective of the true capabilities of the code.

It is important to use realistic particle distributions forthese tests. Though perfectly gridded particle distribu-tions would yield good results for some tests, as has beendemonstrated in the literature, such well arranged distri-butions cannot be expected in a general flow. Instead,we realize cubes of relaxed, glassy particle distributionsusing several iterations of Phurbas’s void and clump de-tection algorithms, and then tile these distributions tofill the problem domain. This also ensures that initially,no particle adaption occurs until the particles move farenough to justify it. This allows both the use of a real-istic particle distribution and makes it possible to createa set of predictably refined initial conditions for conver-gence studies. Irregular initial particle distributions alsoremove the need to set up tests at odd angles to preventaligning waves and shock fronts with a grid.

3.1. Linear Waves

To verify the convergence of the scheme and its accu-racy in the linear domain, three MHD waves are modeled.The three waves are a magnetoacoustic wave propagat-ing perpendicularly to the background magnetic field,a shear Alfven wave propagating along the backgroundfield, and a sound wave propagating in an unmagnetizedmedium. We compare the results with solutions of thedispersion relation for the MHD equation, including thebulk viscosity ζl. The solutions for the magnetoacousticand sound waves are derived in Appendix A.

To set this problem up, we use a cubic domain, withside length 1.0, is initialized with density ρ = 1, pres-sure P = 1/γ, and adiabatic index γ = 5/3, in whichthe waves propagate in the x-direction. For the mag-netoacoustic wave the magnetic field is B =

√3z, for

the Alfven wave it is B = 1.0x, and for the sound wavethe magnetic field is set to zero. The initial condition isgenerated from a relaxed particle distribution so that noparticle deletion or addition initially occur. For runs with

10−2 10−1 100

λ

10−3

10−2

10−1

100

L1

Err

or/A

mpl

itude

Sound

10−2 10−1 100

λ

10−5

10−4

10−3

10−2

10−1

100

L1

Err

or/A

mpl

itude

Alfven

10−2 10−1 100

λ

10−3

10−2

10−1

100

L1

Err

or/A

mpl

itude

Magnetoacoustic

Figure 1. Convergence of linear waves. Points show the relativeL1-norm errors derived from the comparison of Phurbas results tosolutions of the MHD dispersion relation including the stabilizingbulk viscosity (see Appendix A). The slopes plotted show second-order convergence.

0.0 0.2 0.4 0.6 0.8 1.0x

−0.10

−0.05

0.00

0.05

0.10

By

λ = 14

λ = 18

λ = 116

λ = 132

λ = 148

λ = 164

Figure 2. Circularly polarized Alfven waves after five box cross-ings with resolutions given by the legend. Note the rapid conver-gence of the higher resolution models.

resolution higher than the lowest value, the same set ofparticles used in the lowest resolution test is scaled andtiled to fill the computational volume. The wave is prop-agated one wavelength, and then the L1-norm error issummed across all fields. We analyze the convergence ofthe relative L1 error, dividing the absolute error by theamplitude given by the linear analysis in Appendix A,as for the waves with a compressive nature (sound andmagnetoacoustic), the analytical solution varies with res-olution. All the waves are observed to converge with atleast second order accuracy, as shown in Figure 1.

3.2. Circularly Polarized Alfven Wave

For our next test of MHD, we run finite-amplitude, cir-cularly polarized, Alfven plane waves using the param-eters from Toth (2000) in a cubic domain with periodicboundary conditions, with the propagation direction par-allel to the x-axis. This is equivalent to α = 0 in the for-malism of Toth (2000). Specifically, the initial conditionsare ρ = 1.0, Vx = 0.0, Bx = 1.0, Vy = 0.1 sin(2πx) = By,Vz = 0.1 cos(2πx) = Bz, P = 0.1, and γ = 5/3. Thewave is propagated five wavelengths, returning to its orig-inal position. The solutions shown in Figure 2 show thatat low resolution, the wave is strongly damped, while asresolution increases the wave rapidly converges. Figure

Page 4: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

4

10−2 10−1 100

λ

10−5

10−4

10−3

10−2

10−1

L1

Err

or

Figure 3. L1-norm errors for circularly polarized Alfven wavesrun with resolution λ after five box crossings. The plotted referenceslope is 2.

3 shows the L1 norm errors, which converge faster thansecond order.

3.3. Shock Tubes

To test performance on supersonic and super-Alfvenicproblems, we set up several shock tube problems. Weused the parameters given in Table 1 on long rectangulardomains with periodic boundaries. A spatially constantresolution criterion λ allows comparison to grid basedcodes, while an appropriately density dependent reso-lution criterion allows comparison to other Lagrangianmethods. For the constant λ tests we denote the dis-tance along the long axis of the domain in units of λ.

3.3.1. Sod Shock Tube

We first run the classic Sod (1978) shock tube, in gaswith γ = 7/5 on a domain of size 64 × 1 × 1 units. Asmooth transition between the left and right states witha width of 0.3 units is described with a fifth-order spline.In the first version of this test we use a refinement criteriaλ = 0.125ρ1/3 that yields a constant mass per resolutionelement (that is, per region with volume of 4/3πλ3). Thisis in effect the resolution criterion used by SPH. In Fig-ure 4 the solution at time t = 13.8 is shown. For this testthe x axis on the plot is denoted in units of λ in the leftinitial state. Unlike SPH, Phurbas supports more gen-eral refinement criteria. As a simple example, we ran thesame Sod test problem with spatially constant resolutionλ = 0.125. Figure 5 shows the result at time t = 15. Theresult is generally very similar to the result with mass-based refinement, with the main change being that theshock is thinner, as the local resolution is higher in theconstant-refinement case. In either case, the shock speedis reasonably well reproduced.

3.3.2. MHD Shock Tubes

We next perform a suite of MHD shock tube tests,selecting from the large set of standard MHD Riemannproblems used in the literature. To tabulate reference so-lutions, we have used Athena (Stone et al. 2008) at highresolution in 1D. The first test we show is the classicalBrio-Wu 1988 shock tube test, which is a standard prob-lem, though not particularly stringent. The test shown inFigure 2a of Ryu & Jones (1995, denoted RJ2a) providesa more complete test of the appearance of the various

possible MHD discontinuities. Ryu & Jones (1995) intheir Figure 4d show a test (denoted RJ4d) of other dis-continuities. The problem described by Falle (2002) inhis Figure 6 (denoted F6) is specifically used to demon-strate shock errors in non-locally-conservative methods.Finally, the test shown in Figure 6 of Dai & Woodward(1994), as well as in Figure 1a of Ryu & Jones (1995,denoted RJ1a) is commonly used as a stringent test of∇·B errors in shocks, and in the case of Phurbas demon-strates the effects of local non-conservation errors asso-ciated with strong MHD shocks. Note that with the ex-ception of the Brio-Wu test, all these MHD shock tubetests use an adiabatic gas with γ = 5/3.

Brio-Wu— The Brio-Wu 1988 shock tube (see Table 1)is an MHD analog to the Sod shock tube problem. Weset up this test in gas with γ = 2, on a fully periodicdomain of 128 × 1 × 1 units, with constant resolutionλ = 0.125. A smooth transition between the left andright states with a width of 3 units was produced with acosine function. The width of the transition region waschosen to avoid excessive start-up transients.

As the problem was run in two mirror images in a pe-riodic volume, only half of the periodic volume used isshown in Figure 6, with the x-axis labeled in λ units,at time t = 7.3. The solution captures the fundamentalfeatures of the problem, including, from left to right, therarefaction fan, the compound wave, the contact discon-tinuity, the slow shock, and the fast rarefaction wave.

The final panel of Figure 6 shows a measure of theeffect of ∇·B. Here the quantity λ(∇·B)/|B| is the frac-tional magnetic field error on the scale of λ. Grey pointsin this panel show the raw values of this quantity, withmaximum magnitude 10−3. However, the scatter is verysymmetric, indicating that most of it can be attributedto the truncation error in the approximation of ∇·B it-self. To extract the coherent skew from zero, we plot thedata binned in bins with width λ as the black step curve,demonstrating that the normalized ∇·B errors are lessthan 10−4.

The Athena solution that we compare our result to,as well as the usually accepted numerical solutions tothe Brio-Wu problem, show a compound wave structure,seen at x ≈ −25 in Figure 6. This structure shouldnot formally exist (Falle & Komissarov 2001), but mostmultidimensional numerical methods, including Phurbas,show it as part of the solution.

RJ2a— The test shown in Figure 2a of Ryu & Jones(1995) (also see Dai & Woodward (1994) Table 3a) isshown in Figure 7 at time t = 12. Initial conditions forthis test are listed in Table 1 as RJ2a. This test is other-wise set up in the same manner and on the same domainas the Brio-Wu test. A high resolution solution was com-puted with Athena for comparison. As Stone et al. (2008)point out, this test is particularly interesting because itrequires modeling a fast magnetosonic shock and a rota-tional discontinuity in each direction of propagation, aswell as a contact discontinuity in the center. No visibleringing is seen at the shocks. The largest coherent ∇·Berrors are also seen near the fast shocks, but the largestscatter in particle ∇·B values is located at the contactdiscontinuity.

Page 5: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

Phurbas MHD Code. II. Tests 5

Table 1Shock Tube Left and Right States

Test ρ Vx Vy Vz P Bx By Bz

Sod Left 1 0 0 0 1 0 0 0Sod Right 0.125 0 0 0 0.1 0 0 0Brio-Wu Left 1 0 0 0 1 0 1 0Brio-Wu Right 0.125 0 0 0 0.1 0 -1 0RJ2a Left 1.08 1.2 0.01 0.5 0.95 2/

√4π 3.6/

√4π 2/

√4π

RJ2a Right 1 0 0 0 1 2/√

4π 4/√

4π 4/√

4πRJ4d Left 1 0 0 0 1 0.7 0 0RJ4d Right 0.3 0 0 1 0.2 0.7 0.7 1F6 Left 0.5 0 2 0 10 2 2.5 0F6 Right 0.1 -10 0 0 0.1 2 2.5 0RJ1a Left 1 10 0 0 20 5/

√4π 5/

√4π 0

RJ1a Right 1 -10 0 0 1 5/√

4π 5/√

4π 0

Figure 4. Sod (1978) shock tube, run with mass-based refinement, equivalent to a Lagrangian method such as SPH. The x-axis is denotedin units of λ of the initial left state density. Phurbas result in black, reference solution in gray.

RJ4d— The test shown in Figure 4d of Ryu & Jones(1995) is shown in Figure 8 at time t = 11.5. This testwas run with the same computational domain and res-olution as the previous test but with the left and rightstates listed in Table 1 as test RJ4d. A small overshootcan be seen on the leftmost rarefaction wave. This is aresult of the bulk viscosity of the scheme.

F6— The test shown by Falle (2002) in his Figure 6 isshown in Figure 9 at time t = 2.9. This test was used toshow an error in the ZEUS (Stone & Norman 1992) so-lution. The initial states are listed in Table 1 as test F6and the problem was run in a domain of 64× 1× 1 units

with λ = 0.25. Fixed boundaries were used in the x di-rection and periodic boundaries in the y and z directions.Compared to the nonconservative ZEUS result shown inFalle (2002) the slow shock is captured more accurately.At this resolution, the slow shock and the contact dis-continuity directly behind it have not yet separated, andthe bulk viscosity of the scheme is causing an undershootin density at the foot of the contact discontinuity. Theleft-going features also show overshoots in density andspecific internal energy that are initial transients causedby the bulk viscosity. These effects are not however dueto significant nonconservation errors.

Page 6: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

6

Figure 5. Sod (1978) shock tube run with constant spatial resolution. Phurbas result shown in black, reference solution in gray.

Figure 6. Brio-Wu 1988 shock tube solution with Phurbas solution in black, and high-resolution Athena solution in gray. Lower rightpanel: One in ten unbinned values of ∇·B as grey points, binned values as black steps.

Page 7: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

Phurbas MHD Code. II. Tests 7

Figure 7. Ryu & Jones (1995) test from their Figure 2a (model RJ2a). High resolution Athena solutions are shown in gray, while thenormalized ∇·B is shown as gray points, and the binned values are shown in black steps. One in ten particles is plotted in the ∇·B scatter.

Figure 8. Ryu & Jones (1995) test from their Figure 4d (model RJ4d). High resolution Athena solution shown in gray, while thenormalized ∇·B is shown as gray points, and the binned values are shown in black steps. One in ten particles plotted in ∇·B scatter.

Page 8: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

8

Figure 9. Falle (2002) test from their Figure 6 (our test F6), which was used to demonstrate an error in the ZEUS algorithm. Highresolution Athena solution shown in gray, while the normalized ∇·B is shown as gray points, and the binned values are shown in blacksteps. One in ten particles is plotted in ∇·B scatter.

Figure 10. Riemann problem test shown by Ryu & Jones (1995) in their Figure 1a, run without elliptic projection ∇·B correction. Highresolution Athena solution shown in gray, while the normalized ∇·B is shown as gray points, and the binned values are shown in blacksteps. One in ten particles is plotted in the ∇·B scatter.

RJ1a— The test shown by Dai & Woodward (1994) intheir Figure 6, is shown in Figure 10 at time t = 3.5.This test also appears in Ryu & Jones (1995) in theirFigure 1a, in Table 6 of Toth (2000), and in Mignoneet al. (2010). In the latter two it is used as a demonstra-tion of ∇·B errors. We show this problem here as a testof the technique used in Phurbas to handle ∇·B, thoughwe expect that the strength of the shocks in this prob-lem lies outside of the intended use regime of Phurbas.A computational volume 64× 1× 1 units was used, withfixed value boundaries in the x direction, and periodicboundaries in the y and z directions with left and rightstates listed in Table 1 as test RJ1a. As Dai & Wood-ward (1994) show, the solution consists of a right goingfast shock with Mach number 6.54, a left going fast shock

with Mach number 2.54, a slow shock, a slow rarefaction,and a contact discontinuity. Phurbas shows a ∇·B errorof a few parts in 104 in the region lying between the twofast shocks.

3.4. Kelvin-Helmholtz Instability

As an example of multidimensional smooth flow withbulk motions, we demonstrate the performance of Phur-bas on three-dimensional Kelvin-Helmholtz instability.Recently Kelvin-Helmholtz instability has attracted sig-nificant discussion following the demonstration by Agertzet al. (2007) that some SPH formulations fail to show thegrowth of the instability in a particular test problem.A number of works have discussed aspects of Kelvin-Helmholtz instability in numerical methods used in astro-

Page 9: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

Phurbas MHD Code. II. Tests 9

physics, particularly in Lagrangian schemes (Price 2008;Wadsley et al. 2008; Cha et al. 2010; Heß & Springel2010; Springel 2010a; Read et al. 2010; Junk et al. 2010;Valcke et al. 2010; Springel 2010b; Robertson et al. 2010;Springel 2011).

In the terminology of Robertson et al. (2010) andSpringel (2010b) we use a smoothed interface initial con-dition. However, unlike Springel (2010b) we choose asmoothing of the interface such that a closed-form alge-braic expression can be computed for the first order, lin-ear, perturbation theory prediction for the growth rate inan incompressible flow on an infinite domain. Wang et al.(2010) have derived such an analytic treatment, provid-ing an exact analytic benchmark for the first time. Fromthat work, we select an initial condition with an expo-nential smoothing. The initial condition for the Kelvin-Helmholtz test is as follows in coordinates where x isparallel to the direction of flow, and z is in the directionof slab symmetry. Density is given by

ρ =

ρ1 − ρme

y−1L if 1 > y > 0

ρ2 + ρme−y+1

L if 2 > y > 1

ρ2 + ρme−(3−y)

L if 3 > y > 2

ρ1 − ρme−(y−3)

L if 4 > y > 3,

(1)

where ρ1 = 1.0, ρ2 = 1.1, ρm = (1/2)(ρ1 − ρ2), and L =0.025. The velocity field is given by a similar smoothedprofile with a perturbation in the x direction

Vx =

U1 − Ume

y−1L if 1 > y > 0

U2 + Ume−y+1

L if 2 > y > 1

U2 + Ume−(3−y)

L if 3 > y > 2

U1 − Ume−(y−3)

L if 4 > y > 3,

(2)

where U1 = 0.5, U2 = −0.5, Um = (1/2)(U1−U2), and aperturbation in the y direction

Vy = δv sin(4πx)

exp(4π(y − 1)) if 1 > y > 0exp(4π(−y + 1)) if 2 > y > 1exp(4π(−(3− y)) if 3 > y > 2exp(4π(−(y − 3)) if 4 > y > 3,

(3)where δv = 0.01. Pressure is set to 2.5, and γ = 5/3.

To extract the growth of the velocity perturbation, weuse a discrete convolution over the particles. We use thistechnique, as opposed to a discrete Fourier transform ongridded values, as the discrete convolution maps more di-rectly to the meshless Phurbas discretization. We definethe magnitude of the unstable y-velocity mode

M = 2

[(∑si∑di

)2

+

(∑ci∑di

)2] 1

2

, (4)

0.0 0.2 0.4 0.6 0.8 1.0x

0.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

y

0.98

1.00

1.02

1.04

1.06

1.08

1.10

1.12

ρ

Figure 11. Kelvin-Helmholtz instability test presented at thehighest resolution used here (λ = 1/256). A density slice is shownat t=2.52.

where all the sums run over N particles, and

si =

Vy sin(4πx) exp(−4π|y − 1|) if y < 2Vy sin(4πx) exp(−4π|(4− y)− 1|) if y > 2,

(5)

ci =

Vy cos(4πx) exp(−4π|y − 1|) if y < 2Vy cos(4πx) exp(−4π|(4− y)− 1|) if y > 2,

(6)

di =

exp(−8π|y − 1|) if y < 2exp(−8π|(4− y)− 1|) if y > 2.

(7)

(8)

The domain is 4 × 1 units with thickness 1/32, 1/64,or 1/128, simulated with uniform target resolutions λ =1/64, 1/128, and 1/256.

In Figure 11 the developed state of the highest resolu-tion run is shown, while Figure 12 shows the growth ofthe unstable y-direction velocity mode and the maximumy-direction kinetic energy. The linear perturbation the-ory predictions from Wang et al. (2010) for the growthrate of the mode amplitude and the maximum y-directionkinetic energy are also plotted as a guide, but due to theperiodic domain, compressibility, and finite perturbationmagnitude we cannot expect the result to exactly followthis curve. However, clear convergence toward the lineartheory can be seen as resolution increases. A more so-phisticated, multiple code verification study, circumvent-ing the limitations of the incompressible theory compari-son for a similar problem, will be presented in a separatepublication.

3.5. Magnetorotational Instability in a Cylinder

The magnetorotational instability (MRI; Balbus &Hawley 1991) is thought to be an important mechanismfor driving turbulence in protoplanetary disks (Balbus &Hawley 1998). We have performed a test similar to onedone by Flock et al. (2010) to examine the growth rate ofMRI during its linear phase. For this test, we remove thebackground Keplerian shear flow from the velocity field,

Page 10: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

10

0.0 0.5 1.0 1.5 2.0 2.5Time

10−3

10−2

10−1

100A

mpl

itude

0.0 0.5 1.0 1.5 2.0 2.5Time

10−6

10−5

10−4

10−3

10−2

10−1

max

(ρV

2 y)

Figure 12. Left: Kelvin-Helmholtz instability mode growth formodels with λ = 1/64 (dashes), 1/128 (tight-spaced dashes), and1/256 units (dotted), compared to the predicted growth rate (solid)from the linear, incompressible theory derived by Wang et al.(2010). Right: Maximum y-direction kinetic energy for the sameruns, again compared to the predicted growth rate from linear,incompressible theory.

and evolve only the perturbations to the initial steadystate velocity. That is, the velocity field we evolve and

fit in this test is V′ = V − Ωrφ where r is the cylin-drical radius from the point (0.5,0.5), Ω = r−1.5 is the

Keplerian angular velocity and φ is the unit vector inthe azimuthal direction. Additionally, to ensure that themagnetic field configuration we study is consistent be-tween resolutions, we solve only for perturbations fromthe initial magnetic field configuration. Solving only forthe perturbations is particularly useful here as the MRIgrows fastest where the orbital timescale is smallest.

The magnetic field configuration used in this test, anannulus of uniform vertical field, is chosen to artificiallycut off the growth of MRI at a finite radius. Ensuringthat the MRI is cleanly shut off and that the annulus isrepresented in a constant manner allows clearer measure-ments of the convergence of the growth rate in the mag-netized annulus. The domain is an annulus with radiusranging from 0.08 to 0.32 and height 0.0375 units. Thevertical boundaries are periodic. The inner and outer ra-dial boundaries are fixed-value, arranged by preventingtime evolution for particles with radius greater than 0.3or less than 0.1. The initial density is 1.0 everywhere.A vertical magnetic field is imposed with radial profileBz(r) = B0bp(r), where B0 = 0.0824 and

bp(r) =

1

2+

1

2tanh

(5− sin

[2π(r − 0.05)

0.2

]), (9)

which gives a magnetized annulus. The sound speed inthe magnetized annulus was set to cs = 0.824, and theinternal energy in the non-magnetized region adjusted sothat the total pressure (thermal plus magnetic) is con-stant. The radial velocity is perturbed with

Vr(z) = 10−5csbp(r) cos(2πz/0.1). (10)

Spatially constant resolutions of λ = 1/240, λ = 1/320,and λ = 1/400 were used corresponding to λ = 1/9λMRI,λ = 1/12λMRI, λ = 1/15λMRI where λMRI = 0.0375is the wavelength of the fastest growing MRI mode atr = 0.17.

We then measure the growth of the most unstablemode at r = 0.17. Figure 13 shows the radial mag-netic field configuration achieved at time 0.94 (or 2.13orbits at r = 0.17) for all three resolutions. To calculatethe mode amplitude M , we use a convolution defined di-rectly on the particles, instead of gridding and Fouriertransforming the data. The motivations are the same aswhen this procedure was used for the Kelvin-Helmholtz

test. In this case,

M =

[(∑si∑di

)2

+

(∑ci∑di

)2] 1

2

, (11)

where all sums run over the N points, and

si = Br,i sin

(2π

0.0375zi

)exp

(− (ri − r0)2

σ2

), (12)

ci = Br,i cos

(2π

0.0375zi

)exp

(− (ri − r0)2

σ2

), (13)

di = exp

(− (ri − r0)2

σ2

). (14)

The chosen width of the convolution σ = 2.7×10−6 min-imizes the radial range that influences the measurement,while still giving sufficiently low sampling noise.

We plot the evolution of the mode amplitude in Fig-ure 14 together with the maximum growth rate ofexp(0.75Ω) predicted by a linear perturbation analysis ofvertical field MRI. The modeled growth rates are reason-ably consistent with the prediction from the linear anal-ysis for the fastest growing mode. Importantly, in thecontext of the findings of Flock et al. (2010), where spu-riously high growth rates were observed, we find growthrates slightly lower than the theoretical maximum value.

4. SUMMARY AND DISCUSSION

4.1. Effective Resolving Power

To determine if Phurbas can be used for practical com-putations, we need to establish some guidelines for itsrelative ability to resolve particular phenomena. Thisshould be done cautiously, as different classes of al-gorithms have different properties in each flow regime.An equivalence or difference between algorithms in oneregime may not hold across different regimes. In anycase, it is expected that an unstructured mesh or un-structured meshless method will have a lower effectiveresolution than a structured mesh method. This is be-cause a given number of resolving elements can representthe largest possible set of wavelengths when they are ar-ranged in a regular manner. Given these caveats, we cancompare the test results that we have presented here toexamples computed with Eulerian, mesh-based schemes.

The first example is the circularly polarized Alfvenwave test. The lowest resolution, three-dimensional,Athena results in a rectangular domain published inStone et al. (2008, Fig. 33) correspond to 20 and 39cells per wavelength, computed with third order spatialreconstruction and HLLD fluxes. The Phurbas results onthis test at λ = 1/8 and λ = 1/16 of a wavelength appearto roughly equal the accuracy of the 20 and 39 cells perwavelength Athena results in the sense that the final am-plitude of the wave in the Phurbas results is closer to theanalytically correct value even though there are fewer res-olution elements used per wavelength. This result shouldbe interpreted cautiously, as the two codes have differentand nonlinear numerical dissipation. Nevertheless, thiscan be interpreted to mean that the Phurbas effectiveresolution λ is roughly equal to two Athena cells as ameasure of resolution. (On average, there should be oneparticle in each volume of radius λ.) In this sense Phur-

Page 11: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

Phurbas MHD Code. II. Tests 11

0.2 0.3 0.4 0.5 0.6 0.7 0.80.0000

0.0375

0.2 0.3 0.4 0.5 0.6 0.7 0.80.0000

0.0375

0.2 0.3 0.4 0.5 0.6 0.7 0.80.0000

0.0375

0.2 0.3 0.4 0.5 0.6 0.7 0.80.0000

0.0375

−0.024 −0.018 −0.012 −0.006 0.000 0.006 0.012 0.018 0.024Br

Figure 13. Linear phase growth of MRI shown via azimuthal field slices at time 0.94 for resolutions (from top to bottom) of λ =1/160, 1/240, 1/320, and 1/400.

0.0 0.5 1.0 1.5 2.0 2.5 3.0Time [Orbits]

14

12

10

8

6

4

2

0

log e

(Mode A

mplit

ude)

Linear Theory Rateλ=1/6λMRI

λ=1/9λMRI

λ=1/12λMRI

λ=1/15λMRI

Figure 14. Linear phase growth of MRI shown for the modeamplitude given by equation (11) at r = 0.17 for the resolutionsλ given in the legend, compared to the growth rate predicted bylinear theory.

bas with a third-order polynomial fit is competitive witha spatially third-order grid code.

A possibly more operationally useful comparison canbe drawn from the results of the linear phase MRI growthtest. Flock et al. (2010) claim that in the code Pluto(Mignone et al. 2007) with piecewise linear reconstruc-tions and an HLLD Riemann solver, 10 cells per wave-length are required to resolve the growth of MRI. Ourtest in section 3.5 shows Phurbas requires ∼ 9 λ perMRI wavelength to resolve the growth. Thus, for thistest we can say that one cell ≈ 1λ. The algorithm usedby Flock et al. (2010) has a stencil size of five cells, whilePhurbas can be said to have a stencil size of 2rf = 4.6λ,so the same rough proportionality holds between the twoalgorithms when expressed in terms of stencil size.

4.2. Advantages and Disadvantages

The main advantage of Phurbas is its Lagrangian na-ture. Eulerian codes suffer from numerical dissipationthat varies with the speed and direction of the flow acrossthe grid. Phurbas’s formulation cleanly avoids this be-

havior. For systems where the bulk velocity varies as amultiple or large fraction of the wave speeds, this meansPhurbas can capture the flow with more uniform fidelityacross the domain. Techniques that add an extra ad-vection step to an Eulerian method (e.g. Masset 2000;Johansen et al. 2009) can only efficiently handle simpleflow geometries. Moreover, in Phurbas, the time stepis only dependent on Galilean-invariant quantities. Forflow with bulk velocities greater than the signal speedsthat determine the Courant time step limit, Phurbas hasa significant advantage in the number of time steps thatmust be computed to reach a given physical time.

The resolution criterion in Phurbas is spatially contin-uous, unlike in adaptive mesh refinement techniques, sothere are no abrupt resolution jumps that can lead toundesirable artifacts. Also, due to the Lagrangian andmeshless nature of the code, refined regions can be arbi-trarily shaped and follow the flow with minimal creationand deletion of resolution elements.

As Phurbas formally computes strong solutions to thegoverning partial differential equations using a method-of-lines type approach, it is relatively simple, comparedto Godunov methods for example, to switch to an alter-nate set of variables or even alternate equations. Thecentral limitation is only that the equations should beamenable to the explicit Hermitian time integration used.However, changing the time integration scheme wouldnot fundamentally alter the method.

A moving unstructured mesh or meshless method mustwin in terms of the Galilean invariance of the numericaldiffusion, adaptivity, and the time step advantages, sincethe quality of the spatial derivatives on an unstructuredset of discretization points is lower than for equivalentfits on a grid of points. For problems where the La-grangian and adaptive nature of Phurbas is of no signif-icant advantage, a grid-based method such as the Pen-cil Code (Brandenburg & Dobler 2002) remains substan-tially more efficient.

4.3. Future Prospects

Page 12: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

12

Several enhancements to Phurbas can be made, whichwe briefly mention here.

• The Phurbas discretization is very flexible in howit can incorporate governing equations other thanideal MHD. Implementing non-ideal MHD is rela-tively simple with forward-time-centered-space vis-cosity and resistivity operators.

• Self-gravity can be implemented using the existingGADGET-2 tree algorithm and particle massesderived from a local Voronoi tessellation.

• Passive tracer particles and interacting dust parti-cles can be added in a straightforward manner, us-ing the spatial fitting and time integration methodsused for gas particles.

• In the moving least squares procedure the choiceof least squares error and Cartesian polynomialfunctions for the fitting procedure is not obviouslythe ideal choice, and alternate fitting proceduresshould be explored. These could include those witha basis that can be used to minimize the variationor oscillation of the fitted function, and fitting themagnetic field using a set of divergence-free basisfunctions (McNally 2011).

• Least-squares minimization itself does not appearto be a unique choice, and less computationallyintensive gradient approximation procedures couldbe used.

• Non-Lagrangian particle trajectories can be added,using similar logic to the steering of Voronoi cellgenerating centers in Springel (2010a). This couldreduce the number of particle additions and dele-tions, and hence diffusivity in shear flows.

• An improved void check algorithm could reducethe number of redundant particle creation requests,minimizing the potentially expensive step of prun-ing of the proposed particle addition list.

• A diffusion with properties similar to a hyperdif-fusion would be of great advantage if applied tothe density and internal energy fields to smoothout the smallest scale structures. The challenge ofthis enhancement is to find an approximation withsufficiently robust conservation properties.

Evidently, there are many possible alterations and exten-sions that can be made to Phurbas that will significantlyalter both the nature of the scheme and the capabilitiesof the code. We believe that Phurbas is not just a newmethod for MHD, but one of the first practical examplesof a new class of schemes for mathematical modeling ofsimilar physical problems.

Simon C.O. Glover wrote the initial version of the rou-tine to couple the Phurba MHD module to GADGET-2, which lies at the core of Phurbas. The tests shownhere are of the version of the code incorporating inter-polating fits as advised by the anonymous referee. As

noted in Paper I, this was a contribution equivalent toco-authorship. We are indebted to Volker Springel formaking the source code of GADGET-2 publicly avail-able (Springel 2005). We also thank the authors ofAthena for making it publicly available (Stone et al.2008). M.-M.M.L. and C.P.M. acknowledge hospital-ity from the Max-Planck-Institut fur Astronomie, andM.-M.M.L additionally acknowledges hospitality of theInstitut fur Theoretische Astrophysik der Uni. Heidel-berg. This work has been supported by National ScienceFoundation CDI grant AST-0835734 and allocation TG-MCA99S024, originally from the Teragrid, and now fromthe Extreme Science and Engineering Discovery Environ-ment (XSEDE), which is supported by National ScienceFoundation grant number OCI-1053575.

REFERENCES

Agertz, O. et al. 2007, MNRAS, 380, 963, arXiv:astro-ph/0610051Balbus, S. A., & Hawley, J. F. 1991, ApJ, 376, 214Balbus, S. A., & Hawley, J. F. 1998, Rev. Mod. Phys., 70, 1Brandenburg, A., & Dobler, W. 2002, Comp. Phys. Comm., 147,

471, arXiv:astro-ph/0111569Brio, M., & Wu, C. C. 1988, J. Comp. Phys., 75, 400Cha, S.-H., Inutsuka, S.-I., & Nayakshin, S. 2010, MNRAS, 403,

1165Dai, W., & Woodward, P. R. 1994, J. Comp. Phys., 111, 354Falle, S. A. E. G. 2002, ApJ, 577, L123, arXiv:astro-ph/0207419Falle, S. A. E. G., & Komissarov, S. S. 2001, J. Plasma Phys., 65,

29Flock, M., Dzyurkevich, N., Klahr, H., & Mignone, A. 2010,

A&A, 516, A26+, 0906.5516Heß, S., & Springel, V. 2010, MNRAS, 406, 2289, 0912.0629Johansen, A., Youdin, A., & Klahr, H. 2009, ApJ, 697, 1269,

0811.3937Junk, V., Walch, S., Heitsch, F., Burkert, A., Wetzstein, M.,

Schartmann, M., & Price, D. 2010, MNRAS, 407, 1933Maron, J., McNally, C. P., & Mac Low, M.-M. 2012,

ApJS AcceptedMasset, F. 2000, A&AS, 141, 165, arXiv:astro-ph/9910390McNally, C. P. 2011, MNRAS, 413, L76, 1102.4852Mignone, A., Bodo, G., Massaglia, S., Matsakos, T., Tesileanu,

O., Zanni, C., & Ferrari, A. 2007, ApJS, 170, 228,arXiv:astro-ph/0701854

Mignone, A., Tzeferacos, P., & Bodo, G. 2010, J. Comp. Phys.,229, 5896, 1001.2832

Price, D. J. 2008, J. Comp. Phys., 227, 10040, 0709.2772Read, J. I., Hayfield, T., & Agertz, O. 2010, MNRAS, 405, 1513,

0906.0774Robertson, B. E., Kravtsov, A. V., Gnedin, N. Y., Abel, T., &

Rudd, D. H. 2010, MNRAS, 401, 2463, 0909.0513Ryu, D., & Jones, T. W. 1995, ApJ, 442, 228,

arXiv:astro-ph/9404074Sod, G. A. 1978, J. Comp. Phys., 27, 1Springel, V. 2005, MNRAS, 364, 1105, arXiv:astro-ph/0505010Springel, V. 2010a, MNRAS, 401, 791, 0901.4107Springel, V. 2010b, ARA&A, 48, 391Springel, V. 2011, ArXiv e-prints, 1109.2218, accepted, To appear

in Tessellations in the Sciences: Virtues, Techniques andApplications of Geometric Tilings, eds. R. van de Weijgaert, G.Vegter, J. Ritzerveld and V. Icke, Springer

Stone, J. M., Gardiner, T. A., Teuben, P., Hawley, J. F., &Simon, J. B. 2008, ApJS, 178, 137, 0804.0402

Stone, J. M., & Norman, M. L. 1992, ApJS, 80, 791Toth, G. 2000, J. Comp. Phys., 161, 605Valcke, S., de Rijcke, S., Rodiger, E., & Dejonghe, H. 2010,

MNRAS, 408, 71, 1006.1767Wadsley, J. W., Veeravalli, G., & Couchman, H. M. P. 2008,

MNRAS, 387, 427Wang, L. F., Ye, W. H., & Li, Y. J. 2010, Phys. Plasmas, 17,

042103

Page 13: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

Phurbas MHD Code. II. Tests 13

APPENDIX

DISPERSION RELATION AND MODIFIED WAVES

The test in §3.1 is a convergence test to the solution of the linearized version of the modified MHD equations thatPhurbas solves. We derive here the dispersion relation and solutions in the cases used in the convergence test. Westart with the MHD mass, momentum, and induction equations, with a bulk viscosity term ρ∇(ζ∇ ·V) added to themomentum equation,

∂tρ+ ρ∇ ·V = 0 (A1)

ρ∂tV +∇P − (∇×B)B + ρ∇(ζ∇ ·V) = 0 (A2)

∂tB +∇× (V ×B) = 0, (A3)

and for adiabatic gas we also use an energy equation

∂t

(P

ργ

)= 0. (A4)

In these equations, ρ is density, V is velocity, P is pressure, B is magnetic field, and γ is the adiabatic index.Linearizing, and taking the viscosity ζ as constant we obtain

∂tρ+ ρ0∇ ·V = 0 (A5)

ρ0∂tV +∇P − (∇×B)×B0 + ρ0ζ∇(∇ ·V) = 0 (A6)

−∂tB +∇× (V ×B) = 0 (A7)

∂t

(P

P0− γρ

ρ0

)= 0 (A8)

where subscripts 0 indicate background values, and unsubscripted variables are fluctuations. Substituting the formexp(i(k · r− ωt)) as a dependence for all variables to search for wave solutions gives

−ωρ+ ρ0k ·V = 0 (A9)

−ωρ0V + kP − (k×B)×B0 + ζiωk(k ·V) = 0 (A10)

ωB + k× (V ×B0) = 0 (A11)

−ω(P

P0− γρ

ρ

)= 0 (A12)

Solving these transformed version of the mass, induction, and equation of state for the perturbed variables gives

ρ = ρ0k ·Vω

(A13)

P = γP0k ·Vω

(A14)

B =(k ·V)B0 − (k ·B0)V

ω(A15)

We can then substitute these into the linearized momentum equation to yield[ω2 − (k ·B0)2

ρ0

]V =[

γP0

ρ0+

B20

ρ0

]k− (k ·B0)

ρ0B0

(k ·V)− (k ·B0)(V ·B0)

ρ0k− ζiωk(k ·V) (A16)

Substituting in the Alfven and sound speeds

VA =

√B2

0

ρ0B0, VS =

√γP0

ρ0(A17)

we obtain [ω2 − (k ·VA)2

]V =

(V 2s + V 2

A)k− (k ·VA)VA

(k ·V)− (k ·VA)(V ·VA)k− ζiωk(k ·V). (A18)

Page 14: ATEX style emulateapj v. 5/2/11 · Preprint typeset using LATEX style emulateapj v. 5/2/11 PHURBAS: AN ADAPTIVE, LAGRANGIAN, MESHLESS, MAGNETOHYDRODYNAMICS CODE. II. IMPLEMENTATION

14

We can now choose a propagation direction of the wave, the direction of the wave vector k. The wave vector k ischosen to lie in the x− z plane, at an angle θ clockwise from the z-axis. This gives

[ω2 − k2V 2A cos2 θ]V =

(V 2s + V 2

A)k− z|k|V 2A cos θ

(k ·V)− k2VA cos θ(V ·VA)− ζiωk(k ·V). (A19)

Upon transforming this into a matrix eigenvalue problem, and solving for the eigenvectors V one obtains expressions forthe eigenvalues, which can be solved for ω. Unfortunately, we have only found analytic solutions for two special cases ofthe propagation direction θ. These cases are used to test the convergence of our scheme. For propagation perpendicularto the background magnetic field B0, θ = π/2 and the first eigenvalue corresponds to a magnetoacoustic wave, with

speed given by Re(ω)/k =√|k2ζ2/4− (V 2

A + V 2s )|, and attenuation given by Im(ω) = ik2ζ/2. For propagation in the

direction of the background magnetic field B0, θ = 0 and the first eigenvalue corresponds to a sound wave, with speedgiven by Re(ω)/k =

√|k2ζ2/4− (V 2

s )|, and attenuation given by Im(ω) = ik2ζ/2. In general, the shear Alfven waveeigenmodes are unaffected by the addition of the bulk viscosity, as they do not involve compressive motions.