# SpinW

**SpinW** is a Matlab library that can plot and numerically simulate magnetic structures and excitations of given spin Hamiltonian using classical Monte Carlo simulation and linear spin wave theory.

**This wiki is moving to a new address: www.psi.ch/spinw. The latest code and tutorials are available there. The documentation will be moved soon.**

## Contents |

## Content of this wiki

SpinW 2.0 beta is available, download here: http://www.psi.ch/spinw. For future updates use the sw_update() command in Matlab that automatically downloads the latest version. Examples and news can be also found on the blog: spinw.tumblr.com.

**Tutorials** contain several example codes with explanation.

**Documentation** gives detailed explanation for functions and data structures.

**Index** lists all pages in this wiki in alphabetical order.

**Install** gives instructions for downloading and installing the library and the list of changes.

**Publications** lists publications using SpinW (slides of the talk at Neutrons 2.0 meeting can be found here spinw-toth.pdf).

**F.A.Q.** frequently asked questions.

## Forum

For questions and discussion see the SpinW Forum.

## Bug reports

Future code host: http://code.google.com/p/spinw/.

## What SpinW can do

In short spinW can solve the following spin Hamiltonian using classical and quasi classical methods:

,

where *S*_{i} are spin vector operators, *J*_{ij} are 3x3 matrices describing pair coupling between spins, *A*_{ij} are 3x3 anisotropy matrices, *B* is external magnetic field and *g*_{i} is the g-tensor.

** Crystal structures **

- definition of crystals with arbitrary unit cell, using space group or symmetry operators
- definition of non-magnetic atoms and magnetic atoms with arbitrary moment size
- publication quality plotting of crystal structures (atoms, labels, axes, surrounding polyhedron, anisotropy ellipsoids, DM vector, etc.)

** Magnetic structures **

- definition of 1D, 2D and 3D magnetic structures
- representation of incommensurate structures using rotating coordinate system or complex basis vectors
- generation of magnetic structures on a magnetic supercell
- plotting of magnetic structures

** Magnetic interactions **

- simple assignment of magnetic interactions to neighbouring magnetic atoms based on distance
- possible interactions: Heisenberg, Dzyaloshinskii-Moriya, anisotropic and general 3x3 exchange tensor
- arbitrary single ion anisotropy tensor (easy-plane, easy-axis, etc)
- Zeeman energy in homogeneous magnetic field including g-tensor
- calculation of symmetry allowed elements of the above tensors based on the crystallographic space group

** Simulation of magnetic structures **

- classical energy minimization assuming single-k magnetic structure for fast and simple solution for ground state magnetic structure
- simulated annealing using the Metropolis algorithm on an arbitrary number of magnetic unit cells
- parallel tempering to calculate temperature dependent properties
- calculating equilibrium properties (heat capacity, magnetic susceptibility, etc.)
- magnetic structure factor calculation using FFT
- simulation of magnetic neutron diffraction and diffuse scattering

** Simulation of magnetic excitations in general commensurate and incommensurate magnetic structures**

- using linear spin-wave theory
- calculation of dispersion, correlation functions
- calculation of neutron scattering cross section for unpolarized neutrons including the magnetic form factor (when using FullProf notation e.g. 'MCr3' in the name of the magnetic ion)
- calculation of polarized neutron scattering
- arbitrary exchange interaction tensors
- including single ion anisotropy and magnetic field
- allows different moment sizes for different sites
- easy calculation of powder spectra
- the algorithm: spinwave_algorithm.pdf (Many thanks to Johannes Reim for the LaTeXing)

** Plotting spin wave spectra **

- plotting dispersions and correlation functions
- calculation and plotting of the convoluted spectra for direct comparison with inelastic neutron scattering
- full integration into Horace for plotting and fitting, see http://horace.isis.rl.ac.uk
- creation of iData objects from calculated spectra for plotting, data manipulation and fitting, see http://ifit.mccode.org

** Fitting spin wave spectra **

- using arbitrary parameter function
- robust fitting, even when the number of simulated spin wave modes differs from the measured number of modes

** Feel free to ask questions & requests! **

Dr. Sándor Tóth