generates magnetic structure GENMAGSTR(obj, 'option1', value1 ...) There are several ways to generate magnetic structure. The selected method depends on the 'mode' option, see below. The magnetic structure is stored in the obj.mag_str field. Input: obj sw class object. Options: mode Mode how the magnetic structure is generated. 'random' generates random spin directions with zero k. 'direct' direct input of the magnetic structure from the S, k, n parameters. 'extend' Simply extend the existing or input structure (param.S), if no structure exists, random structure is generated. If defined param.S is used as starting structure for extension. If the starting structure is already extended with other size, the spins in the original unit cell are used. Magnetic ordering wavevector k will be set to zero. To generate structure with non-zero k, use 'helical' or 'direct' option. (default) 'helical' generates helical structure, starting structure is defined by param.S, the normal vector of rotation is stored in param.n, the ordering wavevector is stored in param.k. If param.S is complex, it is used as basis vectors to generate magnetic structure according to the following formula (param.n value then omitted): M_i(r) = R(2*pi*km*r)*M_i. where M_i vectors are defined in param.S. It has to contain either 1 spin direction or as many as the number of magnetic atoms in the crystallographic unit cell. In the first case, the r position is the atomic position, in the second case r is the lattice translation vector of the crystallographic cell where the moment directions are calculated. 'rotate' uniform rotation of all magnetic moments with a param.phi angle around the param.n vector. If param.phi=0, all moments are rotated so, that the first moment is parallel to param.n vector in case of collinear structure or in case of planar structure param.n defines the normal of the plane of the magnetic moments. 'func' function that defines the magnetic moments, ordering wave vector and normal vector from parameters in the following form: [M, k, n] = @(x)func(M0, x) where M is matrix with dimensions of [3 nMagExt]. k is the ordering wave vector, its size is (1,3). n is the normal vector of the spin rotation plane, its dimensions are [1 3]. The default is @gm_spherical3d. For planar magnetic structure use @gm_planar. Only param.func and param.x have to be defined for this mode. 'fourier' generate magnetic structure from Fourier components, usefull for multi-k structures. It creates a magnetic supercell that incorporates the magnetic structure using the following equation: S_{l,j} = sum_k F(k)_j*exp(-i*k*l) Where the summation runs over all given k-vectors, S_{l,j} is the direction of the ordered moment of the l-th unit cell, j-th atom. The size of the generated supercell is determined by the 'nExt' option. The 'Fk' option gives the Furier components and the k-vectors in a cell in the following structure: {Fk1 k1 Fk2 k2 ...} The Fk1, Fk2 etc are complex matrices that contain the Fourier compoents on every magnetic atom in the crystallographic unit cell. They have a dimension of [3 nMagAtom]. The k1, k2 etc are k-vectors of the Fourier compoents, with dimensions of [1 3]. Since the generated magnetic structures have to be real, the -k compoents are automatically added: F(-k) = conj(F(k)). Example input: {[1 -1;i1 -i1;0 0] [1/2 0 0] [1 -1;0 0; i1 -i1] [0 1/2 0]} This gives a double k structure for a lattice with two magnetic atoms in the unit cell.The Fourier compoents are by default in the xyz coordinate system but if 'unitS' is set to 'lu', than the moment components are assumed to be in lattice units. phi Angle of rotation of the magnetic moments in rad. Default value is 0. nExt Number of unit cell to extend the magnetic structure, dimensions are [1 3]. Default value is stored in obj. If nExt is a single number, then the size of the extended unit cell is automatically determined from the magnetic ordering wavevector. If nExt = 0.01, then the number of unit cells is determined so, that in the extended unit cell, the magnetic ordering wave vector is [0 0 0], within the given 0.01 error. k Magnetic ordering wavevector in r.l.u., dimensions are [1 3]. Default value is defined in obj. n Normal vector to the spin rotation plane, dimensions are [1 3]. Default value [0 0 1]. S Direct input of the spin values, dimensions are [3 nSpin]. Every column defines the S_x, S_y and S_z components of the moment in the xyz Descartes coodinate system. Default value is stored in obj. Fk Fourier compoents for a multi-k magnetic structure in a cell. For description, see the 'fourier' mode description above. No default value, it has to be defined if 'mode' is 'fourier'. unitS Units for S, default is 'xyz', optionally 'lu' can be used, in this case the input spin components are assumed to be in lattice units and they will be converted to the xyz coordinate system. epsilon The smalles value of incommensurability that is tolerated without warning. Default is 1e-5. func Function that produce the magnetic moments, ordering wave vector and normal vector from the param.x parameters in the following form: [M, k, n] = @(x)func(M0,x) where M is (3,nMagExt) size matrix. k is the ordering wave vector, its size is (1,3). n is the normal vector of the spin rotation plane, its dimensions are [1 3]. The default is @gm_spherical3d. For planar magnetic structure use @gm_planar. x0 Input parameters for param.func function, dimensions are [1 nx]. norm Set the length of the generated magnetic moments to be equal to the spin of the magnetic atoms. Default is true. r0 If true and only a single spin direction is given, the spin phases are determined by atomic position times k-vector, while if it is false, the first spin will have zero phase. Output: The obj.mag_str field will contain the new magnetic structure. Example: USb = sw; USb.genlattice('lat_const',[6.203 6.203 6.203],'angled',[90 90 90],'sym','F m -3 m') USb.addatom('r',[0 0 0],'S',1) FQ = {[0;0;1+1i] [0 0 1] [0;1+1i;0] [0 1 0] [1+1i;0;0] [1 0 0]}; USb.genmagstr('mode','fourier','Fk',FQ,'nExt',[1 1 1]) plot(USb,'range',[1 1 1]) The above example creates the multi-q magnetic structure of USb with the FQ Fourier components and plots the magnetic structure. See also SW, SW.ANNEAL, SW.OPTMAGSTR, GM_SPHERICAL3D, GM_PLANAR.