addg(obj, matrixIdx, {atomTypeIdx}, {atomIdx})


addg(obj, matrixIdx, {atomTypeIdx}, {atomIdx}) assigns the matrix selected by matrixIdx (using either the matrix label or matrix index) to the magnetic sites selected by atomTypeIdx that can contain a name of an atom or its atom index (see spinw.atom). If atomTypeIdx is not defined, g-tensor will be assigned to all magnetic atoms.


The following example will add the diagonal matrix to all magnetic atoms as anisotropic g-tensor and show the effect of a fourfold axis:

cryst = spinw
cryst.genlattice('lat_const',[4 4 3],'spgr','P 4')
cryst.addatom('r',[1/4 1/4 1/2],'S',1)
cryst.addmatrix('label','g_1','value',diag([2 1 1]))

Input Arguments

Either an integer, that selects the matrix obj.matrix.mat(:,:,matrixIdx), or a string identical to one of the previously defined matrix labels, stored in obj.matrix.label. Maximum value is .
String or cell of strings that select magnetic atoms by their label. Also can be a vector that contains integers, the index of the magnetic atoms in spinw.unit_cell, this will assign the given g-tensor to all symmetry equivalent atoms. Maximum value is . If atomTypeIdx is not defined, the given g-tensor will be assigned to all magnetic atoms. Optional.
A vector that contains indices selecting some of the symmetry equivalent atoms. Maximum value is the number of symmetry equivalent atoms corresponding to atomTypeIdx. If the crystal symmetry is higher than , atomIdx is not allowed, since the g-tensor for equivalent atoms will be calculated using the symmetry operators of the space group. Optional.

Output Arguments

The function adds extra entries to the obj.single_ion.g matrix.

See Also

spinw | spinw.addcoupling | spinw.addaniso | spinw.addmatrix