Friday, October 20, 2017

newtonian mechanics - Update velocity or position first in computation?


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?



Answer



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.



No comments:

Post a Comment

classical mechanics - Moment of a force about a given axis (Torque) - Scalar or vectorial?

I am studying Statics and saw that: The moment of a force about a given axis (or Torque) is defined by the equation: $M_X = (\vec r \times \...