SunnySuite / Sunny.jl

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

Support Asymmetric Correlations #174

Closed Lazersmoke closed 9 months ago

Lazersmoke commented 1 year ago

Out of equilibrium, correlations <A(t) B(0)> and <B(t) A(0)> are different; https://journals.aps.org/prl/pdf/10.1103/PhysRevLett.131.077101

This PR adds support for asking Sunny for these asymmetric correlations. In the LSWT case, this does nothing because the Sab tensor is explicitly symmetric there (for now).

In the classical case, this PR makes two changes:

  1. The correlations no longer "loop around" using the periodization of the fourier transform convolution. Previous to this PR, the computed correlation was a linear combination of <B(0) A(t)> + <B(0) A(t - T)> where T is the length of the sample trajectory, and t < T. Thus, the A -> B and B -> A correlations were mixed up. This PR resolves this by padding the B trajectory with zeros, performing the convolution, then trimming the padding (which now contains unphysical loop-around artifacts). This is not optimized yet
  2. Changes the observables interface by allowing e.g. both (Sx,Sy) and (Sy,Sx) correlations, and no longer assuming hermitian Sab anywhere. Additionally, a new mode :all_available is allowed, which is documented and comes with flavor text explaining the order of the correlations within the vector of correlations that is returned. This is mainly to allow users to ask for (Sx,Sy) and (Sy,Sx) correlations easily without requiring a custom intensity formula and without computing all 9 correlations. By default now, all 9 3x3 dipole-dipole correlations are computed, since they are generally different. Having an asymmetric Sab tensor means that you are out of equilibrium, and is one way to recognize that Langevin didn't do what you wanted

There is a test now which compares the new method of correlation calculation to an FFT-less reference computation.

kbarros commented 1 year ago

Overall this looks good to me. There is a failing test on line 6 of test_correlations.jl due to I not being defined?

    sc = dynamical_correlations(sys; Δt = 0.1, ωmax = 10.0, nω=100, observables = [:A => I(2), :B => I(2)])
Lazersmoke commented 1 year ago

Lets discuss at the meeting: Are these the correct correlations to be computing? I think that they are but I'm still in the process of verifying this myself. In particular, how are correlations at negative times to be treated (currently, see below, all correlations are at positive times)? This can be very relevant for glassy systems.

https://github.com/SunnySuite/Sunny.jl/blob/70c7aaedeaadf92a50ccecbb383ddfb82baf3e9e/test/test_correlation_sampling.jl#L31-L38

Lazersmoke commented 1 year ago

Ok, status update on this PR:

Those bolded points should be addressed before merging.

changes to BandStructure, which I need as hooks for susceptibility code, but which are also relevant here due to the 2pi factor change (which is conceptually about what are the semantics of BandStructure/"the residues")

Other stuff that's in this PR due to churn but is helpful and should stay:

Lazersmoke commented 12 months ago

This is ready to merge in my opinion!

kbarros commented 12 months ago

If this works like we're hoping then we can get rid of process_trajectory kwarg, e.g., these docs.

- `process_trajectory`: Specifies a function that will be applied to the sample
    trajectory before correlation analysis. Current options are `:none` and
    `:symmetrize`. The latter will symmetrize the trajectory in time, which can
    be useful for removing Fourier artifacts that arise when calculating the
    correlations.
kbarros commented 12 months ago

After the Zoom call, my understanding is that the normalization of LSWT intensities is exactly unchanged, but we need to verify the normalization of intensities from classical dynamics. Specifically, is there a test of the sum rule? Also, if the overall scaling factor is changing anywhere for intensities, we need to document this as a breaking change in versions.md

ddahlbom commented 12 months ago

Thanks for making all these revisions. I'll spend some time with this tomorrow (run some tests, make sure I understand more of the details). This seems like a neat approach.

Lazersmoke commented 9 months ago

Closing in favor of #217