CRPropa is a public astrophysical simulation framework for propagating extraterrestrial ultra-high energy particles. https://crpropa.github.io/CRPropa3/
This PR adds a default value for the volume clipping switch to the GridProperties module.
Context:
Creating a grid (e.g. Grid3f) is possible in different ways. Either grid properties can be defined as separate arguments or a GridProperties instance is used as a single argument for the Grid constructor.
However, the handling to define the clipVolume value was different depending on the chosen constructor. This behavior is unified by this PR and defaults now to clipVolume=false for all Grid constructors.
Issue:
Using the Grid constructor with the GridProperties argument led to a random initialization of the clipVolume variable.
Problem:
This might have led to an unnoticed effect, e.g. in turbulent magnetic field creation, where the field strength outside the original grid volume would have been set to zero. To see this problem, you can run the following code:
from crpropa import *randomSeed = 42Brms=8*nGlMin = 60*kpclMax=800*kpcsIndex=5./3.turbSpectrum = SimpleTurbulenceSpectrum(Brms, lMin, lMax, sIndex)gridprops = GridProperties(Vector3d(0), 256, 30*kpc)BField = SimpleGridTurbulence(turbSpectrum, gridprops, randomSeed)R = Vector3d(10, 1, 5)*MpcBField.getField(R)
This PR adds a default value for the volume clipping switch to the
GridProperties
module.Context: Creating a grid (e.g.
Grid3f
) is possible in different ways. Either grid properties can be defined as separate arguments or a GridProperties instance is used as a single argument for the Grid constructor. However, the handling to define the clipVolume value was different depending on the chosen constructor. This behavior is unified by this PR and defaults now toclipVolume=false
for all Grid constructors.Issue: Using the Grid constructor with the GridProperties argument led to a random initialization of the clipVolume variable.
Problem: This might have led to an unnoticed effect, e.g. in turbulent magnetic field creation, where the field strength outside the original grid volume would have been set to zero. To see this problem, you can run the following code:
from crpropa import *
randomSeed = 42
Brms=8*nG
lMin = 60*kpc
lMax=800*kpc
sIndex=5./3.
turbSpectrum = SimpleTurbulenceSpectrum(Brms, lMin, lMax, sIndex)
gridprops = GridProperties(Vector3d(0), 256, 30*kpc)
BField = SimpleGridTurbulence(turbSpectrum, gridprops, randomSeed)
R = Vector3d(10, 1, 5)*Mpc
BField.getField(R)