Magnetic confinement in a tokamak I have a question about why exactly the twisting of the field lines in a Tokamak solves the magnetic confinement issue. My understanding is that the magnetic confinement issue arises in the toroidal geometry because from Ampere's law it follows that the field will be stronger near the inner part of the torus (the field falls off like $1/r$). This causes charged particles to drift either up or down as they spiral around the field lines since due to the varying field strength the local radius of curvature alternates between larger and smaller. I understand how inducing a current in the plasma causes the field to twist, causing the field lines to make a helical shape. I don't see though exactly how this solves the confinement issue. While the the field lines do make a helical shape it seems like the local strength of the magnetic field will remain roughly the same, and so I don't see really how the twisting prevents the drifting previously described. Can someone clarify for me?
 A: Overview
There are standard approaches to answering this question that I feel do not satisfy those interested in quantitative details.  So, in what follows I will explain the implications of the poloidal magnetic field using explicit solutions of the single-particle equations of motion, followed by plots of these solutions.
The motion of a particle in a toroidal field is composed of (1) a fast circular orbit of the particle about the magnetic field together with (2) slow parallel motion and drift motion of the center of the circular orbit in (1).  The motion (1) is called the gyromotion and the motion (2) is call the parallel plus drift.  Thus, in (2), we are talking about the motion of the gyrocenter.  The notion of gyrocenter motion is fundamental to the theory of plasma transport, and is the basis of both neoclassical and gyrokinetic theory.  Symbolically, the gyrocenter motion is written as
$$\mathbf{v} = v_\parallel \mathbf{b} + \mathbf{v}_d \; ,$$ 
where $v_\parallel = v_\parallel(\theta)$ is the parallel velocity, $\mathbf{b} = \mathbf{B}/B$ is a unit vector in the direction of the magnetic field $\mathbf{B}$, and $B = B(\theta)$ is the magnetic field strength.  Also, $\mathbf{v}_d$ is the drift velocity.  Drift velocity is discussed ad nauseum elsewhere and so we will just write the radial drift without a derivation.  
Gyrocenter motion
The equations for gyrocenter motion are well-known, but for a tokamak with arbitrary shape they are complicated.  However, if the tokamak cross-section is circular, and the aspect ratio $R/r \gg 1$ (here, $R$ is the major radius and $r$ is the minor radius), then the equation are relatively simple.  In this limit, the equations of motion are
\begin{align}
\frac{d\varphi}{dt} \simeq &~ v_\parallel \mathbf{b} \cdot \mathbf{e}_\varphi = \frac{v_\parallel}{R_0} \quad \text{(toroidal direction)} \\
\frac{d\theta}{dt} \simeq &~v_\parallel \mathbf{b} \cdot \mathbf{e}_\theta =\frac{v_\parallel}{q R_0} \quad \text{(poloidal direction)} \\
\frac{dr}{dt} \simeq &~ \mathbf{v}_d \cdot \mathbf{e}_r =-\frac{v_\parallel^2+\mu B}{\Omega R_0} \sin\theta \quad \text{(radial direction)} 
\end{align}
I am using the fact that $v_\parallel \gg v_d$ to keep these equations as simple as possible.  Note that the energy (over mass) $\varepsilon = v^2/2$ and magnetic moment $\mu = v_\perp^2/2B$ are conserved (constant along an orbit) quantities.  Also, $\Omega$ is the gyrofrequency which depends on the particle mass (otherwise there is no explicit mass dependence).  Finally, the safety factor ($q$) is the ratio of fields
$$q \simeq \frac{r B_\varphi}{R B_\theta}$$
This implies that in the limit of no poloidal field, $q \rightarrow \infty$.  One interesting property of these orbits is that for some values of parameters, the orbits become trapped -- with a characteristic banana shape -- in the poloidal plane.  These banana orbits are illustrated below.
Equations suitable for programming
As written, they are approximate but provide a huge amount of insight into the operation of a tokamak.  However, they are still not quite in a useful form.  According to plasma equilibrium theory, the magnetic field strength can be written as
$$B(\theta) = B_0 \left( 1-\epsilon \cos \theta\right) = B_0 G(\theta)$$
where $\epsilon = r/R \ll 1$.  
\begin{align}
\frac{d\varphi}{d\tau} = &~ \pm \sqrt{1-\lambda G} \\
\frac{d\theta}{d\tau} = &~\pm  \frac{1}{q}\sqrt{1-\lambda G} \\
\frac{dr}{d\tau} = &~ -\rho \left( 1-\lambda G/2\right) \sin\theta 
\end{align}
where $\tau = vt/R$ is the transit time and $\rho = v/\Omega$ is the gyroradius, and $\lambda = \mu B_0/\varepsilon$ is a parameter.  Care must be taken to select the correct sign of the square root for trapped-particle orbits.
\begin{align}
\text{Passing particles} \quad 0 < \lambda < \frac{1}{1+\epsilon} \\
\text{Trapped particles} \quad  \frac{1}{1+\epsilon} < \lambda < \frac{1}{1-\epsilon} 
\end{align}
Examples of passing and banana orbits
Setting $r(0)=0.7$, $\rho=0.01$ and $\epsilon=0.2$, we can trace the orbit shapes in the plane $\varphi=0$ (the so-called poloidal plane).  Note that, according to the results in the previous section, particles with $\lambda < 0.0833$ are passing and $0.833 < \lambda < 1.25$ are trapped.  In the plots, the contour $r=1$ represents the plasma boundary.  Thus, we have chosen the plasma minor radius as the unit of length.  The results illustrate both circular (passing) orbits and trapped (banana) orbits.



Simple passing limit
When $\lambda \ll 1$, the particles are passing with a simple orbit equation
\begin{align}
\frac{d\theta}{d\tau} = &~ \frac{1}{q} \\
\frac{dr}{d\tau} = &~ -\rho \sin\theta 
\end{align}
Solving these equations give the parametric form of a simple passing-particle orbit with orbit width $q\rho$:
$$r(\theta) = r(\pi/2) + q \rho \cos(\theta)$$
This reaffirms the well-known result that the orbit width is larger than the gyroradius by a factor of $q$.  In a tokamak, we usually have $1 < q < 4$.
Loss of confinement
Consider the passing limit described in the previous section, for which the orbit with is $q\rho$.  Evidently, when $q\rho > 1$, the orbit is larger than the plasma and will be lost when it crosses this boundary.  Thus, a poloidal field must not only exist, but it must be strong enough to ensure $q\rho \ll 1$.
A: It is correct that a geometry with a purely toroidal magnetic field (i.e. where the field lines are not twisted) does not result in confinement. Such devices are sometimes called simple magnetized torus. The problem is the varying magnetic field strength across the torus cross section as you described it, resulting in drifts of electron and ions in opposite directions (up and down).
These drift motions result in a vertical electric field and that results in an $E\times B$ drift whose direction is independent of the charge. For a purely vertical E-field and a purely toroidal B-field, the drift is along the radial coordinate and the plasma is lost. No confinement. 
You can overcome this by twisting the magnetic field lines, as you mentioned it. The idea is simple: charged particles can move freely along the magnetic field lines. Think of a twisted field line that connects a region in the upper half of the torus and a region in the bottom half. Remember that there is a potential difference between these two regions (as just explained and as also explained by you). Due to the connection by the field line, this potential difference is simply annihilated, electrons are flowing to the positive field and ions to the negative (the corresponding currents are referred to as Pfirsch-Schlüter-currents). 
The electric field is no more, no $E\times B$ drift, no plasma losses (at least not due to this mechanism) and we have a nice toroidal confinement device like a tokamak.
A: Alf's and jcandy's answers are already complete - I just want to add a brief answer using the conserved quantities of the single-particle motion. 
The single-particle Lagrangian is independent of the toroidal angle ($\phi$) due to toroidal periodicity of the helical field, i.e. toroidal symmetry. This gives rise to the conserved toroidal angular momentum
\begin{equation}
p_{\mathrm{can}} = (m v_{\phi} - q A_{\phi})R \approx m v_{\parallel} R - q \psi = \rm{constant}\,,
\end{equation}
where $\psi$ is the poloidal magnetic flux due to the poloidal magnetic field. The conserved energy is
\begin{equation}
E=\frac{1}{2} m v_{\parallel}^2 + \mu B=\mathrm{constant}\,.
\end{equation}
Since the magnetic moment $\mu$ in the above energy equation is an adiabatic invariant, $v_{\parallel}$ is bounded. As a result, the poloidal magnetic flux $\psi$ is also bounded by angular momentum conservation. Therefore, a particle's motion is confined to regions of a certain poloidal magnetic flux, so the poloidal component of the magnetic field solves the confinement issue. In a tokamak, the poloidal field is created by the toroidal plasma current, while in a stellarator both poloidal and toroidal fields are supplied by external currents.
This description is found (together with a good explanation of drifts) in de Blank's article on guiding center motion.
