bfield

class bfield.B_grid(coords: jax.Array | List[jax.Array] | Tuple[jax.Array], coords_field: jax.Array | List[jax.Array] | Tuple[jax.Array])[source]

Bases: object

grid B field model. See Synax paper for more details.

Parameters:
  • coords (Union[jax.Array,List[jax.Array],Tuple[jax.Array]]) – coordinates of all integration points. Should be of size (3,…), for example coords[0] is the x-coordinates.

  • coords_field (Union[jax.Array,List[jax.Array],Tuple[jax.Array]]) – coords[i] is the 1D vector of coordinates along i-th axis. Since the grid is a regular 3D grid, 1D vectors are sufficient to represents the coordinates.

Returns:

A instance of grid B field generator.

B_field(B_field_grid)

Calculate grid B-field at all positions specified by coords.

Parameters:

B_field_grid (Dict[str,float]) – your field in a regular 3D grid.

Returns:

jnp.Array of shape (coords[0].shape,3). coords is the parameter of your B_grid instance.

class bfield.B_jf12(coords: jax.Array | List[jax.Array] | Tuple[jax.Array])[source]

Bases: object

jf12 B field model(https://ui.adsabs.harvard.edu/abs/2012ApJ…757…14J/abstract).

Parameters:

coords (Union[jax.Array,List[jax.Array],Tuple[jax.Array]]) – coordinates of all integration points. Should be of size (3,…), for example coords[0] is the x-coordinates.

Returns:

A instance of jf12 B field generator.

static B_calc(jf12_params: Dict[str, float], r: float, phi: float, z: float, is_r_less_rmin=1.0, is_r_less_rcent=1.0, b_disk=1.0, mask=1.0)[source]

Calculate jf12 B-field at a given position (r,phi,z).

Parameters:
  • jf12_params (Dict[str,float]) – A dict contains all parameters of the jf12 model.

  • r (float) – r in cylindrical coordinates.

  • phi (float) – phi in cylindrical coordinates.

  • z (float) – z in cylindrical coordinates.

  • is_r_less_rmin – is this position less than the outer boundary of the molecular ring region. 1 for not, 0 for yes.

  • is_r_less_rcent – is this position less than the inner boundary of the molecular ring region. 1 for not, 0 for yes.

  • b_disk – B field in this spiral arm. 0. for all non-spiral-arm positions.

  • mask – is this position less than the outer boundary of the total B field. 1 for not, 0 for yes.

Returns:

(Bx,By,Bz) in this position.

B_field(jf12_params)

Calculate jf12 B-field at all positions specified by coords.

Parameters:

jf12_params (Dict[str,float]) – A dict contains all parameters of the jf12 model.

Returns:

jnp.Array of shape (coords[0].shape,3). coords is the parameter of your B_jf12 instance.

static get_index(r: float, phi: float, z: float) int[source]

Calculate the which spiral arms is position specified by coordinates in.

Parameters:
  • r (float) – r in cylindrical coordinates.

  • phi (float) – phi in cylindrical coordinates.

  • z (float) – z in cylindrical coordinates.

Returns:

Spiral arm index (0-7). 8 for not in any spiral arms.

class bfield.B_lsa(coords: jax.Array | List[jax.Array] | Tuple[jax.Array])[source]

Bases: object

lsa B field model. See Synax paper for more details.

Parameters:

coords (Union[jax.Array,List[jax.Array],Tuple[jax.Array]]) – coordinates of all integration points. Should be of size (3,…), for example coords[0] is the x-coordinates.

Returns:

A instance of lsa B field generator.

static B_calc(lsa_params, r, z, cos_p, sin_p, mask)[source]

Calculate lsa B-field at a given position (r,phi,z).

Parameters:
  • lsa_params (Dict[str,float]) – A dict contains all parameters of the lsa model.

  • r (float) – r in cylindrical coordinates.

  • z (float) – z in cylindrical coordinates.

  • cos_p (float) – cos(phi), phi is the polar angle in cylindrical coordinates.

  • sin_p (float) – sin(phi), phi is the polar angle in cylindrical coordinates.

  • mask – is this position less than the outer boundary of the total B field. 1 for not, 0 for yes.

Returns:

(Bx,By,Bz) in this position.

B_field(lsa_params)

Calculate lsa B-field at all positions specified by coords.

Parameters:

lsa_params (Dict[str,float]) – A dict contains all parameters of the lsa model.

Returns:

jnp.Array of shape (coords[0].shape,3). coords is the parameter of your B_lsa instance.