Sie sind auf Seite 1von 80

The University of Toledo

The University of Toledo Digital Repository


Theses and Dissertations

2010

Modeling diffusion using an agent-based approach


Pratibha Sapkota
The University of Toledo

Follow this and additional works at: http://utdr.utoledo.edu/theses-dissertations


Recommended Citation
Sapkota, Pratibha, "Modeling diffusion using an agent-based approach" (2010). Theses and Dissertations. Paper 962.

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

Dr. Defne Apul, Committee Chair

Dr. Daryl F. Dwyer, Committee member

Dr. Gursel Serpen, Committee member

Dr. Patricia R. Komuniecki, Dean


College of Graduate Studies

The University of Toledo


May 2010

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,

therefore, the results obtained differed.

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

An Abstract of .................................................................................................................... iii


Acknowledgements ............................................................................................................. v
Table of Contents ............................................................................................................... vi
List of Tables ...................................................................................................................... ix
List of Figures ..................................................................................................................... x
1. Introduction ..................................................................................................................... 1
1.1 Arsenic contamination as a widespread problem ...................................................... 1
1.2 Remediation of arsenic contaminated waters ............................................................ 2
1.3 Fate and transport of arsenic in a wetland ................................................................. 2
2. Motivation ....................................................................................................................... 7
3. Background .................................................................................................................... 8
3.1 Contaminant transport processes ............................................................................... 8
3.1.1 Diffusion ............................................................................................................. 8
3.2. Agent-Based Modeling (ABM) .............................................................................. 11
3.2.1 Introduction to ABM......................................................................................... 11
3.2.2 What is an agent? .............................................................................................. 12
3.3 Equation Based Modeling (EBM) and Agent-Based Modeling (ABM) ................. 13
3.4 Comparison of Various ABM tools ......................................................................... 14
3.5 NetLogo: The ABM of preference .......................................................................... 15
3.5.1 Features and Structure of NetLogo ................................................................... 16
3.5.2 NetLogo in various disciplines ......................................................................... 16

vi

4. Overview of Approach and Objectives ......................................................................... 19


4.1 Objectives ................................................................................................................ 19
5. Methodology ................................................................................................................ 20
5.1 Description of NetLogo platform ............................................................................ 20
5.2 Agents in NetLogo .................................................................................................. 23
5.3 Input/ Output ........................................................................................................... 25
5.4 Problem Description ................................................................................................ 25
5.5 Problem 1: Diffusion in water ................................................................................. 26
5.5.1 Model setup in NetLogo ................................................................................... 26
5.5.2 Sensitivity Analysis .......................................................................................... 29
5.5.3 Modeling diffusion in water using HYDRUS .................................................. 30
5.6 Problem 2: Diffusion in saturated soil ..................................................................... 32
5.6.1 Model setup in NetLogo ................................................................................... 32
5.6.2 Model setup in HYDRUS ................................................................................. 33
5.7 Problem 3: Diffusion in saturated soil with varying porosity ................................. 35
5.7.1 Model setup in NetLogo ................................................................................... 35
5.7.2 Model setup in HYDRUS ................................................................................. 36
6. Results and Discussion .................................................................................................. 37
6.1 Results from problem 1: Diffusion in water ............................................................ 37
6.1.1 Results from NetLogo model ............................................................................ 37
6.1.2 Result from HYDRUS model ........................................................................... 42
6.1.3 Comparison of HYDRUS and NetLogo results ................................................ 43
6.2 Results from problem 2: Diffusion in soil ............................................................... 45
6.2.1 Results from HYDRUS and NetLogo............................................................... 45
6.3 Results from problem 3: Diffusion in soil with varying porosity............................ 46
6.3.1 Results from HYDRUS and NetLogo............................................................... 46
7. Conclusion and Future work ......................................................................................... 48
7.1 Conclusion ............................................................................................................... 48
7.2 Future Work ............................................................................................................. 49
References ......................................................................................................................... 50
vii

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

Table 1: Comparison between various agent-based platforms (taken from Railsback,


(2006)) ............................................................................................................................... 14
Table 2: Wetland processes and similar examples in NetLogo library ............................. 18
Table 3: Mean, Standard deviation, and Coefficient of Variation (CV) of cumulative flux
(mg/m2) for a turtle ............................................................................................................ 40
Table 4: Different number of runs with 1 turtle representing 1mg ................................... 42

ix

List of Figures

Figure 1: Conceptual model [adapted from Zhang et al. 2008] .......................................... 3


Figure 2: Conceptual description of an agent (Macal and North, 2005) ........................... 12
Figure 3: Screen shot of interface tab. The black box is the view. ................................... 21
Figure 4: Screen shot of procedure tab.............................................................................. 22
Figure 5 NetLogo world [Adapted from Xin and Li, 2008]............................................. 24
Figure 6: Uniformly Contaminated water ........................................................................ 27
Figure 7: Screenshot of Coordinates ................................................................................. 28
Figure 8: Pink represents contaminated water layer and blue represents uncontaminated
water layer ......................................................................................................................... 31
Figure 9: Uniformly contaminated saturated soil .............................................................. 32
Figure 10: Pink represents the contaminated soil layer and blue represents
uncontaminated water in HYDRUS setup ........................................................................ 34
Figure 11: Uniformly contaminated saturated soil ............................................................ 35
Figure 12: Pink represents the contaminated soil layer and blue represents
uncontaminated water in HYDRUS setup ........................................................................ 36
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 after 40 days. ........................................................ 38
Figure 14: 1 turtle representing 10mg. The graph was obtained by running the same
simulation 50 times with 1 turtle equal to 10mg. .............................................................. 39
Figure 15: Plot obtained by assigning a turtle 1mg each. The plot is smooth although it
shows some variation among the 50 simulations. ............................................................. 39
x

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

1.1 Arsenic contamination as a widespread problem

Arsenic is a toxic metal that is introduced in the subsurface by mining activities,


irrigation practices, and disposal of industrial wastes. Arsenic contaminated groundwater
is a widespread problem and poses health problems such as black disease, diabetes,
kidney and lung disease, high blood pressure, and reproductive disorder (WHO, 2004).
Among the various risks, drinking arsenic contaminated groundwater poses the greatest
threat to human health. The United States Environmental Protection Agency (USEPA)
has categorized arsenic as carcinogenic and has lowered the contaminant level deemed
safe for drinking water from 50 ppb to10 ppb (USEPA, 2001). Arsenic concentrations
above the given levels have been found in groundwater (often the only source of drinking
water) in many countries including Bangladesh, India, Vietnam, China, and United
States; this contamination was attributed to anthropogenic sources (Nordstom,2002;
Smedley and Kinniburgh, 2002). Therefore, it is of utmost importance to find a way to
remove arsenic from the contaminated water.

1.2 Remediation of arsenic contaminated waters

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

The biogeochemistry of arsenic in wetlands is a complex process which includes


chemical and microbiological reactions (Figure 1). Several processes such as adsorption,
reduction-oxidation, precipitation, plant uptake, and microbial activity contribute towards

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

Sorbed As (V) compounds

As (V)
Desorption
Methylation

Reduction

Oxidation

Oxidation

As (III)
Microbial activity

Reduction

Adsorption

Sorbed As (III) compounds


Desorption

Dissolution

Precipitation

Diffusion

Diffusion

As compounds

Input

Output
Advection

Advection

Figure 1: Conceptual model [adapted from Zhang et al. 2008]

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

= linear velocity [L/T]


D=Hydrodynamic dispersion [L2/T]
Hydrodynamic dispersion is the sum of dispersion and diffusion (D =De+ L
 ) .
Where
De = effective diffusion coefficient [L2/T]
L = dispersion[L]
Under flow conditions, diffusion is insignificant, therefore it is neglected. However, in
quiescent conditions (
= 0), diffusion dominates because of random motion of
contaminant molecules. Ficks law, which is used to describe diffusion, states that the
mass diffusing is proportional to the concentration gradient. In one dimension, the
transport process is given by


= ( )



Where, D= Diffusion coefficient [L2/T]


dC/dx=Concentration gradient[M/L3/L]
Numerical models have been widely used to gain insight into the fate of the
chemicals in wetlands. Finite difference method (FDM), finite element method (FEM),
integrated finite difference method (IFDM), boundary integral equation method, and
analytical elements are some of the methods used for fate and transport modeling
(Alhumaizi, 2004; Narasimhan and Witherspoon, 1978; Ligget and Liu, 1983; Strack,
1987). Among them, FDM and FEM are more commonly used to solve flow problems.
Studies have shown that FDM requires relatively large computational time and is often
unstable when dealing with steep concentration gradients (Alhumaizi, 2004; Botte, Ritter
and White, 2000). Piatkowski et al. (2003) showed that FEM is more useful than FDM
for irregular boundaries and is relatively stable than FDM when dealing with steep
concentration gradients. To summarize, FDM is easy to program, understand, and is a
good method when dealing with simpler boundaries. However, FEM is better at
approximating complex boundaries and is able to simulate point sources and sinks,
seepage faces, and moving water table.
The transport of arsenic in wetlands is determined by the presence of adsorptiondesorption sites, the effect of humic substance, and the presence of competing anions.
Adsorption-desorption behavior of arsenic is responsible for non equilibrium transport of
arsenic in soil, making it difficult to model using existing fate and transport models.
Because arsenic cycling in wetland is a complex process and adsorption in soils is
nonlinear (Zhang and Selim, 2006), it is necessary to understand the relationship among

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

ABM is a simulation method that has proven its usefulness in handling


complexities in diverse fields such as ecology (Takasu, 2009; Uchmanski et al., 2008),
medicine (Gary and Wilensky, 2009; Eapen, 2009), and economics (Remenik, 2009;
Damaceanu, 2008), yet ABM has not been used as much in environmental modeling.
ABM allows the incorporation of heterogeneity and variability within the population and
does not make any averaging assumptions; thus it is a promising method for modeling
fate and transport compared to existing EBM methods. For example, arsenic cycling in
wetland is a very complex process which requires monitoring of various arsenic species
simultaneously. The above studies have proved the capabilities of ABM for handling
complexities. Therefore, the overarching goal of this study was to model wetland
processes using agent-based approach. However, since this was a daunting task, this
thesis addressed only the diffusion process in wetlands or any other porous media. To
my knowledge, this study is the first attempt to model fate and transport of contaminants
through porous media at the individual level using ABM.

3. Background

3.1 Contaminant transport processes

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

concentration gradient (Fetter, 1993). Einstein studied the probabilistic nature of


diffusion process and explained that the Brownian motion of the particles in a fluid use
probability density functions (Weber, 1996). He showed that the movement of each
particle in the fluid is independent of the other particles, and that diffusion coefficient
increases as a function of movement of the particles.

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.

At the microscopic level, diffusion results from individual displacement of


diffusing particles, also referred as diffusive jumps. Diffusive jumps are usually singlemolecule jumps of fixed length. Diffusivity can be expressed in terms of physical
quantities that describe elementary jump processes such as jump rates and jump distance
of a molecule. The jump rate of a molecule depends on its individual energy, Boltzmann
constant, and the absolute temperature (Flynn, 1972).
=o exp (-G/kBT)
is the jump rate, G is the Gibbs free energy, kB is the Boltzment constant, o is the
Debye frequency, and T the absolute temperature. If the jump distance of the molecule is
given by [L]and the jump rate from one plane to the neighboring one is [L/T], then

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

where C1 and C2 represent concentration [parts L-3] at point 1 and 2.


Concentration C(x,t)changes slowly as a function of the distance variable x in terms of
distances between two jumps. First order Taylor expansion of C(x,t) results in
C1-C2 =- C/x 3
Inserting equation 2 and 3 in 1 results in
J= - 2 C/x.4
After comparison with Ficks law the diffusion coefficient is determined to be
D= 2 .5
This shows that the diffusion coefficient is related to the distance squared and jump rate.
Additional details on the equation and its derivation can be found elsewhere (Flynn,
1970; Franklin, 1975; Bennett, 1975)

10

3.2. Agent-Based Modeling (ABM)


3.2.1 Introduction to ABM

ABM is a form of computational simulation that is gaining popularity in various


disciplines (Bonabeau, 2002; Macal and North, 2005). ABM enables building models
where individual entities and their interactions are directly represented. In ABM, a
system is modeled as a collection of autonomous decision-making entities called agents.
These agents are adaptive to their surrounding environment and can react to the
environmental conditions. ABM allows visualizing the emergence of macro level
behavior from micro level. A simple ABM can exhibit complex behavior patterns and
provide valuable information about the system that it emulates. In addition, agents may
be capable of evolving, allowing unanticipated behaviors to emerge.

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?

An agent is defined as an autonomous entity with its own set of characteristics


and that can act on its own. The important feature of an agent is shown in Figure 2. An
agent has a set of characteristics that allows it to act independently. An agent is able to
perceive its environment. Thus, agents can determine what agents or objects are located
near them. An agent is able to move within the space, can send or receive messages from
other agents, and can interact with the environment (perform) and it has a set of goals that
it pursues with its own initiative (making it proactive).

 Autonomous unit
 Social
 reactive
 Proactive

Figure 2: Conceptual description of an agent (Macal and North, 2005)

12

ENVIRONMENT

ENVIRONMENT

Agent

3.3 Equation Based Modeling (EBM) and Agent-Based Modeling (ABM)

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).

Table 1: Comparison between various agent-based platforms (Railsback, (2006))


User materials
ABM
User base
Modeling Speed of Ease of
platforms
Language execution learning and
programmin
g
Diminishing Java
Moderate Moderate
Good
Ascape
documentation
Mason

Increasing

Java

Fastest

Moderate

Limited
documentation

Repast

Large

Java,
python

Fast

Moderate

Limited
documentation

.etLogo

Large

NetLogo

Moderate

Good

Extensive
documentation

SWARM

Diminishing Objective Moderate


C,Java

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

NetLogo is a modeling environment based on agents designed for simulations of


natural phenomena. It was designed by Uri Wilensky in 1999 and it is in a process of
continuous development and modernization at the Center for Connected Learning and
Computer-Based Modeling Northwestern University. NetLogo is written in Java
language and can be run on all major platforms (Mac, Windows, Linux). NetLogo is a
freeware and can be downloaded from the following web address:
http://ccl.northwestern.edu/netlogo/.

15

3.5.1 Features and Structure of .etLogo

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.

NetLogo is also popular in medical and biomedical disciplines because of its


ability to deal with finer details and track numerous parameters at a time. For example,
Eapen (2009) developed a NetLogo model for laser hair removal. Modeling laser hair
removal requires monitoring numerous parameters simultaneously which is difficult
using existing modeling methods, but NetLogo proved effective in tracking the numerous
parameters. Modeling wetland processes require monitoring various parameters at a time.
Factors such as pH, Fe and Mn oxides, sulfides, and organic matter should be monitored
simultaneously as they impact reduction and oxidation of arsenic. The above example
proves the capability of NetLogo for monitoring numerous parameters at a time which is
very important for modeling reduction and oxidation.

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.

Table 2: Wetland processes and similar examples in NetLogo library


Wetland processes
Adsorption/Desorption

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

Related .etLogo models

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

Where,KM is called the


Michaelis Constant

18

Enzyme Kinetics(Appendix A)

4. Overview of Approach and Objectives

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


Select an ABM platform for modeling diffusion.

Develop an agent-based model for diffusion in water and porous media using an
agent-based approach.


Perform sensitivity analysis to determine a suitable agent size.

Perform sensitivity analysis to evaluate intrinsic randomness of the agentbased model.

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

5.1 Description of .etLogo platform

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.

In NetLogo, two-or three-dimensional models can be created. In the 2D version of


NetLogo, the interface tab includes a black square called view which is made up of
patches. A patch is a spatial environment on which the agents move. The simulation
program instructs the agents to move and act from patch to patch. The results can be seen
in the view (Figure 3). The interface tab is a visual editor in which one can edit graphical
elements such as buttons, sliders, switches, monitor, and output (Figure 3). Interface tab
also allows changing the world dimension, and the dimension of the overall setup.

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.

Figure 4: Screen shot of procedure tab

22

5.2 Agents in .etLogo

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

max pxcor, max pycor


(16, 16)

min pxcor, max pycor


(-16, 16)

Patch
Link
Turtle

min pxcor ,min pycor


(-16,-16)

max pxcor, min pycor


(16,-16)

Figure 5 NetLogo world [Adapted from Xin and Li, 2008]

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

5.3 Input/ Output

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.

5.4 Problem Description

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.

5.5 Problem 1: Diffusion in water

5.5.1 Model setup in .etLogo

A beaker of water uniformly contaminated to a certain depth was simulated


(Figure 6). Initially the two sections of the beaker are envisioned to be separated from
each other using a thin plate which is then instantaneously removed and with time, the
chemical diffuses throughout the entire beaker of water. The amount of chemical
reaching the top of the beaker as a function of time was measured as flux. This basic
numerical experiment was performed for the preliminary evaluation of NetLogo model.
The success of this model provides insights into the limitations and strengths of NetLogo
for modeling the diffusion process.

26

22mm

15mm

Figure 6: Uniformly Contaminated water


The simulation was performed with an initial contaminant (H2AsO-4)
concentration of 150mg/L. Therefore, the net concentration (per unit area) in the beaker
for the depth of 15mm of contaminated layer is 2,250mg/m2 (150mg/L *103/m3*1L
*0.015)). The dimension in the model is entered as patches and the user decides the unit
dimension a patch represents. For example, a NetLogo dimension of 20mm can be
populated with 20 patches each 1 mm2, or 40 patches each 0.5 mm2. For the current
simulation, a total of 120 patches were used which was equivalent to a vertical distance
of 22mm, therefore the size of each patch was 0.1833 mm. The min-pycor, max-pycor,
min-pxcor and max-pxcor for the current simulation are -82, 38, -60, and 60 (Figure 7).
Since the model wraps horizontally (turtles appear on left side of view when it disappears
on right side), it is considered a 1D model and the horizontal patches were not taken into
account.

27

Figure 7: Screenshot of Coordinates

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

=0.78 mm2/tick where, 1 tick = 14.4 min


=4.3 * 0.1833 mm2/tick
=4.3 patches/tick
Where, 1 patch = 0.183mm
For the given simulation, the turtles move over 4.3 patches in a tick which is equivalent
to the diffusion coefficient of H2AsO-4. Equation 5 showed that diffusion coefficient is
related to the distance travelled by an individual molecule (D= 2 ). Unlike Brownian
particles, the contaminants were not assigned individual energies since it added to the
complexity of the model. Keeping track of energies for each molecule would be
cumbersome, thus making it difficult to model.
5.5.2 Sensitivity Analysis
Since the contaminants were represented as agents in the model, the given
contaminant concentration (150mg/L) needed to be changed into agent form. Sensitivity
analysis was performed to obtain a proper balance of data points and runtime. The
simulation was run with a turtle representing various amounts (100mg, 10mg, 1mg, and
0.1 mg) of contaminants. For example, when each turtle represented 1mg, 2250 turtles
were used to represent 2250mg of contaminants. Similarly, when each turtle represented
10mg, 225 turtles were used to represent 2250mg. The simulation was run 50 times in
each case to see if the variation increased with run time.

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.

5.5.3 Modeling diffusion in water using HYDRUS


The HYDRUS program is a finite element model that solves Fickian-based
advection-diffusion equation for solute transport. The standard diffusion equation in one
dimension is given by
 

=  


Where Dw [L2/T] is the diffusion coefficient in water and


!

is the change in

concentration with time. Molecular diffusion coefficient of contaminant in water was


7.82*10-5m2/day (Li and Gregory, 1974). Contaminant concentration of 150mg/L was
entered in the contaminated layer via the graphical editor as shown in Figure 8. The
contaminated sediment depth was 15 mm and the overall depth of the beaker was 22mm
as in the NetLogo model.

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

5.6 Problem 2: Diffusion in saturated soil

5.6.1 Model setup in .etLogo

In problem 2, diffusion of a contaminant from saturated soil to overlying water


was simulated. It was assumed that the soil was uniformly contaminated throughout the
depth of 15mm (Figure 9). The setup is similar to Thoma et al (1993) without a cap
sediment layer. With time the contaminant diffused into the water. The amount of
chemical reaching the top of the beaker was quantified as flux. The basic buttons required
for simulation are setup and go. Other buttons used were porosity, count agents,
and count void spaces.

Water
(7mm)

Uniformly
contaminated layer
(15mm)

Figure 9: Uniformly contaminated saturated soil

Brown patches represented soil and white particles represented contaminant. It


can be seen that the soil was uniformly contaminated to a depth of 15 mm and the overall
32

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.

5.6.2 Model setup in HYDRUS


The standard diffusion equation as discussed in section 5.3.3 was used for
modeling diffusion in soil. The model setup was similar to diffusion in water. In soil,
diffusion cannot proceed as fast as it can in water because the contaminants must follow
longer pathways as they travel around soil particles. To account for this, an effective
diffusion coefficient is used instead of molecular diffusion coefficient in water.
The effective diffusion coefficient of a solute in a soil is estimated from the solute's
diffusion coefficient in water, soil porosity, and soil water content using MQ model
(Millington and Quirk, 1961). Since the contaminant follow tortuous path in the porous
soil, the effective diffusivity equation for the simulation is given by De = Dw (/)
(Millington and Quirk, 1961) and Tortuosity () is given by

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

5.7 Problem 3: Diffusion in saturated soil with varying porosity

5.7.1 Model setup in .etLogo


In problem 3, diffusion of contaminant from saturated soil to overlying water
layer was simulated. The setup was similar to problem 2, but with varying porosity.
Figure 11 shows the model setup in NetLogo. The basic buttons required were setup
and go buttons. Other buttons used were porosity, count agent and count void
spaces.

Water
(7mm)

Uniformly contaminated
layer (7.32 mm)
Porosity (0.49)

Uniformly contaminated
layer (7.68 mm)
Porosity (0.3)

Figure 11: Uniformly contaminated saturated soil


Soil was represented by brown patches and contaminants were represented by
white particles. The soil was uniformly contaminated to the depth of 15mm. Initially the
water above 15 mm was assumed to be contaminant free. Lower half of the soil was 30
percent porous and the upper half of the soil was 49 percent porous. The contaminants

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.

5.7.2 Model setup in HYDRUS


The setup was similar to the setup in 5.6.2 and since the HYDRUS model was
not able to take varying porosities into account, the molecular diffusion coefficients from
both of the layers were averaged and entered as follows.
(3.02*10-5m2/day + 1.57*10-5m2/day) /2 = 2.29*10-5m2/day.
The overall depth of the beaker was 22mm and the contaminated sediment depth was 15
mm as in the NetLogo model (Figure 12).

Figure 12: Pink represents the contaminated soil layer and blue represents
uncontaminated water in HYDRUS setup

36

6. Results and Discussion

6.1 Results from problem 1: Diffusion in water

6.1.1 Results from .etLogo model

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 14: 1 turtle


tle representing 10mg. The graph was obtained by running the same
simulation 50 times with 1 turtle equal to 10mg.

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

Table 4: Different number of runs with 1 turtle representing 1mg


.umber
of runs
10runs

50runs

100runs

mean
Std
dev
CV
mean
Std
dev.
CV
mean
Std
dev.
CV

Simulation duration (days)


1
436.5

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

6.1.2 Result from HYDRUS model


Cumulative flux is quantified as the amount of contaminant reaching the top of
the beaker. Figure 17 shows a steep increase in cumulative flux until day 10 and a
stabilized flux after that. The contaminants had already reached the top of the beaker by
the10th day, therefore the cumulative flux stabilized. The result obtained from HYDRUS
was deterministic; therefore, sensitivity and randomness analyses were not performed for
the given simulation.

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]

Figure 17: Cumulative flux after 40 days

6.1.3 Comparison of HYDRUS and .etLogo results


When the HYDRUS and NetLogo results were plotted, a close resemblance was
found between HYDRUS and NetLogo results. Figure 18 shows that the cumulative flux
predicted by HYDRUS was higher than the cumulative flux predicted by NetLogo. More
contaminant particles stayed inside the beaker in the case of NetLogo than in HYDRUS.
Therefore, the amount of flux from NetLogo results was less than the amount from
HYDRUS results. For example, the flux after 20 days in NetLogo was 2175mg/m2,
whereas in HYDRUS it was 2230mg/m2.

43

2500

Cum flux [mg/m2]

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

NetLogo vs. HYDRUS


45 degree line

500
0
0

500

1000

1500

2000

2500

HYDRUS (mg/m2)
Figure 19: HYDRUS vs. NetLogo for diffusion in water

44

6.2 Results from problem 2: Diffusion in soil


6.2.1 Results from HYDRUS and .etLogo

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

6.3 Results from problem 3: Diffusion in soil with varying porosity


6.3.1 Results from HYDRUS and .etLogo
Figure 22 shows that the cumulative flux predicted by NetLogo was higher than
the cumulative flux predicted by HYDRUS during the first 20 days. This could be
because in NetLogo model the upper part of the soil was highly porous. This means the
NetLogo setup has a higher molecular diffusion coefficient initially than that of
HYDRUS, which uses the average value. Therefore, NetLogo slightly overpredicted

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. Conclusion and Future work

7.1 Conclusion

This is an exploratory research to model wetland processes using an agent-based


method. Since modeling wetland processes is a daunting task, only diffusion process was
modeled. The model results obtained for the diffusion have been verified against
HYDRUS-1D, a FEM based modeling platform. The results obtained from both models
for diffusion in water were in good agreement with each other. However, the HYDRUS
and NetLogo results for diffusion in soil differed. The difference is attributed to tortuosity
and assumption of simple particle-wall collision of contaminants.

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.

7.2 Future Work

Representing a soil matrix is a complex process in which organic matter, mineral


(sand, silt, and clay) and micro-pores and macro-pores are organized differently
according to their size. The soil model can be further developed by adding effects of
organic matter, and micro and macro-pores. Furthermore, more research is needed to add
processes such as adsorption-desorption, redox to the existing model simultaneously
along with diffusion.

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.

Hellweger, F.L., 2007. Is it time to abandon the chemistry approach to biogeochemistry?


Water Environment Federation, WEFTEC 0.7, 5646-5665.
Hellweger, F.L., and Kianirad, E., 2007. Accounting for intrapopulation variability in
biogeochemical models using agent-based methods. Environ. Sci. Technol., 41:28552860.
Kadlec, R.H., Reddy, K.R., 2001. Temperature effects in treatment wetlands. Water
Environ. Res., 73: 543-557
Kalbitz, K., and Wenrich, R., 1998. Mobilization of heavy metals and arsenic in polluted
wetland soils and its dependence on dissolved organic matter. Sci. Total Environ. 209:
2739.
Kao, C.M., Wu, M.J., 2001. Control of non-point source pollution by a natural wetland.
Water Sci. Technol., 43: 169174.
Krishna,R., and Wesselingh,J.A.,1997.The Maxwell-Stefan approach to mass
transfer.,52:861-911.

53

La Force,M.J.,Hansel,C.M., and Fendorf,S.,2000.Arsenic speciation, seasonal


transformations, and co-distribution with iron in mine waste-influenced pasturine
emergent wetland.Environ.Sci.Technol., 34: 3437-3943
Li, Y. & Gregory, S., 1974. Diffusion of ions in sea water and in deep-sea sediments .
Geochim . Cosmochim . Acta 38:703-714.
Ligget,J.A., and Lie, P.L., 1983.The Boundary Integral Equation method for porous
media flow,Allen and Unwin,255.
Macal, C.M., and North, M.J., 2005. Tutorial on agent-based modeling and simulation.
Proceedings of the 2005 Winter Simulation Conference: 2-15.
Mahimairaja, S., Bolan, N.S., Adriano, D.C., and Robinson, B.,2005.Arsenic
contamination and its risk management in complex environmental settings. Adv.Agron.,
86:1-82
Millington, R.J., and Quirk, J.P., 1961. Permeability of porous solids. Trans. Faraday
Soc. 57: 12001207.
Narasimhan, T.N., and Witherspoon, P.A.,1978. Numerical model for saturatedunsaturated flow in deformable porous media.3. Applications, Water Resources
Research, 14:1017-1034
Nordstorm, D.K., 2002.Public health-Worldwide occurrences of arsenic in
groundwater.Science., 296:2143-2145
Piatkowski,W.,Antos,D.,and Kaczmarski,K,2003. Modeling of preparative
chromatography processes with slow intraparticle mass transport kinetics. Journal of
ChromatographyA, 988:219-231.

54

Pierce,M.L., and Moore,C.B.,1980.Adsorption of arsenite on amorphous iron hydroxide


from dilute aqueous solution.Environ.Sci.Technol.14:214-215
Railsback, S. F., Lytinen, S. L., Jackson, S. K., 2006. Agent-based simulation platforms:
Review and development recommendations, Simulation., 82: 609-623.
Rebour, V., Billiotte, J., Deveughele, M., Jambon, A. and le Guen, C., 1997. Molecular
diffusion in water-saturated rocks: A new experimental method. J. Contam. Hydrol.,
28:71-93.
Reid. R. C., Sherwood, T. K., 1966.The Properties of Gases and Liquids, p 543,
McGraw-Hill, New York, N.Y., 1966
Remenik, D., 2009. Limit theorems for individual-based models in economics and
finance. Stochastic Processes and their Applications, 119:2401-2435.
Reynolds, C., 1982. Computer animation with scripts and actors, Proceedings of the
9th Annual Conference on Computer Graphics and Interactive Techniques, 289-296
Salgado, E. and Aranda, J., 2007. An agent-based solution of Lagrange equations for
adsorption processes. Computers & Chemical Engineering, 31:1663-1670.
Schuler, A.J., 2005. Diversity matters: dynamic simulation of distributed bacterial states
in suspended growth biological wastewater treatment systems. Biotechnol. Bioeng. 91:
6274.
Selvadurai, A.P.S., 2004. On the uniqueness theorem for advection-diffusive transport in
porous media: A canonical Proof. Transport in porous media.56:51-60.
Simunek, J., Sejna, M., and Van Genuchten, M.T.1999. The HYDRUS-2D Software
Package for Simulating the Two-Dimensional Movement of Water, Heat, and Multiple

55

Solutes in Variably-Saturated Media, version 2.0. Riverside, CA: U.S. Salinity


Laboratory.
Smedley, P.L., and Kinniburgh, D.G.,2002.A review of source,behavior and distribution
of arsenic in natural waters. Appl.Geochem., 17:517-568.
Smith, E., Naidu, R., and Alston, A.M., 1998.Arsenic in the soil environment: A
review.Adv.Agron., 64: 149-195.
Solano, M., Soriano, P., Ciria, M., 2004. Constructed wetlands as a sustainable solution
for wastewater treatment in small villages. Biosyst.Eng., 87: 109118.
Sommerfeld, M., Hubber, N.,1999. Experiemental analysis and modeling of particle-wall
collisions.Int J Multi-Phase flow., 25:1457
Strack,O.D.L.,1988.The analytical element method for regional groundwater
modeling,In: solving groundwater flow problems with models, National water
wellAssoc.,Columbus,ohio:929-941.
Takasu, F., 2009. Individual-based modeling of the spread of pine wilt disease: vector
beetle dispersal and the Allee effect. Population Ecology, 51:399-409.
Thoma, G.J., Reible, D.D., Valsaraj, K.T. and Thibodeaux, L.J., 1993. Efficiency of
Capping contaminated sediments in-situ. 2. Mathematics of Diffusion Adsorption in the
capping layer. Environ. Sci. Technol., 27:2412-2419.
Uchmanski, J., Kowalczyk, K. and Ogrodowczyk, P., 2008. Evolution of theoretical
ecology in last decades: why did individual-based modelling emerge. Ecological
Questions, 10:13-18.
Valsaraj, K.T. and Sojitra, I., 1997. Transport of hydrophobic organic compounds by
colloids through porous media .3. Diffusion from sediment porewater to overlying water

56

in laboratory microcosms. Colloids and Surfaces a-Physicochemical and Engineering


Aspects, 121:125-133.
Valsaraj, K.T., Qaisi, K.M., Constant, W.D., Thibodeaux, L.J. and Ro, K.S., 1998.
Diffusive transport of 2,4,6-trinitrotoluene (TNT) from contaminated soil to overlying
water. J. Hazard. Mater., 59:1-12.
Weber, J.W., and Digiano,F.A., 1995. Process Dynamics in Environmental
Systems.Wiley-Interscience Pub.Co.
Wilensky, U., 1998. NetLogo Wolf Sheep Predation model (Computer Program). Center
for Connected Learning and Computer-Based Modeling, Northwestern University
http://ccl.northwestern.edu/netlogo/models/WolfSheepPredation
Wilkin, R.T., Ford, R.G., 2006.Arsenic solid-phase partitioning in reducing sediments of
a contaminated wetland. Elsevier Science Bv, pp. 156-174
Wishart, D. S., Yang, R., Arndt, D., Tang,P., and Cruz,J., 2004. Dynamic cellular
automata: An alternative approach to cellular simulation. Silico Biology, 4:1-3.
Worall, P., Peberdy, K.J., Millett, M.C., 1997. Constructed wetland and natural
conservation. Water Sci. Technol, 3: 205213.
World Health Organization (WHO).2004. Arsenic in drinking water.,WHO,Geneva.
Xin, J.H., Li,P.X., and Feng,H.X.,2008. Sustainability education based on NetLogo
modeling environment:Taking climate change simulation as an example, Journal of
Communication and Computer, ISSN1548-7709, USA
Yang, Y., and Li, J., 1996. New Fick's law for self-diffusion in liquids. Journal of
Applied Physics, 80: 6188-6191.

57

Zhang,H., and Selim,H.M.,2006.Modeling the transport and retention of arsenic(V) in


soils. Soil Sci.Soc. Am.J.,70:1677-1687.
Zhang, H. and Selim, H.M., 2008. Reaction and transport of arsenic in soils: Equilibrium
and kinetic modeling. Advances in Agronomy, Vol 98. Elsevier Academic Press Inc, San
Diego, pp. 45-115.

58

Appendices

Appendix A: Information Tab for Enzyme Kinetics and B-Z reaction

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

Here E represents Enzyme, S Substrate, E-S Enzyme-Substrate complex, and P product.


The rate constants are Kc for complex formation, Kd for complex dissociation, Kr for
catalysis. The first step in catalysis is the formation of the E-S complex. This can consist
of either covalent or non-covalent bonding. The rates of complex formation and
dissociation are very fast because they are determined by collision and separation of the
molecules. The next step is for the enzyme to catalyze the conversion of substrate to
product. This rate is much slower because the energy required for catalysis is much
higher than that required for collision or separation.
The model demonstrates several important properties of enzyme kinetics. Enzyme
catalysis is often assumed to be controlled by the rate of complex formation and
dissociation, because it occurs much faster than the rate of catalysis. Thus, the reaction
becomes dependent on the ratio of Kc / Kd. The efficiency of catalysis can be studied by
observing catalytic behavior at different substrate concentrations.
By measuring the rate of complex formation at different substrate concentrations, a
Michaelis-Menten Curve can be plotted. Analysis of the plot provides biochemists with
the maximum rate (Vmax) at which the reaction can proceed. As can be seen from the
model, this plot is linear at low levels of substrate, and non-linear at higher levels of
substrate. By examining the model, the reasons for this relationship can be seen easily.

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

Appendix B: Information Tab for Diffusion in Water

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

Appendix C: Information Tab for Diffusion in Porous Media

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

Appendix D: .etLogo Code for Diffusion in Water

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

Appendix E: .etLogo code for Diffusion in Soil

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 ]

;;the coordinates are customly arranged. Patches with


;; is modeled as uniformly contaminated

;; 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

[sprout 1 [set color white set size .001 ] ]

;; create 1 turtles on each black


;; patch and not on top of soil

end
to go
if ticks >= 4000 [stop]

;; stop if ticks is greater than 4000

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

;; if turtles move beyond max-pycor i.e. top of beaker,

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

Appendix F: .etLogo code for Diffusion in Soil with Varying Porosity

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

[ sprout 1 [set color white set size .001 ] ]


and

;; create 1 turtles on each black patch


;; not on top of soil

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

;;869 is the total concentration in the beaker

to do-edge-routine
set heading (heading - random 180) ;; turn around 180 degree
end

68

Das könnte Ihnen auch gefallen