MicromagneticAnalysisTools.Calculate

Tools for calculating quantities from simulation data.

MicromagneticAnalysisTools.Calculate.HopfIdx(m, acc=8)

Calculate the Hopf index of a magnetization vector field of shape (Nx, Ny, Nz, 3).

Parameters:
  • m (ndarray) – Magnetization array of the shape (Nx, Ny, Nz, 3).

  • acc (int, optional) – Order of the accuracy for which the derivatives should be calculated (see findiff documentation).

Returns:

The calculated Hopf index of the texture.

MicromagneticAnalysisTools.Calculate.Hopf_density(m, acc=8)

Calculate the Hopf index density of a magnetization vector field of shape (Nx, Ny, Nz, 3).

Parameters:
  • m (ndarray) – Magnetization array of the shape (Nx, Ny, Nz, 3).

  • acc (int, optional) –

    Order of the accuracy for which the derivatives should be calculated (see findiff documentation).

Returns:

Array of Hopf index density of the system, of the shape (Nx, Ny, Nz).

MicromagneticAnalysisTools.Calculate.NskArray(directory, zIndex=0, startFile=None, endFile=None, calculateFromX=None, calculateToX=None, calculateFromY=None, calculateToY=None, startXFrac=0, endXFrac=1, startYFrac=0, endYFrac=1)

Get the Nsk of the simulation over time. The arguments define the area of the sample over which the Nsk array should be calculated. Can either specify in terms of units (i.e. nanometres), of in terms of the fractional length of the system.

Parameters:
  • directory (str) – The directory in which the simulation data is stored.

  • zIndex (int, optional) – The index along the z-axis for which the skyrmion centre should be calculated (for a 3D sample).

  • startFile (str, optional) – The simulation file from which the counting should start (i.e. skipping over files at the beginning).

  • endFile (str, optional) – The simulation at which the counting shold end.

  • calculateFromX (float, optional) – The value of x in nm from which the skyrmion number calculation should start (e.g. cutting off edge effects).

  • calcualteToX (float, optional) – The value of x in nm to which the skyrmion number calculation should start (e.g. cutting off edge effects).

  • calculateFromY (float, optional) – As above, but in the y-direction.

  • calculateToY (float, optional) – As above, but in the y-direction.

  • startXFrac (float, optional) – Like above, but with fractions rather than nm.

  • endXFrac (float, optional) – Like above, but with fractions rather than nm.

  • startYFrac (float, optional) – Like above, but with fractions rather than nm.

  • startYFrac – Like above, but with fractions rather than nm.

Returns:

A 1D array of the skyrmion number over the course of the simulation, for each file.

MicromagneticAnalysisTools.Calculate.getMeanSpeed(times, COM, rampIdx, component)

Get the mean x-component of the skyrmion velocity over time. Only consider values obtained after ramping has finished.

Parameters:
Returns:

The average speed along the specified direction over the course of the simulation.

MicromagneticAnalysisTools.Calculate.getRampIdx(directory, component)

Get the index of the point in the simulation (e.g. 0 -> m000000.ovf, 1-> m000001.ovf, …) where the current reaches a constant. Note that we assume the current to be monotonically increasing.

Parameters:
  • directory (str) – The directory in which the simulation data is stored.

  • component (str) – The direction in which the current is running; can be x, y, or z.

Returns:

The index at which the current stops ramping.

MicromagneticAnalysisTools.Calculate.skyrmionCOM(directory, inFile, dx, dy, zIndex=0, edgeCutXFrac=0.1, edgeCutYFrac=0.1)

Calculate the centre of the skyrmion by obtaining the “centre of mass” of the skyrmion number density.

Parameters:
  • directory (str) – The directory in which the simulation data is stored.

  • inFile (str) – The filename for which to calculate the skyrmion’s centre.

  • dx (float64) – The simulation cell size in the x-dimension, in nm.

  • dy (float64) – The simulation cell size in the y-dimension, in nm.

  • zIndex (int, optional) – The index along the z-axis for which the skyrmion centre should be calculated (for a 3D sample).

  • edgeCutXFrac (float64, optional) – The fraction of the system along the x-axis that should be cut off at the edges (thus allowing edge effects to be excluded).

  • edgeCutYFrac (float64, optional) – Same as above but for the y-axis.

Returns:

A two-element array of the form [x-coordinate of centre of skyrmion, y-coordinate of centre of skyrmion].

MicromagneticAnalysisTools.Calculate.skyrmionCOMArray(directory, edgeCutXFrac=0.1, edgeCutYFrac=0.1, zIndex=0)

Get an array of the centre of mass of the skyrmion over the entire simulation.

Parameters:
  • directory (str) – The directory in which the simulation data is stored.

  • edgeCutXFrac (float64, optional) – The fraction of the system along the x-axis that should be cut off at the edges (thus allowing edge effects to be excluded).

  • edgeCutYFrac (float64, optional) – Same as above but for the y-axis.

  • zIndex (int, optional) – The index along the z-axis for which the skyrmion centre should be calculated (for a 3D sample).

Returns:

Array of centres of mass over the entire simulation, of the shape (Number of files, 2).

MicromagneticAnalysisTools.Calculate.skyrmionCOMArrayCoMoving(directory, zIndex=0, boxSize=None, startFile=None, endFile=None)

Get an array of the centre of mass of the skyrmion over the entire simulation=, using a co-moving frame, allowing seamlessness when using PBCs.

Parameters:
  • directory (str) – The directory in which the simulation data is stored.

  • zIndex (int, optional) – The index along the z-axis for which the skyrmion centre should be calculated (for a 3D sample).

  • boxSize (float64, optional) – Size of the box around the guess centre of mass in nm, to avoid integrating over the entire system.

  • startFile (str, optional) – The starting file for which the helicity should be calculated.

  • endFile (str, optional) – The ending file for which the helicity should be calculated.

Returns:

Array of centres of mass over the entire simulation, of the shape (Number of files, 2).

MicromagneticAnalysisTools.Calculate.skyrmionCOMCoMoving(directory, inFile, dx, dy, zIndex, guessX, guessY, boxSize=None)

Calculate the skyrmion’s position by converting to a co-moving frame, which allows seamlessness with PBCs.

Parameters:
  • directory (str) – The directory in which the simulation data is stored.

  • inFile (str) – The filename for which to calculate the skyrmion’s centre.

  • dx (float64) – The simulation cell size in the x-dimension, in nm.

  • dy (float64) – The simulation cell size in the y-dimension, in nm.

  • zIndex (int, optional) – The index along the z-axis for which the skyrmion centre should be calculated (for a 3D sample).

  • guessX (float64) – Initial guess of the skyrmion’s x-position, in cells.

  • guessY (float64) – Initial guess of the skyrmion’s y-position, in cells.

  • boxSize (float64, optional) – Size of the box around the guess centre of mass in nm, to avoid integrating over the entire system.

Returns:

A two-element array of the form [x-coordinate of centre of skyrmion, y-coordinate of centre of skyrmion].

MicromagneticAnalysisTools.Calculate.skyrmionNumber(m)

Calculate the skyrmion number for a magnetization array of shape (Nx, Ny, 1, 3), for a given z.

Parameters:

m (ndarray) – Array of shape (Nx, Ny, 1, 3).

Returns:

The skyrmion number of the texture in the array.

MicromagneticAnalysisTools.Calculate.skyrmionNumberDensity(m, dx, dy, lengthUnits=None)

Calculate the skyrmion number density of a magnetic texture contained in an array of shape (Nx, Ny, 1, 3)

Parameters:
  • m (ndarray) – Array of shape (Nx, Ny, 1, 3).

  • dx (float64) – The simulation cell size in the x-dimension, in nm.

  • dy (float64) – The simulation cell size in the y-dimension, in nm.

  • lengthUnits (float64, optional) – Amount by which to scale discretisation (which rescales number density).

Returns:

Two-dimensional array of skyrmion number densities over the x-y plane.

MicromagneticAnalysisTools.Calculate.skyrmion_helicity(directory, filename)

Calculate the skyrmion helicity from an ovf file. The calculation works by sweeping down the y-axis, and getting the points to the left and right of the centre, which are closest to m_z = 0 (where we define the radius of the skyrmion). We then take the mean helicity of all of these points on the radius. We assume that the system is a thin film, i.e. that the system only has one layer along the z-axis.

IMPORTANT: We assume a single skyrmion in a collinear background!

Parameters:
  • directory (str) – The directory containing the ovf file for which the helicity should be calculated.

  • filename (str) – The ovf file containing the skyrmion for which the helicity should be calculated.

Returns:

The calculated helicity (between -pi and pi).

MicromagneticAnalysisTools.Calculate.skyrmion_helicity_array(directory, startFile=None, endFile=None)

Get an array of skyrmion helicities for a given simulation directory. Note that this only works for a single skyrmion in a collinear background.

Parameters:
  • directory (str) – The directory containing the ovf file for which the helicity should be calculated.

  • startFile (str, optional) – The starting file for which the helicity should be calculated.

  • endFile (str, optional) – The ending file for which the helicity should be calculated.

Returns:

Array of calculated helicities.

MicromagneticAnalysisTools.Calculate.speedAgainstTime(times, COM, component)

Return the speed of the skyrmion as an array.

Parameters:
Returns:

An array of speed against time in the specified direction.