Grids are polarized at various voltages, to achieve the desired beam energy. The first grid separates the source plasma from the accelerator. In second grid, often named extraction grid, permanent magnets are inserted to deflect the stray electron currents and to prevent them from being further accelerated, because both negative ions and electrons could be electrostatically accelerated. Magnetic field must be compensated by opposite fields, so ion beams do not deflect. For behaviour predictions and simulations, programs are used to numerically solve dynamics and Poisson equations.