- Defined in File PlaneWaveTurbulence.h
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:
USE_SIMDoption should be explicitly enabled in CMake. Currently, this sets GCC flags that tell the compiler to allow SIMD instructions.
- One also should enable the
FAST_WAVESoption to tell the compiler that you specifically want it to include the SIMD version of PlaneWaveTurbulence.
- 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.
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.
getField(const Vector3d &pos) const
Evaluates the field at the given position.
Theoretical runtime is O(Nm), where Nm is the number of wavemodes.
const TurbulenceSpectrum &