SunnySuite / Sunny.jl

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

Refactor bond-handling code in PairInteractions.jl into new type `BondTable` #11

Closed ColeMiles closed 2 years ago

ColeMiles commented 2 years ago

In the previous code generating pair interactions, and using them to compute energies and fields, there was a lot of difficult-to-read code which mucked around with lists of bonds living on different sublattices.

This PR attempts to consolidate all of that logic into a new (internal) type BondTable, which exposes simple interfaces for iterating over all bonds, the culled bonds, or just those on a certain sublattice.

An additional goal of this refactor is that a single Vector{Bond} is more amenable to being put on the GPU than the Vector{Vector{Bond}} we worked with previously. The CUDA kernels I have been working on depend on this linear layout.

ddahlbom commented 2 years ago

This all looks very clean and sensible to me. All the energy functions are easier to read (and presumably to construct) in this form, and it's nice to have the data packed together.

ColeMiles commented 2 years ago

This all looks very clean and sensible to me. All the energy functions are easier to read (and presumably to construct) in this form, and it's nice to have the data packed together.

Thank you! Glad it seems reasonable.

I had to force-push this branch again following a rebase back onto main (due to the commit fixing plotting issues), but if all the tests pass I guess it's good to go?

kbarros commented 2 years ago

I would personally say "go for it" if you think it's ready. I trust your judgment. Unfortunately I won't be able to read carefully until next week, but at that time I'd like to dig in a bit deeper to the code.