ExCALIBUR-NEPTUNE / nektar-diffusion-ambipolar

Other
0 stars 0 forks source link
Nektar++ diffusion
Software License

Nektar-diffusion proxy-app

Table of contents

Description

Nektar-diffusion proxy-app: An anisotropic thermal conduction proxy-app for the magnetized plasma written in Nektar++ framework [1]. The derivation of the anisotropic thermal conduction in the magnetized plasma and its variational formulation are documented in the docs folder. For the detailed formulations and tutorials of Nektar++, please refer to the documentation on the Nektar++ website. Some examples are provided in the example folder.

The variational formulation of the two-dimensional anisotropic thermal conduction in the magnetized plasma can be written as

Variational formulation

where $\psi$ and $T$ respectively are the test function and the temperature. $\mathbf{\kappa}_c$ is the anisotropic thermal conductivity tensor and $Q$ represents the heat source in field. $\mathbf{n}$ is the outward normal vector along the boundaries of the domain.

Installation and dependencies

The Nektar-diffusion proxy-app should be compiled against Nektar++ v5.5.0. This can be done by either using pre-compiled binary packages or compiling it from source. Alternatively a Dockerfile image can be generated which includes Nektar++, the nektar-diffusion proxy-app and the included examples.

Docker

To use the docker image, clone the nektar-diffusion repository and, from the top directory, build the image using

docker build -t nektar-diffusion .

and then run an interactive shell

docker run -it nektar-diffusion /bin/bash

Using Nektar++ binary packages

Install CMake using your normal package management tools.

Install the v5.5.0 libnektar++-dev or libnektar++-devel package (as appropriate), following instructions at https://www.nektar.info.

Then compile the nektar-diffusion solver using

mkdir build && cd build
cmake ..
make install

Using Nektar++ source code

Download the source code for Nektar++ v5.5.0

git clone https://gitlab.nektar.info/nektar/nektar
cd nektar
git checkout v5.5.0

Compile it following the instructions at https://www.nektar.info. To save time, set NEKTAR_BUILD_SOLVERS=OFF and NEKTAR_BUILD_DEMOS=OFF. Many of the dependencies are available as pre-built packages in most Linux distributions (e.g. Boost, TinyXML, Scotch, BLAS, LAPACK). It is recommended to turn on the NEKTAR_USE_MPI option to enable parallel execution. Run make install to collate the binaries and library files under the dist sub-directory and (optionally) set CMAKE_INSTALL_PREFIX to your preferred install location. To check Nektar++ is built correctly run ctest.

Then compile the nektar-diffusion solver using

mkdir build && cd build
cmake -DNektar++_DIR=/path/to/build/dist/lib/nektar++/cmake -DNEKTAR_BUILD_DOCS=ON ..
make install

where /path/to/build/dist/lib/nektar++/cmake is the path containing the Nektar++Config.cmake file.

Debugging compilation, installation and testing:

If the compilation fails, check the possible broken links during the configuration by the command ccmake .. and toggle the curses interface to the advanced mode by press the t key. A list of detailed links to the libraries will appear for investigation.

If an error was observed during installation, take note the description of this error and identify which program causes it. For example, if it is related to mpi, double check the possible broken links of mpi during configuration or verify the working condition of the pre-installed mpi on the cluster. In addition, the installed programs should be compatible with the version of Nektar++. The full list of the compatible versions of program can be found in the user-guide.

If some testing cases fail during ctest, check the log files in the $HOME/nektar-v5.5.0/build/Testing/Temporary/ folder and identify the origin of the error.

Execution

If Nektar++ has been compiled from source, it is convenient to add the location of the binary files to the system PATH:

export PATH="$PATH:/path/to/nektar++/build/dist/bin"

In the provided examples, the mesh is prepared using gmsh. However, the Nektar++ meshes are also provided.

To modify the mesh, Gmsh is required. It can be installed by using binary packages provided the Linux distribution or compiling from source by running

cd $HOME
wget https://gmsh.info/bin/Linux/gmsh-2.16.0-Linux64.tgz
tar -xvzf gmsh-2.16.0-Linux64.tgz
cd gmsh-2.16.0-Linux
echo 'PATH=$HOME/gmsh-2.16.0-Linux/bin:$PATH' >> $HOME/.bashrc
source $HOME/.bashrc

To run the examples provided in the example folder, access the folder containing a particular example and execute the following command:

  1. convert mesh
gmsh -2 -order 1 domain.geo
NekMesh domain.msh domain.xml
  1. execute simulation
mpirun -np 4 DiffusionSolver domain.xml conditions.xml
  1. post-processing
FieldConvert domain.xml domain.fld domain.vtu

The output file format is in .vtu (VTK file) which can be visualised in Paraview.

Parameters

The key parameters to set up the simulation are listed below:

| Parameter | Description | | :--- | :--- | | theta | angle of magnetic field | | B | magnitude of magnetic field | | k_par | thermal conductivity parallel to magnetic field | | k_perp | thermal conductivity perpendicular to magnetic field | | epsilon | diffusion coefficient | | A = m_i/m_p | ratio between masses of ions and proton | | Z | ion charge state | | lambda | Coulomb logarithm | | TimeStep | time step size | | NumSteps | total number of time steps | | IO_CheckSteps | output frequency |

Typically the angle and magnitude of the magnetic field should be specified a prior. The angle is measured with respect to the positive $x$ axis in the clock-wise direction. Particularly, the magnitude of the magnetic field impose influences on the thermal diffusivity perpendicular to the magnetic field line. In an unsteady simulation, The values of TimeStep and NumSteps respectively are the time step size in numerical integration and the total number of the time steps. The value of IO_CheckSteps is used to control the ouptut frequency with respect to the time steps.

Examples

Two examples are provided:

Unsteady Ring

This example has initial conditions of a heat sink with a Gaussian shape on one side of an annular domain; an equal heat sink is on the opposite side of the annulus. A magnetic field circulates around the void. The thermal conductivity along the magnetic field lines is much greater than the conductivity perpendicular to the field lines. The function describing the sources and sinks is (in Cartesian coordinates):

$$\dot{T} = k_{\parallel}\left(e^{-\frac{(x-x_c-x_s)^2}{{l_s}^2}-\frac{(y-y_c-y_s)^2}{{l_s}^2}}

where $(x_c,y_c)$ are the coordinates of the centre and $(x_s,y_s)$ are the coordinates of the centre of the Gaussian relative to the centre. Meanwhile the magnetic field is given by:

$$ B_x =\frac{y-y_c}{\sqrt{(x-x_c)^2+(y-y_c)^2}} $$

$$ B_y =-\frac{x-x_c}{\sqrt{(x-x_c)^2+(y-y_c)^2}} $$

$$ B_z =0 $$

The domain is subject to Dirichlet boundary conditions $T=0$ outside and inside the annular region.

Shown below is the system at an early stage System at an early state

Shown below is the system at a later stage System at an evolved state

MAST-U

The second example is a poloidal section through the MAST-U device, using the magnetic field given in the file B.pts. The heat diffusion is again isotropic, favouring the magnetic field direction.

For the boundary conditions, the core region is held at a high temperature TCore, and the outer region at a low temperature (300 and 0 respectively for these images). Currently the domain does not have axial symmetry, so does not completely represent the true scenario.

Shown below is the system at an early stage System at an early state

Shown below is the system at a later stage System at an evolved state

References

[1] Cantwell et al, Nektar++: An open-source spectral/hp element framework., JCP, 2015 [DOI]

License

See the LICENSE file for license rights and limitations (MIT).