SpinDynamica is a set of packages for spin dynamical calculations in Mathematica.  The software is intended as a useful tool for both analytical and numerical calculations in spin physics, in particular the spin dynamics encountered in magnetic resonance.


SpinDynamica includes routines for

• deriving and manipulating the matrix representations of nuclear spin operators, in arbitrary Hilbert space bases. There are routines for spin angular momentum operators, product operators, singlet-triplet bases, single transition operators, etc.

• deriving and manipulating the matrix representations of nuclear spin superoperators, in arbitrary Liouville space bases. Includes commutation superoperators, double commutation superoperators, coherence order filtration superoperators, and relaxation superoperators, which may be thermalized to provide the correct thermal equilibrium states.

• performing numerical and symbolic spin dynamics simulations of arbitrary pulse sequences or sequences of time-dependent events, including evolution under arbitrary spin Hamiltonians, arbitrary spin Liouvillian superoperators, arbitrary time-dependent functions of Hamiltonians or Liouvillian superoperators, and any combination of these. These routines allow trajectory tracing for any set of nuclear spin observables under arbitrary sequences of events. As default, numerical calculations are generated by Liouville-space evolution calculations employing the in-built Mathematica tools for numerical solution of differential equations (options for using diagonalisations and matrix exponentials are provided as well).

• useful packages for Euler angles, reference frame transformations, Wigner matrices, Clebsch-Gordon coefficients, quaternions.

• some useful 3D graphical objects and routines for visualizing rotations.

• manipulations of data, including one and two-dimensional Fourier transforms, presented according to common NMR conventions.

Malcolm Levitt’s research group uses these routines extensively to explore magnetic resonance concepts and develop new experimental methods.  We expect them to be useful for the wider community as well.  Mathematica is well-known as a powerful tool for symbolic mathematics but in its latest versions it is also becoming a serious tool for large-scale numerical mathematics as well.  In particular, parallelization of tasks has been implemented in Mathematica 7.0.  Using SpinDynamica for spin dynamical simulations provides immediate access to all of these features as well as the well-known symbolic and graphical features of Mathematica.

SpinDynamica is probably not as fast for numerical simulations as purpose-built lower-level routines such as SIMPSON and SPINEVOLUTION, although thorough head-to-head tests have not yet been done. However, it is much more general and optimized modules for specific numerical tasks, such as approximate large-spin-system simulations, may be developed in the future.

In its current state (2014), SpinDynamica allows acceptably fast numerical simulations for up to about 5 coupled spins-1/2, including arbitrary time-dependent Hamiltonians and relaxation superoperators.   This is an on-going project and will continue to be developed over many years. Packages for assembling pulse sequences, spin Hamiltonians and relaxation superoperators are under development and will be released over time. More efficient powder averaging for solid-state NMR, and the incorporation of chemical exchange, are under preparation. Multidimensional spectroscopy if not yet fully implemented, as well. It takes some time to ensure that these features are implemented with full generality!

About SpinDynamica

What is SpinDynamica? SpinDynamica is a set of packages for Mathematica, programmed by Malcolm Levitt, with recent input from Andreas Brinkmann, Jyrki Rantaharju and Soumya Singha Roy.  The software provides a useful tool for both analytical and numerical calculations in spin physics, in particular the spin dynamics encountered in magnetic resonance. • SpinDynamica’s terms of …

View page »


SpinDynamica is programmed mainly by Malcolm Levitt. Additional code and assistance has been provided by: Jyrki Rantaharju (speed enhancements) Andreas Brinkmann (parallelization and powder averaging). Soumya Singha Roy (isotope data)  

View page »

Terms of Use

SpinDynamica is open-source and freely available for use. For published work, please cite the following publication on SpinDynamica: C. Bengs, M. H. Levitt, SpinDynamica: Symbolic and numerical magnetic resonance in a mathematica environment, Magn Reson Chem, 2017, DOI: 10.1002/mrc.4642 If you use one of the add-ons, please credit the author(s) of that as well. If …

View page »

System requirements

SpinDynamica runs on any platform supporting Mathematica 8, with an appropriate license. SpinDynamica will probably run under Mathematica 9, but has not yet been tested in that environment. SpinDynamica 2.6.0 and later implement automatic parallelization of ensemble averages over all available kernels on the current platform.    

View page »

Set Up

To use SpinDynamica, download and unzip the zip file available from the link at the top entry of the Download page. Place the packages wherever you want on your computer. You need to tell Mathematica where the packages are by executing the following instruction: This instruction may be placed either as the first line of …

View page »

Add Ons

An “add-on” refers to a Mathematica package which uses SpinDynamica but which is not included in the SpinDynamica release. You can submit your own add-on!  To learn more, read our add-on submission guidelines Currently available add-ons: AdiabaticTools by Christian Bengs. S(n)/SO(3) dual pairing by Christian Bengs. MatrixPlot3D by Michael Tayler SymmetryBasedRecouplingAnalysis by Andreas Brinkmann and Malcolm Levitt. …

View page »

Submit an Add-on

Our aim is to have SpinDynamica community members share Mathematica code as “add–ons“, in order to enhance functionality not yet incorporated into the main SpinDynamica release. Examples of current add–ons: • Graphical representation of pulse sequences • Tools to visualise matrices in 3D • Data import and processing routines for common spectrometer platforms Submitting an …

View page »