# Particle System Waterfall

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## WHAT IS IT?

This particle system models a waterfall where a steady stream of particles is created, then fall and bounce off the bottom.

For basics on particle systems, start with Particle System Basic and Particle System Fountain.

## HOW IT WORKS

In this model each particle has three main behaviors:

- If there is room ahead, it continues its trajectory.
- If it's about to touch the floor, its velocity-y is reversed and scaled by a restitution coefficient.
- If it's about to touch the left side, right side or ceiling, it disappears.

A particle with an initial velocity emerges from the top left of the world. It is subjected to the force of gravity, which slows it down and pulls it to the bottom of the world. In addition, forces of wind and viscosity are present. The maximum number of particles and the particle rate can be changed with the appropriate sliders. Finally, the step of the systems, which controls the precision of the system calculations can be increased or decreased, but it will change the speed of the systems since more calculations have to be done for a more precise simulation. Below, the use of each slider, button and switch is explained.

## HOW TO USE IT

Press GO to start the particle waterfall. You can then modify the settings to change how the waterfall behaves. Note that no new particles will emerge once MAX-NUMBER-OF-PARTICLES has been reached, until one or more die by reaching the ceiling or sides.

World boundaries: When a particle leaves the world, the PATCH-AT command returns NOBODY. Thus, every iteration, if PATCH-AT does not return NOBODY, the particle continues its trajectory. However, if the particle is close to the left wall, right wall or ceiling, and the patch-at command returns that the next patch does not exist (i.e., NOBODY), and the particle "dies".

Bouncing: In order to bounce off the floor, the particle must detect if its next position will be outside of the world. If the patch at the next location is equal to NOBODY and the particle is away from the other walls, the particle's velocity-y (VELOCITY-Y in the code) is multiplied by a negative constant (related to RESTITUTION-COEFFICIENT) to make it bounce vertically.

Energy restitution: RESTITUTION-COEFFICIENT models the energy interchanged by the particle when it bounces off the walls. If the coefficient is less than 1, it models a realistic damping caused by the energy dissipated in the collision. If the coefficient is greater than 1, the walls increment the particle's kinetic energy with each bounce. This behavior can be sometimes observed in pinball machines.

Initial velocities: The INITIAL-VELOCITY-X and INITIAL-VELOCITY-Y sliders control the initial velocity in the x and y axes for each particle.

INITIAL-RANGE-X: To make the particle system appear more realistic, each particle can be given a different random velocity at startup. To set the random velocities, give INITIAL-RANGE-X a nonzero value. Larger values will spread the waterfall out more. (Even when this switch is off, the particles will have distinct trajectories, due to their different masses.)

Maximum particle number: The number of particles in the system is bounded by the MAX-NUMBER-OF-PARTICLES slider. Once the particle count reaches the MAX-NUMBER-OF-PARTICLES limit, the generation of new particles is stopped. Note that each time a particle reaches the edge of the screen it dies, providing an opening for another particle to be created.

Gravity: Gravity acts downwards, and is implemented by adding a negative number, the GRAVITY-CONSTANT, to the y force accumulator. We also scale the effect of gravity according to the particle's mass. This simulates the effect of air resistance.

Wind: The wind force sways the particles of the system left and right in the world by adding a WIND-CONSTANT-X force in the x-axis.

Viscosity: The viscosity force resists the motion of a particle by exerting an opposite force proportional to the VISCOSITY-CONSTANT to the speed of the particle. A higher VISCOSITY-CONSTANT means the particles flow easier.

Step size: A smaller STEP-SIZE will increase the precision of the trajectories but slow down the model computation. A large STEP-SIZE will decrease the precision of the trajectories but speed up the model computation. Every iteration, STEP-SIZE scales the particle's velocity and change in location.

Particle rate: The particle RATE sets the rate at which new particles are generated. A rate of 0 will stop the waterfall's flow.

## THINGS TO NOTICE

The particles spread out horizontally according to size. Why?

## THINGS TO TRY

Move the sliders and switches to see the behaviors you get from each force. For example, by moving all sliders but GRAVITY-CONSTANT to a neutral position, you can see how gravity acts on the particles. After you have seen how each individual force acts (initial velocities, viscosity, wind, and the restitution coefficient), combine them to see how they act together.

You should pay particular attention to RESTITUTION-CONSTANT, what happens when the restitution constant is below 1 and what happens when the restitution constant is above 1?

Move the sliders in order to make the model look the most like a real waterfall to you.

Remember you can move the sliders while the model is running.

## EXTENDING THE MODEL

Hide the particles and put the pen down in the CREATE-PARTICLE procedure to see the trajectories of the particles accumulate over time.

Change the color of the particles when they bounce.

Change the position of the particle source.

Try to make the particles bounce off the right and left wall so the water accumulates.

Add a repulsion force so the particles do not overlap and the water level goes up.

Change the model to make it look like another physical phenomena.

## NETLOGO FEATURES

A difficulty in this example is to detect when a particle is going to hit a wall in order to make it bounce or die. Check the `apply-forces`

procedure to see how the `patch-at`

, `nobody`

, `max-pxcor`

, `max-pycor`

, and `min-pxcor`

. If you do not take care to detect the boundaries and you try to move the turtle out of bounds you will receive the following error message:

Cannot move turtle beyond the world's edge.

In order to avoid getting this error message, check if the patch in the following xcor ypos position exists with for example the following true/false reporter:

```
patch-at step-x step-y = nobody
```

## RELATED MODELS

Particle System Basic

Particle System Fountain

Particle System Flame

## CREDITS AND REFERENCES

See Particle System Basic for a list of references on particle systems.

Thanks to Daniel Kornhauser for his work on this model.

## HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

- Kornhauser, D. and Wilensky, U. (2007). NetLogo Particle System Waterfall model. http://ccl.northwestern.edu/netlogo/models/ParticleSystemWaterfall. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

## COPYRIGHT AND LICENSE

Copyright 2007 Uri Wilensky.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

## Comments and Questions

turtles-own [ mass velocity-x ; particle velocity in the x axis velocity-y ; particle velocity in the y axis force-accumulator-x ; force exerted in the x axis force-accumulator-y ; force exerted in the y axis ] to setup clear-all set-default-shape turtles "circle" reset-ticks end to go create-particles compute-forces ; calculate the forces and add them to the accumulator apply-forces ; calculate the new location and speed by multiplying the ; forces by the step-size tick-advance step-size display end to create-particles ;; using a Poisson distribution keeps the rate of particle emission ;; the same regardless of the step size let n random-poisson (rate * step-size) if n + count turtles > max-number-of-particles [ set n max-number-of-particles - count turtles ] ask patch min-pxcor max-pycor [ sprout n [ set color blue set size 0.5 + random-float 0.5 set mass 5 * size ^ 2 ; mass proportional to square of size setxy min-pxcor max-pycor set velocity-x initial-velocity-x - random-float initial-range-x + random-float initial-range-x set velocity-y initial-velocity-y ] ] end to compute-forces ask turtles [ ; clear the force-accumulator set force-accumulator-x 0 set force-accumulator-y 0 ; calculate the forces apply-gravity apply-wind apply-viscosity ] end to apply-gravity ;; turtle procedure ; scale the force of the gravity according to the particle's mass; this ; simulates the effect of air resistance set force-accumulator-y force-accumulator-y - gravity-constant * mass end to apply-wind ;; turtle procedure set force-accumulator-x force-accumulator-x + wind-constant-x set force-accumulator-y force-accumulator-y + wind-constant-y end to apply-viscosity ;; turtle procedure set force-accumulator-x force-accumulator-x - viscosity-constant * velocity-x set force-accumulator-y force-accumulator-y - viscosity-constant * velocity-y end ; calculates the position of the particle at each step but bounces if the particle ; reaches the edge to apply-forces ask turtles [ ; calculate the new velocity of the particle set velocity-x velocity-x + ( force-accumulator-x * step-size) set velocity-y velocity-y + ( force-accumulator-y * step-size) ; calculate the displacement of the particle let step-x velocity-x * step-size let step-y velocity-y * step-size let new-x xcor + step-x let new-y ycor + step-y if patch-at step-x step-y = nobody [ ; if the particle touches a wall or the ceiling, it dies if new-x > max-pxcor or new-x < min-pxcor or new-y > max-pycor [ die ] ; if the particle touches the floor, bounce with floor-damping set velocity-y (- velocity-y * restitution-coefficient) set step-y velocity-y * step-size set new-y ycor + step-y ] facexy new-x new-y setxy new-x new-y ] end ; Copyright 2007 Uri Wilensky. ; See Info tab for full copyright and license.

There are 10 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Particle System Waterfall.png | preview | Preview for 'Particle System Waterfall' | almost 10 years ago, by Uri Wilensky | Download |

This model does not have any ancestors.

This model does not have any descendants.