# Blog

Viewing posts for the category Featured on frontpage

## Non-linear least squares fitting of a two-dimensional data

The scipy.optimize.curve_fit routine can be used to fit two-dimensional data, but the fitted data (the ydata argument) must be repacked as a one-dimensional array first. The independent variable (the xdata argument) must then be an array of shape (2,M) where M is the total number of data points.

## ExB drift for an arbitrary electric potential

As described in the previous blog post charged particle moving in crossed constant magnetic and electric fields exhibits a drift velocity, $(\boldsymbol{E}\times\boldsymbol{B})/B^2$, perpendicular to both $\boldsymbol{E}$ and $\boldsymbol{B}$. The particle's trajectory in this situation can be found analytically. For an arbitrary $\boldsymbol{E}$, some kind of numerical integration of the equation of motion is usually necessary, but the force that the particle experiences at an instant is perpendicular to to the electric field and the particle therefore undergoes its gyromotion along an isocontour of electrostatic potential, $V$ (since $\boldsymbol{E} = -\nabla V$).

## Gyromotion of a charged particle in a magnetic field

A charged particle of mass $m$ and charge $q$ moving with a velocity $\boldsymbol{v}$ in an an electric field $\boldsymbol{E}$ and a magnetic field $\boldsymbol{B}$ is subject to a Lorentz force, $\boldsymbol{F}$, given by $$\boldsymbol{F} = q(\boldsymbol{E} + \boldsymbol{v}\times\boldsymbol{B}).$$ The equation of motion for a single particle is therefore given by Newton's second law as $$\boldsymbol{\ddot{r}} = \frac{q}{m}(\boldsymbol{E} + \boldsymbol{v}\times\boldsymbol{B}).$$ Here we will consider a uniform magnetic field, $\boldsymbol{B} = (0,0,B)$ and zero electric field, $E=0$. In this case, the trajectory of the particle can be obtained by solving the equation of motion analytically, but here we integrate it numerically using SciPy's integrate.odeint method. Assuming the particle starts off with non-zero components of its velocity parallel ($v_\parallel$) and perpendicular ($v_\perp$) to the magnetic field, it moves in a helix, with radius given by $$\rho = \frac{mv_\perp}{|q|B},$$ known as the Larmor or cyclotron radius (or gyroradius).

## Types of plasma

Two important parameters in plasma physics are the electron Debye length, $\lambda_{\mathrm{D}e}$, a measure of the distance over which charge-screening effects occur and deviations from quasi-neutrality are observed, and the number of paricles in a "Debye cube" (of side length $\lambda_{\mathrm{D}e}$), $N_\mathrm{D}$.

## Plotting nuclear fusion cross sections

In a nuclear fusion reaction two atomic nuclei combine to form a single nucleus of lower total mass, the difference in mass, $\Delta m$ being released as energy in accordance with $E = \Delta m c^2$. It is this process which powers stars (in our own sun, hydrogen nuclei are fused into helium), and nuclear fusion has been actively pursued as a potential clean and cheap energy source in reactors on Earth for over 50 years.