Magnetic fields with cell-like structure
The magnetic fields in this module are of a simple cell-like structure, i.e., the field strength is constant but the orientation changes randomly from one cell to the next.
The cell size is given by the coherence length and stored in gammaALPs.bfields.cell.Bcell.Lcoh
,
the magnetic field strength is stored in gammaALPs.bfields.cell.Bcell.B
.
New random fields are computed by gammaALPs.bfields.cell.Bcell.new_Bn()
and
gammaALPs.bfields.cell.Bcell.new_Bcosmo()
for a cosmological magnetic field.
For a cosmological magnetic field the evolution with redshift of the coherence length and the field
strength are taken into account, see, e.g., [DeAngelis2011].
The simple cell model was used in, e.g., [Horns2012] and [Meyer2013] to model the photon-ALP mixing in galaxy clusters.
Reference / API
- class gammaALPs.bfields.cell.Bcell(B, Lcoh, seed=None)[source]
Bases:
object
Class to calculate a turbulent magnetic field with a cell like structure
- property B
- property Lcoh
- new_Bcosmo(z, Bscale=None, cosmo=FlatLambdaCDM(name=None, H0=<Quantity 70. km / (Mpc s)>, Om0=0.3, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=None), nsim=1)[source]
Calculate two components of a cosmological turbulent magnetic field and the angle between the the two.
B field will be scaled with (1. + z)^2 and coherence length with (1. + z)
- Parameters:
z (float) – redshift to source
Bscale (array-like, float, or None) – if not None, float or Nd-dim array with scaling factor for magnetic field along distance travelled
cosmo (
FlatLambdaCDM
) – chosen cosmology, default is H0 = 70, Om0 = 0.3nsim (int) – number of random realizations of the magnetic field. Default: 1
- Returns:
B, Psin, dL, zstep – Squeezed (nsim,Nd)-dim array with absolute value of transversal field, angles between total transversal magnetic field and the \(y\) direction, coherence lengths of cells in observer’s frame and associated steps in redshift
- Return type:
tuple with
ndarray
- new_Bn(Nd, Bscale=None, nsim=1)[source]
Calculate two components of a turbulent magnetic field and the angle between the the two.
- Parameters:
- Returns:
B, Psin – Two squeezed (nsim,Nd)-dim array with absolute value of transversal field, as well as angles between total transversal magnetic field and the \(y\) direction.
- Return type:
tuple with
ndarray
Note
If z is not a multiple integer of Lcoh, last not fully crossed domain will be discarded
- gammaALPs.bfields.cell.rand(d0, d1, ..., dn)
Random values in a given shape.
Note
This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.
Create an array of the given shape and populate it with random samples from a uniform distribution over
[0, 1)
.- Parameters:
d0 (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
d1 (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
... (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
dn (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
- Returns:
out – Random values.
- Return type:
ndarray, shape
(d0, d1, ..., dn)
See also
Examples
>>> np.random.rand(3,2) array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #random