Magnetic fields and trapped particles