diffusion2

No preview image

1 collaborator

Default-person daniel kim (Author)

Tags

diffusion 

Tagged by Forrest Stonedahl over 9 years ago

hydrogen 

Tagged by Forrest Stonedahl over 9 years ago

independent study course 

Tagged by Forrest Stonedahl over 9 years ago

materials science 

Tagged by Forrest Stonedahl over 9 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 4.1 • Viewed 265 times • Downloaded 15 times • Run 2 times
Download the 'diffusion2' modelDownload this modelEmbed this model

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


WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

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

Click to Run Model

;if pborder? []
globals [xsetup ysetup hnum patchmark]
breed [hydrogens hydrogen]  ;;hydrogen
breed [startpts startpt]
breed [borders border]
;breed [droppers dropper]

to setup
  
  clear-all
  set xsetup -10
  set ysetup -10
  set hnum 0
  set patchmark 800
  
  ask patches 
  [
    if (pycor > min-pycor) and (pycor < max-pycor) and (pxcor > min-pxcor) and (pxcor < max-pxcor)
    [set pcolor 98]
  ]
  
  set-default-shape hydrogens "circle"
  create-hydrogens 400 
  [
    set color green
    set size 0.5
    set label-color blue - 2
    setxy min-pxcor min-pycor
  ]  
  
  set-default-shape startpts "circle"
  create-startpts 400 
  [
    set color gray
    set size 0.25
    set label-color blue - 2
    setxy min-pxcor min-pycor
  ]
  
  set-default-shape borders "border"
  create-borders (count patches)
  [
    set color 95
    face one-of neighbors4
    setxy min-pxcor min-pycor
  ]
  
  ;set the first one
  ask hydrogen 0 [setxy -10 -10]
  ask startpt 400 [setxy -10 -10]

  loop
  [

    if not any? hydrogens with [(pxcor =  min-pxcor) and (pycor =  min-pycor)]
    [ stop ]
 

    ask hydrogen hnum [setxy xsetup ysetup]
    
    ask startpt (hnum + 400) 
    [ setxy xsetup ysetup
      ;create-link-with hydrogen hnum
      ]
    

    
    set xsetup xsetup + 1
    if (xsetup = 10)
    [ set xsetup -10
      set ysetup ysetup + 1 ]
    set hnum hnum + 1
  ]
  
  set xsetup -19
  set ysetup -19
  
  ask border (patchmark)
  [ setxy xsetup ysetup ]
  
  loop
  [   
    if not any? borders with [(pxcor =  min-pxcor) and (pycor =  min-pycor)]
    [ stop ]
    
    set xsetup xsetup + 1
    
    ask border patchmark
    [ 
      setxy xsetup ysetup 
      if (xsetup = 20)
      [ set xsetup -20
        set ysetup ysetup + 1 ]
      set patchmark patchmark + 1]]
end 

to go
  if not any? hydrogens [ stop ]

  ;center hydrogens
  ask hydrogens
  [ setxy pxcor pycor ]
  
  ask hydrogens
  [ ;if the hydrogen is within the yellow border
    ifelse ((xcor < max-pxcor) and (xcor > min-pxcor) and (ycor < max-pycor) and (ycor > min-pycor)) 
    
    [ ;if theres no place to jump, just jiggle
      ifelse (count (neighbors4 with [not any? hydrogens-here]) = 0)
      [ ;rt (random 4) * 90 
        ;fd (random 100) / 200 
        ]
      ;if there are empty places to jump
      [ ifelse (random 100 < jumpChance)
        [ face one-of neighbors4 with [not any? hydrogens-here]
          fd 1 ]
        [ ;rt (random 4) * 90 ; else jiggle
          ;fd (random 100) / 200 
          ]]]
    [ ask patch-here 
      [ set pcolor pcolor + 1]
      die ]
    
  ]
  
  set-current-plot "hCount"
  set-current-plot-pen "hydrogens"
  plot count hydrogens

  
  
  tick
end 

There is only one version of this model, created over 9 years ago by daniel kim.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.