Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content

Fix division by 0 for empty simulations and particle allocation in flattop

liemen_a requested to merge fixNoParticleSimulations into master

Two problems that this merge should fix:

1. Flattop does not allocate particle correctly.

Problem: When running generateParticles(...), pc_m->setLocalNum(0); is not enough to reset the particle count, since it does not recalculate totalNum_m in ippl::ParticleBase.

Solution: Call ParticleBase::destroy(...). When called with localNum_m (so ALL particles are destroyed), it simply resets the counts without additional computation (exactly what we want).

Alternative: Create a setter for totalNum_m, but this would require to change ippl.

2. DistributionMoments class has problem for empty simulations.

Problem: For empty simulations (Np = 0), it will divide by 0 when averaging over all particles. This leads to some values being nan which should be 0 instead.

Solution: Simply do something like Np = (Np == 0) ? 1 : Np; when necessary to divide by 1 instead of 0 whenever moments are calculated.

Merge request reports

Loading