# Particle System Basic

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

## WHAT IS IT?

Particle systems are used in computer graphics to simulate the appearance of physical phenomena that can be modeled as a collection of particles. For example, some typical particle systems include: waterfalls, fire, smoke, explosions, snow, and meteors.

This example demonstrates how to write a very simple particle system only. For example, particles are only created at setup time. See the other particle system models for elaborations on the basic particle system idea.

## HOW IT WORKS

At each iteration of the GO routine, tiny forces steer the particle through its trajectory. Particles have a velocity in the x and y axes, a step and a force accumulator. This model uses a procedure to compute the forces (COMPUTE-FORCES) and another one to apply the forces (APPLY-FORCES). Combined, these procedures continuously move the particles over time.

Below are the steps for moving each particle:

1.- Initialization

First, the force accumulators are cleared of the previously calculated forces.

2.- Force Calculation

Force calculation is trivial for this particular particle system since the sole force of the model, gravity, is represented by a constant negative number. However, force calculation in general can be harder when more complicated forces, such as springs, are involved.

3.- Force Summation

After all of the individual forces are computed, the APPLY-FORCES routine sums all of them and calculates the resulting velocity of the particle.

4.- Displacement

Finally, a new position is calculated by multiplying the velocity by STEP-SIZE and adding the displacement to the current particle location. STEP-SIZE represents the small amount of time during which the forces are applied.

Notice that in this model the particles die when they reach the world boundaries.

## HOW TO USE IT

To observe only one particle at a time:

1.- Change the PARTICLES-NUMBER and STEP-SIZE.

2.- Press SETUP

3.- Press GO (Observe how the turtles move through the world.)

5.- You can optionally change the GRAVITY-CONSTANT and observe how the behavior changes.

Note that you can change the GRAVITY-CONSTANT and the STEP-SIZE while the particle is moving. For example, if the user wants the particles to fly higher he can decrease the gravity, but if he wishes the particles to stay lower he can increase the gravity pull.

## THINGS TO NOTICE

The more particles you create, the slower the model runs.

The greater the step size, the faster the model runs. (What happens if you make the step size too large?)

## THINGS TO TRY

Change the GRAVITY-CONSTANT slider while the particle is moving. Note how it stays floating or falls quickly depending when and how you adjust the gravity constant slider.

## RELATED MODELS

Particle System Fountain

Particle System Waterfall

Particle System Flame

## CREDITS AND REFERENCES

Particle Systems

http://www.siggraph.org/education/materials/HyperGraph/animation/particle.htm

Particle Systems by Allen Martin

http://web.cs.wpi.edu/~matt/courses/cs563/talks/psys.html

William T. Reeves, "Particle Systems - A Technique for Modeling a Class of Fuzzy Objects", Computer Graphics 17:3 pp. 359-376, 1983 (SIGGRAPH 83).

http://portal.acm.org/citation.cfm?id=357320

Physically based modeling Online SIGGRAPH 2001 Course Notes

http://www.pixar.com/companyinfo/research/pbm2001/

Particle Systems on Wikipedia

http://en.wikipedia.org/wiki/Particle_system

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 Basic model. http://ccl.northwestern.edu/netlogo/models/ParticleSystemBasic. 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 [ 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 ask patch 0 (max-pycor / 2) [ sprout num-particles [ set velocity-x 10 - (random-float 20) ; initial x velocity set velocity-y 10 - (random-float 20) ; initial y velocity pen-down ] ] reset-ticks end to go if not any? turtles [ stop ] 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 ; calculate and sum all the forces exerted on the particles to compute-forces ask turtles [ ; clear force accumulators set force-accumulator-x 0 set force-accumulator-y 0 ; calculate forces apply-gravity ] end ; updates the accumulator with the gravity force to apply-gravity ;; turtle procedure set force-accumulator-y force-accumulator-y - gravity-constant end ; calculates the position of the particles at each step 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 ;; if the turtle tries to leave the world let it die if patch-at step-x step-y = nobody [ die ] ;; if the turtle does not go out of bounds ;; add the displacement to the current position let new-x xcor + step-x let 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 Basic.png | preview | Preview for 'Particle System Basic' | almost 10 years ago, by Uri Wilensky | Download |

This model does not have any ancestors.

This model does not have any descendants.