llg3d.solvers.math_utils

Mathematical utility functions for solvers.

Functions

cross_product(a, b)

Compute cross product \(a \times b\).

normalize(m_n)

Normalize the magnetization array (in place).

cross_product(a, b)[source]

Compute cross product \(a \times b\).

This implementation is faster than np.cross for large arrays.

Parameters:
  • a (ndarray) – First vector (shape (3, nx, ny, nz))

  • b (ndarray) – Second vector (shape (3, nx, ny, nz))

Returns:

Cross product \(a \times b\) (shape (3, nx, ny, nz))

Return type:

ndarray

normalize(m_n)[source]

Normalize the magnetization array (in place).

\[\mathbf{m}_n = \frac{\mathbf{m}_n}{|\mathbf{m}_n|}\]
Parameters:

m_n (ndarray) – Magnetization array at time step n (shape (3, nx, ny, nz)).