SunnySuite / Sunny.jl

Spin dynamics and generalization to SU(N) coherent states
Other
65 stars 19 forks source link

Add non-local observables #243

Open Lazersmoke opened 4 months ago

Lazersmoke commented 4 months ago

This PR adds support for a new type of observable to be used with SampledCorrelations: a NonLocalObservableOperator. There should probably be error handling and/or support added for the spin wave theory case, where I'm not sure that this type of observable can be used. (This PR implements the functionality only)

The reason for this is to support computing correlations of the form <s_i(t) energy_grad_j(t')> where energy_grad is the gradient of the Hamiltonian with respect to the spins (component index j). This observable is non-site-local because it depends on exchanges with distant sites along bonds. This type of correlation is important for computing classical response functions.

For such non-local observable, the (only) fast way to generally support it is to let the observable be a callback which computes the value on every site at once.

Currently, the NonLocalObservableOperator constructor and energy_gradient_dipole_observable are not exported, but it can be used like this:

observables = [
  :Sx => [1. 0 0], 
  :Sy => [0. 1 0], 
  :Sz => [0. 0 1],
  :A => Sunny.energy_gradient_dipole_observable(1),
  :B => Sunny.energy_gradient_dipole_observable(2),
  :C => Sunny.energy_gradient_dipole_observable(3),
  :dipoleNorm => Sunny.NonLocalObservableOperator(sys -> norm.(sys.dipoles))]

dsc = dynamical_correlations(sys;Δt = 0.05, nω = 600, ωmax = 1.0, observables)

which results in the usual x,y,z spin (not magnetization) observables, plus the three components of the energy gradient, plus the dipole sector norm being available to compute correlations between.