spatial domain. Information about the number of migrating particles, and the processors that they will migrate into, is collected at each processor. The Pencil Code would then let all processors exchange migrating particles with all other processors. In practice particles would of course only migrate to neighbouring processors. However, at processor numbers of 512 or higher, the communication load associated with each processor telling all other processors how many particles it wanted to send (mostly zero) was so high that it dominated over both the MHD and the particle evolution equations. Since particles in practice only migrate to the neighbouring processors any way, we solved this problem by letting the processors only communicate the number of migrating particles to the immediate neighbours. Shear-periodic boundary conditions require a (simple) algorithm to determine the three neighbouring processors over the shearing boundary in the beginning of each sub-time-step.

Timings
-------

With the changes described in Sect. \[s:memory\] and Sect. \[s:parmig\] the Pencil Code can be run with gas and particles efficiently at several thousand processors, provided that the particles are well-mixed with the gas.

  Run    $L_x \times L_y \times L_z$   $N_x \times N_y \times N_z$   $\nu_3=D_3=\eta_3$    $B_0$        $\beta$      $\Delta v$   $\tilde{G}$   $\Delta t$   