Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

I want to implement a simple particules system using the velocity form of the Verlet algorithm as integrator.

Initial conditions at $t=0$ for a given particule $p$:

  • mass: $ m $
  • position: $\overrightarrow x(t=0) = \overrightarrow x_0$
  • velocity: $\overrightarrow v(t=0) = \overrightarrow v_0$
  • forces applied to it: $ \overrightarrow F(t=0) = \overrightarrow F_0 $

Algorithm's recipe says:

  1. Calculate: $\overrightarrow v(t+\frac{1}{2}\Delta t) = \overrightarrow v(t) + \frac{1}{2}\overrightarrow a(t)\Delta t$
  2. Calculate: $\overrightarrow x(t+\Delta t) = \overrightarrow x(t) + \overrightarrow v(t+\frac{1}{2}\Delta t) \Delta t$
  3. Derive: $\overrightarrow a(t+\Delta t)$ from the interaction potential using $\overrightarrow x(t+\Delta t)$
  4. Calculate: $\overrightarrow v(t+\Delta t) = \overrightarrow v(t + \frac{1}{2}\Delta t) + \frac{1}{2}\overrightarrow a(t+\Delta t)\Delta t$

Let's apply it in order to find $\overrightarrow x(t=1)$ and $\overrightarrow v(t=1)$, so with $\Delta t = 1$:

  1. $\overrightarrow v(0+\frac{1}{2}1) = \overrightarrow v(0) + \frac{1}{2}\overrightarrow a(0)1 = \overrightarrow v_0 + \frac{1}{2}\frac{\overrightarrow F_0}{m}$ [OK using Newton's second law]
  2. $\overrightarrow x(0+1) = \overrightarrow x(0) + \overrightarrow v(0+\frac{1}{2}1) 1 = \overrightarrow x_0 + (1.)$ [OK using previous result (1.)]
  3. ???
  4. $\overrightarrow v(0+1) = \overrightarrow v(0 + \frac{1}{2}1) + \frac{1}{2}\overrightarrow a(0+1)1 = (1.) + \frac{1}{2}(3.)$ [OK using (1.) and (3.)]

--

So I'm stuck with (3.)

I have to calculate $\overrightarrow a(0+1)$ but I don't know how... I can't apply Newton's second law here since I don't know $\overrightarrow F(t=1)$. Algorithm says "from the interaction potential using (1.)" but I don't understand what it means...

Can you help?

Thank you

share|improve this question
1  
related: physics.stackexchange.com/questions/33751/… –  leonbloy Aug 16 '12 at 18:25

2 Answers 2

I think you all your steps are correct, I would suggest adding units though, otherwise adding $\vec{x}$ and $\vec{v}$ can be misleading.

For step 3. You can just calculate $a = F/m$, where $F$ can either be gravitation $F=m g$, so it does not depend on $x$, or for example for a spring dependent on $x$, so $F = -k x$, here you need the next position from step 2.

share|improve this answer
    
For step 3., I'm at $t=0$ and I'm calculating $\overrightarrow a(t+1)$ eg $\overrightarrow a(1)$. I only know $\overrightarrow F_{t=0}$ not $\overrightarrow F_{t=1}$ so like I was saying, I can't apply Newton's second law $\overrightarrow a(1) = \overrightarrow F_1/m$ since I don't have $\overrightarrow F_1$... –  abernier Aug 17 '12 at 9:13
    
It depends on your potential, so as an example for a spring $F(1) = -k x(1)$, which you can use to calculate $a(1)$. The next position $x(1)$ comes from your second step. –  Alexander Aug 17 '12 at 13:42
    
But what if I can't have $F(1)$ for example in my case $F(t)$ depends on a user's interaction, eg: drag with mouse — so I cannot predict $F(1)$ when at $t = 0$ It's not a spring, or maybe it could be, but dragged by a crazy user with a mouse in his hand so I cannot have $k$ in advance. –  abernier Aug 17 '12 at 23:15
    
@abernier: You always need to know the conditions beforehand, so I think there is no way your simulation lags 1 frame behind the user input. Maybe our game development partner site has more input on this. –  Alexander Aug 18 '12 at 19:19

To integrate your equation, you need to know the force law: F(x)=-dU(x)/dx F(x)= (U(x)-U(x+Dx))/Dx

What kind of potential to you deal with ?

share|improve this answer
    
What $U$ is for ? –  abernier Aug 17 '12 at 9:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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