espresso icon indicating copy to clipboard operation
espresso copied to clipboard

Particle counter per type broken

Open fweik opened this issue 5 years ago • 5 comments

There is a mechanism for tracking the number of particles per type in the head node particle data interface. This does so by tracking type changes thru the front end, but does not register type/particles changes from other places e.g. by collisions. This count is used in the reaction ensemble (and exposed to the user), and wrong counts can lead to wrong results. There are concrete plans to use RE and reactions/collision together, so this has to be fixed.

The preferred way to fix this by calculating the particles counts on demand in the reaction ensemble on the front end, where also all the global information is available. I think the state tracking to brittle, and generally not a good idea.

fweik avatar Feb 17 '20 21:02 fweik

Was #3495.

fweik avatar Feb 17 '20 21:02 fweik

The preferred way to fix this by calculating the particles counts on demand in the reaction ensemble on the front end

What mechanism do you have in mind? The current state tracking is of O(1) and avoids looping over all particles to determine the number of particles of a given type. This state tracking, therefore, is fast compared to looping over all particles and reading their type which is O(N).

jonaslandsgesell avatar Feb 17 '20 22:02 jonaslandsgesell

It has to be calculated once when the control transfers to the RE, then the changes done by the RE itself can be tracked without recounting. A linear term is no problem, considering that the RE e.g. also does linear searches for neighbor distances when inserting as well as energy calculations which are more expensive. Also I'm sure there are even faster methods to obtain an incorrect result :-)

fweik avatar Feb 18 '20 13:02 fweik

In addition, particles of type 0 created with system.part.add(pos=[1, 2, 3]) cannot react, because they are not tracked by the particle map (#4588). All ESPResSo versions since 4.0.0 are affected by this bug.

jngrad avatar Oct 07 '22 16:10 jngrad

The particle map is not cleared when the list of particles is cleared (#4645).

jngrad avatar Jan 09 '23 19:01 jngrad