Particle System Fountain

Particle System Fountain preview image

2 collaborators

Uri_dolphin3 Uri Wilensky (Author)

Tags

computer science 

Tagged by Reuven M. Lerner almost 6 years ago

particle system 

Tagged by Reuven M. Lerner almost 6 years ago

particles 

Tagged by Reuven M. Lerner about 6 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 206 times • Downloaded 14 times • Run 1 time
Download the 'Particle System Fountain' modelDownload this modelEmbed this model

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 particle fountain emitting particles from the bottom of the world.

In this model each particle has two main behaviors:

  • If there is room ahead it continues its trajectory.
  • If it's about to touch the edge of the world, it dies.
    Forces such as gravity, wind, and viscosity act on the particles as well.

HOW IT WORKS

A particle with an initial velocity emerges from the bottom center of 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 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 fountain. You can then modify the settings to change how the fountain behaves. Note that once the maximum number of particles is reached, particles will cease to emerge until another particle leaves room by dying when it is about to touch the sides or ceiling.

  • 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 fountain out more. (Even when this switch is off, the particles will have distinct trajectories, due to their different masses.)

  • Gravity: Gravity acts downwards, and is implemented by adding a negative number, the GRAVITY-CONSTANT, to the y force accumulator. Gravity is unrealistic in this system, in that its acceleration changes depending on the particle's mass. This is an important characteristic of particles systems: We can create motions that do not strictly follow real-world physical rules.

  • 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 will increase the precision of the trajectories but slow down the model computation, while a large step will decrease the precision of the trajectories but speed up the model computation. Every iteration, the STEP-SIZE scales the velocity and change in location of the particle.

  • 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 world it dies, hence by providing room for another particle to be created.

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

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, gravity coefficient), combine them to see how they act together.

Move the sliders in order to make the model look the most like a real water fountain.

Remember that 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 position of the particle source.

Change the model to make it look like another physical phenomenon, such as lava or soap bubbles.

Make the particle system look like rain, snow, or another phenomenon by changing the model to emit particles from different locations at the top of the world.

NETLOGO FEATURES

A difficulty in this example is to detect when a particle has reached the edge of the world, so it can be made to disappear. Check the apply-forces procedure to see how the patch-at and nobody primitives are used to do this detection.

RELATED MODELS

Particle System Basic
Particle System Waterfall
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:

COPYRIGHT AND LICENSE

Copyright 2007 Uri Wilensky.

CC BY-NC-SA 3.0

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

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

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 0 (min-pycor + 1)
  [
    sprout n
    [
      set color blue
      set size 0.1 + random-float 1.0
      set mass size ^ 2  ; mass proportional to size squared
      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
  [
    set force-accumulator-x 0
    set force-accumulator-y 0
    apply-gravity
    apply-wind
    apply-viscosity
  ]
end 

to apply-gravity  ; turtle procedure
  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 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.

Uploaded by When Description Download
Uri Wilensky about 6 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 6 years ago Updated version tag Download this version
Uri Wilensky over 6 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 7 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky almost 9 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 9 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 9 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 9 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 9 years ago Model from NetLogo distribution Download this version
Uri Wilensky about 9 years ago Particle System Fountain Download this version

Attached files

File Type Description Last updated
Particle System Fountain.png preview Preview for 'Particle System Fountain' about 6 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.