Closed zahachtah closed 1 year ago
I think you know that already, but you can provide an array of radii using a closure. For example:
julia> using CellListMap.PeriodicSystems
julia> using StaticArrays
julia> x = rand(SVector{2,Float64}, 10^3); radius = 0.1*rand(10^3);
julia> function f(i,j,d2,out,radius)
if sqrt(d2) < radius[i] + radius[j]
out += d2
end
return out
end
f (generic function with 1 method)
julia> map_r(sys,radius) = map_pairwise((x,y,i,j,d2,out) -> f(i,j,d2,out,radius), sys)
map_r (generic function with 1 method)
julia> map_r(sys,radius)
54.23996361943458
If, on the other side, there are groups of particles with very wide varying radii, it may be interesting to split the computation into different cell lists, using the interface that accepts two sets of particles. That would be more low level, and may be important if for instance there is a smalls subset of particles with a larger radius, such that computing their interactions separately could be useful.
Yes, I do something like that now, but that does not save f function calls. Was looking at the code for how you do the neighborlist if it would be possible to make that list dependent on per ”particle” reaktion distance. But its a niche thing so don’t put any effort into it :-) But I might tinker a little!
Hi Again, one more question:
particles in biology are organisms with varying traits. This means for example, that in a spatial food web simulation the distance at which an organisms reacts to another organism is dependent on .e.g. the organism size and can vary very much.
If I run a model with CellListMaps I now need to put the maximum reaction distance of all organisms as cutoff and then implement a per organism condition in the function that gets called by map_pairwise! to account for different reaction distances.
I see that cutoff in e.g. PeriodicSystem is of type number. But would it be possible to optionally provide an array of per particle reaction distances that sets the cutoff per organism/particle?