CS199 Higher Order Simulation and Chaos

On this page, we'll discuss some more complex issues of simulating physical systems. This is all continuous process simulation, not discrete event.

Solar Systems, Springs and Pendulums

The N-body problem is a standard one for simulation in physics: given the masses and locations of N bodies (such as 1 sun and 8 or 9 planets), and the law of universal gravitation, simulate their motion.

Note that simulation is crucial because there is no closed-form solution to the N-body problem: that is, there's no closed-form function, P(t), that gives the position [coordinates (x,y,z)] of a body at time t as a function of the positions, masses and velocities of all the bodies at time 0. Inventing some notation, we would love to have:

P(t) = f([Pi(0)],[Mi],[Vi(0)])

Simulating the N-body problem turns out to be hard to get exactly right, particularly over large time scales.

Here's a simplification that is actually harder. Imagine simulating a pendulum: a mass swinging back and forth. Remember, even though this is called Continuous Simulation, we are simulating in discrete time steps.

Now, consider the simulation as the pendulum nears the top of its arc. In fact, consider the next to last step before it turns around. Call this time t.

a curve like a sine curve, with several
marked points

What about if we use the average of the two velocities? This is better. Much closer. But still not quite right.

a curve like a sine curve, with the tangents
draw for two points near the apex

What if we use the initial derivative to find the midpoint and use that derivative for the whole segment. This is pretty good, too. It's called the midpoint method.

a curve like a sine curve, with the tangents
draw for two points near the apex and also the mean of those tangents,
which roughly parallels that section of the curve

There are lots of other cool techniques. This is covered in courses on numerical solutions to differential equations.

Mass Spring Simulation

A Mass-Spring system is a classic differential equation system. (If you google it, you'll get lots of hits.) It has a similar solution to the pendulum. We'll look at it more closely.

Newton's law says that

F=ma

Hook's law says that springs exert a force that is inversely proportional to the amount that they are stretched. Let's use x to represent the amount of stretch, so when x=0, the spring is neither stretched nor compressed. Springs are characterized by a spring constant called "k" that is the proportionality constant.

F = -kx

Combining these two, we find that the object is accelerated by an amount that depends on its position:

ma = -kx
a = -(k/m)x

Acceleration is just the derivative of velocity:

dv/dt = -(k/m)x

What we're doing in simulation is using a biggish delta-t and computing deltas of other things. Graphically, this is like putting a tangent on the function at that point and extrapolating forward.

delta_v = -(k/m)x * delta_t

We can use an accumulator (holding tank) to keep track of the current velocity:

v_new = v_old + delta_v

We can also use the velocity to change the position, since that's what velocity means:

v = dx/dt
delta_x = v*delta_t

As with velocity, we can use an accumulator (holding tank) to keep track of the current position:

x_new = x_old + delta_x

Here's a sample simulation model:

mass-spring2.mox

Try the following:

Advantages and disadvantages of simulation:

Message:

When differential equations can be solved, the solution is always superior to numerical simulation. Simulation can work when differential equations can't be solved.

Chaos Theory

If you saw "Jurassic Park," you know the bumper sticker version of the important new field of Chaos Theory.

A better but still over-simplified version is the following:

Systems can be highly sensitive to initial and current conditions, so that they are in principle unpredictable, even with a good model.

So, the jig is up for simulation, right? Not completely. We never expected perfection, and this just seals our fate.

  1. This work is licensed under a Creative Commons License
  2. Creative Commons License
  3. Viewable With Any
Browser
  4. Valid HTML 4.01!
  5. Valid CSS!