An accurate and efficient general method to constrain the magnetization of individual atoms or groups of atoms within a fully relativistic non-collinear spin density functional theory formalism is presented and implemented within the SIESTA code. This approach can be applied to study a variety of complex magnetic configurations and to build effective magnetic Hamiltonians for multiscaling micromagnetic simulations. As an example, the method is applied to obtain constrained magnetic states for a Fe 3 structure, and for a S=1/ 2 kagome layer (vanadium oxyfluoride V 7 O 6 F 18 ). Of paramount importance in spintronics is the control and manipulation of magnetic interactions between constituent species, characterized mainly by the pair-wise magnetic exchange tensor ij . By constraining the atomic magnetizations of an infinite Fe linear chain, the total selfconsistent energy values are mapped to a generalized Heisenberg model, obtaining not only the diagonal terms of ij but also the off-diagonal contributions due to the explicit presence of the spin-orbit coupling in the formalism. The diagonal values of ij promote short ranged ferromagnetic alignment whilst the non-zero off-diagonal values can lead to the formation of the spiral states in the chain, as expected from theory.