API Reference

class hopfindex.HopfIndexCalculator(m, method_name, Delta_x=1.0, Delta_y=1.0, Delta_z=1.0)

Bases: object

Class to calculate the Hopf index of a vector field using various methods.

Parameters:
  • m (np.ndarray) – Vector field array of shape (Nx, Ny, Nz, 3).

  • method_name (str) – Method to use for the calculation. Options are: ‘twopointstencil’, ‘fivepointstencil’, ‘solidangle’, ‘solidanglefourier’.

  • Delta_x (float, optional) – Grid spacing in the x-direction. Default is 1.0.

  • Delta_y (float, optional) – Grid spacing in the y-direction. Default is 1.0.

  • Delta_z (float, optional) – Grid spacing in the z-direction. Default is 1.0.

Raises:

ValueError – If the method_name is not a valid option or if m is not a 4D array with a shape of (Nx, Ny, Nz, 3).

emergent_field()

Compute the emergent field using the specified method.

Returns:

Array representing the emergent field.

Return type:

np.ndarray

Raises:

ValueError – If method ‘solidanglefourier’ is used but emergent_field calculation is attempted.

hopf_density()

Calculate the Hopf density for real-space methods.

Returns:

Array representing Hopf density.

Return type:

np.ndarray

Raises:

ValueError – If the calculation is attempted with ‘solidanglefourier’ method.

hopf_index()

Calculate the Hopf index based on the selected method.

Returns:

Hopf index value.

Return type:

float