### BOUT++

BOUT++ is a 3D plasma fluid simulation code which has been developed at York in collaboration with the MFE group at LLNL and the MCS division at ANL. Key features are

- Finite difference in non-orthogonal coordinate systems. Can handle complicated topologies such as the x-point region in tokamaks
- Written in C++ in a modular way. One section of the code (e.g. differencing methods, or output format) can be changed with minimal alterations to the rest of the code
- Can solve an arbitrary number of scalar and vector fluid equations
- Range of time integration schemes available, including fully implicit (BDF, backwards Euler, Crank-Nicholson,...) and explicit schemes (Euler, RK4, Karniadakis, Adams ...), which can be chosen at run-time based on input options
- High-order differencing schemes are implemented, including a 3rd-order WENO scheme for advection and MUSCL schemes. These result in lower numerical dissipation and better handling of shocks. These can also be changed at run-time
- The portion of the code which specifies the equations to be solved is (relatively) small, typically 50-500 lines of code compared to ~30,000 lines for the whole code. This makes the equations being solved very clear and easy to change
- Scales well using to several thousand processors for typical problems. Work ongoing to improve scalability to tens of thousands and beyond

A common problem with large simulation codes is that it can be very difficult to understand what equations they are solving, making peer review of simulation results difficult. BOUT++ tries to make this easier, so that the inputs to a simulation can be verified without having to grok thousands of lines of code. As an example, the important lines in an MHD example are:

```
ddt(rho) = -V_dot_Grad(v, rho) - rho*Div(v);
```

ddt(p) = -V_dot_Grad(v, p) - gamma*p*Div(v);

ddt(v) = -V_dot_Grad(v, v) + ((Curl(B)^B) - Grad(p))/rho;

ddt(B) = Curl(v^B);

Of course obtaining good performance or numerical stability occasionally requires access to the underlying algorithms, and this is still possible. You can start with a simple set of equations and then tweak the code later to optimise it.

#### Getting BOUT++

BOUT++ is open source under the Lesser General Public License (LGPL), and is available on github here. To get a copy, you can download a zip file from the github website, but the recommended way is to use Git to download the latest version and keep up to date. Assuming Git is installed, run the command:

```
$ git clone git://github.com/boutproject/BOUT.git
```

Instructions on installing BOUT++ are on the wiki page, including the basics of using Git for version control. To do anything useful, you will also need to install the following libraries:

- FFTW (version 3) is used for Fast Fourier Transforms (FFTs)
- NetCDF (version 4) for file input/output

- SUNDIALS solvers for implicit time integration. For most simulations, the CVODE solver is used, but if constraints are needed then the IDA Differential Algebraic Equation (DAE) solver can also be used.
- PETSc for high-performance parallel libraries
- PACT for backwards compatibility with BOUT and UEDGE

#### Recent papers

Some recent papers using BOUT++

- B D Dudson, A.Allen, G.Breyiannis, E.Brugger, J.Buchanan, L.Easy, S.Farley, I.Joseph, M. Kim, A.D.McGann, J.T.Omotani, M.V.Umansky, N.R.Walkden, T.Xia, X.Q.Xu BOUT++: Recent and current developments Journal of Plasma Physics 2014.
- J T Omotani, B D Dudson, E Havlickova, M Umansky Non-local parallel transport in BOUT++ Journal of Nuclear Materials 2014.
- N R Walkden, B D Dudson, G Fishpool Characterization of 3D filament dynamics in a MAST SOL flux tube geometry. Plasma Phys. Control. Fusion 55 105005 (2013). Also available as an arXiv preprint.
- J Omotani, B Dudson Non-local approach to kinetic effects on parallel transport in fluid models of the scrape-off layer Submitted to PPCF. arXiv pre-print available here.
- P W Xi, X Q Xu, X G Wang, and T Y Xia Influence of equilibrium shear flow on peeling-ballooning instability and edge localised mode crash. Phys. Plasmas 19, 092503 (2012)
- B Dudson, S Farley, L Curfmann McInnes Improved Nonlinear Solvers in BOUT++. Submitted to Computer Physics Communications. Preprint arXiv plasm-phys/1209.2054, report ANL/MCS-P3025-0812
- T Y Xia, X Q Xu, B D Dudson, J Li Nonlinear Simulations of Peeling-Ballooning Modes with Parallel Velocity PerturbationContrib. Plasma Phys., 52: 353–359 (2012)
- B Friedman, M V Umansky, T A Carter Grid Convergence Study in a Simulation of LAPD Turbulence Contrib. Plasma Phys., 52: 412–416 (2012)
- J R Angus, M V Umansky, and S. I. Krasheninnikov 3D Blob Modelling with BOUT++Contrib. Plasma Phys., 52: 348–352 (2012)
- J R Angus, M V Umansky, and S. I. Krasheninnikov Effect of Drift Waves on Plasma Blob Dynamics Phys. Rev. Lett. 108, 215002 (2012)
- B Friedman, T A Carter, M V Umansky, D Schaffner, B Dudson Energy dynamics in a simulation of LAPD turbulence. Physics of Plasmas 19 (2012) 102307
- P B Snyder, R J Groebner, J W Hughes, T H Osborne, M Beurskens, A W Leonard, H R Wilson and X Q Xu A first-principles predictive model of the pedestal height and width: development, testing and ITER optimization with the EPED model Nucl. Fusion
**51**(2011) 103016 - X Q Xu, B D Dudson "Nonlinear ELM simulations based on a nonideal peeling ballooning model using the BOUT++ code". Nucl. Fusion
**51**(2011) 103040 - B D Dudson, X Q Xu, M V Umansky, P.B.Snyder, H.R. Wilson Simulation of Edge Localised Modes using BOUT++. Invited paper to the 2010 Joint Varenna-Lausanne international workshop. Plasma Phys. Control. Fusion
**53**(2011) 054005 doi: 10.1088/0741-3335/53/5/054005 - X Q Xu, B D Dudson, P.B.Snyder, M V Umansky, H.R. Wilson Nonlinear simulations of peeling-ballooning modes with anomalous electron viscosity and their role in ELM crashes Phys. Rev. Lett. 105 (2010) 175005
- B. D. Dudson, M. V. Umansky, X. Q. Xu, P. B. Snyder, H. R. Wilson: BOUT++: a framework for parallel plasma fluid simulations. Computer Physics Communications 180 (2009), pp. 1467-1480 doi:10.1016/j.cpc.2009.03.008. Also available as an arXiv pre-print