globals [ current-row ;; agentset of patches in current row total-oil ;; keeps track of how much ground has been saturated ;; since the simulation began. ] to setup ca set total-oil 0 ask patches [ set pcolor brown ;; unsaturated soil if (pxcor = screen-edge-x) [ set pcolor yellow ] ;; Place a boundary on the right side of the screen. ;; This prevents the oil from wrapping laterally. ] ;; set up top row set current-row patches with [pycor = screen-edge-y] ask current-row [ if (pxcor mod 2 = 0) and (pcolor != yellow) [ set pcolor red ] ;; This code initializes the "oil spill". Red ;; patches represent the leading edge of the spill. ] do-plot end to go if not any? current-row with [pcolor = red] [ stop ] percolate do-plot wrap-oil end to percolate ask current-row with [pcolor = red] [ ;; oil percolates to the two patches southwest and southeast ask patches at-points [[-1 -1] [1 -1]] [ if (pcolor = brown) and (random-float 100 < porosity) [ set pcolor red ] ] set pcolor black set total-oil total-oil + 1 ] ;; advance to the next row set current-row patches-from current-row [patch-at 0 -1] end to wrap-oil if pycor-of one-of current-row = screen-edge-y [ ;; force a display update before we clear the screen display ask patches with [pcolor = black] [ set pcolor brown ] ] end to do-plot ;; This plot displays the number of patches that are red (percolating oil). set-current-plot "Percolating Oil" plot count current-row with [pcolor = red] ;; This plot displays the number of patches that are black (saturated soil). set-current-plot "Saturated Soil" plot total-oil end ; *** NetLogo Model Copyright Notice *** ; ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML). The project gratefully acknowledges the support of the ; National Science Foundation (Applications of Advanced Technologies ; Program) -- grant numbers RED #9552950 and REC #9632612. ; ; Copyright 1998 by Uri Wilensky. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. Updated 2003. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1998). NetLogo Percolation model. ; http://ccl.northwestern.edu/netlogo/models/Percolation. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/Percolation ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 233 10 645 643 100 150 2.0 0 10 1 1 1 CC-WINDOW 5 461 226 643 Command Center BUTTON 17 37 72 70 setup setup NIL 1 T OBSERVER T BUTTON 155 37 210 70 go go T 1 T OBSERVER NIL SLIDER 17 75 208 108 porosity porosity 0.0 99.0 62.0 1.0 1 % PLOT 5 114 226 286 Percolating Oil time oil 0.0 30.0 0.0 50.0 true false PENS "default" 1.0 0 -65536 true PLOT 5 287 226 459 Saturated Soil time total oil 0.0 30.0 0.0 400.0 true false BUTTON 73 37 154 70 go once go NIL 1 T OBSERVER T @#$#@#$#@ WHAT IS IT? ----------- This model shows how an oil spill can percolate down through permeable soil. It was inspired by a similar model meant to be done by hand on graph paper (see "Forest Fires, Oil Spills, and Fractal Geometry", Mathematics Teacher, Nov. 1998, p. 684-5). HOW TO USE IT ------------- Push the SETUP button. The oil spill is represented by red patches, which start at the top of the screen. (The model represents an oil spill as a finite number of oil "particles", or simply oil drops. The oil drops sink downward through the soil by moving diagonally to the right or left. The patches through which the drops spread represent the empty spaces in the soil and the POROSITY slider represents the soil's porosity (it's "holeyness"). Each drop's chance of actually moving on down is contingent on a certain probability, set by the POROSITY slider. That is, the higher the porosity, the higher the chance of a drop to percolate through it. This models the fact that in more porous soil, oil has a greater chance of continuing downward. Press the GO button to run the model. It can be run as long as you like; it resets to the top of the screen when it reaches the bottom. It stops automatically when the oil spill stops advancing. The two plots show how large the leading edge of the spill is (red) and how much soil has been saturated (black). THINGS TO NOTICE ----------------- Try different settings for the porosity. What do you notice about the pattern of affected soil? Can you find a setting where the oil just keeps sinking, and a setting where it just stops? If percolation stops at a certain porosity, it's still possible that it would percolate further at that porosity given a wider graphics window. Note the plot of the size of the leading edge of oil. Does the value settle down roughly to a constant? How does this value depend on the porosity? EXTENDING THE MODEL ------------------- Give the soil different porosity at different depths. How does it affect the flow? In a real situation, if you took soil samples, Could you reliably predict how deep an oil spill would go or be likely to go? Currently, the model is set so that the user has no control over how much oil will spill. Try adding a feature that will allow the user to specify precisely, when s/he presses SETUP, the amount of oil that will spill on that go. For instance, a slider may be useful here, but you'd have to modify the code to accommodate this new slider. Such control over the to-be-spilled amount of oil gives the user a basis to predict how deep the oil will eventually percolate (i.e. how many empty spaces it will fill up). But then again, the depth of the spill is related to the soil's porosity. Can you predict the depth of the spill before you press GO? NETLOGO FEATURES ---------------- This is a good example of a cellular automaton model, because it uses only patches. It also uses a simple random-number generator to give a probability, which in turn determines the average large-scale behavior. This is also a simple example of how plots can be used to reveal, graphically, the average behavior of a model as it unfolds. RELATED MODELS -------------- "Fire" is a similar model. In both cases, there is a rather sharp cutoff between halting and spreading forever. This model qualifies as a "stochastic" or "probabilistic" one-dimension cellular automaton. For more information, see the "CA Stochastic" model. CREDITS AND REFERENCES ---------------------- To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Percolation model. http://ccl.northwestern.edu/netlogo/models/Percolation. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 1998 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Percolation for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 @#$#@#$#@ NetLogo 2.0beta5 @#$#@#$#@ setup repeat screen-size-y - 1 [ go ] @#$#@#$#@ @#$#@#$#@