Surface Flow

No preview image

1 collaborator

Default-person Garrett Love (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.2 • Viewed 172 times • Downloaded 11 times • Run 0 times
Download the 'Surface Flow' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

globals [informed ]
turtles-own [flowed]
patches-own [ pote accum]

to setup
  clear-all
  set informed FALSE                                                                   ; Flags to control when message is provided.  No need to give the same message more than once.  But in the simplest approach, clear-all clears variables, so pressing setup again resets the flags and messages will show again.
  load-energies
  reset-ticks
end 

to load-energies
 let grid
 (list
 100  98 100 100 100  97  98  99 100 100
 95  92  97  99  97  94  91  92  90  93
 91  89  93  96  91  90  88  84  87  86
 85  83  89  88  84  85  82  80  82  83
 79  77  83  82  81  79  77  77  78  80
 72  73  75  77  75  71  72  73  74  75
 68  69  68  70  71  67  67  66  69  70
 63  64  65  66  63  64  62  61  66  67
 60  61  60  59  58  60  57  58  63  63
 53  58  57  56  53  56  52  53  59  60
 )
  let xer 0
  let yer world-height - 1
  let v 0
  let i 0
  while [ yer >= 0 ]                                                                   ; Cycle through, reading values and assigning them to patches.
  [
    while [ xer <= 9 ]
    [
      ask patch xer yer [ set pote item i grid ]
      set i i + 1
      set xer  xer + 1
    ]
    set yer yer - 1
    set xer 0
  ]
  let mx max [ pote ] of patches                                                       ; Get the minimum and maximum pote for patches for use in scaling colors
  let mn min [ pote ] of patches
  ask patches
  [
    set pcolor scale-color green pote mn mx
    ifelse pcolor <= 53                                                                 ; Change label colors based on the colors of the patches.  This seems odd to me.  It works in a way, but may confuse students.
    [ set plabel-color white ]
    [ set plabel-color black ]
    set plabel pote                                                                    ; And label the patches.
  ]
end 

to go
  ifelse count turtles = 0
  [
    if not Leave-pathways? [clear-drawing]
    ; Create a water drop.  Where it is created includes complicating options, so moved to procedure
    repeat num-drops [add-drop]

  ]
  [ ; Flow the water drop ...
    wait 0.2
    ask turtles [set flowed TRUE]
    if not Leave-pathways? [ask patches [set accum 0]]
    ask turtles
    [
      if Leave-pathways? [set accum accum + 1 if accum / 3 > pen-size [set pen-size round (accum / 3)]]
      flow
    ]

    ask turtles [if flowed = FALSE [die]]; If water has not moved kill the drop
  ]
end 

to add-drop
  ; If water is to be placed randomly ...
  ifelse Place-water-randomly? = TRUE
  [
    ifelse Water-from-top-only? = TRUE
    [ ; Water will appear in the top row only.
      ask one-of patches with [ pycor = 9 ]
      [
        sprout 1
        [
          set shape "drop"
          set color blue + 1
          set size 0.7
          set pen-size 2
          ifelse Record-pathways? = TRUE
          [ pen-down ]
          [ pen-up ]
        ]
      ]
    ]
    [ ; Water will appear anywhere in the arena
      ask one-of patches
      [
        sprout 1
        [
          set shape "drop"
          set color blue + 1
          set size 0.7
          set pen-size 2
          ifelse Record-pathways? = TRUE
          [ pen-down ]
          [ pen-up ]
        ]
      ]
    ]
  ]
  [
    if informed = FALSE
    [
      user-message "Click to add a water droplet."
      set informed TRUE
    ]
    if mouse-down? = TRUE
    [
      let xer int ( mouse-xcor + 0.5 )
      let yer int ( mouse-ycor + 0.5 )
      if Water-from-top-only? = TRUE [ set yer 9 ]                                    ; Likely not used much, but included for completeness.  Can be removed if desired.
      ask patch xer yer
      [
        sprout 1
        [
          set shape "drop"
          set color blue + 1
          set size 0.7
          set pen-size 2
          ifelse Record-pathways? = TRUE
          [ pen-down ]
          [ pen-up ]
          display
          wait 0.1                                                                      ; Pause to make sure the droplet shows on the cell selected.
        ]
      ]
    ]
  ]
end 

to flow
  let xer xcor
  let yer ycor
  downhill pote
  if xer = xcor and yer = ycor [ set flowed FALSE ]
end 

There is only one version of this model, created about 6 years ago by Garrett Love.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.