Closed kbarros closed 1 year ago
At the types level, the main difference is that System.interactions_union
now stores a union, which is either Vector{Interactions}
or Array{Interactions, 4}
. Which one determines the "mode" (homogeneous or inhomogeneous).
https://github.com/SunnySuite/Sunny.jl/blob/inhomogeneous/src/System/Types.jl#L56
There is now a function is_homogeneous
to query this mode:
https://github.com/SunnySuite/Sunny.jl/blob/inhomogeneous/src/System/Interactions.jl#L20
To minimize code duplicated, this PR refactors various functions. For example, energy
now calls energy_aux
, which loops over contributions for a list of cells. In the case of inhomogeneous cells, the list of cells has only one cell at a time:
https://github.com/SunnySuite/Sunny.jl/blob/inhomogeneous/src/System/Interactions.jl#L204
This PR introduces a new function
new_sys = to_inhomogeneous(sys)
. The new systemnew_sys
is a copy ofsys
that allows inhomogeneous interactions. The new system supports functions likeset_exchange_at!
which sets an exchange interaction on just a single bond, ignoring symmetry and symmetry propagation.