Class JF12FieldSolenoidal

Inheritance Relationships

Base Type

Class Documentation

class JF12FieldSolenoidal : public JF12Field

JF12FieldSolenoidal galactic magnetic field model.

Implements a modified JF2012 Galactic magnetic field model. This implementation inherits most methods from the initial JF12Field, just the regular disk field and the poloidal halo “X field” are altered.

A solenoidal transition for the disk field (which redirects the magnetic flux of the magnetic spiral field at the boundaries and lets the field strength tend to 0 in a continuous way) and an improved version of the JF12 X field (with parabolic field lines at z = 0 instead of sharp kinks) were added in order to smooth the field and avoid violations of magnetic flux conservation, see: Kleimann et al, 2018, arXiv:1809.07528, Solenoidal improvements for the JF12 Galactic magnetic field model.

The turbulent field component is the exact same as in the initial JF12 implementation and should be used with care since the new regular and old turbulent field do not match in the transition regions of the spiral field.

Public Functions

JF12FieldSolenoidal(double delta = 3 * kpc, double zs = 0.5 * kpc)

Constructor

Parameters
  • delta: Transition width for the disk field such that the magnetic flux of the spiral field lines is redirected between r = 5 kpc and r = 5 kpc + delta as well as r = 20 kpc - delta and r = 20 kpc. The input parameter delta should be non-negative and smaller than 7.5 kpc. The default value is 3 kpc.
  • zs: Scale height for the X-shaped poloidal halo field such that the straight field lines are replaced by parabolas for abs(z) < zs. The input parameter zs should be non-negative. The default value is 500 pc.

void setUseStriatedField(bool use)
void setUseTurbulentField(bool use)
void setDiskTransitionWidth(double delta)

Adjust the transition width of the disk field.

Return
Void
Parameters
  • d: The new transition width for the disk field with field strength transitions and flux redirection between r = 5 kpc and r = 5 kpc + delta as well as r = 20 kpc - delta and r = 20 kpc. Should be non-negative and smaller than 7.5 kpc.

double getDiskTransitionWidth() const
void setXScaleHeight(double zs)

Adjust the scale heigth of the X field.

Return
Void
Parameters
  • zs: The new scale height of the X field with parabolic field lines for abs(z) < zs. Should be non-negative.

double getXScaleHeight() const
Vector3d getXField(const double &r, const double &z, const double &sinPhi, const double &cosPhi) const
Vector3d getDiskField(const double &r, const double &z, const double &phi, const double &sinPhi, const double &cosPhi) const
void deactivateOuterTransition()

Disable the transition of the spiral field strength to 0 at the outer boundary such that only the magnetic flux at the 5 kpc ring is redirected. Thus, the spiral field lines are continued to r = 20 kpc as in the initial JF12 field. You can reactivate the outer transition afterwards via setDiskTransitionWidth which sets both transition widths at the inner and outer boundary.

Return
Void

double getDiskTransitionPolynomial(const double &r) const

Evaluate the polynomial which provides the transition of the spiral field strength to zero in the transition regions. This transition is differentiable at the boundaries of the unaltered spiral field and contuinuous at the outer boundaries of the spiral field where the field strength goes to zero.

Return
The value of the transition polynomial at r if r is inside one of the transition regions. Otherwise, return (5 kpc)/r, i.e. the scaling of the spiral field, if r is inside the region where the spiral field remains unaltered.
Parameters
  • r: Distance of the current position to the z axis in the usual galactocentric cylindrical coordinates. Should be non-negative.

double getDiskTransitionPolynomialDerivative(const double &r) const

Evaluate the derivative of the polynomial which provides the transition of the spiral field strength to zero in the transition regions. The derivative is needed to restore solenoidality in the transition region.

Return
The value of the transition polynomial derivative at r if r is inside one of the transition regions. Otherwise, return 0.
Parameters
  • r: Distance of the current position to the z axis in the usual galactocentric cylindrical coordinates. Should be non-negative.

double getHPhiIntegral(const double &r, const double &phi) const

Evaluate an angular azimuth integral over the piecewise constant spiral field strengths at r_1 = 5 kpc. This integral is needed to restore the solenoidality of the spiral field in the transition regions.

Return
The value of the azimuth integral over the spiral field strengths at r_1 = 5 kpc from at fixed phi0 to the current phi which is mapped back to r_1 = 5 kpc along the spiral field line passing through (r,phi).
Parameters
  • r: Distance of the current position to the z axis in the usual galactocentric cylindrical coordinates. Should be non-negative.
  • phi: Azimuth angle of the current position in galactocentric cylindrical coordinates. Can be any double.

double getSpiralFieldStrengthConstant(const double &r, const double &phi) const

Find the correct magnetic spiral arm for the current position and return its field strength at r_1 = 5 kpc.

Return
The value of the spiral field strength b_j
Parameters
  • r: Distance of the current position to the z axis in the usual galactocentric cylindrical coordinates. Should be non-negative.
  • phi: Azimuth angle of the current position in galactocentric cylindrical coordinates. Can be any double.

void randomStriated(int seed = 0)
void randomTurbulent(int seed = 0)
void setStriatedGrid(ref_ptr<Grid1f> grid)

Set a striated grid and activate the striated field component

Parameters
  • grid: scalar grid containing random +1/-1 values, 100 parsec grid spacing

void setTurbulentGrid(ref_ptr<Grid3f> grid)

Set a turbulent grid and activate the turbulent field component

Parameters
  • grid: vector grid containing a random field of Brms = 1

ref_ptr<Grid1f> getStriatedGrid()
ref_ptr<Grid3f> getTurbulentGrid()
void setUseRegularField(bool use)
void setUseDiskField(bool use)
void setUseToroidalHaloField(bool use)
void setUseXField(bool use)
bool isUsingRegularField()
bool isUsingStriatedField()
bool isUsingTurbulentField()
bool isUsingDiskField()
bool isUsingToroidalHaloField()
bool isUsingXField()
double logisticFunction(const double &x, const double &x0, const double &w) const
Vector3d getRegularField(const Vector3d &pos) const
Vector3d getToroidalHaloField(const double &r, const double &z, const double &sinPhi, const double &cosPhi) const
Vector3d getStriatedField(const Vector3d &pos) const
double getTurbulentStrength(const Vector3d &pos) const
Vector3d getTurbulentField(const Vector3d &pos) const
Vector3d getField(const Vector3d &pos) 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

bool useRegularField
bool useStriatedField
bool useTurbulentField
bool useDiskField
bool useToroidalHaloField
bool useXField
double rArms[8]
double pitch
double sinPitch
double cosPitch
double tanPitch
double cotPitch
double tan90MinusPitch
double bDisk[11]
double bRing
double hDisk
double wDisk
double bNorth
double bSouth
double rNorth
double rSouth
double wHalo
double z0
double bX
double thetaX0
double sinThetaX0
double cosThetaX0
double tanThetaX0
double cotThetaX0
double rXc
double rX
double sqrtbeta
ref_ptr<Grid1f> striatedGrid
ref_ptr<Grid3f> turbulentGrid
double bDiskTurb[8]
double bDiskTurb5
double zDiskTurb
double bHaloTurb
double rHaloTurb
double zHaloTurb
size_t _referenceCount