Introductory Concepts for Wave Dynamics Part 2
Simulation vs Animation
A simulation begins with a mathematical or behavioral model of a system.
-
The model is built on a framework of procedural logic and computation.
-
The data which the model uses is well defined and specific:
-
friction and other forces
-
size, position, velocity etc.
-
any other numbers or logical relationships which are important to describe the real world system being simulated.
-
Data which comes from the user interface is usually called a parameter. Generally there is a slider or similar GUI component to set a value.
-
Some of the data can be generated internally by the model.
Models can be relatively simple and still give complex results.
-
The simulation runs using the model:
The simulation is divided into small time steps.
-
For each current time step, the model is computed. Then the agents are all updated using the new data from the model.
-
This can be things like position, rotation, velocity, acceleration. It can also be a color change, or one agent creating or destroying another agent.
-
Because the model is a computer program, the variety of behavior and results from a simulation is almost limitless.
-
The model has a state which is the total of all the data, logic, computation and other procedures or information which is designed into the model.
-
The state generally changes with each time step. The time step is chosen to be small enough so the changes are gradual, not radical.
-
If the time step is too large it is easy for the model to become unstable. If this happens, the simulation should be restarted with a smaller time step so the simulation run produces legitimate results.
-
The models in NetLogo are called "agent based simulations"
This means that each object you see on the screen is an agent. An agent is like an animal: it exists separately from other agents, but usually communicates with the other agents. Each agent has its own behavior which may be influenced by communication with other agents.
-
NetLogo calls these agents "turtles". The origin of the NetLogo language is the Logo language which called the agents turtles because it sounds friendly and fun. Keep in mind that you can do some pretty serious work with these turtles.
-
Each turtle has its own set of behavioral rules. These are generally fairly simple. The complexity of the simulation arises when many turtles work together, communicating with each other, telling the other turtles information about what this turtle is doing (or about to do, or just did).
-
The behavioral rules can be logical, like "go forward 3 spaces and turn 10 degrees left". This type of rule is used in the NetLogo model file called "sunflower".
-
The rules can be mathematical, like "ask all your neighbor turtles what is their position and velocity at the current simulation time step. Use this information to compute your own velocity and position at the next time step." This type of rule is similar to what is used in the Wave Machine model.
-
Turtles may all have the same rules, or every turtle could have a different set of rules. Small groups of turtles may have a commonly held set of rules, and different groups can have different sets of rules.
-
All these various possibilities are what give rise to complex behavior. It is very similar to the way biological societies work. Bees and ants are good examples of large groups of agents which follow simple rules to accomplish very focused, useful tasks, e.g. storing enough food for winter, so that all the agents have enough to eat.
-
In the wave tutorial, you can look at the WaveMachineNNN.nlogo files to see the code which all the turtles on the screen use as their set of rules.
-
The code is fairly simple.
-
"setup" routine initializes the model for each simulation run.
-
"run" is called at each time step of the simulation.
-
"run" calls "propagate" which does the wave calculations.
-
the other routines are utilities.
-
In each simulation page, there is a link to look at the code, which is the same for all the simulations.
-
Only the values of the parameters changes to produce the wide variety of behaviors of the different simulations.
-
Each simulation computes the values for all the parameters and the interaction of the turtles in realtime as the simulation proceeds. This is the primary difference between a simulation and an animation:
Simulations compute data for every time step of the simulation run. This data is then used to produce graphics which are displayed on the computer screen. The graphics are showing you what the simulation is doing. You can change some of the parameters while the simulation is running. Doing this will produce some unique and surprising results.
-
An animation is a set of static images which are presented on screen one after the other, like a movie. The images don't change, so the animation is the same from one run to the next.