SpiDy.jl: open-source Julia package for the study of non-Markovian stochastic dynamics

SpiDy.jl solves the non-Markovian stochastic dynamics of interacting classical spin vectors and harmonic oscillator networks in contact with a dissipative environment. The methods implemented allow the user to include arbitrary memory effects and colored quantum noise spectra. In this way, SpiDy.jl provides key tools for the simulation of classical and quantum open systems including non-Markovian effects and arbitrarily strong coupling to the environment. Among the wide range of applications, some examples range from atomistic spin dynamics to ultrafast magnetism and the study of anisotropic materials. We provide the user with Julia notebooks to guide them through the various mathematical methods and help them quickly set up complex simulations.


Statement of need
The problem of simulating the dynamics of interacting rotating bodies and harmonic oscillator networks in the presence of a dissipative environment can find a vast range of applications in the modeling of physical systems.This task is rendered particularly challenging when one desires to capture the non-Markovian effects that arise in the dynamics due to strong coupling with the environment.SpiDy.jl is a library that allows the user to efficiently simulate these systems to obtain both detailed dynamics and steady state properties.
A relevant example of the applicability of SpiDy.jl is the modeling of spins at low temperatures and at short timescales, which is a fundamental task to address many open questions in the field of magnetism and magnetic material modeling (Halilov et al., 1998).State-of-the-art tools such as those developed for atomistic spin dynamics simulations are based on solving the Landau-Lifshitz-Gilbert (LLG) equation (Evans et al., 2014).Despite their massive success, these tools run into shortcomings in accurately modeling systems at low temperatures and for short timescales where environment memory effects have been observed (Ciornei et al., 2011;Neeraj et al., 2020).Recent work has focused on developing a comprehensive quantumthermodynamically consistent framework suitable to model the dynamics of spins in magnetic materials while addressing these shortcomings (Anders et al., 2022).This framework includes strong coupling effects to the environment such as non-Markovian memory, colored noise, and quantum-like fluctuations.At its core, SpiDy.jlimplements the theoretical framework introduced in Anders et al. (2022), allowing for the study of environment memory effects and anisotropic system-environment coupling.SpiDy.jlcan be readily adopted for atomistic spin dynamics simulations (Barker & Bauer, 2019;Evans et al., 2014), ultrafast magnetism (Beaurepaire et al., 1996), and ferromagnetic and semiconductive systems exhibiting anisotropic damping (Chen et al., 2018).A further set of applications stems from the extension of SpiDy.jl to handle the non-Markovian stochastic dynamics of harmonic oscillators.This model will be of interest in the field of quantum thermodynamics where harmonic oscillators play a key role in modeling open quantum systems.The package is written in pure Julia and we take advantage of the efficient DifferentialEquations.jlpackage (Rackauckas & Nie, 2017) by reducing evaluation redundancy, using callbacks, and pre-allocations.
The software package has seen a wide range of applications to date.Firstly, the convenience of three independent environments in SpiDy.jlfinds application in the microscopic modeling of spins affected by noise due to vibrations of the material lattice (Anders et al., 2022).SpiDy.jl also found application in the demonstration of the quantum-to-classical correspondence at all coupling strengths between a spin and an external environment (Cerisola et al., 2024).Here, the temperature dependence of the spin steady-state magnetization obtained with SpiDy.jl is successfully compared with the classical mean force state of the system.Hartmann et al. ( 2023) take advantage of the customizable coupling tensor in SpiDy.jl to explore the anisotropic effects of the environment on the system.Berritta et al. (2023) use SpiDy.jl as a sub-routine to build quantum-improved atomistic spin dynamics simulations.In the paper, the authors take advantage of the customizable power spectrum to implement ad-hoc simulations matching known experimental results.Lastly, with an eye to the harmonic oscillator side, SpiDy.jl is used to match the quantum harmonic oscillator dynamics with its stochastic counterpart (Hogg et al., 2024).Here, the authors exploit the recent implementation of harmonic oscillator dynamics.

Overview
To model a system of interacting classical spin vectors, SpiDy.jlsolves the generalized stochastic LLG equation (Anders et al., 2022) dS  () where S  () represents the -th spin vector, the interaction matrix  , sets the interaction strength between the -th and -th spins, B is the external field, which determines the natural precession direction and frequency of the spins in the absence of interaction, and   () is the time-dependent stochastic field induced by the environment.Finally, the last integral term in Eq.( 1) gives the spin dissipation due to the environment, including non-Markovian effects accounted for by the memory kernel matrix   ().In addition, SpiDy.jl also allows to study the stochastic dynamics of coupled harmonic oscillator networks in a form similar to Eq.(1).
In conclusion, SpiDy.jlimplements the stochastic dynamics of coupled integro-differential equations to model systems of interacting spins or harmonic oscillator networks subject to environment noise.Among others, some of the key features of the package include: • Coloured stochastic noise that satisfies the FDR and accounts for both classical and quantum bath statistics.• Simulation of non-Markovian system dynamics due to the memory kernel   ().
• Custom system-environment coupling tensors, allowing for isotropic or anisotropic couplings.Both amplitudes and geometry of the coupling can be specified.• Choice between local environments, i.e. distinct baths acting on the single sub-system, or a single common environment.
We show an example run of the stochastic trajectories in the case of a single spin in Figure 1.
The code used to generate this example can be found in the GitHub repository of SpiDy.jl.1)).We show an example set of 5 stochastic trajectories of the spin dynamics (colored semi-transparent lines) together their stochastic average (gray solid line).Note that, while we show only 5 trajectories for clarity, the average dynamics is obtained from 10000 trajectories.We also represent the range of one standard deviation from the average dynamics (gray-shaded area).In the inset, we show the convergence of the same dynamics towards the steady state at longer times.This example is obtained using the Lorentzian parameters "set 1" obtained from Anders et al. (2022).The code used to generate the stochastic trajectories is included in the GitHub repository.

Figure 1 :
Figure 1: Single-spin dynamics.Dynamics of the , , and  spin components.The components are normalized against the total spin length  0 and time axes are expressed in units of the Larmor frequency  L ( L = |B| in Eq.(1)).We show an example set of 5 stochastic trajectories of the spin dynamics (colored semi-transparent lines) together their stochastic average (gray solid line).Note that, while we show only 5 trajectories for clarity, the average dynamics is obtained from 10000 trajectories.We also represent the range of one standard deviation from the average dynamics (gray-shaded area).In the inset, we show the convergence of the same dynamics towards the steady state at longer times.This example is obtained using the Lorentzian parameters "set 1" obtained fromAnders et al. (2022).The code used to generate the stochastic trajectories is included in the GitHub repository.