Class PlaneWaveTurbulence

Inheritance Relationships

Base Type

Class Documentation

class PlaneWaveTurbulence : public TurbulentField

Interpolation-free turbulent magnetic field based on the GJ99 and TD13 papers.


This class provides a turbulent magnetic field that is generated as described by (Giacalone and Jokipii, 1999) and (Tautz and Dosch, 2013). Instead of using an inverse Fourier transform to generate the field on a grid which then needs to be interpolated to obtain in-between values this method only generates the wave modes making up the turbulent magnetic field ahead of time. At run time, when the field’s value at a particular position is required, these plane waves are then evaluated analytically at that position. This guarantees that the resulting field is completely free of divergence, reproduces the mean field strength accurately, and does not suffer from other interpolation-induced problems. The disadvantage is that the number of wave modes is drastically smaller when compared with initTurbulence, which might have physical ramifications on the particles propagating through the field. Furthermore, depending on the exact setting, the implementation is somewhat slower (see Schlegel et al. for details).

Using the SIMD optimization

In order to mitigate some of the performance impact that is inherent in this method of field generation, an optimized version utilizing data-level parallelism through SIMD instructions is provided. More specifically, this implementation uses the AVX extension to the x86 instruction set. In order to use this optimized version, three conditions need to be met:

  1. The USE_SIMD option should be explicitly enabled in CMake. Currently, this sets GCC flags that tell the compiler to allow SIMD instructions.
  2. One also should enable the FAST_WAVES option to tell the compiler that you specifically want it to include the SIMD version of PlaneWaveTurbulence.
  3. Finally, the CPU that will actually run the code needs to support the required extensions: AVX and everything below. These extensions are relatively common, but there may still be processors in use that do not support them.

Public Functions

PlaneWaveTurbulence(const TurbulenceSpectrum &spectrum, int Nm = 64, int seed = 0)

Create a new instance of PlaneWaveTurbulence with the specified parameters. This generates all of the wavemodes according to the given parameters.

  • Nm: number of wavemodes that will be used when computing the field. A higher value will give a more accurate representation of the turbulence, but increase the runtime for getField.
  • seed: can be used to seed the random number generator used to generate the field. This works just like in initTurbulence: a seed of 0 will lead to a randomly initialized RNG.

Vector3d getField(const Vector3d &pos) const

Evaluates the field at the given position.

Theoretical runtime is O(Nm), where Nm is the number of wavemodes.

double getBrms() const
virtual double getCorrelationLength() const
virtual Vector3d getField(const Vector3d &position, double z) const
size_t addReference() const
size_t removeReference() const
int removeReferenceNoDelete() const
size_t getReferenceCount() const

Protected Attributes

const TurbulenceSpectrum &spectrum
size_t _referenceCount