Beruflich Dokumente
Kultur Dokumente
2010
This Thesis is brought to you for free and open access by The University of Toledo Digital Repository. It has been accepted for inclusion in Theses and
Dissertations by an authorized administrator of The University of Toledo Digital Repository. For more information, please see the repository's About
page.
A Thesis
entitled
Modeling Diffusion Using an Agent-Based Approach
by
Pratibha Sapkota
Submitted to the Graduate Faculty as partial fulfillment of the
requirements for Masters of Science degree in Civil Engineering
An Abstract of
Modeling Diffusion Using an Agent-Based Approach
by
Pratibha Sapkota
Submitted to the Graduate Faculty as partial fulfillment of the
requirements for Masters of Science degree in Civil Engineering
The University of Toledo
May 2010
Arsenic is one of the toxic substances introduced in groundwater by various
anthropogenic and natural sources. Understanding fate and transport of arsenic in
groundwater and wetlands is crucial for remediation. Previously fate and transport of
arsenic have been modeled using various equation based methods (EBM) such as
ordinary differential equations (ODE) and partial differential equations (PDE), which
encompass rigorous mathematics and assume that only one species of arsenic is present.
But in reality, various forms of arsenic are present in groundwater. Based on the
availability of oxygen, arsenic transforms from one form to another, thus creating a
heterogeneous mix. Therefore, the equations used to describe the relation among
parameters of interest become non-linear. The agent-based method (ABM) has emerged
as a potential tool to model multidisciplinary and highly complex environmental
problems. The goal of this research was to develop an ABM for the transport of arsenate
(H2ASO4-) in water and soil. First, the diffusion of arsenate from contaminated water into
the overlying uncontaminated water was modeled and second, the diffusion of arsenate
iii
from contaminated soil to the overlying uncontaminated water was modeled. Since this is
the first time the model was developed using ABM, the results obtained from both
models were compared with results from HYDRUS 1-D for verification. Although
HYDRUS can model diffusion process, it is unable to model processes such as reduction
and oxidation of arsenic, which is an important process for arsenic remediation.
Therefore, HYDRUS is used for initial comparison purpose. The results obtained from
ABM and HYDRUS-1D for diffusion in water showed good agreement with each other.
However, the results obtained for diffusion in soil using ABM and HYDRUS 1-D were
not in complete agreement with each other. The difference in the results obtained was due
to the relation on which each model focused upon. Specifically, HYDRUS results were
obtained by assigning diffusivity coefficient value and monitoring variability over time
by using partial differential equations. However, ABM results were obtained by allowing
each individual contaminant to move freely in the porous soil. Another reason for the
difference was due to tortuosity. In HYDRUS, tortuosity depends on porosity (i.e. = 1/3
), but ABM model does not have a specific relation between tortuosity and porosity,
iv
Acknowledgements
First of all, I would like to thank my advisor Dr. Defne Apul for her constant support and
guidance throughout my research. I am thankful for her encouragement during my time in
UT. I also thank her for giving me an opportunity to work under her guidance.
I would also like to thank Dr. Daryl Dwyer and Dr. Gursel Serpen, my committee
members for their presence in my masters thesis. I would like to thank them for giving
valuable suggestions and feedbacks.
Special thanks to my friends Chirjiv Anand and Jill Shalabi for their valuable help and
suggestions throughout my thesis.
Lastly, I am very thankful to my family. They have always supported, encouraged, and
inspired me in every step of my life and work. Finally, and most of all, I want to thank
my husband, who makes everything I do worthwhile. His love, support, and patience
make me very happy. I am very thankful for every moment I spend with him and this
thesis is dedicated to him.
Table of Contents
vi
Appendices ........................................................................................................................ 59
Appendix A: Information Tab for Enzyme Kinetics and B-Z reaction............................. 59
Appendix B: Information Tab for Diffusion in Water ...................................................... 61
Appendix C: Information Tab for Diffusion in Porous Media.......................................... 62
Appendix D: NetLogo Code for Diffusion in Water ........................................................ 63
Appendix E: NetLogo code for Diffusion in Soil ............................................................. 65
Appendix F: NetLogo code for Diffusion in Soil with Varying Porosity ......................... 67
viii
List of Tables
ix
List of Figures
Figure 16 : The plot is obtained by assigning 0.1 mg to a turtle. The plot is very smooth
and the variation after 50 simulations is also very small. ................................................. 40
Figure 17: Cumulative flux after 40 days ......................................................................... 43
Figure 18: Cumulative flux after 40 days ......................................................................... 44
Figure 19: HYDRUS vs. NetLogo for diffusion in water ................................................. 44
Figure 20: Diffusion in soil ............................................................................................... 45
Figure 21: HYDRUS vs. NetLogo for diffusion in soil .................................................... 46
Figure 22: Cumulative flux after 40 days for diffusion in soil with varying porosity ...... 47
xi
1. Introduction
Recently there has been a keen interest in using constructed wetlands for water
quality improvement (Green et.al., 1997; Goulet et. al., 2001; Kadlec and Reddy, 2001).
Constructed wetlands are recognized as energetically sustainable systems because they
use natural energy to reduce pollutants. Various efforts have been made in the past to
treat arsenic laden wastewater using wetlands and algae ponds (La Force et al., 2000;
Wilkin and Ford, 2006; Kalbitz and Wenrich, 1998; Buddhawong et al., 2005). These
studies have shown that the removal capacities are higher in soil based wetlands than in
algae ponds.
Mechanisms involved in arsenic removal from water in a wetland are very
complex, comprising a large array of physical, chemical, and microbiological reactions.
Numerous studies have given details on complex processes involved in arsenic removal
from water using wetlands (Smith et al., 1998; Mahimairaja et al., 2005). These studies
showed that wetlands with proper soil type, plants, and microorganisms are efficient for
reducing arsenic below influent concentrations.
1.3 Fate and transport of arsenic in a wetland
removing arsenic from water. Adsorption on soil colloids (clay, oxides, Al, Fe,
Mn, CaCO3, organic matter) is one of the most important processes in arsenic removal
from soil solutions. Precipitation of solid phase is another mechanism of arsenic removal
from the soil solutions. Reduction-Oxidation (Redox) of arsenic compounds also plays a
vital role in removing arsenic by changing arsenic compound into different forms. Microorganisms such as bacteria, fungi also help in reducing arsenic concentration from the
soil solutions by changing arsenic compound into volatile form.
As(V) compounds
Plant uptake
Precipitation
Demethylation
Organic As
Adsorption
As (V)
Desorption
Methylation
Reduction
Oxidation
Oxidation
As (III)
Microbial activity
Reduction
Adsorption
Dissolution
Precipitation
Diffusion
Diffusion
As compounds
Input
Output
Advection
Advection
The fundamental processes for moving and mixing contaminants in wetlands are
advection, diffusion, and dispersion. Advection is the transport of contaminant along the
flow of water. Diffusion and dispersion signify the mixing of contaminants due to
concentration gradients. The most commonly used equation for the transport of
contaminants in porous media, the advection dispersion equation, is given by
=
Where
the individual components in order to make future predictions accurately. Hellweger and
Kianirad (2007) have shown that for a system that is heterogeneous and non-linear,
existing modeling methods produce significant errors because variability within species is
not accounted for. Therefore, research is needed for characterizing and quantifying the
sources of variability so that accurate models can be developed.
The agent-based method (ABM) has emerged as a potential tool to deal with the
multidisciplinary and highly complex environmental problems. The growing interest in
this technique is due to its ability to incorporate more realistic assumptions than existing
fate and transport models; therefore, ABM is proving effective in simulating many real
world fate and transport problems. Salgado and Aranda (2007) developed and compared
the performance of ABM to equation based modeling (EBM) and found that for modeling
adsorption on solid surfaces, results obtained from ABM were more stable than the
results obtained from EBM. Gujer (2002) and Schuler (2005) showed that EBM
introduces error while simulating water quality models because it uses an averaging
assumption for nutrient uptake across the entire population. Hellweger (2007) has
suggested ABM as an alternative to EBM in such a situation as it does not make any
averaging assumptions.
2. Motivation
3. Background
The basic transport processes governing the transport of chemicals are advection,
diffusion, and dispersion. All of these processes can occur simultaneously during the
transport of chemicals or the transport can be dominated by a single process. For
example, when flow velocity is zero, chemical movement takes place through diffusive
transport and when flow velocity is large, advection and dispersion effects dominate.
Computational approaches to problems involving advection-diffusion equations are
relatively well studied, and in depth discussions about transport phenomenon and
applications can be found in various textbooks (Bear, 1972; Freeze and Cherry, 1979;
Fetter, 1993).
3.1.1 Diffusion
Diffusion is one of the widely studied transport processes in fate and transport
problems (Selvadurai, 2004; Bulavin et al., 2008; Rebour et al., 1997). Fick introduced
the concept of diffusion and stated that diffusive flux is directly proportional to
Existing experimental methods only provide the effective diffusion coefficient i.e.
coefficient averaged over diffusion zone (Weber, 1996). Gathering information relating
to individual diffusion mechanisms, molecular level characteristics using the existing
methods is also very difficult, if not impossible. Individual level modeling appears to be
the viable method for gaining insights into the complexities of diffusion, and it provides a
fundamental framework for solving diffusion problems.
without a driving force, forward and backward jumps occur with the same jump rate.
The net flux J [amount L-2T-1]
from one point to another is given by
J= n1 n2.
where n1[L-2] and n2[L-2] are related to volume concentrations of diffusing molecules
C1=n1/ ,
C2=n2/ 2
10
ABM is also known by several other names such as Agent-Based Systems (ABS)
and Individual Based Modeling (IBM). All of these terminologies are extensively used
(Macal and North, 2005), but ABM is used throughout this thesis. All the agents in the
system are modeled within a region called an environment. The environment is a virtual
world where the agents act.
Cellular Automata (CA) is yet another form of computational modeling that was
used to model complex environment but it is not as sophisticated as ABM. In CA the grid
is homogeneously populated with agents; whereas in ABM, the agents are heterogeneous
and therefore do not necessarily occupy all spaces within the grid. In CA, agents dont
11
interact with other agents outside their immediate neighborhood, but in ABM agents are
more flexible in interaction with other agents.
3.2.2 What is an agent?
Autonomous unit
Social
reactive
Proactive
12
ENVIRONMENT
ENVIRONMENT
Agent
The fundamental difference between ABM and EBM is the relationship on which
they focus. EBM begins with a set of equations that has a pre-determined relationship
among the parameters of interest. The equations are used to monitor parameter
variability over time by using ordinary differential equations (ODE) or over time and
space by using partial differential equations (PDE). The results obtained using these
equations are the outcomes of individual behaviors but those behaviors have no explicit
representation in EBM. For example, the advection dispersion equation presented in
section 1.3 models concentrations which is an aggregate parameter arising from a
collection of individual; individual behaviors are not explicitly represented in the
advection dispersion equation. In contrast, ABM begins by representing the behavior of
each individual, and then allows each individual component to interact, which produces
the ultimate outcome. Thus relationships among the parameters of interest are an output
of modeling process; they are not the input to the models (Xin and Li, 2008). In most
cases, EBM tends to aggregate the values when modeling the system. This aggregation of
the values is imprecise, and eventually leads to erroneous results (Hellweger, 2007).
To summarize, ABM has several advantages over EBM. ABM captures emergent
phenomena of global behavior from local interactions and provides a natural description
of the system that is close to reality (Bonabeau, 2002). Apart from that it is more flexible
than EBM. For example, more agents can be easily added during the simulation. The
major advantage of ABM lies in its ability to handle complexity with ease. It can also
13
encapsulate the randomness of complex systems. Moreover, it does not require as much
mathematical knowledge as is required for traditional methods [EBM] (Wishart et al.,
2004).
3.4 Comparison of Various ABM tools
ABM has been popular in various disciplines including economics, social science,
medicine, and ecology (Bonabeau, 2002), therefore, various agent-based models have
been developed. Table 1 shows the comparison of some of the popular ABM tools. ABM
platforms have been compared with respect to some of the most important features.
More information on these platforms can be found elsewhere (Berryman, 2008;
Railsback, 2006).
Increasing
Java
Fastest
Moderate
Limited
documentation
Repast
Large
Java,
python
Fast
Moderate
Limited
documentation
.etLogo
Large
NetLogo
Moderate
Good
Extensive
documentation
SWARM
Poor
Good
documentation
14
SWARM is one of the oldest and most stable ABMs that is able to support
complex models, but has weak error-handling capability. Repast is one of the powerful
agent-based modeling platforms. However, it requires an extensive knowledge of Java
and is suitable for computationally intensive models. Mason is also a good simulation
tool and is a good choice for an experienced programmer but is computationally
intensive. NetLogo has a user friendly environment and has its own programming
language that is simpler than Java or Objective-C. It also has good documentation and
visualization abilities. From the above comparison, NetLogo was found to be a suitable
platform for modeling since it is able to handle a large number of agents. Time spent on
developing this model is less than time required for some other library-based platforms
such as Repast, SWARM. Also, studies in different fields have proven the efficacy of
NetLogo for handling complexity (Chitnis & Itoh, 2004; Damaceanu, 2008; Xin et al.,
2008)
3.5 .etLogo: The ABM of preference
15
NetLogo has three main entities: agents, landscape, and observer. All of these
entities can run code, and interact with each other. Variables can be defined globally and
all entities have access to them. This structure gives modelers a great deal of flexibility
while creating models. Furthermore, NetLogo is easy to use and has excellent
documentation.
3.5.2 .etLogo in various disciplines
NetLogo has emerged as a powerful and elegant language that can incorporate
complexity and heterogeneity in a few lines of code with relative ease. Although
NetLogo has been increasingly used in many disciplines, a few examples of its use are
discussed below.
Lockta Volterra model (predator prey model, Forrestor, 1971), one of the popular
models in ecology, was traditionally simulated using EBM. Lockta Volterra model is
used to make future predictions about population level, growing population, and the rate
of consumption of natural resources. EBM solves differential equations that calculate the
value of a variable at the next time step for the given population using the value at the
current time step, but each individual in the population is not uniquely represented. This
makes it hard to model heterogeneity among individuals. It is also hard to represent
individual behaviors that depend on its past experience. But NetLogo has proved its
capability in such a scenario. When the same model was simulated in NetLogo, each
agents past behavior along with heterogeneity was modeled with ease (Wilensky, 1998).
This feature is very helpful for the current research. Figure 1 shows that arsenic species
16
changes from arsenate to arsenite and vice versa, thus making it heterogeneous. The
above example shows that NetLogo allows modeling such scenarios which are
impossible using existing EBM as it can only model homogeneous individuals.
Similarly, NetLogo has also been used for modeling complex economic systems.
For example, Damaceanu (2008) modeled wealth distribution among upper, middle, and
lower class. Each patch had some amount of resource and the turtles collected some of
that resource in order to survive. The amount of resource that each turtle collected was its
wealth. The above example proves the capability of NetLogo to model processes such as
adsorption and desorption as arsenate adsorbs on soil matrix rich in Fe and Al. Such
scenarios are difficult to model using EBM as it requires rigorous mathematics and may
not be solvable.
17
Table 2 shows the wetland processes of interest and existing NetLogo models that
resemble those processes. Left most column shows the general equation used for the
wetland processes. Middle column gives an example of equation used. The last column
shows examples of similar processes modeled in NetLogo which is useful for modeling
the wetland processes. Further details about the NetLogo models can be found in the
appendix section.
AsO43- + FeOH+3H+=
Enzyme Kinetics(Appendix A)
AB
Desorption
FeH2ASO4+H20
Reduction/Oxidation
2MnO2+H3ASO3=
2MnOOH+H3AsO4
2MnOOH+H3AsO3=
2MnO+H3AsO4+H2O
Oxidation
B
Reduction
Precipitation/Dissolution
A+B
Adsorption
Adsorption
A +B
Example
Precipitation
AB
Dissolution
B-Z reaction(Appendix A )
Dissolution
FeAsO4.2H2O+H+=
Enzyme Kinetics(Appendix A)
H2AsO4-+Fe(OH)2++H2O
Plant uptake and Microbial
uptake
=
+
= ( + )/
A+E
K1
K-1
K2
C+E
18
Enzyme Kinetics(Appendix A)
The primary objective of this study was to model diffusion using an agent-based
approach. With an agent-based approach, a greater understanding of transport of
contaminants may be possible because the results obtained are the outcomes of individual
interactions. Also, an agent-based approach provides an opportunity to examine the
impact of assumptions made by equation based approach.
4.1 Objectives
The objectives of the current study was to
Develop an agent-based model for diffusion in water and porous media using an
agent-based approach.
Verify the results obtained from diffusion in water and porous media against a well
established FEM based fate and transport model, HYDRUS.
19
5. Methodology
The NetLogo window has three tabs: interface tab, the information tab, and
procedures tab as shown in the top left of Figure 3. Only one tab is visible at a time but
one can switch between different tabs by clicking on the tabs at the top of the window.
The interface tab is used to visualize the output of the simulation and to control it. The
information tab provides text-based documentation about the simulation and expected
results. The procedure tab is the workspace where the code of the model is stored.
20
Figure 3: Screen shot of interface tab. The black box is the view.
The information tab provides an environment for the programmer to describe the
model. By default, the information tab includes the following sections: What is it?,
21
How it works, How to use it, Things to notice, Things to try, Extending the
model, NetLogo features, Related models, and Credit and References. The
programmer can edit these sections and add equations and methods used. The
information tab for the current research can be found in Appendices B and C.
In the procedure tab commands are written in a specific format as shown in Figure
4. (The code used in this study is given in Appendices D, E and F) The program has three
parts: first, the global variables are defined; second, setup procedure is written to
initialize the simulation; and third, go procedure is written that is repeatedly executed by
the system. The go procedure tells each agent to carry out the given instruction
independently. Agents in NetLogo model are referred as turtles. Typically, a population
of turtles is initialized and procedures are written that control the behavior of the turtles.
The turtles represent physical entities whose behaviors result in movements around the
two dimensional world.
22
NetLogo has four different types of agents and each agent can follow instructions
and carry out its own activity. These agents are turtles, patches, links, and observer
(Figure 5). Turtles are the functional agents and the patch is a square ground over which
the turtles move. Initially, the world is empty and the turtles are created by the observer.
In addition, the patches can create turtles, too. Patches and turtles have their coordinates
determined by the variables xcor and ycor for turtles, and pxcor and pycor for patches.
The patch with the coordinate (0, 0) is the origin which can be placed anywhere in the
view box based on the model requirement. The total number of patches is determined by
the parameters min-pxcor, max-pxcor, min-pycor, and max-pycor.
By default, NetLogo has fixed patch coordinate values, when the model starts that
can be changed accordingly. For example, when NetLogo starts, min-pxcor, max-pxcor,
min-pycor, and max-pycor values are -16, 16, -16, and 16 respectively (Figure 5). This
means pxcor and pycor both range from -16 to 16, so there are 33 times 33, or 1089
patches. The patches coordinates are only integers whereas the turtles coordinates are
whole numbers and fractions. This means the turtles can move anywhere on the patch. A
link is an agent that connects two turtles if there is relation between them.
23
Observer
Patch
Link
Turtle
In NetLogo world, the patches can wrap around indicating that when a turtle
moves to the edge of the world it disappears and then reappears on the opposite end. If
this approach is used, a one dimensional simulation can be run using a two dimensional
view box. Time is discrete in NetLogo and turtles act on each tick. A tick represents one
step of the model, i.e., one cycle of the main loop. Ticks can be either seconds, hours,
days based on the simulation requirement. If the daily events are simulated, then the time
scale is one tick per day. If hourly events are simulated, then one tick is an hour. The real
time the model takes to run is different than the model time. For example, if time scale is
one tick per year, and the model only takes one second to run, then 100 years simulation
can be simulated in 100 seconds.
24
Once the code is finalized, input parameters are provided via various buttons in
the interface tab. Output from the simulation is viewed in the interface tab without
changing the window. Basic buttons required for NetLogo are setup and go buttons which
are created by the user. Other buttons such as sliders, switches, and monitors are created
by the user based on the requirement. Output plots can easily be exported to an excel
sheet for further analysis.
Two problems were simulated using NetLogo and HYDRUS. These two
problems were adopted from Thoma et al.s work (1993). Thoma et.al (1993) studied the
transport of 2, 4, 6-trichlorophenol (TCP), a hydrophobic pollutant released from lake
bed sediments. The model consisted of a uniformly contaminated layer at the bottom of a
vertical column; sediment cap layer in the middle, and the water column at the top. The
sediment cap layer and the water column were initially contamination free. With time, the
contaminant in the contaminated sediment bed diffused into the cap layer and the water
column. Two diffusion scenarios were studied. First, the transport of contaminant in
sediment without capping was studied, and then the transport of contaminant with
sediment cap was studied. The model results were also compared with lab results, which
showed good agreement with each other, indicating that the transport mechanism is well
understood.
25
The setup for the current research is similar to that of Thoma et al (1993) but
without the sediment cap. The transport of H2AsO-4 was studied instead of TCP. The
molecular diffusion coefficient of the species is 7.82*10-5m2/day (Li and Gregory, 1974).
The problem is analyzed in two parts; first, diffusion of contaminant in water was
modeled, second, diffusion of contaminant in soil was modeled. Thoma et al. (1993) was
chosen as one of the standards for verifying NetLogo model because of its focus on
diffusion process. Alshawabkeh et al. (2005) used the Thoma et al. (1993) model to
develop criteria for evaluation and design of contaminated sediment. Similarly Valsaraj et
al. (1997) used Thomas equation to study diffusion of organic compounds through
porous media. Other authors (Valsaraj et al. (1998); Eek et al. (2008); Chen et al. (2009)
etc.) have also used the concept of Thoma et al. because of the simplicity of problem
analyzed.
26
22mm
15mm
27
According to Weber (1995), individual molecules inside the beaker have their
respective kinetic energies and undergo frequent collisions with each other. As a result of
these collisions, contaminants move in random directions. These resulting collisions carry
individual molecules from the region of higher concentration to lower or vice versa.
For the given simulation, the contaminants move randomly inside the beaker
based on a diffusivity value assigned to them. The diffusivity value is the number of
patches over which a turtle moves in a tick. Molecular Diffusion coefficient of H2AsO-4
is given by
0.0543mm2/min
= 0.78 mm2/14.4min
28
NetLogo also has built-in randomness, therefore, the simulation results vary slightly each
time the model is run. After determining the suitable amount a turtle should represent, the
29
same simulation was run over and over to see if randomness increased. The same
simulation was run 100 times to monitor net randomness of NetLogo model.
!
is the change in
30
Figure 8: Pink represents contaminated water layer and blue represents uncontaminated
water layer
The profile window allows the user to define the spatial distribution of
parameters. All the parameters in this window can be added or edited using the edit
window. The user selects the part of the domain to add a particular value for the selected
variable. The profile window is very user friendly; it is possible to select an individual
node, part of the domain, or the entire domain. For the given simulation, the
concentration of 150mg/L was assigned by selecting the rectangular domain represented
by pink as shown in Figure 8. Color-coded window on the left side of the window shows
the values represented by the domains. Blue represents a concentration of 0 and pink
represents a concentration of 150mg/L.
31
Water
(7mm)
Uniformly
contaminated layer
(15mm)
depth of the setup was 22mm. Initially, the water above 15mm was assumed to be
contaminant free. The porosity of soil was 0.49. The contaminants were uniformly
distributed throughout the depth. As discussed in section 5.5.1, the contaminants move
over 4.3 patches at each tick. When the contaminants hit a soil particle (brown patch), it
bounces off of it at an angle. According to particle-wall collision theory, when a particle
hits a smooth wall with an angle , it rebounds with a reflection angle of (180).
However, in reality the reflection angle depends on factors such as frictional force, wall
roughness, and particle spin and is a complicated process (El Hor et al., 2008;
Sommerfield, 1999). The contaminants also follow particle-wall collision principle
(Weber, 1996). Therefore, in order to keep the model simple, smooth wall reflection was
assumed for the current simulation.
33
= -1/3
Therefore, the input parameters for diffusion in soil model are porosity and diffusivity.
The porosity value of 0.49 and the diffusivity value of 7.82*10-5m2/day were used, and
then the simulation was run for 40 days. The contaminated sediment concentration was
entered through the graphical editor as shown in Figure 10. Pink represents uniformly
contaminated soil with depth of 15 mm and the blue domain represents water with depth
of 7mm.
Figure 10: Pink represents the contaminated soil layer and blue represents
uncontaminated water in HYDRUS setup
34
Water
(7mm)
Uniformly contaminated
layer (7.32 mm)
Porosity (0.49)
Uniformly contaminated
layer (7.68 mm)
Porosity (0.3)
35
move over 4.3 patches in a tick as discussed in section 5.6.1.The simulation was
performed with an initial contaminant concentration (H2AsO-4) of 150mg/L. The net
concentration in the beaker for the depth of 7.32 mm was 1098mg/m2
(150mg/L*1000m3*7.32/1000). Similarly, the net concentration in the beaker for the
depth of 7.68 mm was 1152 mg/m2 (150mg/L*1000m3*7.68/1000).Therefore, the net
concentration in the beaker was 2250mg/m2.
Figure 12: Pink represents the contaminated soil layer and blue represents
uncontaminated water in HYDRUS setup
36
The results obtained from sensitivity analysis for one turtle representing various
masses of contaminants are shown in Figures 13, 14, 15, and 16. Figure 13 shows that the
plot obtained by assigning 100mg to 1 turtle is zigzag in nature. It also shows that when
the same simulation was run multiple times, the resulting flux varies. For example,
cumulative flux after 10 days varies from 1950 mg to 2250 mg. The mean value of
cumulative flux was 2137.5mg in 10days and the standard deviation on 10th day was
112.5(Table 3). Similarly, when the same simulation was run again with relatively small
amount representing a turtle, then the curve became smoother as shown in Figure 14.
37
Figure 13:: 1 turtle equivalent to 100mg. The graph was obtained by running the same
simulation 50 times with 1 turtle equal to 100mg. The figure shows that the
cumulative flux varied between 2050 to 2250 mg afte
after 40 days.
Figure14 shows that the curve obtained by assigning 1 turtle equal to 10mg is
much smoother than the one obtained by assigning 1 turtle equal to 100mg. Even
smoother curves are seen when a tu
turtle was assigned 1mg (Figure 15)) and 0.1 mg (Figure
16),
), and the variation after multiple runs was also very small. This shows that smaller the
amount a turtle represents the smoother the curve becomes. A smoother curve represents
continuous distribution of data and facilitates easy comparison of data. How
However, using a
large number of turtles to represent the given concentration slows the simulation run
significantly. The simulation run time for a turtle representing 100mg was minute,
whereas the simulation run time for a turtle representing 10 mg and 1 mgg were
approximately 1 and 2 minutes. However, when the simulation was run with a turtle
representing 0.1mg, the simulation run time increased to 13 minutes, which is much
slower compared to the earlier cases.
38
Figure 15:: Plot obtained by assigning a turtle 1mg each. The plot is smooth although it
shows some variation among the 50 simulations.
.
39
Figure 16 : The plot is obtained by assigning 0.1 mg to a turtle. The plot is very smooth
and the variation after 50 simulations is also very small.
Table 3: Mean, Standardd deviation, and Coefficient of Variation (CV) of cumulative flux
(mg/m2) for a turtle
Simulation duration (days)
Mass
1
10
20
30
40
equivalent
1 turtle=
375
2137.5
2212.5
2225
2225
mean
100mg
std.dev
128.17
112.6
74.4
70.71
70.71
CV
0.34
0.05
0.033
0.031
0.031
mean
416.25
2097.5
2182.5
2202.5
2210
1 turtle=
std.dev
64.79
24.34
23.75
19.82
13.09
10mg
CV
0.155
0.011
0.01
0.008
0.005
mean
436.5
2097
2180.3
2204 2210.2
1 turtle=
stdev
16.51
10.9
9.86
6.76
5.86
1mg
CV
0.037
0.005
0.004
0.003
0.002
mean
422.96
2094.32
2180.98
2203.74 2209.9
1 turtle=
std.dev
6.02
4.08
1.42
1.81
1.1
0.1mg
CV
0.014
0.001
0.0006
0.0008 0.0004
40
Table 3 shows that deviation is very high after a day when turtles were assigned
100mg , but the deviation gradually decreased when turtles were assigned 10, 1, and, 0.1
mg. When small mass equivalents were assigned to each turtle, the deviation decreased
along with coefficient of variation. The small CV represents small variation among the
cumulative flux simulations and indicates a good fit for the current scenario. The table
obtained displays the expected result, which is also in agreement with Figures13-16 in
showing reduced variation in data for turtles with smaller concentrations. Based on the
results obtained it was decided to represent 1 turtle as 1mg for the current model.
Representing 1 turtle as 1mg yields similar result to the one representing 1 turtle as 0.1
mg but takes less time to run the simulations.
The results for 1 turtle representing 1mg obtained by running the same simulation
multiple times is shown in Table 4 along with mean, standard deviation, and CV values.
Even after running the simulation 100 times the CV was less than 0.1 and the deviation
was also small. This confirms that the variation among different simulation runs
remained negligible when 1 turtle represented 1mg.
41
50runs
100runs
mean
Std
dev
CV
mean
Std
dev.
CV
mean
Std
dev.
CV
30
2204
40
2210.2
10.9
9.86
6.76
0.005
0.003
0.003
2098.1 2182.72 2204.76
5.86
0.002
2210.74
12.59
8.53
6.91
18.51
0.043
0.006
0.003
0.003
428.46 2097.03 2180.71 2203.48
6.3
0.002
2209.93
16.51
0.037
424.46
18.25
0.042
10
2097
12.41
0.005
20
2180.3
7.84
0.003
6.59
0.002
6.47
0.002
42
2500.00
Cum flux[mg/m2]
2000.00
1500.00
1000.00
500.00
0.00
-500.00
10
20
30
40
50
time[days]
43
2500
2000
1500
HYDRUS
1000
NetLogo
500
0
0
10
-500
20
30
40
50
time[days]
Figure 18: Cumulative flux after 40 days
When HYDRUS and NetLogo results were plotted against each other (Figure 19),
a good fit was found between the two models. Again when the results were compared
with a 45 degree line, NetLogo results slightly underpredicted HYDRUS results.
NetLogo(mg/m2)
2500
2000
1500
1000
500
0
0
500
1000
1500
2000
2500
HYDRUS (mg/m2)
Figure 19: HYDRUS vs. NetLogo for diffusion in water
44
It can be seen from Figure 20 that both models produced similar results during the
first 10 days but after 10 days flux values from NetLogo were less than HYDRUS. The
difference in the result obtained was due to the relation on which each model focuses
upon. For example, HYDRUS results were obtained by assigning diffusivity coefficient
value and monitoring variability over time by using partial differential equations.
However, NetLogo results were obtained by allowing each individual contaminant to
move freely in the porous soil, which produced the given output. Another reason for the
difference is due to the tortuosity. Tortuosity depends on porosity (i.e. = -1/3), but
NetLogo model does not have a specific relation between tortuosity and porosity,
therefore, the result obtained differ. Also, using the ideal scenario for contaminant
bouncing may have caused the results to differ.
2500
Cum flux[mg/m2]
2000
1500
HYDRUS
1000
NetLogo
500
0
0
-500
10
20
30
40
time[days]
Figure 20: Diffusion in soil
45
50
When HYDRUS and NetLogo results were plotted against each other (Figure 21),
a good fit was found between the two models. However, when the results were compared
with a 45 degree line, the NetLogo results underpredicted HYDRUS results most of the
time. This could be because of contaminants getting trapped inside dead-end pores of soil
in the case of NetLogo.
2500
NetLogo
2000
1500
NetLogo vs. HYDRUS
1000
45 degree line
500
0
0
500
1000
1500
2000
2500
HYDRUS
Figure 21: HYDRUS vs. NetLogo for diffusion in soil
46
HYDRUS results for the first 20 days. The flux values from NetLogo were less than the
flux values from HYDRUS after 20 days. This could be because of contaminants getting
trapped inside dead-end pores of soil in the case of NetLogo.
2500
Cum flux[mg/m2]
2000
1500
HYDRUS
1000
NetLogo
500
0
0
-500
10
20
30
40
50
time[days]
Figure 22: Cumulative flux after 40 days for diffusion in soil with varying porosity
47
7.1 Conclusion
This is the first time diffusion has been modeled using NetLogo; therefore, much
emphasis is placed on verifying results with HYDRUS, a popular fate and transport
modeling platform. While comparing NetLogo results with HYDRUS, it appears that
HYDRUS is used to determine a time frame that a tick should represent in NetLogo.
However, both the models were run independently, and comparison was done against
each other. For the current diffusion model, a tick can represent any period of time (e.g.
day, year), with the diffusion coefficient changed accordingly. Since HYDRUS was run
with a time increment of 14.4 minutes, a tick for the current NetLogo model represented
48
14.4 minutes. Both models were run upto a period of 40 days with a time increment of
0.01 days or 14.4minutes.
49
References
Alhumaizi, K., 2004. Comparison of finite difference methods for the numerical
simulation of reacting flow. Computers and Chemical Engineering., 28:1759-1769
Alshawabkeh, A.N., Rahbar, N., and Sheahan, T., 2005. A model for contaminant mass
flux in capped sediment under consolidation. J. Contam. Hydrol., 78:147-165.
Bastian, R.K., and Hammer, D.A., 1993. The use of constructed wetlands for wastewater
treatment and recycling. In: G.A. Moshiri, Editor, Constructed Wetlands for Water
Quality Improvement, Lewis Publishers, Ann Arbor: 5968.
Bennett, C.H., 1975. Diffusion in Solids Recent Developments, A.S. Nowick, J.J.
Burton (Eds.), Academic Press, Inc.
Berryman,M., 2008. Review of Software Platforms for Agent-based Models, Defense
Science and technology operation, Land Operations Division, Edinburgh, Australia: 9-15.
Bonabeau, E., 2002. Agent-based modeling: Methods and techniques for simulating
human systems. Proceedings of the National Academy of Sciences, 99:7280-7287.
Botte,G. G., Ritter, J. A., and White, R.E. 2000.Comparison of finite difference and
control volume methods solving differential equations. Computers and Chemical
Engineering., 28:597-603
Buddhawong, S., Kuschk, P., Mattusch, J., Wiessner, A. and Stottmeister, U., 2005.
Removal of arsenic and zinc using different laboratory model wetland systems. Eng. Life
Sci., 5:247-252.
Bulavin, L.A., Lokotosh, T.V. and Malomuzh, N.P., 2008. Role of the collective selfdiffusion in water and other liquids. Journal of Molecular Liquids, 137:1-24.
50
Cameron, K., Madramootoo, C., Crolla, A., Kinsley, C., 2003. Pollutant removal for
municipal sewage lagoon effluents with a free-surface wetland. Water Res., 37: 2803
2812.
Casti, J. L., 1998. Would-Be Worlds: How Simulation is changing the Frontiers of
Science, John Wiley & Sons Ltd, New York.
Chen, Y.M., Xie, H.J., Ke, H. and Chen, R.P., 2009. An analytical solution for onedimensional contaminant diffusion through multi-layered system and its applications.
Environ. Geol., 58:1083-1094.
Chitnis, A.B. and Itoh, M., 2004. Exploring alternative models of rostral-caudal
patterning in the zebrafish neurectoderm with computer simulations. Curr. Opin. Genet.
Dev., 14:415-421.
Crites, R., and Tchobanoglous,G.,1998.Small and decentralized wastewater management
systems,McGraw-Hill,Boston
Damaceanu, R.C., 2008. An agent-based computational study of wealth distribution in
function of resource growth interval using NetLogo. Appl. Math. Comput., 201:371-377.
DeAngelis, D.L., Mooij, W.M. 2005. Individual-based modeling of ecological and
evolutionary processes. Annual Review of Ecology, Evolution, and Systematics., 36:147168.
Dixit, S., and Hering, J.G., 2003. Comparison of arsenic (V) and arsenic(III) sorption
onto iron oxide minerals:Implication of arsenic mobility. Environ. Sci. Technol.,
37:4182-4189.
51
Dyke, H. V., Savit, R., and Riolo, R. L., 1998 Agent-based modeling vs. equation-based
modeling:A case study and users guide, Proceedings of Workshop on Modeling Agentbased Systems:10-25.
Eapen, B.R., 2009. Agent-based model of laser hair removal: A treatment optimization
and patient education tool. Indian J Dermatol Venereol Leprol, 75:383-7
El Hor, H. and Linz, S.J., 2008. Bounce of a particle: Oblique impact on structured
surfaces. Chaos Solitons & Fractals, 36:73-81.
Eek, E., Cornelissen, G., Kibsgaard, A. and Breedveld, G.D., 2008. Diffusion of PAH
and PCB from contaminated sediments with and without mineral capping; measurement
and modelling. Chemosphere, 71:1629-1638.
Fetter, C. W. 1993. Contaminant Hydrogeology. Macmillan Pub. Co.
Flynn, C.P., 1972. Point Defects and Diffusion, Clarendon Press, Oxford.
Forrester, J. W.1971. World dynamics. Cambridge: MIT Press.
Franklin, W.M., 1975. Diffusion in Solids Recent Developments, A.S. Nowick,
J.J. Burton (Eds.), Academic Press, Inc.
Freeze, R. A., and Cherry, J.A., 1979. Groundwater Prentice-Hall, Inc., Englewood
Cliffs, NJ, 604 pp.
Garcia, J., Aguirre, P., Mujeriego, R., Huang, Y., Ortiz, L., Bayona, J., 2004. Initial
contaminant removal performance factors in horizontal flow reed beds used for treating
urban wastewater. Water Res., 38:16691678.
Gary, A., and Wilensky, U., 2009. From Artificial Life to In Silico Medicine. Springer
London. 183-214.
52
Gujer, W., 2002. Microscopic versus macroscopic biomass models in activated sludge
systems. Water Sci. Technol. 45: 111.
Green, M.B., Griffin, P., Seabridge, J.K., Dhobie, D., 1997. Removal of bacteria in
subsurface flow wetland. Water Sci. Technol. 35, 109116.
Goulet, R.R., Pick, F.R. and Droste, R.L., 2001. Test of the first-order removal model for
metal retention in a young constructed wetland. Ecol. Eng., 17:357-371.
53
54
55
56
57
58
Appendices
Enzyme Kinetics
This model demonstrates the kinetics of single-substrate enzyme-catalysis. The
interactions between enzymes and substrates are often difficult to understand and the
model allows users to visualize the complex reaction.
The standard equation for this reaction is shown below.
|
|
Kc
Kr
E + S <=======> E-S ------> E + P
Kd
59
Enzyme catalysis can also be controlled using inhibitors. Inhibitors are molecules that are
structurally similar to substrate molecules that can complex with the enzyme and interfere
with the E-S complex formation. Subsequently, the shape of the Michaelis-Menten
Curve will be altered. The model demonstrates the effects of inhibitors on catalysis.
More information on this model can be found at
http://ccl.northwestern.edu/netlogo/models/EnzymeKinetics. Center for Connected
Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
B-Z reaction
The Belousov-Zhabotinsky reaction (or B-Z reaction for short) is an unusual chemical
reaction. Instead of steadily moving towards a single equilibrium state, it oscillates back
and forth between two such states. Before this "chemical oscillator" was discovered, it
was thought that such a reaction could not exist.
If you do the reaction in a beaker, the whole beaker regularly changes color from yellow
to clear and back again, over and over. In this case, we say that the reaction is oscillating
in time. However, if you do the reaction in a thin layer of fluid trapped between two glass
plates, then a beautiful pattern emerges of concentric or spiral waves of color change
passing through the fluid. Here, the reaction is oscillating in both time and space.
This model is a cellular automaton (or CA) that produces spiral waves that resemble
those produced by the B-Z reaction. Similar spiral waves have also been observed in
biological systems, such as slime molds.
The B-Z reaction is a redox reaction that periodically moves between an oxidized and a
reduced state, and has been demonstrated for various chemicals. This model does not
attempt to replicate the actual mechanism of the chemical reaction, which is quite
complex (including 18 reactions and 21 species, according to the Fields-Koros-Noyes
model). The abstract features shared by the real reaction and this model include:
1. Two end states.
2. A positive feedback mechanism.
3. A negative feedback mechanism.
The positive feedback mechanism acts to push the system further in the direction that it is
already going, reinforcing and amplifying the initial change. (In the chemical reaction,
positive feedback comes from auto-catalysis.) The negative feedback mechanism pushes
the system back in the opposite direction once a threshold is reached, suppressing or
counteracting the effected change. More information on this model can be found at
http://ccl.northwestern.edu/netlogo/models/B-ZReaction. Center for Connected Learning
and Computer-Based Modeling, Northwestern University, Evanston, IL.
60
WHAT IS IT?
The model shows diffusion in liquid. The beaker is uniformly contaminated to the depth
of 15mm and the overlying water layer is initially contamination free.
HOW IT WORKS
The turtles move on certain number of patches randomly at each tick. The turtles
reaching the top of the model vanish.
HOW TO USE IT
The buttons used for this model are SETUP, GO, DIFFUSE, and NUMBER
SETUP button initializes the model
GO button runs the simulation
DIFFUSE slider allows the user to assign the number of patches turtles move in a tick.
NUMBER slider allows the user to change the number of turtles during the simulation.
THIGS TO TRY
Diffusive slider can be changed before or during the simulation run. Changing diffusive
slider affects the outcome of the simulation.
Number slider can be used to add more turtles before or during the simulation run. The
user can see the difference in the run time of the model.
EXTEDIG THE MODEL
The model can be further extended by adding temperature effect.
RELATED MODELS
Gaslab Adiabatic Piston
Gaslab Free Gas
61
WHAT IS IT?
This model shows diffusion in saturated soil. The soil is uniformly contaminated to the
depth of 15mm and the overlying water layer is initially contamination free.
HOW IT WORKS
The turtles move randomly inside the beaker and the turtles reaching the top of the beaker
vanish. The turtles move over certain number of patches at a tick. When the turtles hit
the brown patches (soil) they turn around 180 degrees and start moving elsewhere.
HOW TO USE IT
The buttons used for this model are SETUP, GO, DIFFUSE, and NUMBER
SETUP button initializes the model; GO button runs the simulation
DIFFUSE slider allows the user to assign the number of patches turtles move in a tick.
NUMBER slider allows the user to change the number of turtles before and during the
simulation run.
THIGS TO OTICE
This model shows how turtles look ahead before they move. By looking ahead, a turtle
determines what is in front of it and take a necessary action. Looking ahead is
appropriate in situations where the turtle is not supposed to go "on top of" certain agents.
The turtles look ahead of them and if they see brown patches they turn around 180
degrees and start moving randomly.
THIGS TO TRY
Diffuse slider can be changed before or during the simulation run. Changing diffusive
slider affects the outcome of the simulation.
Number slider can be used to add more turtles before or during the simulation run. The
user can see the difference in the run time of the model.
Soil Porosity can be changed to see how the flux varies when one changes the porosity.
EXTEDIG THE MODEL
The model can be extended by separating micropores, macropores, and adding the effects
humic substances.
RELATED MODEL
Bounce example
62
Comments are indicated by semi-colon (;;). Detail about NetLogo codes can be
downloaded from
http://cc.northwestern.edu/netlogo/docs.
to setup
;; begins defining a procedure named "setup".
ca
;; resets the world to an initial, empty state
setup-patches
;; moves to setup-patches procedure
setup-reaction
;; moves to setup- reaction procedure
do-plots
;; moves to plot
end
;; end the setup procedure
to setup-patches
ask patches [set pcolor white]
;; set up all the patches white
ask patches with [pycor = min-pycor] [set pcolor brown ]
end
to setup-reaction
crt numbers [set shape "circle" set color red set size 0.001 setxy random-xcor random
minpycor]
;; create given number of turtles (given via slider), with shape circle, size 0.183
;;m, which are distributed uniformly throughout the depth of 15mm.
end
to go
if ticks >= 4000 [stop] ;;it the ticks is greater than 4000 the simulation stops.
ask turtles [
ifelse [pcolor] of patch-ahead dist = nobody [set heading (heading random 180)]
[fd dist]] ;; ask turtles if they reach at the bottom of the beaker bounce back, else it is
safe to
;; move the given distance(dist =3.4,i.e., .0432mm2/min)
enterwatercolumn
tick
;; increases time count by 1
do-plots
end
63
to enterwatercolumn
ask turtles [ if ycor >= max-pycor ;;if turtles reach the top of the beaker ask them to
[ die ] ]
;;die
end
to do-plots
set-current-plot "cumulative-flux"
set-current-plot-pen "cumulative-flux"
plot number - count turtles
;; plots cumulative flux
set-current-plot "instantaneous-flux"
set-current-plot-pen"instantaneous-flux"
plot count turtles with [pycor = max-pycor ] ;; plots instantaneous flux
end
64
Comments are indicated by semi-colon (;;). Detail about NetLogo codes can be
downloaded from
http://cc.northwestern.edu/netlogo/docs.
globals [flux]
patches-own [depth] ;; patch variable
to setup
ca
setup-patches
end
to setup-patches
ask patches with [pycor < 0]
ycor < 0
soil
[let n random-float 1.0
[
if n <= 0.51
[ set pcolor brown ]
;; ask 51% of the patches to set color brown; this means the
;; soil is 49% porous
]
ask patches with [ pycor = min-pycor ] [set pcolor brown ] ;;bottom of the beaker
ask patches with [pycor >= 0 and pycor <= max-pycor] ;;water layer
[set pcolor pink - 4 ]
;; different color set up for clear visualization
ask n-of 2250 (patches with [pcolor = black ]) ;;ask n number of black void space out
of
;;2250
65
end
to go
if ticks >= 4000 [stop]
ask turtles
[
ifelse (patch-ahead temp = nobody ) or ([pcolor] of patch-ahead temp = brown )
;; the world does not wrap vertically so when the turtles reach the bottom of beaker
;;or hit the soil it performs do-edge routine
;;else it start moving the given distance
[do-edge-routine]
[fd dist]
enterwater ]
do-plot
tick
;;increase counter by 1
end
to enterwater
if ycor >= max-pycor
[die]
end
to do-edge-routine
set heading (heading - random 180)
end
to - plot
set-current-plot "cumulative-flux"
set-current-plot-pen "cumulative-flux"
set flux count turtles
plot number - count turtles
end
66
globals[flux]
to setup
ca
setup-colour
setup-patches
end
to setup-colour
ask patches with [pycor <= -40 ] ;; different color for clear visualization
[set pcolor gray ]
end
to setup-patches
ask patches with [pycor <= -40 ] ;;the coordinates are custom arranged. Patches with
;;ycor < 0 is modeled as uniformly contaminated soil
[
let n random-float 1.0
if n <= 0.7
[ set pcolor brown - 0.1] ;; ask 70% of the patches to set color brown; this means the
;; soil is 30% porous
]
ask patches with [pycor > -40 and pycor < 0]
[let n random-float 1.0
if n <= 0.52
;; ask 52% of the patches to set color brown; this means the soil is
;;48% porous
[ set pcolor brown ] ]
ask patches with [pycor >= 0 and pycor <= max-pycor]
[set pcolor pink - 4 ] ;; one way to set up color for clear visualization
ask n-of 1098 (patches with [pcolor = black ]) ;; ask n number of black void space in soil
;;out of 1098;which is the concentration for the
given depth.
67
ask n-of 1152 (patches with [pcolor = gray ]) ;;ask n number of gray void space in soil
out
;;of 1152; which is the concentration for the given depth
[ sprout 1 [set color white set size .001 ] ]
end
to go
if ticks >= 4200 [stop]
ask turtles
[
ifelse (patch-ahead temp = nobody ) or ([pcolor] of patch-ahead temp = brown ) or
([pcolor] of patch-ahead temp = brown - 0.1 )
;; the world does not wrap vertically so when the turtles reach the bottom of beaker
or hit the soil it performs do-edge routine
;;else it start moving the given distance
[do-edge-routine]
[fd temp]
enterwater
]
do-plot
tick ;; increase time counter
end
to enterwater
if ycor >= max-pycor
;; if turtles move beyond max-pycor i.e. top of beaker, ask
them to die
[die]
end
to do-plot
set flux count turtles
plot 2250 - flux
end
to do-edge-routine
set heading (heading - random 180) ;; turn around 180 degree
end
68