SpinWaveToolkit.MacrospinEquilibrium#

class SpinWaveToolkit.MacrospinEquilibrium(Ms, Bext, theta_H, phi_H, theta=None, phi=None, demag=None, verbose=True)#

Compute magnetization equilibrium direction in a macrospin approximation.

Can be used to find static equilibrium position before calculating the spin-wave dispersion relation in other classes. See Examples for more.

### update exact example (e.g. a layer with PMA)

Usually searches for a local equilibrium based on the initial position. (The equilibrium is a minimum in the energy density landscape.)

Caution

The model might get stuck in labile equilibria, therefore it is encouraged to slightly perturb the angles (e.g. by 1 µrad) to get more reliable results from the calculations.

Includes the effect of the thin film’s demagnetizing field (dipolar energy), external field (Zeeman energy) and any number of uniaxial anisotropies with arbitrary directions of the anisotropy axis.

All angles are given in the laboratory (lab) frame of reference, i.e. z || thin film normal, and x || IP projection of spin wave wavevector.

Note

Cubic anisotropy is not implemented for now, as its usage is not very common in our experiments.

Parameters:
Msfloat

(A/m) saturation magnetization of the magnetic material.

Bextfloat

(T ) magnitude of external field.

theta_H, phi_Hfloat

(rad) polar and azimuthal angles of the external field direction.

theta, phifloat or None

(rad) polar and azimuthal angle of magnetization. Serves as the starting point for minimize. If None, the values are inferred from theta_H and phi_H, respectively. Default is None.

demag(3, 3) array or None, optional

The demagnetization tensor in the lab frame. If None, np.diag([0.0, 0.0, 1.0]) is used, which corresponds to an infinite thin film in the xy plane. Default is None.

verbose: bool, optional

Additional informative output to console? Default is True.

Attributes:
Msfloat

(A/m) saturation magnetization of the magnetic material.

dfloat

(m ) thickness of the magnetic film.

Bextdict

Dictionary containing the spherical coordinates of the external magnetic field. It has keys {“Bext”, “theta_H”, “phi_H”}.

Mdict

Dictionary containing the spherical coordinates of magnetization. It has keys {“theta”, “phi”}.

b(3,) array

Unit vector of external magnetic field. Depends on Bext.

demag(3, 3) array

The demagnetization tensor in the lab frame.

anisdict

Dictionary of anisotropies. Each (uniaxial) anisotropy has a unique name key, which can be then used to access its properties, which are stored as another dictionary with the following keys:

  • “Ku” - uniax. anisotropy strength (J/m^3)

  • “theta” - polar angle of anisotropy axis (rad)

  • “phi” - azimuthal angle of anisotropy axis (rad)

  • “Na” - corresponding tensor calculated from the three parameters above.

Na_tot(3, 3) array

Sum of all anisotropy tensors. Depends on anis.

eden_zeeman, eden_demag, eden_anis_unifloat

(J/m^3) Zeeman, dipolar, and uniax. anisotropy energy density, respectively. Stored as results of the last minimize() call.

resscipy.optimize.OptimizeResult

Full output of the scipy.optimize.minimize function from the last calculation. (That is, given as None until first run.)

verbosebool

Additional informative output to console?

Methods

add_uniaxial_anisotropy(name[, Ku, theta, ...])

Add uniaxial anisotropy to the system.

recalc_params()

Recalculate/update the values of dependent variables, e.g. field unit vector and total anistropy tensor.

minimize([scipy_kwargs, verbose])

Evaluate the minimization problem.

eval_energy(m[, components])

Evaluate the energy density for the magnetization direction angles m = (theta, phi).

getHeff()

Calculate effective field with the current magnetization direction.

hysteresis(Bext, theta_H, phi_H[, scipy_kwargs])

Calculate a hysteresis curve from a vector of swept field values.

Examples

maceq = MacrospinEquilibrium(
    Ms=800e3, Bext=150e-3, theta_H=np.deg2rad(10),
    phi_H=np.deg2rad(60), theta=0, phi=np.deg2rad(30)
)
maceq.add_uniaxial_anisotropy("uni0", Ku=15e3, theta=0, phi=0)
maceq.add_uniaxial_anisotropy("uni1", Ku=10e3,
    theta=np.deg2rad(70), phi=np.pi/2)
maceq.minimize()
print(maceq.M)
add_uniaxial_anisotropy(name, Ku=0.0, theta=0.0, phi=0.0, Bani=None, Na=None)#

Add uniaxial anisotropy to the system. Only the first order constant is assumed.

Parameters:
namestr

String name to use as key in the dictionary of anisotropies. If an anisotropy with the same name already exists, it is silently overwritten.

Kufloat, optional

(J/m^3) uniaxial anisotropy constant. Easy plane anisotropy for Ku < 0 and easy axis for Ku > 0. Unused if Na or Bani is specified.

thetafloat, optional

(rad) polar angle of the anisotropy axis in the lab frame. Unused if Na is specified.

phifloat, optional

(rad) azimuthal angle of the anisotropy axis in the lab frame. Unused if Na is specified.

Banifloat, optional

(T ) uniaxial anisotropy field. If specified (and non-zero), Ku input is not used, but rather is recalculated from Bani as Ku = Ms*Bani/2. Default is None.

Na(3, 3) array or None, optional

() uniaxial anisotropy tensor. Can be used for direct assignment. However, when used, the other parameters are not recalculated into the anisotropy dict. Default is None.

eval_energy(m, components=False)#

Evaluate the energy density for the magnetization direction angles m = (theta, phi).

Returns:
edenfloat or list[float]

(J/m^3) energy density. If components is False, given as a sum of all components (float). Returns a list of components otherwise.

getHeff()#

Calculate effective field with the current magnetization direction.

Performs a numerical derivative of the energy density wrt. magnetization to get the effective field vector.

Returns:
theta_Heff, phi_Hefffloat

(rad) polar and azimuthal angle of the effective field direction.

Hefffloat
  1. effective field magnitude.

hysteresis(Bext, theta_H, phi_H, scipy_kwargs=None)#

Calculate a hysteresis curve from a vector of swept field values.

Any of the input (field-related) values can be swept, but the other two have to be either of same shape or floats.

Parameters:
Bextfloat or (N,) array

(T ) amplitude of external magnetic field (can be negative).

theta_Hfloat or (N,) array

(rad) polar angle of external magnetic field.

phi_Hfloat or (N,) array

(rad) azimuthal angle of external magnetic field.

scipy_kwargsdict or None, optional

Dictionary with settings passed to scipy.optimize.minimize(). Cannot contain tol and bounds keywords, as they are fixly set here. If None, {"method": "Nelder-Mead"} is used. Defualt is None. Try changing the optimization method is you have concern about the results (see documentation of scipy.optimize.minimize()). This is not a sweepable parameter!

Returns:
theta, phi(N,) array

(rad) angles related to magnetization direction at each point of the sweep.

Notes

To get a projection of magnetization in a certain direction, you can just put the output of this method to the sphr2cart function provided by SpinWaveToolkit.

For sweeping other parameters, the user is encouraged to write their own script similarly to this method. Currently, we do not plan to implement a general sweep.

minimize(scipy_kwargs=None, verbose=None)#

Evaluate the minimization problem.

Uses the scipy.optimize.minimize function to find the minimum in the 2D energy landscape E(theta, phi).

Result is saved in the attributes M (just magnetization angles) and res (full output).

Parameters:
scipy_kwargsdict or None, optional

Dictionary with settings passed to scipy.optimize.minimize(). Cannot contain tol and bounds keywords, as they are fixly set here. If None, {"method": "Nelder-Mead"} is used. Defualt is None. Try changing the optimization method is you have concern about the results (see documentation of scipy.optimize.minimize()).

verbosebool or None, optional

Additional informative output to console? If None, the value is inferred from the verbose attribute. Default is None.

Notes

The used minimize function usually finds a local minimum based on the initial conditions. This can be used for calculating hysteresis loops and field sweeps. For global minimum finding, a brute force method could be used, but it is not implemented here.

recalc_params()#

Recalculate/update the values of dependent variables, e.g. field unit vector and total anistropy tensor.