Prem Kumar
3

That's an excellent question and the magnetic fields are of course the key players here because charged particles (ions) experience a force as they move in a magnetic field.

The force on a charged particle in a magnetic field is perpendicular to the magnetic field itself and to the  direction of  motion of the particle. So it can't speed up the particle. Instead it makes the particle want to move in a circle. The centripetal force provided by the magnetic field in this case is the 'rope' that keeps the particle moving in a circle and prevents it from 'flying off'. This force is called the Lorentz force. There's a formula for it:

F = q (E + v x B)

where all quantities except q (the charge) are vectors and 'x' is a 'vector cross-product'.

The electric field E speeds up the particle and is used in a particle accelerator to accelerate bunches of charged particles (protons in the LHC at CERN) to speeds close to the speed of light. All the while large magnets (made from superconducting material) generate the magnetic fields required to bend the trajectory followed by the particles inside the accelerator chamber.  These are called dipole magnets and are pretty huge. Read more about them here at the CERN webpage:

The accelerator is also lined with something called quadrupole magnets ( that's a "North-South-North-South" combination of magnetic poles) and even sextupole magnets. These are even more interesting. They reduce any spread in the beam of particles (because the ions want to repel each other and spread out) and concentrate the beam to a line thinner than a hair's breadth, particularly at the points where we want the collisions to happen.

Here's more on these:

http://www.lhc-closer.es/taking_a_closer_look_at_lhc/0.magnetic_multipoles