SunnySuite / Sunny.jl

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

Apply g-tensor uniformly to calculated intensities #231

Closed Lazersmoke closed 8 months ago

Lazersmoke commented 8 months ago

This PR adds support for having observable operators (specifically, the operators Sunny computes correlations between) that vary from site to site. As a side effect, it's now easy to support the Magnetization operator, which is the (static) spin vector operator multiplied from the left by a possibly varying site-to-site tensor g-factor.

kbarros commented 8 months ago

Thanks a lot for putting this together. Should we also switch to g=2 for some of the tests in this PR to exercise the new functionality?

Lazersmoke commented 8 months ago

Squishing the last of the bugs now, and for this PR and the other one which updates the intensities scale, I'm doing this sequence:

  1. Keep the old test data unchanged (for now), and do @test new / g_factor^2 == old to make it pass and be correct
  2. Merge, so that line gets in the commit history
  3. Update the test data in a later commit, and then we'll be back to @test new == old

which I think is reasonable.

kbarros commented 8 months ago

Looks good to me. @ddahlbom would you mind also taking a look?

I guess we're waiting on https://github.com/SunnySuite/Sunny.jl/issues/232 before adding a test with a general 3x3 g-tensor?

Lazersmoke commented 8 months ago

232 only impacts 1/4 modes so we can add three tests and a broken test now

kbarros commented 8 months ago

232 only impacts 1/4 modes so we can add three tests and a broken test now

Adding an anisotropic g-tensor into the tests would be great, is that possible now? Could we additionally have Sunny throw an informative error if it detects the unsupported case? "Anisotropic g-tensor is not currently supported when [...]".

Lazersmoke commented 8 months ago

Now closes #232

kbarros commented 8 months ago

This will resolve both https://github.com/SunnySuite/Sunny.jl/issues/236 and https://github.com/SunnySuite/Sunny.jl/issues/232.

kbarros commented 8 months ago

I took a pass through. Is it feasible to augment the testset "Magnetization Observables" with a test that exercises a nontrivial $g$ tensor with dynamical_correlations? Otherwise looks good to me. @ddahlbom you should take a final pass too.