Diffusion Across Membrane
WHAT IS IT?
This project explores the diffusion of particle across a porous membrane. In this model, there is a bounding box and permeable membrane. The particles are turtles. The particles move by a random walk, or wiggle.
HOW TO USE IT
Click the setup button to setup the bounding box, the membrane and create and place the particles on the right side of the membrane. Click the go button to start the simulation. Click the Stop-it button to stop the simulation.
THINGS TO NOTICE
Watch the count left and the count right monitors to see how many particles are on each side of the membrane. You can also watch the time on the time monitor.
EXPLORATIONS
Add a graph to show the diffusion over time. Create several different membranes and graph the diffusion over time for each of the membranes. Does the number of holes in the membrane or the size of the holes have greater effect on the diffusion rate?
STARLOGO FEATURES
The turtles in this model use a standard wiggle procedure that changes the direction of the turtle very slightly with each step. Is this a reasonable approximation of brownian motion?
Turtle procedures
;; move procedure
;; called by the go button
;; if turtle is on the wall or membrane, bounce off
;; then move like a particle
;;
to move
check-patches
wiggle
end
;; check-patches procedure
;; called by move procedure
;; if the patch color ahead of the turtle is fuschia
;; turn around and go forward 1 step
;;
to check-patches
if pc-ahead = 125 [
rt 180
fd 1
]
end
;; wiggle procedure
;; called by the move procedure
;; Move forward 1 then change heading slightly
;;
to wiggle
fd 1
wait .1
rt random 20
lt random 20
end
Observer procedures
patches-own [box] ; the saved value of the box patches
globals [time] ; time in seconds
;; setup procedure
;; called by the setup button
;; Clear turtles from previous run, initialize the time to 0
;; Clear the graphics and redraw the box using the saved patch values
;; Create 100 turtles and distribute them within the right hand side of the box
to setup
ct
set time 0
clear-graphics
ask-patches [setpc box]
crt 100
ask-turtles [
setxy random screen-half-width random screen-height
setc 46
]
end
;; count-time procedure
;; called by the hidden "start-timer" button (make the window longer to reveal
;; this button.)
;; Advances the time value by 1 each second.
;;
to count-time
set time time + 1
wait 1
end
