# Coordinate systems¶

SpinW uses three different coordinate systems. It is important to consider every time, that a given vector/tensor data is in which coordinate system. In the following documentation the xyz, lu and rlu shorthand notation will be used for the three coordinate systems.

## Lattice units (lu) coordinate system¶

This is the lattice coordinate system. The three axis are the a, b and c crystal axes. For example the vector [0,1,0] denotes a position translated from the origin by b vector. The following sw class properties are stored in lattice units:

Also several function takes input or output in lattice units:

• atomic positions of the output of matom() and atom() methods of sw
• magnetic moments can be given in lattice units for the genmagstr() function (using the ‘unitS’ option with ‘lu’ value)
• calculated bond vectors from couplingtable()

## xyz coordinate system¶

Most of the sw class properties are stored in the xyz coordinate system. The xyz coordinate system is right-handed Cartesian and fixed to the crystal lattice:

• x: parallel to a-axis,
• y: perpendicular to x and in the ab-plane,
• z: perpendicular to xy-plane

The following properties are in the xyz coordinate system:

Also output of several functions are in xyz coordinate system:

• spin-spin correlation function matrix elements calculated by spinwave() method (spec.Sab matrices)
• interaction matrices calculated by couplingtable()

Vectors in reciprocal space in Å$$^{-1}$$ units are also in a right handed Cartesian coordinate system:

• momentum transfer values in Å$$^{-1}$$ reciprocal lattice units of the spec.hklA output of the spinwave() function

## Reciprocal lattice (rlu) coordinate system¶

The reciprocal lattice coordinate system is the dual vector space of the lattice coordinate system. The three axis are the reciprocal lattice vectors denoted by a$$^*$$, b$$^*$$ and c$$^*$$. The following sw class properties are stored in rlu units:

Also several function takes input in rlu units:

• the sw_neutron() function takes the option ‘uv’, that defines the scattering plane by two vectors in rlu
• the first input of the spinwave() function is a list of Q points in rlu units

## Transformation between coordinate systems¶

To transform vectors and tensors between the above coordinate systems, the output of basisvector() function can be used:

tri = sw;
tri.genlattice('lat_const',[3 3 5],'angled',[90 90 120])
BV = tri.basisvector


The BV 3x3 matrix contains the coordinates of the lattice vectors as column vectors: [a b c]. To convert vectors from the abc coordinate system to the xyz, we can do the following:

r_abc = [1/2 1/2; 0];
r_xyz = BV * r_abc