Step-by-step


Preliminary ideas

Suppose we have a variable x that varies as a function of t. (I use these letters only because t can be conveniently referred to as time. Everything that follows would work just as well if the variables were p and q.)

Suppose we wish to plot a graph. One way of doing it is to have a table of values of x and t. Then you just transfer these numbers, in pairs, to the graph grid, mark the points, and join them with a series of straight lines - or, possibly, a curved line. In this method, each point is placed absolutely. Another way is to find yourself in mid-process at a particular point on the grid and then to 'step' to the next point: i.e. each new point is put in the correct place relative to the last point. In this method you draw the line (or series of lines) as you go along.

This latter method is the one we are considering. To use it you need to know the following:

In addition, in order to be able to start at all, you need to know

The last two pieces of information are called boundary conditions.

Different techniques are available, depending on what information one has. This general example is for situations in which we have available a way of calculating the second time derivative of x, namely d²x/dt². You have to remember that d²x/dt² means d/dt(dx/dt), and that the approximate equality of dx/dt and dx/dt means that it is approximately true that dx = (dx/dt)´dt (and that this is true, no matter what the x actually is).

First of all, let's tinker with the red equation. Remembering that we can perfectly well write it in terms of p rather than x, we begin by writing it as

     dp = (dp/dt)´dt

and then rewrite it again as

     dp = d/dt(p)´dt.

Now substitute (dx) for p, again on the grounds that differential equations don't mind what symbol we use. This gives us

     d(dx) =  d/dt(dx)´dt.

Using the red equation again, this time in it's x formulation, we can substitute for the second dx and obtain

     d(dx) =  d/dt((dx/dt)´dt)´dt .

This finally simplifies to

     d(dx) = (d²x/dt²)´dt².

Here are the steps in the main argument.

Everything so far has been perfectly general. Now we focus down onto a particular class of problems that we might wish to model

Application to mechanical problems

We recognise at once that if we are indeed dealing in the variables x and t, then d²x/dt² is the acceleration, and that this will be given by Fresultant /m.

For example, if we are dealing with an elastic force, then the acceleration is -kx/m. If we are dealing with a gravitational force, then the acceleration is g. If we are dealing with a high pressure situation, then the acceleration is pA/m, and so on. So, at each stage in our step-by-step plotting we will be able to refer to the acceleration equation to work out what to put into the d²x/dt² slot.

Setting up an Excel spreadsheet

If our time interval is going to be 0.1 s, then we need to populate column A with 0, 0.1, 0.2, etc all the way down, probably starting in cell A2, leaving row 1 for headings. Populating by hand is laborious and, in any case, we may change our mind about the time interval later. It's quicker to declare the time interval in some harmless cell like F1, and then enter into cell A2 the formula

=(row()-2)*$F$1

and then copy this cell down the page as far as we want to go. The row() function gives you the row number, the -2 adjusts for the fact that we want to start with our zero in cell A2, the *F1 gives us the relevant number of time intervals, whatever we may have decided they should be, while the $ signs mean that Excel will use the contents of cell F1 every time, rather than trying to use F2, F3, etc when we copy down.

Lets' agree to keep dx values in column B and x values in column C. To get going we have to choose starting values, let's enter 0 in B2 and 1 in C2.

Now comes the central part of the process. In cell B3 (our dxnext ) we write

=B2+<acceleration>*$F$1^2

and in C3 we write

=C2+B3

Then we copy these down. Job done! You should be able to see relatively quickly that the first of these equations mirrors exactly the blue equation above, and that the second formula is calculating the new value of x by adding the new value of dx to the old value of x. The only remaining question is what to type where the first equation has <acceleration>? At this stage we have to focus down onto a particular problem.

Mass on a spring.

The physics of stretched springs gives

    acceleration = -kx/m

as indicated above. So all we need to do is to declare the k and m values somewhere - in cells F2 and F3, perhaps - and then substitute

    <acceleration>= - $F$2*C2/$F$3

in the formula for cell B3. The F2 and F3 entries give us the k and m (and the $s keep them constant when we copy down) while the C2 entry gives us the most up-to-date value we have for x, and gets continually updated as we copy down.

To introduce damping, you need to amend this to

    <acceleration>= (- $F$2*C2+<damping force>)/$F$3

This is the creative bit. The turbulent case we discussed was to use rAv² and to make it opposite to the direction of the velocity. One way to make this happen is to use

   <damping force> = - rAvabs(v) .

To achieve this, you will have to declare values of r and A in F4 and F5, while for v you will have to divide the old dx by dt. (You have to use the old dx to avoid circular references). So v is going to be expressed as B2/$F$1

Adding scroll bars

You can attach a scroll bar to any of the F1, F2, etc cells in which you are keeping the parameters. To do this, go to View > Toolbars and click on 'Control Toolbox'. This will produce a small toolbox, initially in Design mode (you toggle the design mode on and off with the icon in the top left: leave it in design mode for the time being). Click on the scroll bar icon, and you will then be able to draw a scroll bar on the spreadsheet, just like you draw any other shape, and it will have all the usual handles for sizing and moving it. Right click on it and select 'Properties'. In the 'Linked cell' box specify a suitable empty cell. Close the Properties dialogue and exit Design mode by clicking the top left on the Toolbox. You will now find that operating the scroll bar makes the number in the linked cell vary between 1 and 32767. It is a simple matter to write a formula in one of your 'parameter' cells (F1,2,3, etc) which scales the linked cell down (or up) to a suitable kind of size for your model. You can do this for as many parameters as you wish. It's seriously cool !!