-1
$\begingroup$

I am trying to create MATLAB code that will simulate a charged particle's path in a magnetic field. I have the user enter vectors for velocity and magnetic field, and then calculate the force vector.

Given these initial conditions, how can I calculate the position vector $[x,y,z]$ of the particle after time t? I'm aware of $\vec{F}=q\vec{V}×\vec{B}$, but am not sure how to determine position once force is found.

Thanks!

$\endgroup$
2
  • 4
    $\begingroup$ Have you considered maybe using Newton's law? $\endgroup$
    – Kyle Kanos
    Mar 9 at 2:41
  • $\begingroup$ Just a note: the vector product symbol can be written: \times $\endgroup$ Mar 9 at 4:09

1 Answer 1

0
$\begingroup$

Newton's second law of motion is one way to derive a set of second order differential equations known as the equations of motion. We can write Newton's second law as: $$\vec F=m\vec a(t)=m{d^2\vec r(t)\over dt^2},$$ where, $\vec a(t)$ and $\vec r(t)=x(t)\mathbf{\hat i}+y(t)\mathbf{\hat j}+z(t)\mathbf{\hat k},$ are the acceleration and position respectively. The velocity is given by: $$\vec v(t)=x'(t)\mathbf{\hat i}+y'(t)\mathbf{\hat j}+z'(t)\mathbf{\hat k}.$$ In the case of a charged particle in a magnetic field: $$\vec F=q\vec v\times\vec B\implies m{d^2\vec r(t)\over dt^2}=q\vec v\times\vec B.$$ So the vector product of $\vec v$ and $\vec B$ is given by: $$\vec v\times \vec B=(y'(t)B_z-z'(t)B_y)\mathbf{\hat i}-(x'(t)B_z-z'(t)B_x)\mathbf{\hat j}+(x'(t)B_y-y'(t)B_x)\mathbf{\hat k}.$$ And the second derivative of the position $\vec r(t)$ as: $${d^2\vec r(t)\over dt^2}=x''(t)\mathbf{\hat i}+y''(t)\mathbf{\hat j}+z''(t)\mathbf{\hat k}.$$ Putting this all together gives a set of coupled differential equations for the respective vector components: $$\begin{align} x''(t)&={q\over m}(y'(t)B_z-z'(t)B_y)\\ y''(t)&={q\over m}(x'(t)B_z-z'(t)B_x)\\ z''(t)&={q\over m}(x'(t)B_y-y'(t)B_x) \end{align}$$ Now armed with the initial conditions for the problem, viz. the initial positions $x(0)=x_0$, $y(0)=y_0$, $z(0)=z_0$, and velocities $x'(0)=v_{x0}$, $y'(0)=v_{y0}$, $z'(0)=v_{z0}$, of the charged particle you can solve for the position as a function of time.

$\endgroup$
2
  • 1
    $\begingroup$ The last piece of this is numeric integration. RK4 in particular is a popular choice. $\endgroup$
    – Cort Ammon
    Mar 9 at 4:03
  • 2
    $\begingroup$ @CortAmmon There is also an analytic solution. $\endgroup$
    – Ghoster
    Mar 9 at 4:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.