0
$\begingroup$

The equations I'm using are:

x = x + (DT * vx)
vx = vx * C

My DT is always 0.01 and the coefficient C (related to a linear drag coefficient, as mentioned in the comments) is greater than 0 and less than 1. The above will keep happening until x naturally reaches its limit.

What I want is an equation to find C given the other three inputs: initial x, initial velocity x and final resting x(this is where the object has come to a stop and vx = 0). Right now it's tedious because I have to plug in ix, ivx and C and run my simulation to see where the object stops. Then I have to do further tweaking to get exactly what I'm looking for.

Here are some samples:

initial x = 3.5
velocity x = -12.0
acceleration = 0.92
final resting x = 2.0

initial x = 3.5
velocity x = -14.0
acceleration = 0.92
final resting x = 1.75

For example(from the first dataset), we start at 3.5 we want to end at 2.0 and our velocity is -12.0 .. what do we need to use for C?

$\endgroup$
0

2 Answers 2

2
$\begingroup$

Basically what you're doing is calculating a discrete time series: you're finding an discrete series of positions $x_n$ (where $n\in\mathbb{Z}_+$) which are paired with times $t_n = t_0 + n\Delta t$. But there are a couple of ways you could interpret this time series, and the formula you're looking for depends on which one you use.

Exact positions

One option is to say that $x_n$ represents the exact position of the particle at time $t_n$. In order to find the asymptotic position as $n\to\infty$ (that is, the position where the particle stops), you need to convert your iterative formulas,

$$\begin{align}x_n &= x_{n-1} + v_{n-1}\Delta t \\ v_n &= Cv_{n-1}\end{align}$$

into direct formulas. Hopefully you can see that, because the speed gets multiplied by $C$ at every step, the speed at the $n$'th step will be given by

$$v_n = C^n v_0$$

Then figuring out the formula for $x_n$ is probably most easily done by finding a pattern:

$$\begin{align}x_1 &= x_0 + v_0\Delta t \\ x_2 &= x_1 + v_1\Delta t \\ &= x_0 + v_0\Delta t + Cv_0\Delta t \\ x_3 &= x_2 + v_2\Delta t \\ &= x_0 + v_0\Delta t + Cv_0\Delta t + C^2v_0\Delta t\end{align}$$

You wind up with

$$x_n = x_0 + v_0\Delta t \sum_{k=0}^{n}C^k$$

In the limit as $n\to\infty$, this simplifies to

$$x_\infty = x_0 + \frac{v_0\Delta t}{1-C}$$

which you can solve for $C$. This equation reproduces the sample results you listed.

It's important to note that the value of $C$ you get from this interpretation depends on your choice of $\Delta t$. To simulate the same motion using a different time step, you'll need to change the value of $C$. Only the ratio $\frac{\Delta t}{1-C}$ is fixed.

Discrete approximation

The other way in which one could interpret your time series is as a discrete approximation to some continuous function $x(t)$ that describes the actual motion. If you find it strange that the result depends on the time step $\Delta t$, this might be worth looking into.

To motivate this interpretation, you need to know something about finite difference approximations. In a nutshell, when you want to use a computer to numerically solve a differential equation, you can replace the derivative operator with a finite difference operator:

$$\frac{\mathrm{d}f}{\mathrm{d}t} \to \frac{f(t + \Delta t) - f(t)}{\Delta t}$$

The thing on the right here is merely the simplest example of a finite difference operator. (It also happens to be quite inaccurate.) This particular one looks a lot like the definition of the derivative, except that $\Delta t$ is finite, not infinitesimal (hence the name).

Your iteration equations can be written in the form

$$\begin{align}\frac{x_n - x_{n-1}}{\Delta t} &= v_{n-1} \\ \frac{v_n - v_{n-1}}{\Delta t} &= \frac{C - 1}{\Delta t}v_n\end{align}$$

You can assume that this is the finite difference approximation to some exact differential equation, and work backwards to find the equation. For example, by replacing the finite difference operator in the position equation with a derivative, you get

$$\frac{\mathrm{d}x}{\mathrm{d}t} = v(t)$$

If you try to do the same thing with the velocity, well, you can't, because the right side doesn't have a defined limit as $\Delta t\to 0$. But there are a couple of little hacks you can use, for example: choose some characteristic time scale $\tau$ and set $\Delta t = \tau$ on the right, while still taking the limit on the left. You wind up with

$$\frac{\mathrm{d}v}{\mathrm{d}t} = \frac{C - 1}{\tau}v(t)$$

Solving this differential equation gives you

$$\begin{align}v(t) &= v(0)e^{-t(1-C)/\tau} \\ x(t) &= x(0) + \frac{v(0)\tau}{1-C} \bigl(1 - e^{-t(1-C)/\tau}\bigr)\end{align}$$

and in the limit as $t\to\infty$,

$$x(\infty) = x(0) + \frac{v(0)\tau}{1-C}$$

which, again, you can solve for $C$. It turns out to be the same thing as before, only with $\tau$ instead of $\Delta t$. This is only the case because this is an exceptionally simple equation, and because of the particular way in which I chose to define the time scale $\tau$. In general, these two methods won't give identical results, in part because of the inaccuracies of the particular finite difference approximation I used.

$\endgroup$
2
  • $\begingroup$ Thank you. Is it possible to implement this type of motion without it being dependent on the DT? $\endgroup$
    – Ryan
    Commented Feb 7, 2012 at 6:49
  • $\begingroup$ No, there's no way to avoid introducing a time scale of some sort if the particle is going to come to rest. $\endgroup$
    – David Z
    Commented Feb 7, 2012 at 7:21
1
$\begingroup$

Integrate with respect to the time. One problem is that if you change DT, you will get a different result, since acceleration does not change with DT, although it should.

Your formulas written as functions:

$$ x(t) = x_0 + \int_0^t v(t) \cdot \mathrm dt $$

$$ v(t) = v_0 \cdot a^t $$

Combining those yields:

$$ x(t) = x_0 + \int_0^t v_0 \cdot a^t \cdot \mathrm dt $$ $$ x(t) = x_0 + v_0 \int_0^t e^{\log(a)t} \cdot \mathrm dt $$ $$ x(t) = x_0 + v_0 \left[ \frac{1}{\log(a)} e^{\log(a)t} \right]_0^t $$ $$ x(t) = x_0 + v_0 \frac{1}{\log(a)} (a^t - 1)$$

$\log(a)$ is negative, so for $t \to \infty$ you should get:

$$ \lim_{t \to \infty} x(t) = x_{\mathrm{final}} = x_0 + v_0 \frac{1}{\log(a)} (0 - 1)$$ $$ x_{\mathrm{final}} = x_0 - v_0 \frac{1}{\log(a)}$$

The greater your $a$ is, the less far the particle will have made it. Sounds reasonable.

If you have a $\mathrm dt = 0.01$ seconds, you will have a factor of $a^{100}$ per second. So for your $a = 0.92$ I would instead use $a^{100} = 0.000239212$ as $a$.

When I put this into my formula, I get:

$$ x_{\mathrm{final}} = 3.5 - (-12.0) \frac{1}{\log(0.000239212)} = 2.0608 $$

$$ x_{\mathrm{final}} = 3.5 - (-14.0) \frac{1}{\log(0.000239212)} = 1.82097 $$

I am not sure whether the formula is wrong or whether your program just makes rounding errors (as usual with numeric calculations).

$\endgroup$
2
  • $\begingroup$ Thank you for the detailed derivation, but I realize I only need a coefficient of friction. See my comment to my original question up top. $\endgroup$
    – Ryan
    Commented Feb 6, 2012 at 23:54
  • $\begingroup$ There were some edits made to the question, in case you'd like to update your answer to reflect them. $\endgroup$
    – David Z
    Commented Feb 7, 2012 at 3:52

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.