NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo User Community Models

(back to the NetLogo User Community Models)


by Gary An, MD (Submitted: 06/08/2006)

[screen shot]

Download DiffusionWithMembraneAsTurtle1
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)


This is a simple model that looks at diffusion of molecules with and without the presence of a membrane with variable permeability. It also includes a very abstracted active transport pump that counteracts the permeability limitations of the membrane. Of note, this model is "intentionally" not refined, to allow for planned input/improvement via student interactions. Of note, this version uses a membrane made from turtles.


The "world" is a container that can be divided into two by adding a membrane. Molecules are represented by circular agents that are added at the bottom screen edge via a button "add-molecule1" or "-2". The molecules have a random movement pattern, and upon initial addition of molecules they will diffuse to fill the space. With the addition of the membrane there is a barrier to this initial diffusion, and dependent upon the set permeability for the membrane it will take longer or shorter to reach equilibrium. The permeability represents a percentage likelyhood that a molecule will pass. The additon of the "Molecule1-pump" allows uni-drectional (from "above" to "below") complete permeability to molecule1.
On the plots the blue line represents the number of molecules (either molecule1 or total) below the membrane, the red line the number of molecules above.
The varible "Osmolality" is a density function of the total number of molecules in each compartment. With the slider "mode" turned to 1 the different compartments will scale to a shade of green dependent upon their osmolality (lighter shade = higher osmolality, darker shade = lower osmolality).


To start, use the "molecule-amount" sliders to set the number of molecules created per patch. Then hit "setup," "add-molecules" to set initial conditions. You can add the membrane and molecule1-pump at the same time. You can set the "mode" to the right of the screen. Hit "go" to go. You can also add molecules during the run as well. You can also change the membrane permeability to either molecule during the run as well.


Notice the diffusion pattern after initial addition of molecule. The movement of the front egde of the particle "wave" looks volitional, but it is a byproduct of the random movement of particles from a higher concentration to a lower one.
Notice the effect of a membrane on the rate of this diffusion. However, also notice that irrespective of the degree of permeability (as long as it is > 0) the system will eventually go to equilibrium. The time to this point, however, is a function of the set permeabilty.
Noice that in order to reinforce any gradient there must be active transport with the molecule1-pump.
Notice that with permeabilty = 100 the molecule-pump has no significant effect.
Switching the "mode" to 1 to scale the background to the osmolality allows you to see the differential gradient enforced by the membrane more clearly.


You can add different numbers of molecules to see if there is a change in the time to equilibrium (would you expect there to be any effect?)
You can change the permeability for molecule1 during a run to simulate a membrane depolarization and then re-establishment of the gradient with molecule1-pump.


Note that in this model the calculations for "osmolality-above" and "osmolality-below" assume the fixed sizes of the two chambers. Similarly, in "mode" = 1 the areas scaled to osmolality are constant. However, you can adjust the placement of the membrane to see the effect of unequal chambers.
You can try adjusting the code to dynamically change the relative size of the chambers to keep osmolality constant. This would simulate the "swelling" of a cell in whom its cell membrane becomes more permeable to water.
You can add additional molecule pumps, perhaps requiring an "energy-consumption" function.
You can add enzyme kinetics between the existing molecules to produce a third molecule species with different permeability/molecular transport pumps.
You can link enzyme kinetics to allow for one of the species of molecules to be the "energy source" for an "energy-consumption" molecule transport pump.
The membrane is currently a patch-based agentset. You can use turtles for this instead to make the membrane spatially dynamic (i.e. shifting to adjust the relative sizes of the chambers in cases with a constant osmolality).
This model could be expanded to simulate virtually any membrane transport/cell surface receptor function.


This model uses the classic "wiggle" code for random movement.
This model uses the code sequence to bounce turtles off barriers (in "to go" => ask molecule1)
This model uses the "mode" slider to scale pcolor to a different variable. I have used multiply expanded versions of "mode" and "set-scale-pc" to check patch variable distributions in models with multiple patch variables as a debugging tool.


This model was developed by Gary An, MD. At time of development he was in the Department of Trauma, Cook County Hospital, Chicago, IL, USA. Email any questions or comments to

(back to the NetLogo User Community Models)