Fluid Motion and Wave Creation

Prepared by: Eric Lloyd

Introduction
Algorithm Description
Results
Usefulness/Applicability
Links to Code/Project

Back to main page

Introduction

While the simulation of wave creation and fluid movement may not initially appear to be an example of emergent behavior, it can be distilled to a system of agents interacting with one another. If we think of a surface of water as a series of tiny individuals, the creation / propagation of waves is simply each agent reacting to its neighbors. This algorithm uses a few basic physics principles (discrete simulation of a spring) to model wave actions. This algorithm shows how large-scale patterned behavior can result from the interaction of simple agents.

Algorithm Description

The algorithm for this behavior is really quite simple. The initial layout for the project looks like this:

Where each red "turtle" represents a "particle" of water (imagine we have a square dish full of water, and we are viewing it from directly above).

For simplicity's sake, I assumed that each agent was fixed in a single patch, and the only motion it could make was a movement up or down (from our view, towards the observer or away from the observer). Every individual turtle had both a position attribute and a velocity attribute. Every agent was initialized to a "position" of 0 and a "velocity" of 0, where a negative position meant further from the observer and a positive position meant closer to the observer. Each agent was continually running the following pseduocode and constantly updating it's position.


   set position to position + velocity (since velocity is a change in position)
   get the position of my eight bordering neighbor "particles"
   calculate the average of these values, and set this value to goalPos
   set dPos (change in position) to the goalPos - pos
   set our velocity to velocity + dPos * c, where c is a "stiffness" constant

The last line in the pseudocode is an implementation of Hooke's Law, which states that Force (or in this case, velocity) is proportional to the change in position, given a constant. This law is usually used in relation to springs, but if we think of the surface of water as a relaxed sort of "trampoline", then Hooke's law provides a perfect method for examining wave behavior.

Now you may have noticed that if all particles are initialized to position 0 and velocity 0, they will never change position, since no neighbors change position. This makes perfect sense--a level collection of water will stay level until something disturbs it. In order to start the simulation, I gave a single particle a position of -1 and veloctiy 0. This was equivalent to someone dropping an item into our "pan" of water.

Results

The results of this experiment were very impressive. To allow an observer to distinguish the different "positions" of each turtle, I made each turtle change color based on its postion. Turtles at position 0 (the starting position -- a "flat" surface of water) were colored red. Turtles with negative positions (farther away from the observer) were colored yellow and turtles with positive position (closer to observer) were colored blue

In a simple setup (and where the particles on the edges of the screen are not allowed to move--they function like the "rim" on a drum head) There was an obvious "ripple" effect that occured outward from the initial point of perterbation. There was also simple relection--the waves tended to bounce back off the "walls" just as real waves would.

     

In a setup with an obstacle in the middle of our screen, we see what appears to be natural wave patterns as the waves "bend" around the wall we've constructed.

     

Usefulness/Applicability

Even though many people will agree this is an interesting example, there may be some question as to its use in any related field. Simulating wave motion in and of itself is not completely interesting, but the idea of position changes between neighboring "particles" is very intruiging. While wasn't able to find any examples of current algorithms that exploit this feautre, I was able to think of a few fields where these simulations may be useful.

A simulation like this may be very useful for predicting the scope and impact of earthquakes. If we could give each agent its own specific "spring constant", then we would effectively be able to describe a map of tendency toward movement based of the movement of neighbors. This could give a good prediction of the complex ground movmement resulting from earthquakes.

Another personally interesting possibility is the design of drum heads. The vibration patterns of most drums are very complex, and it is difficult to completely understand how the design of different types of drums and drum heads produce such varied sounds. For example, how would it effect the vibration of a drum to place a bar accross the middle of the head? With an algorithm like the one I have created, it might be possible to test these theories.

Links to Code/Project
To see my projects in action on the web via a java applet, click on one of the following:

Basic wave movement - no barriers

View online

Advanced wave movement - one barrier

View online

If that doesn't work, you can download the StarLogo package from their homepage at http://education.mit.edu/starlogo/ and my .slogo project files from below

Basic wave movement - no barriers

Right-click and select 'Save as'
waves-8-neighbors.slogo

Advanced wave movement - one barrier

Right-click and select 'Save as'
waves-obstacle.slogo

 

The source code for each project is divided into two separate files, one containing the code for the turtles, one containing the code for the observer

Basic wave movement - no barriers

turtles source code
observer source code

Advanced wave movement - one barrier

turtles source code
observer source code