lehnertu / TEUFEL

THz Emission from Undulators and Free-Electron Lasers
GNU General Public License v3.0
6 stars 2 forks source link

TEUFEL

THz Emission from Undulators and Free-Electron Lasers

This is a C++ project to support tracking of charged particles in arbitrary external fields and to compute the electromagnetic radiation emitted by these particles using the Liénard-Wiechert formula.

The particles are distributed over several compute nodes which communicate using OpenMPI. In this computing model a Bunch() is an ensemble of particles residing on a single compute node. The Beam() may contain a number of bunches with different properties (like mass and charge of the particles). The Beam() is distributed over all available compute nodes which each track their own particles independently.

Every particle stores its full trajectory data. All field computation is done after the tracking is finished. Every compute node computes the fields of its own particles which are then gatherd onto the root node for file output. In addition to the MPI-parallelization, the field computation is parallelized on the nodes using the OpenMP shared memory model. This requires that the full field storage of a single observer can be held in the node memory.

Functionality

Running TEUFEL

TEUFEL is designed to make use of clusters of multi-core nodes. The particles are distributed over the nodes (each tracking its own sub-set of particles) while the particle coordinates are communicated between the nodes after every tracking step using the message passing interface (OpenMPI).

After the tracking every node computes the observed fields from its own set of particles. This is the most time-consuming step of the computation. It is addidionally parallelized using the shared-memory model Open-MP. This way all CPU's available on one node can cooperate to compute the fields. Only a single copy of the fields (which can be very large) needs to be held in memory. After every node has computed the fields from its own particles the total fields are gethered onto the master node (using MPI) and written to file.

As an example, when running a problem on an 8-core workstation where the fields (and necessary communication buffers) fit into the memory twice, one would start TEUFEL with 2 nodes each using 4 CPU's

mpirun -n 2 --cpus-per-rank 4 --oversubscribe ./build/teufel input.xml

On a cluster one would have to submit a batch job with te according information.

Build and Installation

We are using the cmake build system to allow an easy build on a variety of platforms. Here we describe a typical out-of-source build. When cmake ist installed it usually defines a variable CMAKE_MODULE_PATH which set the directories where cmake tries to find its module definitions. TEUFEL adds (in CMakeLists.txt) it directory teufel/lib to this search path. This way some custom FindXXX.cmake files can be found.

First one should obtain the sources by cloning the repository from Github.

git clone http://github.com/lehnertu/teufel.git
cd teufel

A few libraries are required to build the TEUFEL executable.

Then we create a build directory in the downloaded source directory.

mkdir build
cd build

Then we build the makefile from CMakeLists.txt contained in the root directory.

cmake ..

One can check the libraries and tools found and change the make options. This can be usefull if it is desired to build the documentation by default or to skip the build of the test executables (enabled by default).

ccmake ..

After that

make

creates the executable in the build directory.

Documentation

We aim at fully documenting the code for easy reuse and maintenance. The documentation can be built using doxygen.

make docs

The documentation can then be accessed with a browser starting from doc/html/index.html.

Testcases

A number of test cases is provided which serve both for code benchmarking against known results and as coding examples. All tests are built by default in the build directory. For running all the checks in sequence, right away from the build directory, a script is provided in the main folder:

./run_tests

To check for memory leaks the tool Valgrind is recommended.

valgrind --tool=memcheck tests/teufel.xxx

For some testcases and examples python scripts for visualizing the data are provided in the scrips/ directory. For reading HDF5 files these scripts use the h5py library which can be installed from the "python-h5py" package on most Linux systems.

Known Issues