San Joaquin Delta Levee Simulator

San Joaquin Delta Levee Simulator preview image

1 collaborator

Default-person Shane McDonald (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.3.1 • Viewed 189 times • Downloaded 22 times • Run 0 times
Download the 'San Joaquin Delta Levee Simulator' 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

breed [waters water]
breed [grounds ground]
breed [levees levee]
breed [plants plant]
breed [watertables watertable]
breed [pumps pump]
breed [flatbeds flatbed]
breed [persons person]
breed [clouds cloud]
breed [rains rain]
globals [material_toughness]

to animation
  clear-all
  create-grounds 1 [                                                                                    ;all the code in to setup basically setups the background and the environment
    set color 34
    set shape "ground"
    set size 25
    setxy 0 -14.1
    set heading 180 ]
  create-levees 1 [
    set shape "levee-Left"
    set size 15
    setxy -10 -16
    set heading 0
  ]
  create-levees 1 [
    set shape "levee-right"
    set size 15
    setxy 10 -16
    set heading 0
  ]
  create-waters 1 [
    set color [ 52 111 194]
    set shape "water"
    set size 18
    setxy -15 -14.1
    set heading 180
  ]
  create-waters 1 [
    set color [ 52 111 194]
    set shape "water"
    set size 18
    setxy 16 -14.1
    set heading 180
  ]
  create-watertables 1 [
    set color [ 52 111 194 80]
    set shape "watertable"
    set size 24
    setxy 0 -14.1
    set heading 180
  ]
  ask patches [set pcolor scale-color 86 (pycor) -4 20 ]show shade-of? blue red
  ask patches with [pycor < 0] [set pcolor scale-color 54 (pycor) 4 -20] show shade-of? blue red
  crt 1 [ set shape "sun" set size 13 setxy -13 13]
  create-clouds 1 [set shape "cloud2" set heading 90 set size 4 setxy -7 3]
  create-clouds 1 [set shape "cloud2" set heading 90 set size 4 setxy 10 13]
  create-clouds 1 [set shape "cloud2" set heading 90 set size 4 setxy -10 9]
end 

to construction
  ask grounds [                                                                                      ; moves the ground down as the levees move up
    wait .2
    if ycor >= -16 [ fd .1]
  ]
  ask levees [                                                                                       ; moves levees up by .05 until it is <= -15 and then sets size to 15
    if ycor <= -15 [ fd .05]
    set size  15
  ]
 ask watertables [                                                                                   ; moves the translucent water table down in sync with the ground, grows so it stays even with levees
   if ycor > -16 [
   wait .2
   fd .2
   set size(size + .3)
   ]
 ]
  ask waters [
    if size <= 20 [ set size(size + .2)]                                                             ;slowly increases the waters size by adding .2 to the current size each iteration
  ]
end 

to reinforcement                                                                                     ;adds rocky exterior, plants and pump
   ask levees [                                                                                      ;rocky exterior, changes shape of left side levee
     if xcor = -10 [ set shape "levee-left-rocky"]
   ]
  if count flatbeds = 0 and count plants = 0 [                                                       ;Adds the Flatbed Truck to the simulation.
  create-flatbeds 1 [
  set shape "flatbed"
  set size 3.5
  set color grey
  setxy -9 -11.55
  ]
 ]
  ask flatbeds [                                                                                    ;moves flatbed truck
    if xcor < 9 [
      set heading 90
      fd 1.5
      ]
    if xcor >= 9 [                                                                                  ;adds rocky exterior, changes shape of right side levee
      ask levees [
        if xcor = 10 [ set shape "levee-right-rocky" ]
      ]
      die
    ]
   ]
   if count persons = 0 AND count plants != 7 and count flatbeds = 0[                               ;added so plants and persons don't spawn crazily

   create-persons 1 [                                                                               ;Say hello to Jack age = ticks / x * y * z >= 100
      wait .2
      set color black
      set shape "person"
      set size 2
      setxy -7 -11.4
      set heading 90
    ]
   ]
  wait .25
  if count plants < 7 and count flatbeds = 0 [                                                      ; creates 7 plants, starting from the left side and moving towards the right
    wait .3
    create-plants 1 [
      set color green
      set shape "plant"
      set size 1.5
      setxy -7 -11.4
      set heading 90
     ]
    ask persons [                                                                                   ;commands the person to move two units until it is at an x coordinate <= 14
      if xcor <= 14 [fd 2]
    ]
    ask plants [
      if xcor <= 14 [fd 2]
     ]

 ]
  if count plants = 7 AND count pumps = 0 [                                                         ;once all 7 plants are done, creates a pump
    wait .3
    create-pumps 1
    ask pumps [
      set heading 0
      set color 7
      set shape "pump"
      set size 6
      setxy -7 -12.1
      ask persons [
        die
      ]
    ]
  ]
end 

to maintenance

   ask waters [
    if xcor = 16 [                                                                                ; orients and adjusts the position of right side water
      set heading 90
      fd 1.2
      set heading 180
    ]
    if xcor = -15 [                                                                               ; "" for left
      set heading 270
      fd 1.2
      set heading 180
    ]
    if size <= 25 [                                                                               ; "raises the water level" by increasing the size of the water turtle
    wait .2
    set size(size + .5)
    ]
    if size >= 25 [                                                                               ; increases the size of the levees to compensate for increased water level
      ask levees [
        if size < 17 [
        wait .2
        set size(size + .4)
      ]
     ]
    ]
   ]
   ask watertables [                                                                              ; increases the height of the water table as the water levelp increases
     if size <= 34 [
     wait .2
     set size(size + .4)
     ]
   ]
end 

to pumping
  ask watertables [                                                                               ; "pumps" out the water, decreases water level
    if size >= 28 [
      wait .2
      set size (size - .6)
    ]
  ]
end 

to simulation
  clear-all
  ask patches [set pcolor scale-color 86 (pycor) -20 20 ]show shade-of? blue red                  ;creates gradient
  ask patches with [pxcor >= 12 AND pycor <= -4] [set pcolor brown]                               ; following lines set up the ground and levee
  ask patches with [pxcor = 11 AND pycor <= 1] [set pcolor green]                                 ;sets to green as a placeholder color
  ask patches with [pxcor = 10 AND pycor <= 0] [set pcolor green]
  ask patches with [pxcor = 9  AND pycor <= -1] [set pcolor green]
  ask patches with [pxcor = 8  AND pycor <= -2] [set pcolor green]
  ask patches with [pxcor = 7  AND pycor <= -3] [set pcolor  green]
  ask patches with [pxcor = 6  AND pycor <= -4] [set pcolor  green]
  if material = "Gripper System" [ ask patches with [pcolor = green] [set pcolor [51 102 0]]]     ;material specific colors for levee
  if material = "Ground" [ ask patches with [pcolor =  green] [set pcolor [102 51 0]]]
  if material = "Concrete" [ ask patches with [pcolor = green] [set pcolor [128 128 128]]]
  if material = "Rock" [ ask patches with [pcolor =  green] [set pcolor [64 64 64]]]
  if water_level - 16 > 1 [                                                                       ;if the water level is above a certain point, automatically flood the levee
     ask patches with [pcolor != [64 64 64]
       AND pcolor != [128 128 128]
       AND pcolor != [102 51 0]
       AND pcolor != [51 102 0]
       AND pcolor != green
       AND pycor < water_level - 16] [set pcolor blue]
     ask patches with [pycor <= -4
       AND pxcor >= 12][set pcolor brown]
  ]
  if water_level - 16 <= 1 [                                                                       ;if water level is above the ground, but not above the top of the levee, let water run up to the edge but not over
    ask patches with [pcolor != [64 64 64]
      AND pcolor != [128 128 128]
      AND pcolor != [102 51 0]
      AND pcolor != [51 102 0]
      AND pxcor < 12 AND pcolor != green
      AND pycor < water_level - 16] [set pcolor blue]
  ]
  create-turtles plant_life [                                                                      ;creates a couple randomly placed plants
    setxy 13 -3
    set shape "plant"
    set color [21 207 76]
    set size 3
    set heading 90
    fd random 7
    ]
  ask n-of (salinity / 1.5) patches with [pcolor = 105][sprout 1[set shape "circle"
       set size 0.225
       set color white
       set heading random 360]]                                                                    ;creates salt particles to indicate salinity
  reset-ticks
end 

to start
  tick
  wait .5
  ask turtles with [color = white][                                                                ;random salt particle movement
     set heading random 360
       if patch-ahead 2 != nobody [
          if [pcolor] of patch-ahead 2 != 105 [back 2]
          ]
      forward 1
      ]
  if material = "Ground" [ set material_toughness 1]                                               ;sets up material based durability value
  if material = "Gripper System" [ set material_toughness 2]
  if material = "Rock" [set material_toughness 1.25]
  if material = "Concrete" [set material_toughness 1.5]
  if ticks / ( material_toughness * 2) / ( plant_life * .75 ) * ( salinity * .5) * ( water_level * 2) * ( rain_intensity * .2) / 45 >= 100 [ ; calculation for levee durability, when 0, flood the levee
    let break_height -4                                                                            ;creates a variable to hold the level at which the water is supposed to break
    if water_level < 14 [
      set break_height (water_level - 16)
    ]
    ask patches [set pcolor scale-color 86 (pycor) -20 20 ] show shade-of? blue red                ;recreates gradient, effectively clears the map
    ask patches with [pycor < water_level - 16 AND pxcor < 6][set pcolor blue]
    if material = "Gripper System" [ask patches with [pycor <= break_height AND pxcor >= 6][set pcolor [51 102 0]]]
    if material = "Ground" [ask patches with [pycor <= break_height  AND pxcor >= 6][set pcolor [102 51 0]]]
    if material = "Rock" [ ask patches with [pycor <= break_height AND pxcor >= 6][set pcolor [64 64 64]]]
    if material = "Concrete" [ ask patches with [pycor <= break_height  AND pxcor >= 6][set pcolor [128 128 128]]]
    ask patches with [pycor <= break_height  AND pxcor >= 12][set pcolor brown]
    ask patches with [pycor <= water_level - 16 AND pycor >= break_height ][set pcolor blue]
    ask turtles with [color != white AND color != blue ][die]
  ]
  if water_level > 17 [                                                                             ;if water level is above a certain point, flood the levee
    ask patches with [pcolor = [64 64 64]
                OR pcolor = [128 128 128]
                OR pcolor = [102 51 0]
                OR pcolor = [51 102 0]
                OR pcolor = brown
                AND pycor > -4][set pcolor blue ]
    ask turtles with [color != white][die]

  ]
   if count rains < rain_intensity [                                                                ; determines amount of rain water droplets at once
      create-rains 1 [
      set shape "drop"
      set heading 180
      set color blue
      set size .75
      setxy random-xcor 15
    ]
  ]
   ask rains [                                                                                       ;controls rain movement
    if ycor >= -14 [fd 4]
    if ycor <= water_level - 16 [die]
  ]
end 

There is only one version of this model, created almost 3 years ago by Shane McDonald.

Attached files

File Type Description Last updated
San Joaquin Delta Levee Simulator.png preview Preview for 'San Joaquin Delta Levee Simulator' almost 3 years ago, by Shane McDonald Download

This model does not have any ancestors.

This model does not have any descendants.