gigablochs.bloch.unit_field_and_angle

gigablochs.bloch.unit_field_and_angle#

gigablochs.bloch.unit_field_and_angle(B_field, dt, *, tol=1e-14, axis=-1)[source]#

Compute the unit field vector and rotation angle for a given field vector and time step.

Parameters:
  • B_field (ndarray) – Magnetic field vector in Tesla.

  • dt (float) – Time step in seconds.

  • tol (float, optional) – Numerical tolerance to avoid division by zero. The angle of B_field vector with magnitude smaller than tol is set to 0. Default is 1e-14.

  • axis (int, optional) – Axis along the field array which represents the 2D or 3D spatial field vector. Default is the last axis.

Returns:

  • b (ndarray) – Unit field vector.

  • ang (ndarray) – Rotation angle in radians. Same shape as B_field, except for the specified spatial axis.

Notes

The unit field vector and rotation angle are computed as:

\[\vec{b} = \frac{\vec{B}}{|B|} \theta = -\gamma |B| dt\]

where \(|B|\) is the magnitude of the field vector in Tesla, \(\gamma\) is the gyromagnetic ratio in rads/s/T, and \(dt\) is the time step in seconds.