From iffwiki
Jump to navigation Jump to search

The Spirit Atomistic Spin Code is a Open Source Spin Dynamics Code developed in large part at the PGI-1 at Forschungszentrum Jülich (FZJ). It simulates the dynamics of magnetic structures and provides optimization tools for studying transitions and energy landscapes. Noteably, this code provides live visualisations and data plots during simulations. This is a descriptive article, details about the code's implementation can be found under Spirit Code Structure.

The code is hosted on GitHub:

Spirit's Web UI can be found hosted at http://iffwww.iff.kfa-juelich.de/pub/spiritdemo/ (it does not require any installation on the user's side).

Distinguishing features

  • Portability
  • Modularity and extensibility
  • Few external dependencies
  • Desktop User Interface with live visualisation
  • Web interface for e.g. education and portable presentations
  • Accessibility from different programming languages through C API

This code is written in platform-independent C++ and utilizes a modular class structure to enable flexible workflows. The build process is platform-independent as well, due to the use of CMake. This code has been tested on Windows 7 and 10, OSX Yosemite and upwards and various Linux systems including Ubuntu, Arch and CentOS 6. It should run on most other machines as well.

A main focus of the core library is the independence from third party libraries which the user would need to install. It was thus written such that it can be easily integrated into existing CMake projects without adding further dependencies.

A Desktop User Interface (UI) has been written, using QT and OpenGL, enabling the live visualisation of simulation data, including spins and energy gradients. Charts help to visualise the current state with energy plots, including interpolated energies for transitions. For use on clusters or e.g. when a graphical user interface is not needed, the core library can be scripted from Python or Julia. Alternatively, a C++ console version is available, where the user can easily modify the main.cpp to suit his needs.

For less scientific needs (where quantitative results play a minor role), a web interface is available. It runs in most regular browsers and even on some mobile browsers. For this the core library is transpiled to JavaScript using Emscripten (see also here).

Due to the modular structure and the highly portable core library, a wide variety of further UIs are theoretically possible.

Use Cases

Visualise without optimisation

  • e.g. Magnetic field, Effective field, Spin configuration, …
  • Read in from File or create states from UI

Spin Dynamics Simulations (LLG Solvers)

  • Choice of Hamiltonian (Isotropic, Anisotropic, non-heisenberg?, …) for Eff. Field and Energy
  • Choice of Force (pure eff. Field, projections, …)
  • Choice of Optimizer (SIB, Heun, Conj. Gradient, …) and corresponding Parameters. These should take a spin configuration and a force and do one optimisation iteration
  • Run on a single image (choice of single image)
  • Run on an image and save periodically into a chain


  • Choice of Hamiltonian for eff. Field and energy
  • Choice of Force (pure eff. Field, projections, spring forces, …)
  • Choice of Optimizer for single images (Heun, …)
  • Run on an image chain (choice of subset of image chain on which to iterate)


  • Run on a collection of image chains, where each chain is built by saving the corresponding image periodically

Image Gallery

Code Dependencies

This is one of the topics, where the Readme is quite comprehensive. Note that you may need to build QT yourself. You may follow this guide: Building_QT.

Future connections

Related Codes

Micromagnetic codes

Micromagnetics is quite different from atomistic spin treatments, but there is a significant overlap. A few examples of micromagnetic codes:

File I/O and User Input

User Input

  • Manipulate visualisation
  • Change Parameters of Simulations
  • Start and Stop Simulations

File Output

  • Code version and “run” information, e.g. version nr., initial state used, …
  • Energies (.dat and .csv output file formats)
  • Configurations, Atom Positions, Neighbours(.dat output format)
  • Vector field (B-field, effective field)
  • Video Capture

File Input

  • Basis (Atom positions)
  • Shape (Basis translations)
  • Interaction constants (J_ij, D_ij, …)
  • General constants (RNG Seed, …)
  • modular input of Neighbours, spins, spin_pos and so on