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:
- wavenumber
floator array_like (rad/m) wavenumber of the wave.
- wavenumber
- Returns:
See also
- SpinWaveToolkit.wavelength2wavenumber(wavelength)#
Convert wavenumber to wavelength. k = 2*pi/lambda
- Parameters:
- wavelength
floator array_like (m ) wavelength of the wave.
- wavelength
- Returns:
See also
- SpinWaveToolkit.wrapAngle(angle, amin=0, amax=6.283185307179586)#
Wrap angle in radians to range
[amin, amax), by default[0, 2*np.pi).
- 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:
- f
callable() Function to evaluate with signature
f(x, *args).- a, b
float (x units) left and right boundaries of the interval to search.
- dx
float (x units) stepsize of evaluation points (coarse search).
- eps
float, optional (x units) tolerance of the to-be-found roots (fine search).
- args
list, optional List of arguments to be passed to f.
- f
- Returns:
See also
- 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:
- f
callable() Function to evaluate,
f(x, *args).- x1, x2
float (x units) left and right boundaries of the interval to search.
- epsilon
float, optional (x units) tolerance of the to-be-found root.
- args
list, optional List of arguments to be passed to f.
- f
- Returns:
See also
- 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:
- f
callable() Function to evaluate,
f(x, *args).- a, b
float (x units) left and right boundaries of the interval to search.
- dx
float (x units) stepsize of evaluation points.
- args
list, optional List of arguments to be passed to f.
- f
- Returns:
- SpinWaveToolkit.distBE(w, temp=300, mu=-6.626070145940079e-22)#
Returns Bose-Einstein distribution for given chemical potential and temperature.
- SpinWaveToolkit.sphr2cart(theta, phi, r=1.0)#
Convert spherical coordinates to cartesian.
Inputs can be either floats or ndarrays of same shape.
- Parameters:
- Returns:
- xyz
ndarray (length unit) vector of shape
(3, ...)as for (x, y, z).
- xyz
- SpinWaveToolkit.cart2sphr(x, y, z)#
Convert cartesian coordinates to spherical.
Inputs can be either floats or ndarrays of same shape.
- Parameters:
- x, y, z
floator array_like (length unit) cartesian coordinates.
- x, y, z
- Returns: