Flame

Flame preview image

1 collaborator

Hobbes286x286 Rik Blok (Author)

Tags

computer science 

Tagged by Rik Blok almost 11 years ago

particle system 

Tagged by Rik Blok almost 11 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 507 times • Downloaded 37 times • Run 0 times
Download the 'Flame' modelDownload this modelEmbed this model

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


Flame

A [NetLogo] model by Rik Blok.

http://www.zoology.ubc.ca/~rikblok/wiki/doku.php?id=science:popmod:flame:start

This is a simple particle-based simulation of flames. Individual "particles" of flame are produced at the bottom of the world and burn as they float up. It's not meant to capture real fire dynamics but just simulate the look.

References

[[NetLogo]] Wilensky, U. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL. 1999.

Comments and Questions

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

Click to Run Model

turtles-own [
  age
]

patches-own [
  pheading
]

globals [
  top
  bottom
  last-opacity
  last-eddies
  last-fuel
  last-spread
  last-lift
]

to startup
  setup
end 

to setup
  clear-all
  set-default-shape turtles "circle"
  set top    patches with [ pycor = max-pycor ] ; flames end at top
  set bottom patches with [ pycor = min-pycor ] ; flames start at bottom
  reset-ticks
  ; hint
  output-print "A particle model "
  output-print "of fire.\n"
  output-print "Press 'go' to get "
  output-print "started.\n"
  output-print "Then adjust the "
  output-print "sliders to change "
  output-print "the properties "
  output-print "of the flame.\n"
  ; remember slider settings
  set last-opacity opacity
  set last-eddies  eddies
  set last-fuel    fuel
  set last-spread  spread
  set last-lift    lift
end 

to go
  ; any sliders changed?  If so, give hint
  set last-opacity hint "Opacity of flame"    opacity last-opacity
  set last-eddies  hint "Curvature of eddies" eddies  last-eddies
  set last-fuel    hint "Rate of fuel supply" fuel    last-fuel
  set last-spread  hint "Smoothness of wind"  spread  last-spread
  set last-lift    hint "Speed of rise"       lift    last-lift
  ; add fuel to fire
  ask n-of fuel bottom [ add-fuel ]
  ; flames end at top
  ask top [ ask turtles-here [ die ] ]
  ; eddies are a property of location (patch) and change over time
  ask patches [
    set pheading pheading + plus-minus * 10
    if pheading >     eddies   [ set pheading     eddies   ]
    if pheading < ( - eddies ) [ set pheading ( - eddies ) ]
  ]
  ; blend eddies to make more continuous
  diffuse pheading spread
  ask turtles [
    ; add a bit of noise to heading
    set heading pheading + plus-minus * 10
    ; flame rises
    forward lift
    ; flame shrinks and goes red as it ages
    ; except if in a hotspot with lots of fire around.
    ; I don't know how realistic this is but it makes it look more
    ; realistic by creating "tongues" of flame.
    set age age + max sentence 0 ( 10 - count other turtles-here )
    if age < 0 [ set age 0 ]
    if age > 255 [ die ]
    set color ( sentence 255 ( 255 - age ) 0 opacity )
    set size 1 - age / 255
    ;set color scale-color 
  ]
  tick
end 

to add-fuel
  sprout 1 [ 
    ; include some variation in starting "age" of flame particle
    set age random 64
    set color ( sentence 255 ( 255 - age ) 0 opacity )
    ; let flames emerge from anywhere along the bottom
    set xcor xcor + random-float 1
  ]
end 

to-report plus-minus
  ; reports +1 or -1
  report 2 * random 2 - 1
end 

to-report hint [ def new old ]
  ;
  if new != old [
    output-print def
    output-print ( word "changed by " ( new - old ) ".\n" )    
  ]
  report new
end 

There is only one version of this model, created almost 11 years ago by Rik Blok.

Attached files

File Type Description Last updated
Flame.png preview Preview for 'Flame' almost 11 years ago, by Rik Blok Download

This model does not have any ancestors.

This model does not have any descendants.