Molecular Diffusion

Molecular Diffusion preview image

1 collaborator

Default-person David Sousa (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.0 • Viewed 360 times • Downloaded 22 times • Run 0 times
Download the 'Molecular Diffusion' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


THEORY

Molecular diffusion - the brownian motion of molecules in a fluid - is a thermal phenomenon. In a free medium, with no physical constraints, the distribution of the molecules' displacement is a gaussian distribution with variance σ^2=2Dt. Where t is the time interval of diffusion, and D the free diffusion coefficient which depends on the type of molecule and the properties of the fluid. This distribution deviates from it's gaussian nature, when the molecules are under physical constraints.

WHAT IS IT?

Simulation of restricted and unrestricted diffusion of molecules in a fluid.

HOW IT WORKS

Molecules represented by blue dots will random walk according to the specified properties, and eventually colide with a wall.

HOW TO USE IT

In the input box "free-diffusion-value" specifies the free diffusion coefficient with which the step-size of the molecules (see the corresponding monitor) is deduced from the variance formula above.

Specify the time-step in the corresponding input box.

Use the chooser "molecular-distribution" to choose whether to locate all molecules at the center or to distribute them randomly throughout the space.

Click the button "draw cell walls" to draw any walls you want.

Plots and monitors are provided to observe evolution of time, the distribution of the molecules' displacement (both components X and Y), and the evolution of mean diffusion (D) and its components (Dx and Dy), calculated from the the variance formula above. free-diffusion-value (Df) is also ploted as a reference.

Setup and go! (go is also stop)

Alert: Don't click any clear button without stopping simulations first.

Notes: one tick is one time-step; simulations use 1000 molecules; the world has 0.01×0.01mm^2

THINGS TO TRY

1) Setup and go with default settings and no walls. Observe the spreading of the molecules, the spread of the distribution of molecules' displacement and the evolution of diffusion values.

2) Try different parameters and observe.

3) Draw a small cell around the center. Setup, go and observe.

4) Try elongated shapes around the center. Setup, go and observe.

CREDITS

This model was coded by David N. Sousa. Feel free to contact.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals[Difx Dify Dif step-size zoom]

breed[molecules molecule]

molecules-own[init-pos-x init-pos-y dist-x dist-y]

to setup
  ifelse any? patches with [pcolor = red] [clear-drawing clear-globals clear-ticks clear-turtles clear-all-plots][ca]
  set zoom 100
  set step-size sqrt (4 * free-diffusion-value * time-step)
  put-molecules
  reset-ticks
end 

to put-molecules
  create-molecules 1000 [
    ask patch 0 0 [set pcolor black]
    set shape "dot" set size 0.7 set color blue
    set init-pos-x 0 set init-pos-y 0
    if molecular-distribution = "uniform" [
      set init-pos-x random-xcor set init-pos-y random-ycor
      setxy init-pos-x init-pos-y
      while [[pcolor] of patch-here = red] [
        set init-pos-x random-xcor set init-pos-y random-ycor
        setxy init-pos-x init-pos-y
      ]
    ]
  ]
end 

to go
  ask molecules [move]
  tick
  update-vars
end 

to move
  let zoomed-step step-size * zoom
  while [patch-ahead zoomed-step = nobody or [pcolor] of patch-ahead zoomed-step = red][set heading random 360]
  fd zoomed-step
  set heading random 360
end 

to update-vars
  ask molecules [set dist-x xcor - init-pos-x set dist-y ycor - init-pos-y]
  set Difx (mean (map [ ?1 -> (?1 / zoom) ^ 2 ] ([dist-x] of molecules))) / (2 * ticks * time-step)
  set Dify (mean (map [ ?1 -> (?1 / zoom) ^ 2 ] ([dist-y] of molecules))) / (2 * ticks * time-step)
  set Dif ((Difx + Dify) / 2)
end 

There is only one version of this model, created almost 5 years ago by David Sousa.

Attached files

File Type Description Last updated
Molecular Diffusion.png preview preview almost 5 years ago, by David Sousa Download

This model does not have any ancestors.

This model does not have any descendants.