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 30 times • Downloaded 2 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.)


Info tab cannot be displayed because of an encoding error

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 3 months ago by David Sousa.

Attached files

File Type Description Last updated
Molecular Diffusion.png preview preview 3 months ago, by David Sousa Download

This model does not have any ancestors.

This model does not have any descendants.