pySpinW#
pySpinW is the Python implementation of SpinW. It can calculate magnon dispersion curves, optimize magnetic structures, visualize systems, and predict the results of inelastic scattering experiments.
In compact form, the magnetic Hamiltonian has the form:
where \(S_i\) are spin vector operators, \(J_{ij}\) are 3x3 matrices describing pair coupling between spins, \(A_{i}\) are 3x3 anisotropy matrices, \(B\) is the external magnetic field, and \(g_i\) is the g-tensor.
The core calculations are a Rust-backed port of the SpinW algorithms, and the Python interface is designed around constructing a model from objects rather than filling in a fixed form. A minimal ferromagnetic chain looks like this:
from pyspinw import *
unit_cell = UnitCell(1, 1, 1)
site = LatticeSite(0, 0, 0, 0, 0, 1, name="X")
structure = Structure([site], unit_cell=unit_cell)
exchanges = [HeisenbergExchange(site, site, cell_offset=(1, 0, 0), j=-1)]
hamiltonian = Hamiltonian(structure, exchanges)
The package makes the common user-facing classes available with
from pyspinw import *. The main entry points are:
magnetic structures, unit cells, and sites
exchange and anisotropy objects
Hamiltonians and sample models
supercells, propagation vectors, and helper constructors
plotting, viewing, and example-generation utilities
For a more detailed API index, see the API page, and for runnable examples, see Examples.
User guide
Reference