Skip to content

More consistent boxgrid

Philip Bittihn requested to merge boxingtweaks into dev

Improvements/bugfixes in boxgrid:

  1. (very minor) Initialization happened with vectors of Int instead of the actual particle type. I think this causes reallocation on constructing the actual struct, right? This is fixed here.
  2. I am not sure if we rely anywhere on particles outside the boxgrid being intentionally excluded from force calculation, but if we do, I think it's a bad idea (it would break equivalence between boxing and no-boxing simulations). I assume that we don't and that we can just consider it an error if no suitable box can be found for a particle. It should never happen if the grid is correctly constructed and the model makes sure to never produce any particles with positions outside the domain (including removing them immediately). So making it an error also happens in this MR.

Later discovered: It turns out we did not strictly adhere to point number 2, which causes some interactions to be missed in simulations with boxing: The problem is that new particles are added in the main loop using flushadditions, but folding back the positions already happened. Hence, for a single time step, the new particles could potentially be outside the domain (and were skipped from the force calculation if boxing was used!). I fixed this now by splitting up the loop, but there might be better ways to do it, input is appreciated.

Merge request reports