bout++ overview - lawrence livermore national laboratory › content › assets › docs ›...

42
BOUT++ overview Ben Dudson and the BOUT++ team BOUT++ workshop, LLNL 14 th August 2018

Upload: others

Post on 24-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

BOUT++ overviewBen Dudson and the BOUT++ team

BOUT++ workshop, LLNL14th August 2018

Page 2: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

2 / 42

AcknowledgementsMany people have contributed to BOUT++

30 contributors to the github version17 since version 3.0 (Oct 2016), with 3813 commits (~ 5.8 per day)

Particular thanks to:

Peter Hill, David Dickinson, Joseph Parker, David Schworer, John Omotani, Michael Loiten, Jens Madsen, Jarrod Leddy, Nick Walkden, Adam Dempsey, Haruki Seto, Brendan Shanahan, Erik Grinaker, Xiang Liu, Maxim Umansky, Matt Thomas

Page 3: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

3 / 42

Outline

● Plasma modelling, drift-reduced models

● BOUT++ code structure

● Recent changes (last ~ 2-3 years)

– Electromagnetic field solvers, global modes

– Complex magnetic geometries (FCI scheme)

● Getting started

● Contributing to BOUT++

Page 4: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

4 / 42

Tokamak plasmasTypical parameters

● Pressure ~ 1 atmosphere

● Temperature ~ 100 million oC

● Density ~ 1020 m-3 (3.3 x 10 -7 kg/m3 . Air ~ 1.2 kg/m3)

● Sound speed ~ 105 – 106 m/s

● Mean free paths ~ 1 – 100 m

● Ion gyrofrequency ~ GHz

● Global evolution timescale ~ 10s of ms < mm

meters

Page 5: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

5 / 42

Example modelA simple model can be derived from continuity of particles and charge:

Particles drift due to electric fields, magnetic inhomogeneities and time-varying fields

Page 6: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

6 / 42

Example modelSubstituting this velocity into density and current equations gives:

Assuming incompressible, neglecting ion parallel flow, and making thin layer (Boussinesq) approximation gives:

Page 7: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

7 / 42

Example model

Incompressible fluid e.g.Arakawa '65 and extensions

Gradients along magnetic field (compressible fluid)

Need to invert Laplacian to evaluate electric potential.→ Spectral methods, multigrid schemes

Peterson, Hammett: http://dx.doi.org/10.1137/120888053

Page 8: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

8 / 42

BOUT++● An open-source library for solving PDEs in curvilinear geometry

● Specialised operators for plasma applications

● Finite difference / volume code in 3D mapped multi-block geometry

● Solves nonlinearly coupled hyperbolic, parabolic and elliptic equations

● MPI parallelised, scales to ~ 4,000 cores (depending on problem)

● Turbulence ~106-108 unknowns, ~105 core-hours

Page 9: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

9 / 42

BOUT++: example model

ddt(n) = -vE_Grad(n,phi+phi0) + Div_par(Jpar) + 2*DDZ(n)*(rho_s/R_c);

ddt(omega) = -bracket(phi,omega) + Div_par(Jpar) + 2*DDZ(n)*(rho_s/R_c);

phi = phiSolver->solve(omega);

https://github.com/boutproject/BOUT-dev/tree/master/examples/blob2d

Page 10: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

10 / 42

Outline

● Plasma modelling, drift-reduced models

● BOUT++ code structure

● Recent changes (last ~ 2-3 years)

– Electromagnetic field solvers, global modes

– Complex magnetic geometries (FCI scheme)

● Getting started

● Contributing to BOUT++

Page 11: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

11 / 42

BOUT++: Method of LinesPhysical model

ODE time integrator

Evolving fields e.g. density

Time derivatives of each field

Elliptic solvers

Spatial derivatives

Arithmeticoperators

Communication

Page 12: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

12 / 42

BOUT++ mesh3D mesh, locally logically Cartesian

Quantities usually cell centre; some staggered cell face values

Represented as Field3D objects

Field3D n, T;…Field3D p = n * T;

Page 13: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

13 / 42

BOUT++ mesh3D mesh, locally logically Cartesian

Guard/ghost cells used for boundaries and communication

Communication through guard cells

Communication handled by Mesh:

mesh->communicate(n, T);

Page 14: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

14 / 42

BOUT++ mesh3D mesh, locally logically Cartesian

More complicated topologies handled using branch cuts

Page 15: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

15 / 42

BOUT++ mesh3D mesh, locally logically Cartesian

More complicated topologies handled using branch cuts

Tokamak edge simulations usually have at least one “X-point” and a hole in the domain.

Page 16: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

16 / 42

Coordinates

Toroidal angle

Polo

idal an

gle

z

y

Twist-shift boundary (matching) condition

Usually curved, usually non-orthogonalaligned to the helical magnetic field.

In the core of the plasma the domain is a twisted ribbon

Page 17: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

17 / 42

CoordinatesUsually curved, usually non-orthogonalaligned to the helical magnetic field.

In the core of the plasma the domain is a twisted ribbon

Pitch of the magnetic field varies

Leads to shearing of coordinate system

Often necessary to re-map onto local coordinates to reduce shearing

Shifts in toroidal angle → FFTsToroidal angle

Polo

idal an

gle

z

y

Twist-shift boundary (matching) condition

Page 18: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

18 / 42

Modular structure

Factory

Input options

Many parts of BOUT++ have multiple implementations. Changed with an input option, with no/minimal user code changes.

● Time integration● File input/output format● Laplacian solvers● Mesh (more difficult, experimental)

Implementation

Implementation

Implementation

Implementation

Page 19: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

19 / 42

Outline

● Plasma modelling, drift-reduced models

● BOUT++ code structure

● Recent changes (last ~ 2-3 years)

– Electromagnetic field solvers, global modes

– Complex magnetic geometries (FCI scheme)

● Getting started

● Contributing to BOUT++

Page 20: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

20 / 42

Solving potentialsNeed to invert a Laplacian to obtain potential from vorticity:

Parallel componentnot zero, but neglected under flute assumption

Field-aligned coordinates uses toroidal planes as drift planes:

Coordinates

Page 21: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

21 / 42

Solving n=0 modes● Solving on toroidal planes results

in large savings: Each X-Z slice can be solved separately

● For low n modes this simplification breaks down. Results in unphysical electric fields close to the X-point

● A 2D solver has been developed for the n=0 mode using PETSc

B D Dudson, J Leddy, “Hermes”, PPCF 59(5), 054010 (2017)

Page 22: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

22 / 42

Solving n=0 modes

Transient oscillation

Drifts, currentsEvolve n=0 electric field

Transients and steady state

Steady state

B D Dudson, J Leddy, “Hermes”, PPCF 59(5), 054010 (2017)

Page 23: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

23 / 42

Complicated magnetic fieldsX-point Snowflake

W.A.J. Vijvers et al 2014 Nucl. Fusion 54 023009Stellarator

Y Suzuki and J Geiger 2016 PPCF 58 064004

Page 24: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

24 / 42

Flux coordinate independentField aligned grids are required in order to:→ Significantly reduce resolution in one dimension→ Accurately capture anisotropic transport

Field-aligned coordinates have singularities → Reduces convergence rate→ Can lead to numerical instability→ Difficult to resolve features close to the X-point

The FCI approach is to use:● Well-behaved local coordinates,● field-line following and interpolation to calculate

parallel derivatives

[1] F Hariri and M Ottaviani CPC 184 2419 (2013) [2] B Shanahan, P Hill and B Dudson. Journal of Physics; Conference Series 775, 012012 (2016)[3] A.Stegmeir et al. CPC 198, 139-153 (2016)[4] P Hill, B Shanahan and B Dudson CPC 213, 9-18 (2017)

Page 25: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

25 / 42

Tokamak simulationsy

x

z

MAST geometry (shot 14220)R = 0.2 → 2m ; Z = -1.5 → +1.5m

Simple sheath boundary conditions at walls: v

|| = cs

Electromagnetic field evolved (Alfven waves), but B perturbation not included (for now)

Page 26: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

26 / 42

Tokamak filaments (n=5)

x 1019 m-3

Seeded location

x 1019 m-3

Plasma density Plasma density (log)

Page 27: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

27 / 42

Tokamak filaments

Start with an isolated plasma “ball”(no background)

Evolve only parallel diffusion (105 m/s)for ~10µs → Filament

Turn on drifts, electric fields

(Under-resolved proof-of-principle)

50eV 100eV 200eV

Page 28: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

28 / 42

Stellarator simulations

B Shanahan, B Dudson, P Hill, “BSTING”, Submitted to PPCF (2018)

New grid generator for (nearly) arbitrary shapes

Initial blob studies in “straight stellarators”

Simulations of Wendelstein 7-X started

Page 29: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

29 / 42

Other recent changesSome of the many fixes and new features

1. Ability to handle complex 3D magnetic field structures2. Better electromagnetic field solvers3. Running BOUT++ from Python4. Faster, clearer loops, C++11 features**5. Better differential operators, flux-conserving schemes6. More usable, easier to install, debug, optimise, extend

** See performance talk (tomorrow)

Page 30: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

30 / 42

Outline

● Plasma modelling, drift-reduced models

● BOUT++ code structure

● Recent changes (last ~ 2-3 years)

– Electromagnetic field solvers, global modes

– Complex magnetic geometries (FCI scheme)

● Getting started

● Contributing to BOUT++

Page 31: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

31 / 42

Getting startedhttp://boutproject.github.io/

Page 32: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

32 / 42

Getting startedhttp://bout-dev.readthedocs.io

Page 33: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

33 / 42

Getting startedhttps://github.com/boutproject/BOUT-dev

Page 34: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

34 / 42

Install docker

● Provides a reproducible environment (like a virtual machine or BSD jail)

Windows:https://docs.docker.com/docker-for-windows/install/

Mac:https://docs.docker.com/docker-for-mac/install/

Ubuntu linuxhttps://docs.docker.com/install/linux/docker-ce/ubuntu/

Others:https://docs.docker.com/v17.12/install/

Jarrod Leddy (Tech-X)

Page 35: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

35 / 42

BOUT++ docker image● Provides a reproducible environment (like a

virtual machine or BSD jail)

● Preinstalled with PETSc, SLEPC, SUNDIALS, BOUT++, editors and python analysis tools

$ sudo docker pull boutproject/boutproject/bout-next:9f4c663-petsc

$ sudo docker run --rm -it boutproject/bout-next:9f4c663-petsc

Jarrod Leddy (Tech-X)

https://hub.docker.com/r/boutproject/bout-next/

Page 36: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

36 / 42

Outline

● Plasma modelling, drift-reduced models

● BOUT++ code structure

● Recent changes (last ~ 2-3 years)

– Electromagnetic field solvers, global modes

– Complex magnetic geometries (FCI scheme)

● Getting started

● Contributing to BOUT++

Page 37: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

37 / 42

Development process

Code hosted on Github

Page 38: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

38 / 42

Development process

A system of branches with master, next and features

Page 39: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

39 / 42

Development process

Automated testing using Travis (unit, integrated and MMS tests)

Page 40: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

40 / 42

Development process

Merges into next must pass tests and review

Page 41: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

41 / 42

Development process

Documentation automatically pulled from Github to ReadtheDocs

Page 42: BOUT++ overview - Lawrence Livermore National Laboratory › content › assets › docs › workshops › 2018 › 201… · Parallel component not zero, but neglected under flute

42 / 42

Summary

● Fusion plasma physics has many interesting challenges

● BOUT++ has developed as a flexible tool to address a wide range of different problems.

● A good community of users and developers are pushing the code in new directions and adding capabilities

● Development is increasingly professional, with increasing emphasis on maintainability, reproducibility and correctness.

We welcome new contributors and collaborators!