3
$\begingroup$

I am trying to make a simulation of a vibrating string. The string is divided into $n$ points, and each point along the string is acted upon by a force due to the positioning of its neighbors.

I eventually have to update both velocity due to acceleration, and position due to velocity at each point, but the two are dependent on each other.

Is there a physically correct order in which to update position and velocity?

$\endgroup$

1 Answer 1

4
$\begingroup$

The physically correct order would be at the same time. This can be done via $$ x^{n+1} = x^n + v^n\Delta t+\frac12a^n\Delta t^2 \\ v^{n+1} = v^n + \frac12\left(a^n+a^{n+1}\right)\Delta t $$ where $a^n=F\left(x^n\right)$ with $n$ the time-step index.

However, what is done more often is called the Leapfrog scheme in which you update positions and velocities at offset intervals: $$ x^{n+1} = x^n + v^{n+\frac12}\Delta t \\ a^{n+1} = F(x^{n+1}) \\ v^{n+\frac32}=v^{n+\frac12} + a^{n+1}\Delta t $$ Here, the fractional $n$ can be thought of the "cell wall" value (e.g., $x_{i+\frac12}=\frac12(x_i+x_{i+1})$) but in time instead of space.

$\endgroup$
4
  • $\begingroup$ Just a comment, in normal molecular dynamics simulations first method is generally used. This is due to higher order accuracy at the least computational expense. It gives a fourth order accuracy because the third order terms cancel off while doing a Taylor expansion. $\endgroup$ Commented Jun 3, 2014 at 20:11
  • $\begingroup$ @Vaidyanathan: The two are actually equivalent methods, but the first set is generally easier to implement than the latter. And as far as I know, they both are 2nd order schemes, not 4th order. $\endgroup$
    – Kyle Kanos
    Commented Jun 3, 2014 at 20:17
  • $\begingroup$ As far as I remember, Velocity verlet scheme (which is what is commonly referred to the first scheme you have put there) is fourth order in space and second order in velocity. It can be easily shown by subtracting forward and backward Taylor series expansion for positions. Also the reason why it is preferred is because, in MD simulations, "half time step" has less convincing meaning and also if the first method is used, it becomes much easier to vectorize the positions and forces in the system. By the way both are equally good. I am not denying that :) $\endgroup$ Commented Jun 3, 2014 at 20:23
  • $\begingroup$ @Vaidyanathan: IIRC, the Verlet scheme is 4th order while the Velocity Verlet scheme is 2nd order. $\endgroup$
    – Kyle Kanos
    Commented Jun 3, 2014 at 20:27

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.