StructArrays creating a lot of allocations compared to arrays

StructArray is an abstract type.
So, you have to parameterize the SimulationArrays struct to make atom_arrays have a concrete type:

mutable struct SimulationArrays{S<:StructArray}
    atom_arrays::S
    other_stuff::Float64
end

Or you can wrap the double loop in total_lj_force(::SimulationArrays, ...) in a function operating on simulation_arrays.atom_arrays.r and forces.

3 Likes