0

I'm currently trying to approximate the trajectory of a particle inside a 2D vector field.

The particle has an initial position $P = (a,b)$, an initial velocity vector $\vec{V} = (p,q)$, and a given vector field $\vec{F}(x,y)=u(x,y)\mathbf{\hat{\imath}} + v(x,y)\mathbf{\hat{\jmath}}$

I was trying to implement RK4 to solve this problem. The issue is, I don't know how to do it.

I do not know how to implement the initial differential equations required for RK4 nor what the final iterative equation would look like.

Also, how do the final trajectory would be? Its going to be a set of points?

I would appreciate the help if someone could help me to better understand how to carry out this problem.

Thanks so much, I'll be keeping track to any recommendations, comments and answers on this topic. For everything else, have a nice day!

EDIT:

If the problem involving the initial velocity vector becomes too complicated, It can be omitted. Just with the initial position and the vector field should be enough to understand this numerical method. Thanks so much!

  • The initial upside-down question mark is not used in English. What is RK4? – John Douma Jul 27 '21 at 02:41
  • @JohnDouma RK4 is Runge Kutta 4th order (see tags) – Calvin Khor Jul 27 '21 at 02:48
  • @JohnDouma Its a numerical method used to solve differential equations. Also, thanks to the clarification about the question mark, I was not aware of that. I have just edited the title to clarify these problems. – Gabriel Santana Paredes Jul 27 '21 at 02:53
  • 1
    See https://math.stackexchange.com/questions/3946867/numerically-solving-2nd-order-system, https://math.stackexchange.com/questions/4176684/how-to-implement-a-runge-kutta-method-rk4 and links there. – Lutz Lehmann Jul 27 '21 at 07:21
  • 1
    @GabrielSantanaParedes Is your vector field $\vec F$ a force? Can you relate the trajectory, velocity and acceleration? These relations give you the differential equations needed for RK4. – PierreCarre Jul 27 '21 at 08:14
  • @LutzLehmann Thank you for the references! I'm going to read them to hopefully reach an answer. – Gabriel Santana Paredes Jul 27 '21 at 17:56

1 Answers1

1

If the trajectory is $S(t) = (x(t), y(t))$ the velocity and acceleration are given by $$ V(t)= (x'(t), y'(t)), \quad A(t)=(x''(t),y''(t)) $$

So, using Newton's second law (I'm assuming $m=1$) $$ \begin{cases} x''(t) = u(x(t), y(t))\\ y''(t) = v(x(t), y(t)) \end{cases} $$

Considering that RK4 requires 1st order equations, you must rewrite the system as

$$ \begin{cases} x'(t) = v_x(t)\\ y'(t) = v_y(t)\\ v_x'(t) = u(x(t), y(t))\\ v_y'(t) = v(x(t), y(t)) \end{cases} $$

This system (together with the initial conditions for position and velocity) will give you the trajectory and velocity.

PierreCarre
  • 20,974
  • 1
  • 18
  • 34
  • Hey! Thank you so much for replying this well and deriving the equations. Although, I still don't know how to apply RK4 on that. Should I use the Iterative method on the first two equations and then to the last two? Also, if the equations of the vector field are, for example, u(x,y) = cos(x)y and v(x,y) = sin(x)y, one of the last two equations would be something like Vx'(t) = cos[x(t)]*y(t)? I'm sorry, I'm new at numerical analysis and I don't understand this topic very well :(, apologies for that. – Gabriel Santana Paredes Jul 27 '21 at 17:30
  • @GabrielSantanaParedes You need to apply RK4 to a system $W' = G(t,W)$, where $W=(x,y,v_x,v_y)$ and $G(t,W) =(v_x, v_y, u(x,u), v(x,y))$. The four equations are solved simultaneously. – PierreCarre Jul 28 '21 at 07:32