-1
$\begingroup$

I'm looking for a program, which would simulate the path of motion of a body in a coordinate system, given the force acting upon the body. I'd type in the initial conditions such as the velocity, $(x,y)$ position and the formula of the force (e.g. $F=k \sqrt{x^2+y^2}$) and then I'd like the application to simulate the path of motion the body will follow. Does anyone know such a software?

$\endgroup$
1
  • 2
    $\begingroup$ This is basically computing integration curve. Mathematica can easily accomplish that. $\endgroup$
    – Kevin Ye
    Commented Nov 1, 2014 at 23:28

1 Answer 1

3
$\begingroup$

You are asking how to numerically solve a second order initial value problem. An initial value problem involves advancing some initial state over time given an ordinary differential equation (ODE) that describes the time evolution of the state.

There are many books, journal articles, and college classes about this topic. There is no one perfect technique. Some techniques are blindingly simple, others are hideously complex.

As Kevin Ye mentioned, Mathematica can do this quite nicely for many initial value problems. So can Matlab, but you have to know a bit more about numerical integration with Matlab. For example, you need to know whether your problem is stiff. Sometimes these commercial integrators fail miserably. There's a reason there are many books, articles, and classes on the subject. It's not easy, and there is no one perfect technique.

Most ODE solvers address multidimensional first order ODEs. A higher order ODE can readily be converted to a first order ODE by creating a larger state vector. For example, Newton's second law is a second order ODE. Simply create a state vector that contains position and velocity. You asked about two dimensional position (x and y) so that means the composite state vector would have four elements, x, y, and their time derivatives. Voila! The second order ODE $\ddot {\vec x} (t) = \vec F/m$ has been transformed to a first order ODE.

There's a price to pay with using a first order ODE solver on a second order ODE problem. While this transformation works conceptually, it loses something in practice. In particular, it loses "symplecticity". This may not matter if you just want an approximate solution, if the time interval is sufficiently short, or if the ODE solver is very, very good. An example of the latter is the Lawrence Solver for Ordinary Differential Equations, or LSODE, developed at Lawrence Livermore. This is one of the best solvers out there for first order ODEs. It works very nicely on second order problems, too, at least over sufficiently short spans of time so that you don't see that things that should be conserved (energy, linear momentum, and angular momentum) aren't conserved.

The easiest ODE solver is Euler's method. This is a very, very simple technique, and as a result it is typically very, very lousy. However, understanding Euler's method is essential to understanding any more advanced method. You can easily implement Euler's method in a spreadsheet or in an easy-to-learn programming language such as python. You simply advance state one step at a time until you reach the desired end time via $$\vec u(t+\Delta t) = \vec u(t) + \vec f(\vec u(t),t)\,\Delta t$$ where $\vec u(t)$ is the state at time $t$, $\vec f(\vec u(t),t)$ is the function that computes the time derivative of the state, $\Delta t$ is the time step, and $\vec u(t+\Delta t)$ is the estimated state at the next time step $t+\Delta t$. This technique can easily be adapted to Newton's second law via $$\begin{aligned} \vec r(t+\Delta t) &= \vec r(t) + \vec v(t)\, \Delta t \\ \vec v(t+\Delta t) &= \vec v(t) + \frac {\vec F(\vec r(t), \vec v(t), t)}{m}\, \Delta t \end{aligned}$$ Here $\vec F(\vec r, \vec v, t)$ calculates force as a function of position, velocity, and time. This basic implementation is not symplectic: $$\begin{aligned} \vec v(t+\Delta t) &= \vec v(t) + \frac {\vec F(\vec r(t), \vec v(t), t)}{m}\, \Delta t \\ \vec r(t+\Delta t) &= \vec r(t) + \vec v(t+\Delta t)\, \Delta t \end{aligned}$$ In other words, calculate the new velocity first, and use this new velocity to update the position.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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