class FixedSpin(spin_directions=None, fixed_spin_energy=None)

Class for representing a fixed spin configuration.

The spins are fixed by adding an energy penalty on given atoms if their spins are not aligned with the desired direction.

  • spin_directions (list of tuple of (int | PeriodicTableElement, PhysicalQuantity of type angle, PhysicalQuantity of type angle)) – The fixed spin direction for each atom should be given as a tuple with three numbers, corresponding to the atom index and the spherical coordinates theta and phi defining the direction. Alternatively, the spin directions can also be given by element.
    Default: (index, 0.0 * Degrees, 0.0 * Degrees) for each atom
  • fixed_spins_energy (PhysicalQuantity of type energy) – Scaling of the energy penalty if the spins are not aligned with the fixed spin direction.
    Default: 5.0 * eV
Returns:The fixed spin energy
Return type:PhysicalQuantity of type energy

Usage Examples

Setup a FixedSpin object using atom indices:

fixed_spin = FixedSpin(spin_directions=[(0, 60*Degrees, 30*Degrees),
                                        (2, -45*Degrees, 330*Degrees)])

Setup a FixedSpin object by element:

fixed_spin = FixedSpin(spin_directions=[(Hydrogen, 90*Degrees, 30*Degrees),
                                        (Carbon, 54*Degrees, 300*Degrees)])

The following example demonstrates how to run a calculation with the FixedSpin object for a chromium dimer. Note that the chosen parameters might not necessarily represent a physically relevant calculation.


If FixedSpin is used in conjunction with InitialSpin, the latter should define collinear spin directions for all atoms in the system.

 # Define the elements and coordinates.
elements = [Chromium, Chromium]
cartesian_coordinates = [[0.0, 0.0, 0.0],
                         [0.0, 0.0, 1.77]]*Angstrom

# Set up the Cr dimer configuration.
configuration = MoleculeConfiguration(

# Set up an LCAO calculator with non-collinear spin and
# the LDA exchange-correlation.
calculator = LCAOCalculator(

# Set an initial spin of 1.0 in the direction (theta, phi) = (0, 0).
spin_list = [
    (0, 1.0, 0*Degrees, 0*Degrees),
    (1, 1.0, 0*Degrees, 0*Degrees)
initial_spin = InitialSpin(scaled_spins=spin_list)

# Set the spin to be fixed in the direction (theta_0, phi_0) = (0, 0)
# for the first atom and in the direction (theta_1, phi_1) = (15 Degrees, 0)
# for the second atom.
theta_0_fixed = 0*Degrees
theta_1_fixed = 15*Degrees
fixed_spin_list = [(0, theta_0_fixed, 0*Degrees), (1, theta_1_fixed, 0*Degrees)]
fixed_spin = FixedSpin(spin_directions=fixed_spin_list, fixed_spin_energy=5*eV)

# Set the fixed spins as a local magnetic field.

# Set the calculator on the configuration and run the calculation.
configuration.setCalculator(calculator, initial_spin=initial_spin)