The Spherical MHD Code MagIC, Fundamentals

Transcription

The Spherical MHD Code MagIC, Fundamentals
The Spherical MHD Code
MagIC, Fundamentals
Johannes Wicht, Thomas Gasting, Ankit Barik
MPS Katlenburg-Lindau
The Spherical MHD Code MagIC
MPS 2015
MagIC in Words
MagIC solves for thermodynamic evolution,
fluid flow and magnet field generation
Domain = spherical shell
Region below and above domain treated as
boundary conditions or parametrized
Frame of reference rotating with system rotation W
MagIC uses a dimensionless formulation
Poloidal/toroidal decomposition in employed
MagIC is a pseudo spectral code
MagIC uses a mixed impicite, explicite time stepping
The Spherical MHD Code MagIC
MPS 2015
MagIC github
The Spherical MHD Code MagIC
MPS 2015
MagIC homepage
The Spherical MHD Code MagIC
MPS 2015
Spectral and Grid Representation
The Spherical MHD Code MagIC
MPS 2015
input
precomputation
radial derivatives dx0,
operators, constants, ...
fields on grid
parameters,
initial condition xo=x(t0)
precomputation
grid output?
work
yes
grid output
G-files,mov-files, ...
no
nonlinear terms
fields on grid
calculate horizonal derivatives
transform from spectral to grid
non-linear terms
calculated on grid
needed for explicit time step
transform to spectral space
calculate horizontal derivatives
calculate horizonal derivatives
transform from spectral to grid
grid output?
calculated on grid
needed for explicit time step
transform to spectral space
calculate horizontal derivatives
time step ti+1=ti+dt
update xi=x(ti+1)
calculate radial derivative dxi+1
spectral output?
yes
spectral output
spectra, total energies, ...
no
no
new step?
update
spectral output
spectra, total energies, ...
work
yes
no
update
work
update xi=x(ti+1)
calculate radial derivative dxi+1
yes
grid output
G-files,mov-files, ...
non-linear terms
time step ti+1=ti+dt
spectral output?
yes
no
input
nonlinear terms
rampup
MagIC Start
radial derivatives dx0,
operators, constants, ...
work
ram
MagIC Structure
parameters,
initial condition xo=x(t0)
yes
MagIC Stop
new step?
no
finale
final output
time averages quantities,
rst-file, ....
The Spherical MHD Code MagIC
e
final output
time averages quantities,
MPS 2015
Numerical Grid
Non-linear terms calculated on local grid
Gauss-Legendre grid points in latitude
evenly spaced grid points in logitude for FFT
special grid points in radius for FFT
The Spherical MHD Code MagIC
MPS 2015
Horizontal Representation
Spherical surface harmonics in longitude and latitude:
Grid representation:
With degree and order up to
Spectral representation:
The Spherical MHD Code MagIC
MPS 2015
Horizontal Transforms
1) FFT for f m and m f.
with
azimuthal grid points
2) Gauss-Legendre integration for q
l.
with
azimuthal grid points
Clever vector multiplication l q.
Recently both azimuthal transforms changed to SHTns.
3) Full dealiasing with
The Spherical MHD Code MagIC
MPS 2015
Horizontal Derivatives, two Examples
1) Horizontal Laplacian:
2) Latitudinal derivative:
with
so that
The Spherical MHD Code MagIC
MPS 2015
Radial Representation
1) Chebychev polynomials up to degree
with
2) Grid points are the Nr extrema of
:
so that
3) Thus fast cosine transforms can be
4) Dealiasing for Nr>N.
The Spherical MHD Code MagIC
MPS 2015
Spectral Poloidal Dynamo Equation
1) Take radial component of the dynamo equation
2) Plug in horizontal spectral representation of . Multiply with
spherical hamonic, integrate over spherical surface and
use orthogonal relations:
radial diffusion
nonlinear dynamo term
The Spherical MHD Code MagIC
MPS 2015
Solving the Nonlinear Term
1) Calculate horizontal components of EMF
on grid:
so that
2) Transform these to spectral space:
3) Calculate curl in spectral space using recurrence relations:
How does that look like in the code?
The Spherical MHD Code MagIC
MPS 2015
Calculating Nonlinear terms
0) Master: rIterThetaBlocking_seq.f90
1) transform_to_grid_space in
rIterThetaBlocking.f90
2) Legendre transform:
legTFG in legendre_spec_to_grid.f90
3) FFT (internal or MKL) called in rIterThetaBlocking.f90
The Spherical MHD Code MagIC
MPS 2015
ramp
precomputation
radial derivatives dx0,
operators, constants, ...
4) Calculate nonlinear terms on grid:
get_nl.f90
calculate horizonal derivatives
transform from spectral to grid
grid output?
yes
grid outp
G-files,mov-file
no
work
fields on grid
nonlinear terms
Calculating Nonlinear terms
input
parameters,
initial condition xo=x(t0)
non-linear terms
calculated on grid
needed for explicit time step
transform to spectral space
calculate horizontal derivatives
update xi=x(ti+1)
calculate radial derivative dxi+1
spectral output?
yes
spectral ou
spectra, total ene
no
update
work
time step ti+1=ti+dt
new step?
no
yes
The Spherical MHD Code MagIC
finale
final output
time averages quantities,
rst-file, ....
MagIC Stop
MPS 2015
radial derivatives dx0,
operators, constants, ...
Back Transform to Spectral Space
grid output?
yes
grid outp
G-files,mov-fi
no
work
5) transfrom_to_lm_space in
rIterThetaBlocking.f90
6) Gauss-Legendre back transform:
legTFG in legendre_spec_to_grid.f90
nonlinear terms
fields on grid
calculate horizonal derivatives
transform from spectral to grid
non-linear terms
calculated on grid
needed for explicit time step
transform to spectral space
calculate horizontal derivatives
update xi=x(ti+1)
calculate radial derivative dxi+1
spectral output?
yes
spectral ou
spectra, total en
no
update
work
time step ti+1=ti+dt
new step?
no
yes
finale
final output
7) FFT back transform (internal or MKL) called in
rIterThetaBlocking.f90
The Spherical MHD Code MagIC
time averages quantities,
rst-file, ....
MagIC Stop
MPS 2015
nonlinear terms
fields on grid
calculate horizonal derivatives
transform from spectral to grid
grid output?
yes
grid outp
G-files,mov-file
no
8) Calculate extra derivatives in
get_td.F90 called by
rIterThetaBlocking.f90
work
Finish off Induction Term in Spetral Space
non-linear terms
calculated on grid
needed for explicit time step
transform to spectral space
calculate horizontal derivatives
update xi=x(ti+1)
calculate radial derivative dxi+1
spectral output?
yes
spectral ou
spectra, total ene
no
update
work
time step ti+1=ti+dt
new step?
no
yes
finale
final output
time averages quantities,
rst-file, ....
MagIC Stop
9) Output is called dbdt(k,lm)where k numbers the
radial grid points and lm the spherical harmonic modes.
The Spherical MHD Code MagIC
MPS 2015
Everything in Spherical Harmonic Space!
Equations for each radial grid point and spherical harmonic mode!
No spatial derivatives left!
nonlinear dynamo term
How to deal with the time integration, i.e. discretization in time?
The Spherical MHD Code MagIC
MPS 2015
rampu
MagIC Structure
input
parameters,
initial condition xo=x(t0)
The most time consuming
part of the code!
precomputation
radial derivatives dx0,
operators, constants, ...
calculate horizonal derivatives
transform from spectral to grid
grid output?
yes
grid output
G-files,mov-files, ...
no
nonlinear terms
work
fields on grid
non-linear terms
calculated on grid
needed for explicit time step
transform to spectral space
calculate horizontal derivatives
pdate
ork
time step ti+1=ti+dt
The Spherical MHD Code MagIC
update xi=x(ti+1)
calculate radial derivative dxi+1
spectral output?
yes
spectral output
spectra, total energies, ...
MPS 2015
Time Stepping Scheme
Generic evolutions equation with
terms
to be treated implicitely and
terms
to be treated explicitely.
Implicite Crank-Nicolson type time step:
Explicite Adams-Bashforth type time step:
Mixed time step:
The Spherical MHD Code MagIC
MPS 2015
Poloidal Magnetic Potential Time Stepping
with
How does that look like in the code?
The Spherical MHD Code MagIC
MPS 2015
MagIC Structure
yes
grid output
G-files,mov-files, ...
no
nonlinear
wo
grid output?
non-linear terms
calculated
onthe
grid code!
The most important
part
of
needed for explicit time step
transform to spectral space
calculate horizontal derivatives
update xi=x(ti+1)
calculate radial derivative dxi+1
spectral output?
yes
spectral output
spectra, total energies, ...
no
update
work
time step ti+1=ti+dt
new step?
no
yes
finale
final output
The Spherical MHD Code MagIC
time averages quantities,
rst-file, ....
MagIC Stop
MPS 2015
Poloidal Magnetic Potential Time Stepping
We already know how the nonlinear terms is calculated
The time stepping matrix is
Information from previous time steps:
Also used are the following expressions
The Spherical MHD Code MagIC
MPS 2015
Update Routine
Putting it all together:
The time stepping matrix is stored in an LU-decomposed form.
All done in module updateB.f90:
1) Defining the rhs:
The Spherical MHD Code MagIC
MPS 2015
Update Routine
2) Solving the linear equation system:
3) Result is in Cheb-space!
4) Calculate and store radial derivatives in Cheb-space:
5) Calculate and store
The Spherical MHD Code MagIC
for next time step:
MPS 2015
Mode Methods
Adaptive time step according to modified
Courant-Friedrich-Levy criterium.
Coriolis force treated explicitely.
Transform on cylindrical grid for output possible.
The Spherical MHD Code MagIC
MPS 2015