JuliaMolSim / EmpiricalPotentials.jl

Empirical interatomic potentials with Julia, AtomsBase and AtomsCalculators
MIT License
2 stars 0 forks source link

(Weak?) Type Instability SitePotential Implementation #11

Closed cortner closed 1 month ago

cortner commented 2 months ago

The SitePotential implementation using Folds accumulates into a vector containing three different kinds of objects, T, Vector{SVector{3, T}}, SMatrix{3, 3, T}.

   E_F_V = Folds.sum(
      collect(chunks(domain, ntasks)), 
      executor;
      init=[zero(V), AtomsCalculators.zero_forces(at, V), zero(SMatrix{3, 3, typeof(zero(V))})]
   ) do (sub_domain, _)

I immagine that this falls within the range of a short Union that the compiler can still handle. But I wonder whether there is a better way that avoids the type instability entirely. What about using ComponentArrays here? Also a bit more readable.

cortner commented 1 month ago

this still bugs me but it has moved to AtomsCalculatorsUtilities so can be closed here.