magpylib.vector package

The vector subpackage includes functions for vectorized computation of the magnetic field. Use these functions only when performance is an issue, when doing 10 or more evaluations of similar sources (with different parameters).

magpylib.vector.getBv_magnet(type, MAG, DIM, POSm, POSo, ANG=[], AX=[], ANCH=[], Nphi0=50)[source]

Calculate the field of magnets using vectorized performance code.

Parameters:
  • type (string) – source type either ‘box’, ‘cylinder’, ‘sphere’.
  • MAG (Nx3 numpy array float [mT]) – vector of N magnetizations.
  • DIM (NxY numpy array float [mm]) – vector of N dimensions for each evaluation. The form of this vector depends on the source type. Y=3/2/1 for box/cylinder/sphere
  • POSo (Nx3 numpy array float [mm]) – vector of N positions of the observer.
  • POSm (Nx3 numpy array float [mm]) – vector of N initial source positions. These positions will be adjusted by the given rotation parameters.
  • ANG=[] (length M list of size N numpy arrays float [deg]) – Angles of M subsequent rotation operations applied to the N-sized POSm and the implicit source orientation.
  • AX=[] (length M list of Nx3 numpy arrays float []) – Axis vectors of M subsequent rotation operations applied to the N-sized POSm and the implicit source orientation.
  • ANCH=[] (length M list of Nx3 numpy arrays float [mm]) – Anchor positions of M subsequent rotations applied ot the N-sized POSm and the implicit source orientation.
  • Nphi0=50 (integer gives number of iterations used when calculating diametral) – magnetized cylindrical magnets.
magpylib.vector.getBv_current(type, CURR, DIM, POSm, POSo, ANG=[], AX=[], ANCH=[])[source]

Calculate the field of currents using vectorized performance code.

Parameters:
  • type (string) – source type either ‘circular’ or ‘line’
  • MAG (Nx3 numpy array float [mT]) – vector of N magnetizations.
  • DIM (NxY numpy array float [mm]) – vector of N dimensions for each evaluation. The form of this vector depends on the source type. Y=1/3x3 for circular/line.
  • POSo (Nx3 numpy array float [mm]) – vector of N positions of the observer.
  • POSm (Nx3 numpy array float [mm]) – vector of N initial source positions. These positions will be adjusted by the given rotation parameters.
  • ANG=[] (length M list of size N numpy arrays float [deg]) – Angles of M subsequent rotation operations applied to the N-sized POSm and the implicit source orientation.
  • AX=[] (length M list of Nx3 numpy arrays float []) – Axis vectors of M subsequent rotation operations applied to the N-sized POSm and the implicit source orientation.
  • ANCH=[] (length M list of Nx3 numpy arrays float [mm]) – Anchor positions of M subsequent rotations applied ot the N-sized POSm and the implicit source orientation.
magpylib.vector.getBv_moment(type, MOM, POSm, POSo, ANG=[], AX=[], ANCH=[])[source]

Calculate the field of magnetic moments using vectorized performance code.

Parameters:
  • type (string) – source type: ‘dipole’
  • MOM (Nx3 numpy array float [mT]) – vector of N dipole moments.
  • POSo (Nx3 numpy array float [mm]) – vector of N positions of the observer.
  • POSm (Nx3 numpy array float [mm]) – vector of N initial source positions. These positions will be adjusted by the given rotation parameters.
  • ANG=[] (length M list of size N numpy arrays float [deg]) – Angles of M subsequent rotation operations applied to the N-sized POSm and the implicit source orientation.
  • AX=[] (length M list of Nx3 numpy arrays float []) – Axis vectors of M subsequent rotation operations applied to the N-sized POSm and the implicit source orientation.
  • ANCH=[] (length M list of Nx3 numpy arrays float [mm]) – Anchor positions of M subsequent rotations applied ot the N-sized POSm and the implicit source orientation.