Closed mantzaris closed 1 year ago
The crash is actually due to the size of the underlying grid, don't use sizeof
since the function doesn't recursively sum the necessary memory involved, use Base.summarysize
instead. In the latest case you are actually trying to do something like this:
function Grid(d::NTuple{D,Int}) where {D}
stored_ids = Array{Vector{Int},D}(undef, d)
for i in eachindex(stored_ids)
stored_ids[i] = Int[]
end
return stored_ids
end
Grid((1000,1000,1000)) # on my computer this requires more than 12GB of RAM and takes a very long time
since the spacing in initialize(extent=(10^(3),10^(3),10^(3)),num_He_atoms=1001, min_He_distance=2)
is equal to 1 while in the other cases the spacing is equal to 10 which creates under the hood a grid of 100x100x100, which is much more manageable.
So you need to change this line spacing_model = 10^( floor( log10(inter_atomic_distance) ) ) * 0.1
to something else
But you are actually posing another issue, so feel free to submit a new one related to this instead: Is it possible to use a sparse representation of the discrete spaces with SparseArrays
? This way we coud manage with less RAM larger grids in some cases (at the expense of some speed)
Julia version v"1.9.3" Agents v5.17.1
code:
I try to create 10 agents, 100, 1000, ok, but once I try to create 1001 agents, Crash!