## A charged particle in electric and magnetic fields

When a charged particle moves in a electric field $\vec{E}$ and a magnetic field $\vec{B}$, the force on the particle is,

$\vec{F} = q(\vec{E} + \vec{v}\times \vec{B}),$

where $q$ is the charge of the particle and $m$ is the mass. Written out in terms of its three components, the Lorentz force is,

$F_x = q(E_x+v_yB_z-v_zB_y)$,
$F_y = q(E_y+v_zB_x-v_xB_z)$,
$F_z = q(E_z+v_xB_y-v_yB_x).$

In general, the three components of the electric and magnetic fields can be functions of space and time.

 $m=$  kg $q=$  C $E_x=$  V/m $E_y=$  V/m $E_z=$  V/m $B_x=$  T $B_y=$  T $B_z=$  T

The intitial conditions at $t=0$ are:
$x=$  m  $y=$  m  $z=$  m  $v_x=$  m/s  $v_y=$  m/s  $v_z=$  m/s

When a constant uniform electric field is perpendicular to a constant uniform magnetic field, the average velocity of the charged particle will be in the direction perpendicular to both the electric field and the magnetic field. Note that electrons move very fast so a short time step $\Delta t$ must be selected.

### 3-D motion differential equation solver

 $F_x=$ -x*6.6726E-11*5.97219E24/pow(x*x+y*y+z*z,3/2) [N] $F_y=$ -y*6.6726E-11*5.97219E24/pow(x*x+y*y+z*z,3/2) [N] $F_z=$ -z*6.6726E-11*5.97219E24/pow(x*x+y*y+z*z,3/2) [N] $m=$ [kg] Initial conditions: $t_0=$ [s] $\Delta t=$ [s] $x(t_0)=$ [m] $N_{steps}$ $v_x(t_0)=$ [m/s] Plot: t x vx y vy z vz Fx Fy Fz P Ekin W vs. t x vx y vy z vz Fx Fy Fz P Ekin W $y(t_0)=$ [m] $v_y(t_0)=$ [m/s] $z(t_0)=$ [m] $v_z(t_0)=$ [m/s]

 3-D plot:

 $t$ [s] $x$ [m] $y$ [m] $z$ [m] $v_x$ [m/s] $v_y$ [m/s] $v_z$ [m/s] $F_x$ [N] $F_y$ [N] $F_z$ [N] $P$ [W] $E_{\text{kin}}$ [J] $W$ [J]