Functions#

Note

For BLS-related functions, see documentation of the bls submodule.

General functions#

SpinWaveToolkit.wavenumber2wavelength(wavenumber)#

Convert wavelength to wavenumber. lambda = 2*pi/k

Parameters:
wavenumberfloat or array_like

(rad/m) wavenumber of the wave.

Returns:
wavelengthfloat or ndarray

(m ) corresponding wavelength.

SpinWaveToolkit.wavelength2wavenumber(wavelength)#

Convert wavenumber to wavelength. k = 2*pi/lambda

Parameters:
wavelengthfloat or array_like

(m ) wavelength of the wave.

Returns:
wavenumberfloat or ndarray

(rad/m) wavenumber of the corresponding wavelength.

SpinWaveToolkit.wrapAngle(angle, amin=0, amax=6.283185307179586)#

Wrap angle in radians to range [amin, amax), by default [0, 2*np.pi).

Parameters:
anglefloat or array_like

(rad) angle to wrap.

aminfloat, optional

(rad) minimum value of the interval (inclusive).

amaxfloat, optional

(rad) maximum value of the interval (exclusive).

Returns:
wrapped_anglefloat or ndarray

(rad) angle wrapped to [amin, amax).

SpinWaveToolkit.roots(f, a, b, dx=0.001, eps=1e-09, args=())#

Find all roots of a continuous function f(x, *args) within a given interval [a, b].

Detects all roots spaced at least by dx with a precision given by eps.

For optimal performance, normalize dx and eps to the scale of your input. In case it didn’t find all expected roots, try decreasing dx, but note that it can extend the calculation time significantly.

Parameters:
fcallable()

Function to evaluate with signature f(x, *args).

a, bfloat

(x units) left and right boundaries of the interval to search.

dxfloat

(x units) stepsize of evaluation points (coarse search).

epsfloat, optional

(x units) tolerance of the to-be-found roots (fine search).

argslist, optional

List of arguments to be passed to f.

Returns:
xslist[float]

(x units) list of all found roots.

See also

bisect, rootsearch
SpinWaveToolkit.bisect(f, x1, x2, epsilon=1e-09, args=())#

Simple bisection method of root finding.

Must contain only one root in the given interval!

Parameters:
fcallable()

Function to evaluate, f(x, *args).

x1, x2float

(x units) left and right boundaries of the interval to search.

epsilonfloat, optional

(x units) tolerance of the to-be-found root.

argslist, optional

List of arguments to be passed to f.

Returns:
x3float or None

(x units) the root. Returns None if x1 * x2 > 0.

See also

roots, rootsearch
SpinWaveToolkit.rootsearch(f, a, b, dx, args=())#

Search for a root of a continuous function within an interval [a, b].

This function is used as a preliminary search with coarse sampling. Precise position of the root can be found with a more efficient method, e.g. bisection.

Searches from a to b, stops on first identified root.

Parameters:
fcallable()

Function to evaluate, f(x, *args).

a, bfloat

(x units) left and right boundaries of the interval to search.

dxfloat

(x units) stepsize of evaluation points.

argslist, optional

List of arguments to be passed to f.

Returns:
x1, x2float or None

(x units) left and right boundaries of size stepsize containing a root. Returns (None, None) if no roots found.

See also

roots, bisect
SpinWaveToolkit.distBE(w, temp=300, mu=-6.626070145940079e-22)#

Returns Bose-Einstein distribution for given chemical potential and temperature.

Parameters:
wfloat

(rad Hz) angular frequency.

tempfloat

(K ) temperature.

mufloat

(J ) chemical potential.

Returns:
BEdistfloat or ndarray

Bose-Einstein distribution in dependance to frequency.

SpinWaveToolkit.sphr2cart(theta, phi, r=1.0)#

Convert spherical coordinates to cartesian.

Inputs can be either floats or ndarrays of same shape.

Parameters:
thetafloat

(rad) polar angle (from surface normal).

phifloat

(rad) azimuthal angle (from principal in-plane axis, e.g. x or projection of M to film plane).

rfloat, optional

(length unit) radial distance. Default is 1.

Returns:
xyzndarray

(length unit) vector of shape (3, ...) as for (x, y, z).

SpinWaveToolkit.cart2sphr(x, y, z)#

Convert cartesian coordinates to spherical.

Inputs can be either floats or ndarrays of same shape.

Parameters:
x, y, zfloat or array_like

(length unit) cartesian coordinates.

Returns:
thetafloat or ndarray

(rad) polar angle (from surface normal).

phifloat or ndarray

(rad) azimuthal angle (from principal in-plane axis, e.g. x or projection of M to film plane).

rfloat or ndarray

(length unit) radial distance.