The PIC method is widely used for kinetic plasma simulation. It tracks large numbers of charged particles (ions, electrons, etc.) interacting through self-consistent electrostatic (or electromagnetic) fields. A direct “all-pairs” Coulomb force computation would scale as O(N^2) in the number of particles (N), which becomes prohibitive. The PIC method avoids that by introducing a grid on which fields are solved, and particles interact indirectly via the grid.
For a 2D or 3D domain, the algorithm becomes a set of data structures and loops that iterate many time‐steps, and thus is a good candidate for exploring advanced programming, data‐structure design, performance optimisation and parallelisation.
Within the PIC cycle, the charge deposition step plays a crucial role, it maps discrete particle charges onto a continuous grid, enabling the computation of electrostatic fields. This step offers a fascinating blend of numerical methods, data structures, and high-performance computing (HPC) challenges. Despite its apparent simplicity, charge deposition is one of the most computationally intensive and communication-heavy stages in the PIC loop, making it a prime candidate for parallel optimization and scalability.
In electrostatic PIC, each charged particle contributes to the charge density ρ(x, y) on a discrete mesh. Mathematically, for a system of N particles, the charge density on grid node (i, j) is computed as:
· ρ(i, j) = Σₚ qₚ S(xᵢ - xₚ, yⱼ - yₚ)
Here, qₚ is the particle charge, and S(·) is a shape function (e.g., nearest grid point) that determines how particle charge is distributed to surrounding grid points. The choice of S affects both numerical accuracy and computational cost.
The charge deposition process typically involves the following operations:
1. For each particle, determine its position relative to the grid cell.
2. Compute the weight factors using the shape function.
3. Distribute (deposit) the particle charge to the nearest grid nodes, weighted appropriately.
4. Accumulate contributions from all particles to obtain the total charge density.
This step transforms a particle-centered representation into a grid-centered field variable, enabling the Poisson solver to compute electric fields.
Efficient charge deposition relies heavily on data layout. Particles are typically stored in an array-of-structures (AoS) or structure-of-arrays (SoA) format. While AoS is intuitive, SoA is more cache-friendly and amenable to vectorization. However, memory access during charge deposition is irregular because multiple particles may map to the same grid cell.
To mitigate cache contention and race conditions, strategies include:
- Sorting particles by cell to improve spatial locality.
- Using atomic operations to avoid write conflicts.
- Employing private-grid schemes where partial charge arrays are reduced after parallel updates.
A simple 2D visualization can help conceptualize the charge deposition process. Each particle contributes its charge to surrounding grid points with weights determined by its proximity. The figure below illustrates charge deposition for a single particle:
∆X and ∆Y are grid sizes, and ix, iy are fractional distances of particle from D in the X and Y direction, respectively.
Loop over N particles. For each particle you do constant (≈4) grid writes and a handful of floating point ops. So cost ~ O(N).
But the memory access pattern is irregular, i.e. each particle jumps to some cell (determined by its position). So you have scattered writes to the grid array. On modern CPUs/GPUs, that means low spatial locality, poor caching, and potential contention if parallelised.
If the grid is large and particles uniformly cover domain, you may get good work balance, but if particle load is uneven, you may get load imbalance.
Parallelisation & Performance Challenges
Write contention / race‐conditions
Memory access irregularity & cache inefficiency
Load imbalance
Domain decomposition & communication in distributed (MPI) codes
Maintaining numerical correctness under parallelism
References
C. K. Birdsall and A. B. Langdon, Plasma Physics via Computer Simulation.
A. Verboncoeur, “Particle simulation of plasmas: review and advances,” Plasma Phys. Control. Fusion 47 A231 (2005).
Stantchev et al., Fast parallel Particle-To-Grid interpolation for plasma PIC simulations on the GPU, Journal of Parallel and Distributed Computing 68(10):1339-1349, 2008.