Erosion Benchmark

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.1pre9 • Viewed 240 times • Downloaded 32 times • Run 0 times
Download the 'Erosion Benchmark' 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 [
  result
  show-water?     ;; whether the water is visible
  drains          ;; agentset of all edge patches where the water drains off
  land            ;; agentset of all non-edge patches
]

patches-own [
  elevation       ;; elevation here (may be negative)
  water           ;; depth of water here
  drain?          ;; is this an edge patch?
]

to benchmark
  random-seed 19192
  reset-timer
  setup
  repeat 250 [ go ]
  set result timer
end 

to setup
  clear-all
  set show-water? true
  ask patches [
    ifelse bumpy?
       [ ifelse hill?
           [ set elevation -100 * (distancexy 0 0 / max-pxcor) + 100 + random 100 ]
           [ set elevation random 125 ] ]
       [ set elevation 100 ]
    set water 0
    set drain? false
  ]
  ;; the DIFFUSE command is useful for smoothing out the terrain
  if bumpy? [
    repeat terrain-smoothness [ diffuse elevation 0.5 ]
  ]
  ;; make the drain around the edge
  ask patches with [count neighbors != 8]
    [ set drain? true
      set elevation -10000000 ]
  set drains patches with [drain?]
  set land patches with [not drain?]
  ;; display the terrain
  ask land [ recolor ]
end 

to recolor  ;; patch procedure
  ifelse water = 0 or not show-water?
    [ set pcolor scale-color white elevation -250 100 ]
    [ set pcolor scale-color blue (min list water 75) 100 -10 ]
end 

to show-water
  set show-water? true
  ask land [ recolor ]
end 

to hide-water
  set show-water? false
  ask land [ recolor ]
end 

to go
  ;; first do rainfall
  ask land [
    if random-float 1.0 < rainfall [
      set water water + 1
    ]
  ]
  ;; then do flow;  we don't want to bias the flow in any
  ;; particular direction, so we need to shuffle the execution
  ;; order of the patches each time; using an agentset does
  ;; this automatically.
  ask land [ if water > 0 [ flow ] ]

  ;; reset the drains to their initial state
  ask drains [
    set water 0
    set elevation -10000000
  ]
  ;; update the patch colors
  ask land [ recolor ]
  ;; advance to next tick
  tick
end 

to flow  ;; patch procedure
  ;; find the neighboring patch where the water is lowest
  let target min-one-of neighbors [elevation + water]
  ;; the amount of flow is half the level difference, unless
  ;; that much water isn't available
  let amount min list water (0.5 * (elevation + water - [elevation] of target - [water] of target))
  ;; don't flow unless the water is higher here
  if amount > 0 [
    ;; first erode
    let erosion amount * (1 - soil-hardness)
    set elevation elevation - erosion
    ;; but now the erosion has changed the amount of flow needed to equalize the level,
    ;; so we have to recalculate the flow amount
    set amount min list water (0.5 * (elevation + water - [elevation] of target - [water] of target))
    set water water - amount
    ask target [ set water water + amount ]
  ]
end 

There are 3 versions of this model.

Uploaded by When Description Download
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Erosion Benchmark Download this version
Uri Wilensky almost 14 years ago Erosion Benchmark Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.